本文整理汇总了Java中com.intellij.injected.editor.EditorWindow类的典型用法代码示例。如果您正苦于以下问题:Java EditorWindow类的具体用法?Java EditorWindow怎么用?Java EditorWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EditorWindow类属于com.intellij.injected.editor包,在下文中一共展示了EditorWindow类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isClearHighlights
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
private static boolean isClearHighlights(@NotNull Editor editor) {
if (editor instanceof EditorWindow) {
editor = ((EditorWindow) editor).getDelegate();
}
final Project project = editor.getProject();
if (project == null) {
Log.error("isClearHighlights: editor.getProject() == null");
return false;
}
int caretOffset = editor.getCaretModel().getOffset();
final RangeHighlighter[] highlighters =
((HighlightManagerImpl) HighlightManager.getInstance(project)).getHighlighters(
editor);
for (RangeHighlighter highlighter : highlighters) {
if (TextRange.create(highlighter).grown(1).contains(caretOffset)) {
return true;
}
}
return false;
}
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:24,代码来源:MultiHighlightHandler.java
示例2: doHighlighting
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
@NotNull
protected List<HighlightInfo> doHighlighting() {
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
TIntArrayList toIgnoreList = new TIntArrayList();
if (!doFolding()) {
toIgnoreList.add(Pass.UPDATE_FOLDING);
}
if (!doInspections()) {
toIgnoreList.add(Pass.LOCAL_INSPECTIONS);
toIgnoreList.add(Pass.WHOLE_FILE_LOCAL_INSPECTIONS);
}
int[] toIgnore = toIgnoreList.isEmpty() ? ArrayUtil.EMPTY_INT_ARRAY : toIgnoreList.toNativeArray();
Editor editor = getEditor();
PsiFile file = getFile();
if (editor instanceof EditorWindow) {
editor = ((EditorWindow)editor).getDelegate();
file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
}
return CodeInsightTestFixtureImpl.instantiateAndRun(file, editor, toIgnore, false);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:LightDaemonAnalyzerTestCase.java
示例3: getElementAtCaret
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
@Override
@NotNull
public PsiElement getElementAtCaret() {
assertInitialized();
Editor editor = getCompletionEditor();
int findTargetFlags = TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED | TargetElementUtil.ELEMENT_NAME_ACCEPTED;
PsiElement element = TargetElementUtil.findTargetElement(editor, findTargetFlags);
// if no references found in injected fragment, try outer document
if (element == null && editor instanceof EditorWindow) {
element = TargetElementUtil.findTargetElement(((EditorWindow)editor).getDelegate(), findTargetFlags);
}
if (element == null) {
Assert.fail("element not found in file " + myFile.getName() +
" at caret position offset " + myEditor.getCaretModel().getOffset() + "," +
" psi structure:\n" + DebugUtil.psiToString(getFile(), true, true));
}
return element;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:CodeInsightTestFixtureImpl.java
示例4: setupEditorForInjectedLanguage
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
private static void setupEditorForInjectedLanguage() {
if (myEditor != null) {
final Ref<EditorWindow> editorWindowRef = new Ref<EditorWindow>();
myEditor.getCaretModel().runForEachCaret(new CaretAction() {
@Override
public void perform(Caret caret) {
Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(myEditor, myFile);
if (caret == myEditor.getCaretModel().getPrimaryCaret() && editor instanceof EditorWindow) {
editorWindowRef.set((EditorWindow)editor);
}
}
});
if (!editorWindowRef.isNull()) {
myEditor = editorWindowRef.get();
myFile = editorWindowRef.get().getInjectedFile();
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:LightPlatformCodeInsightTestCase.java
示例5: addOccurrenceHighlights
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
@Override
public void addOccurrenceHighlights(@NotNull Editor editor,
@NotNull PsiElement[] elements,
@NotNull TextAttributes attributes,
boolean hideByTextChange,
Collection<RangeHighlighter> outHighlighters) {
if (elements.length == 0) return;
int flags = HIDE_BY_ESCAPE;
if (hideByTextChange) {
flags |= HIDE_BY_TEXT_CHANGE;
}
Color scrollmarkColor = getScrollMarkColor(attributes);
if (editor instanceof EditorWindow) {
editor = ((EditorWindow)editor).getDelegate();
}
for (PsiElement element : elements) {
TextRange range = element.getTextRange();
range = InjectedLanguageManager.getInstance(myProject).injectedToHost(element, range);
addOccurrenceHighlight(editor,
trimOffsetToDocumentSize(editor, range.getStartOffset()),
trimOffsetToDocumentSize(editor, range.getEndOffset()),
attributes, flags, outHighlighters, scrollmarkColor);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:HighlightManagerImpl.java
示例6: refreshUi
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
void refreshUi(boolean selectionVisible, boolean itemsChanged, boolean reused, boolean onExplicitAction) {
Editor editor = myLookup.getEditor();
if (editor.getComponent().getRootPane() == null || editor instanceof EditorWindow && !((EditorWindow)editor).isValid()) {
return;
}
updateScrollbarVisibility();
if (myLookup.myResizePending || itemsChanged) {
myMaximumHeight = Integer.MAX_VALUE;
}
Rectangle rectangle = calculatePosition();
myMaximumHeight = rectangle.height;
if (myLookup.myResizePending || itemsChanged) {
myLookup.myResizePending = false;
myLookup.pack();
}
HintManagerImpl.updateLocation(myLookup, editor, rectangle.getLocation());
if (reused || selectionVisible || onExplicitAction) {
myLookup.ensureSelectionVisible(false);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:LookupUi.java
示例7: isAvailableHere
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
private static boolean isAvailableHere(Editor editor, PsiFile psiFile, PsiElement psiElement, boolean inProject, IntentionAction action) {
try {
Project project = psiFile.getProject();
if (action instanceof SuppressIntentionActionFromFix) {
final ThreeState shouldBeAppliedToInjectionHost = ((SuppressIntentionActionFromFix)action).isShouldBeAppliedToInjectionHost();
if (editor instanceof EditorWindow && shouldBeAppliedToInjectionHost == ThreeState.YES) {
return false;
}
if (!(editor instanceof EditorWindow) && shouldBeAppliedToInjectionHost == ThreeState.NO) {
return false;
}
}
if (action instanceof PsiElementBaseIntentionAction) {
if (!inProject || psiElement == null || !((PsiElementBaseIntentionAction)action).isAvailable(project, editor, psiElement)) return false;
}
else if (!action.isAvailable(project, editor, psiFile)) {
return false;
}
}
catch (IndexNotReadyException e) {
return false;
}
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ShowIntentionActionsHandler.java
示例8: preprocessEnter
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
@Override
public Result preprocessEnter(@NotNull PsiFile file,
@NotNull Editor editor,
@NotNull Ref<Integer> caretOffset,
@NotNull Ref<Integer> caretAdvance,
@NotNull DataContext dataContext,
EditorActionHandler originalHandler) {
int offset = caretOffset.get();
if (editor instanceof EditorWindow) {
file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
editor = InjectedLanguageUtil.getTopLevelEditor(editor);
offset = editor.getCaretModel().getOffset();
}
if (!(file instanceof PyFile)) {
return Result.Continue;
}
// honor dedent (PY-3009)
if (BackspaceHandler.isWhitespaceBeforeCaret(editor)) {
return Result.DefaultSkipIndent;
}
return Result.Continue;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PyEnterAtIndentHandler.java
示例9: doHighlighting
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
@NotNull
protected List<HighlightInfo> doHighlighting() {
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
TIntArrayList toIgnoreList = new TIntArrayList();
if (!doFolding()) {
toIgnoreList.add(Pass.UPDATE_FOLDING);
}
if (!doInspections()) {
toIgnoreList.add(Pass.LOCAL_INSPECTIONS);
}
int[] toIgnore = toIgnoreList.isEmpty() ? ArrayUtil.EMPTY_INT_ARRAY : toIgnoreList.toNativeArray();
Editor editor = getEditor();
PsiFile file = getFile();
if (editor instanceof EditorWindow) {
editor = ((EditorWindow)editor).getDelegate();
file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
}
return CodeInsightTestFixtureImpl.instantiateAndRun(file, editor, toIgnore, false);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:LightDaemonAnalyzerTestCase.java
示例10: getData
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
@Override
public Object getData(String dataId) {
if (PlatformDataKeys.EDITOR.is(dataId)) {
return myEditor;
}
if (dataId.equals(AnActionEvent.injectedId(PlatformDataKeys.EDITOR.getName()))) {
return InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(getEditor(), getFile());
}
if (LangDataKeys.PSI_FILE.is(dataId)) {
return myFile;
}
if (dataId.equals(AnActionEvent.injectedId(LangDataKeys.PSI_FILE.getName()))) {
Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(getEditor(), getFile());
return editor instanceof EditorWindow ? ((EditorWindow)editor).getInjectedFile() : getFile();
}
return super.getData(dataId);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:LightPlatformCodeInsightTestCase.java
示例11: addOccurrenceHighlights
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
@Override
public void addOccurrenceHighlights(@NotNull Editor editor,
@NotNull PsiElement[] elements,
@NotNull TextAttributes attributes,
boolean hideByTextChange,
Collection<RangeHighlighter> outHighlighters) {
if (elements.length == 0) return;
int flags = HIDE_BY_ESCAPE;
if (hideByTextChange) {
flags |= HIDE_BY_TEXT_CHANGE;
}
Color scrollmarkColor = getScrollMarkColor(attributes);
if (editor instanceof EditorWindow) {
editor = ((EditorWindow)editor).getDelegate();
}
for (PsiElement element : elements) {
TextRange range = element.getTextRange();
range = InjectedLanguageManager.getInstance(myProject).injectedToHost(element, range);
addOccurrenceHighlight(editor, range.getStartOffset(), range.getEndOffset(), attributes, flags, outHighlighters, scrollmarkColor);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:HighlightManagerImpl.java
示例12: getData
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
@Override
public Object getData(@Nonnull Key<?> dataId) {
if (PlatformDataKeys.EDITOR == dataId) {
return myEditor;
}
if (dataId == AnActionEvent.injectedId(PlatformDataKeys.EDITOR)) {
return InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(getEditor(), getFile());
}
if (LangDataKeys.PSI_FILE == dataId) {
return myFile;
}
if (dataId == AnActionEvent.injectedId(LangDataKeys.PSI_FILE)) {
Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(getEditor(), getFile());
return editor instanceof EditorWindow ? ((EditorWindow)editor).getInjectedFile() : getFile();
}
return super.getData(dataId);
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:LightPlatformCodeInsightTestCase.java
示例13: disposeWithEditor
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
public static void disposeWithEditor(@Nonnull Editor editor, @Nonnull Disposable disposable) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (Disposer.isDisposed(disposable)) return;
if (editor.isDisposed()) {
Disposer.dispose(disposable);
return;
}
// for injected editors disposal will happen only when host editor is disposed,
// but this seems to be the best we can do (there are no notifications on disposal of injected editor)
Editor hostEditor = editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor;
EditorFactory.getInstance().addEditorFactoryListener(new EditorFactoryAdapter() {
@Override
public void editorReleased(@Nonnull EditorFactoryEvent event) {
if (event.getEditor() == hostEditor) {
Disposer.dispose(disposable);
}
}
}, disposable);
}
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:EditorUtil.java
示例14: addOccurrenceHighlights
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
@Override
public void addOccurrenceHighlights(@Nonnull Editor editor,
@Nonnull PsiElement[] elements,
@Nonnull TextAttributes attributes,
boolean hideByTextChange,
Collection<RangeHighlighter> outHighlighters) {
if (elements.length == 0) return;
int flags = HIDE_BY_ESCAPE;
if (hideByTextChange) {
flags |= HIDE_BY_TEXT_CHANGE;
}
Color scrollmarkColor = getScrollMarkColor(attributes);
if (editor instanceof EditorWindow) {
editor = ((EditorWindow)editor).getDelegate();
}
for (PsiElement element : elements) {
TextRange range = element.getTextRange();
range = InjectedLanguageManager.getInstance(myProject).injectedToHost(element, range);
addOccurrenceHighlight(editor, range.getStartOffset(), range.getEndOffset(), attributes, flags, outHighlighters, scrollmarkColor);
}
}
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:HighlightManagerImpl.java
示例15: addImports
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
public void addImports() {
Application application = ApplicationManager.getApplication();
application.assertIsDispatchThread();
if (!application.isUnitTestMode() && !myEditor.getContentComponent().hasFocus()) return;
if (DumbService.isDumb(myProject) || !myFile.isValid()) return;
if (myEditor.isDisposed() || myEditor instanceof EditorWindow && !((EditorWindow)myEditor).isValid()) return;
int caretOffset = myEditor.getCaretModel().getOffset();
importUnambiguousImports(caretOffset);
List<HighlightInfo> visibleHighlights = getVisibleHighlights(myStartOffset, myEndOffset, myProject, myEditor);
for (int i = visibleHighlights.size() - 1; i >= 0; i--) {
HighlightInfo info = visibleHighlights.get(i);
if (info.startOffset <= caretOffset && showAddImportHint(info)) return;
}
for (HighlightInfo visibleHighlight : visibleHighlights) {
if (visibleHighlight.startOffset > caretOffset && showAddImportHint(visibleHighlight)) return;
}
}
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:ShowAutoImportPass.java
示例16: refreshUi
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
void refreshUi(boolean selectionVisible, boolean itemsChanged, boolean reused, boolean onExplicitAction) {
Editor editor = myLookup.getTopLevelEditor();
if (editor.getComponent().getRootPane() == null || editor instanceof EditorWindow && !((EditorWindow)editor).isValid()) {
return;
}
updateScrollbarVisibility();
if (myLookup.myResizePending || itemsChanged) {
myMaximumHeight = Integer.MAX_VALUE;
}
Rectangle rectangle = calculatePosition();
myMaximumHeight = rectangle.height;
if (myLookup.myResizePending || itemsChanged) {
myLookup.myResizePending = false;
myLookup.pack();
}
HintManagerImpl.updateLocation(myLookup, editor, rectangle.getLocation());
if (reused || selectionVisible || onExplicitAction) {
myLookup.ensureSelectionVisible(false);
}
}
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:LookupUi.java
示例17: printWithHighlighting
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
public static String printWithHighlighting(@Nonnull LanguageConsoleView console, @Nonnull Editor inputEditor, @Nonnull TextRange textRange) {
String text;
EditorHighlighter highlighter;
if (inputEditor instanceof EditorWindow) {
PsiFile file = ((EditorWindow)inputEditor).getInjectedFile();
highlighter = HighlighterFactory.createHighlighter(file.getVirtualFile(), EditorColorsManager.getInstance().getGlobalScheme(), console.getProject());
String fullText = InjectedLanguageUtil.getUnescapedText(file, null, null);
highlighter.setText(fullText);
text = textRange.substring(fullText);
}
else {
text = inputEditor.getDocument().getText(textRange);
highlighter = ((EditorEx)inputEditor).getHighlighter();
}
SyntaxHighlighter syntax = highlighter instanceof LexerEditorHighlighter ? ((LexerEditorHighlighter)highlighter).getSyntaxHighlighter() : null;
((LanguageConsoleImpl)console).doAddPromptToHistory();
if (syntax != null) {
ConsoleViewUtil.printWithHighlighting(console, text, syntax);
}
else {
console.print(text, ConsoleViewContentType.USER_INPUT);
}
console.print("\n", ConsoleViewContentType.NORMAL_OUTPUT);
return text;
}
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:LanguageConsoleImpl.java
示例18: injectedToHost
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
@Override
public int injectedToHost(int offset) {
int offsetInLeftFragment = injectedToHost(offset, true);
int offsetInRightFragment = injectedToHost(offset, false);
if (offsetInLeftFragment == offsetInRightFragment) return offsetInLeftFragment;
// heuristics: return offset closest to the caret
Editor[] editors = EditorFactory.getInstance().getEditors(getDelegate());
Editor editor = editors.length == 0 ? null : editors[0];
if (editor != null) {
if (editor instanceof EditorWindow) editor = ((EditorWindow)editor).getDelegate();
int caret = editor.getCaretModel().getOffset();
return Math.abs(caret - offsetInLeftFragment) < Math.abs(caret - offsetInRightFragment) ? offsetInLeftFragment : offsetInRightFragment;
}
return offsetInLeftFragment;
}
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:DocumentWindowImpl.java
示例19: getCaretForInjectedLanguageNoCommit
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
/**
* Invocation of this method on uncommitted {@code file} can lead to unexpected results, including throwing an exception!
*/
public static Caret getCaretForInjectedLanguageNoCommit(@Nullable Caret caret, @Nullable PsiFile file) {
if (caret == null || file == null || caret instanceof InjectedCaret) return caret;
PsiFile injectedFile = findInjectedPsiNoCommit(file, caret.getOffset());
Editor injectedEditor = getInjectedEditorForInjectedFile(caret.getEditor(), injectedFile);
if (!(injectedEditor instanceof EditorWindow)) {
return caret;
}
for (Caret injectedCaret : injectedEditor.getCaretModel().getAllCarets()) {
if (((InjectedCaret)injectedCaret).getDelegate() == caret) {
return injectedCaret;
}
}
return null;
}
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:InjectedLanguageUtil.java
示例20: getInjectedEditorForInjectedFile
import com.intellij.injected.editor.EditorWindow; //导入依赖的package包/类
@Nonnull
public static Editor getInjectedEditorForInjectedFile(@Nonnull Editor hostEditor, @Nonnull Caret hostCaret, @Nullable final PsiFile injectedFile) {
if (injectedFile == null || hostEditor instanceof EditorWindow || hostEditor.isDisposed()) return hostEditor;
Project project = hostEditor.getProject();
if (project == null) project = injectedFile.getProject();
Document document = PsiDocumentManager.getInstance(project).getDocument(injectedFile);
if (!(document instanceof DocumentWindowImpl)) return hostEditor;
DocumentWindowImpl documentWindow = (DocumentWindowImpl)document;
if (hostCaret.hasSelection()) {
int selstart = hostCaret.getSelectionStart();
if (selstart != -1) {
int selend = Math.max(selstart, hostCaret.getSelectionEnd());
if (!documentWindow.containsRange(selstart, selend)) {
// selection spreads out the injected editor range
return hostEditor;
}
}
}
if (!documentWindow.isValid()) {
return hostEditor; // since the moment we got hold of injectedFile and this moment call, document may have been dirtied
}
return EditorWindowImpl.create(documentWindow, (EditorImpl)hostEditor, injectedFile);
}
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:InjectedLanguageUtil.java
注:本文中的com.intellij.injected.editor.EditorWindow类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论