当前位置: 首页>>代码示例>>Java>>正文


Java InjectedLanguageUtil.getInjectedEditorForInjectedFile方法代码示例

本文整理汇总了Java中com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil.getInjectedEditorForInjectedFile方法的典型用法代码示例。如果您正苦于以下问题:Java InjectedLanguageUtil.getInjectedEditorForInjectedFile方法的具体用法?Java InjectedLanguageUtil.getInjectedEditorForInjectedFile怎么用?Java InjectedLanguageUtil.getInjectedEditorForInjectedFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil的用法示例。


在下文中一共展示了InjectedLanguageUtil.getInjectedEditorForInjectedFile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: injectedEditorIfCharTypedIsSignificant

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
public static Editor injectedEditorIfCharTypedIsSignificant(final char charTyped, @NotNull Editor editor, @NotNull PsiFile oldFile) {
  int offset = editor.getCaretModel().getOffset();
  // even for uncommitted document try to retrieve injected fragment that has been there recently
  // we are assuming here that when user is (even furiously) typing, injected language would not change
  // and thus we can use its lexer to insert closing braces etc
  for (DocumentWindow documentWindow : InjectedLanguageUtil.getCachedInjectedDocuments(oldFile)) {
    if (documentWindow.isValid() && documentWindow.containsRange(offset, offset)) {
      PsiFile injectedFile = PsiDocumentManager.getInstance(oldFile.getProject()).getPsiFile(documentWindow);
      final Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile);
      // IDEA-52375 fix: last quote sign should be handled by outer language quote handler
      final CharSequence charsSequence = editor.getDocument().getCharsSequence();
      if (injectedEditor.getCaretModel().getOffset() == injectedEditor.getDocument().getTextLength() &&
          offset < charsSequence.length() && charTyped == charsSequence.charAt(offset)) {
        return editor;
      }
      return injectedEditor;
    }
  }

  return editor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:TypedHandler.java

示例2: chooseBetweenHostAndInjected

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Nullable
public static Pair<PsiFile,Editor> chooseBetweenHostAndInjected(@NotNull PsiFile hostFile, @NotNull Editor hostEditor, @NotNull PairProcessor<PsiFile, Editor> predicate) {
  Editor editorToApply = null;
  PsiFile fileToApply = null;

  int offset = hostEditor.getCaretModel().getOffset();
  PsiFile injectedFile = InjectedLanguageUtil.findInjectedPsiNoCommit(hostFile, offset);
  if (injectedFile != null) {
    Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(hostEditor, injectedFile);
    if (predicate.process(injectedFile, injectedEditor)) {
      editorToApply = injectedEditor;
      fileToApply = injectedFile;
    }
  }

  if (editorToApply == null && predicate.process(hostFile, hostEditor)) {
    editorToApply = hostEditor;
    fileToApply = hostFile;
  }
  if (editorToApply == null) return null;
  return Pair.create(fileToApply, editorToApply);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ShowIntentionActionsHandler.java

示例3: injectedEditorIfCharTypedIsSignificant

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
static Editor injectedEditorIfCharTypedIsSignificant(final char charTyped, Editor editor, PsiFile oldFile) {
  int offset = editor.getCaretModel().getOffset();
  // even for uncommitted document try to retrieve injected fragment that has been there recently
  // we are assuming here that when user is (even furiously) typing, injected language would not change
  // and thus we can use its lexer to insert closing braces etc
  for (DocumentWindow documentWindow : InjectedLanguageUtil.getCachedInjectedDocuments(oldFile)) {
    if (documentWindow.isValid() && documentWindow.containsRange(offset, offset)) {
      PsiFile injectedFile = PsiDocumentManager.getInstance(oldFile.getProject()).getPsiFile(documentWindow);
      final Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile);
      // IDEA-52375 fix: last quote sign should be handled by outer language quote handler
      final CharSequence charsSequence = editor.getDocument().getCharsSequence();
      if (injectedEditor.getCaretModel().getOffset() == injectedEditor.getDocument().getTextLength() &&
          offset < charsSequence.length() && charTyped == charsSequence.charAt(offset)) {
        return editor;
      }
      return injectedEditor;
    }
  }

  return editor;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:TypedHandler.java

示例4: injectedEditorIfCharTypedIsSignificant

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Nonnull
public static Editor injectedEditorIfCharTypedIsSignificant(final char charTyped, @Nonnull Editor editor, @Nonnull PsiFile oldFile) {
  int offset = editor.getCaretModel().getOffset();
  // even for uncommitted document try to retrieve injected fragment that has been there recently
  // we are assuming here that when user is (even furiously) typing, injected language would not change
  // and thus we can use its lexer to insert closing braces etc
  for (DocumentWindow documentWindow : InjectedLanguageUtil.getCachedInjectedDocuments(oldFile)) {
    if (documentWindow.isValid() && documentWindow.containsRange(offset, offset)) {
      PsiFile injectedFile = PsiDocumentManager.getInstance(oldFile.getProject()).getPsiFile(documentWindow);
      if (injectedFile != null) {
        Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile);
        // IDEA-52375/WEB-9105 fix: last quote in editable fragment should be handled by outer language quote handler
        TextRange hostRange = documentWindow.getHostRange(offset);
        CharSequence sequence = editor.getDocument().getCharsSequence();
        if (sequence.length() > offset && charTyped != sequence.charAt(offset) || hostRange != null && hostRange.contains(offset)) {
          return injectedEditor;
        }
      }
    }
  }

  return editor;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:TypedHandler.java

示例5: chooseBetweenHostAndInjected

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Nullable
public static Pair<PsiFile, Editor> chooseBetweenHostAndInjected(@Nonnull PsiFile hostFile,
                                                                 @Nonnull Editor hostEditor,
                                                                 @Nonnull PairProcessor<PsiFile, Editor> predicate) {
  Editor editorToApply = null;
  PsiFile fileToApply = null;

  int offset = hostEditor.getCaretModel().getOffset();
  PsiFile injectedFile = InjectedLanguageUtil.findInjectedPsiNoCommit(hostFile, offset);
  if (injectedFile != null) {
    Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(hostEditor, injectedFile);
    if (predicate.process(injectedFile, injectedEditor)) {
      editorToApply = injectedEditor;
      fileToApply = injectedFile;
    }
  }

  if (editorToApply == null && predicate.process(hostFile, hostEditor)) {
    editorToApply = hostEditor;
    fileToApply = hostFile;
  }
  if (editorToApply == null) return null;
  return Pair.create(fileToApply, editorToApply);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:ShowIntentionActionsHandler.java

示例6: moveCaret

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static boolean moveCaret(Editor editor, PsiElement current, int offset) {
  editor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, current.getContainingFile());
  final CaretModel caretModel = editor.getCaretModel();
  if (caretModel.getOffset() == offset) return false;

  caretModel.moveToOffset(offset);
  final Caret caret = caretModel.getCurrentCaret();
  ScrollingModel scrollingModel = editor.getScrollingModel();
  if (caret == caretModel.getPrimaryCaret()) {
    scrollingModel.scrollToCaret(ScrollType.RELATIVE);
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:EmmetEditPointUtil.java

示例7: doExtractFunction

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private void doExtractFunction() throws Throwable {
  myFixture.configureByFile(getTestFileName() + ".xsl");
  final Editor editor = myFixture.getEditor();

  assertTrue("Selection required", editor.getSelectionModel().hasSelection());
  editor.getCaretModel().moveToOffset(editor.getSelectionModel().getSelectionStart());

  final XsltExtractFunctionAction action = new XsltExtractFunctionAction() {
    @Override
    protected RefactoringOptions getSettings(XPathExpression expression, Set<XPathExpression> matchingExpressions) {
      return new RefactoringOptions() {
        @Override
        public boolean isCanceled() {
          return false;
        }

        @Override
        public String getName() {
          return "f:foo";
        }
      };
    }
  };

  final PsiFile file = InjectedLanguageUtil.findInjectedPsiNoCommit(myFixture.getFile(), editor.getCaretModel().getOffset());
  final Editor editorWindow = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, file);
  assertTrue(editorWindow instanceof EditorWindow);

  action.invoke(myFixture.getProject(), editorWindow, file, null);

  myFixture.checkResultByFile(getTestFileName() + "_after.xsl");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:Xslt2RefactoringTest.java

示例8: addAvailableActionsForGroups

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static void addAvailableActionsForGroups(@NotNull HighlightInfo info,
                                                 @NotNull Editor editor,
                                                 @NotNull PsiFile file,
                                                 @NotNull List<HighlightInfo.IntentionActionDescriptor> outList,
                                                 int group,
                                                 int offset) {
  if (info.quickFixActionMarkers == null) return;
  if (group != -1 && group != info.getGroup()) return;
  Editor injectedEditor = null;
  PsiFile injectedFile = null;
  for (Pair<HighlightInfo.IntentionActionDescriptor, RangeMarker> pair : info.quickFixActionMarkers) {
    HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;
    RangeMarker range = pair.second;
    if (!range.isValid()) continue;
    int start = range.getStartOffset();
    int end = range.getEndOffset();
    final Project project = file.getProject();
    if (start > offset || offset > end) {
      continue;
    }
    Editor editorToUse;
    PsiFile fileToUse;
    if (info.isFromInjection()) {
      if (injectedEditor == null) {
        injectedFile = InjectedLanguageUtil.findInjectedPsiNoCommit(file, offset);
        injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile);
      }
      editorToUse = injectedEditor;
      fileToUse = injectedFile;
    }
    else {
      editorToUse = editor;
      fileToUse = file;
    }
    if (actionInGroup.getAction().isAvailable(project, editorToUse, fileToUse)) {
      outList.add(actionInGroup);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:40,代码来源:QuickFixAction.java

示例9: getEditor

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
@Nonnull
public Editor getEditor() {
  DocumentWindow documentWindow = getInjectedDocument(myEditor.getCaretModel().getOffset());
  if (documentWindow != null) {
    PsiFile injectedFile = PsiDocumentManager.getInstance(myProject).getPsiFile(documentWindow);
    return InjectedLanguageUtil.getInjectedEditorForInjectedFile(myEditor, injectedFile);
  }
  return myEditor;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:LookupImpl.java

示例10: addAvailableActionsForGroups

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static void addAvailableActionsForGroups(@NotNull HighlightInfo info,
                                                 @NotNull Editor editor,
                                                 @NotNull PsiFile file,
                                                 @NotNull List<HighlightInfo.IntentionActionDescriptor> outList,
                                                 int group,
                                                 int offset) {
  if (info.quickFixActionMarkers == null) return;
  if (group != -1 && group != info.getGroup()) return;
  boolean fixRangeIsNotEmpty = !info.getFixTextRange().isEmpty();
  Editor injectedEditor = null;
  PsiFile injectedFile = null;
  for (Pair<HighlightInfo.IntentionActionDescriptor, RangeMarker> pair : info.quickFixActionMarkers) {
    HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;
    RangeMarker range = pair.second;
    if (!range.isValid() || fixRangeIsNotEmpty && isEmpty(range)) continue;

    if (DumbService.isDumb(file.getProject()) && !DumbService.isDumbAware(actionInGroup.getAction())) {
      continue;
    }

    int start = range.getStartOffset();
    int end = range.getEndOffset();
    final Project project = file.getProject();
    if (start > offset || offset > end) {
      continue;
    }
    Editor editorToUse;
    PsiFile fileToUse;
    if (info.isFromInjection()) {
      if (injectedEditor == null) {
        injectedFile = InjectedLanguageUtil.findInjectedPsiNoCommit(file, offset);
        injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile);
      }
      editorToUse = injectedEditor;
      fileToUse = injectedFile;
    }
    else {
      editorToUse = editor;
      fileToUse = file;
    }
    if (actionInGroup.getAction().isAvailable(project, editorToUse, fileToUse)) {
      outList.add(actionInGroup);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:ShowIntentionsPass.java

示例11: addAvailableFixesForGroups

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static void addAvailableFixesForGroups(@Nonnull HighlightInfo info,
                                               @Nonnull Editor editor,
                                               @Nonnull PsiFile file,
                                               @Nonnull List<HighlightInfo.IntentionActionDescriptor> outList,
                                               int group,
                                               int offset) {
  if (info.quickFixActionMarkers == null) return;
  if (group != -1 && group != info.getGroup()) return;
  boolean fixRangeIsNotEmpty = !info.getFixTextRange().isEmpty();
  Editor injectedEditor = null;
  PsiFile injectedFile = null;
  for (Pair<HighlightInfo.IntentionActionDescriptor, RangeMarker> pair : info.quickFixActionMarkers) {
    HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;
    RangeMarker range = pair.second;
    if (!range.isValid() || fixRangeIsNotEmpty && isEmpty(range)) continue;

    if (DumbService.isDumb(file.getProject()) && !DumbService.isDumbAware(actionInGroup.getAction())) {
      continue;
    }

    int start = range.getStartOffset();
    int end = range.getEndOffset();
    final Project project = file.getProject();
    if (start > offset || offset > end) {
      continue;
    }
    Editor editorToUse;
    PsiFile fileToUse;
    if (info.isFromInjection()) {
      if (injectedEditor == null) {
        injectedFile = InjectedLanguageUtil.findInjectedPsiNoCommit(file, offset);
        injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile);
      }
      editorToUse = injectedEditor;
      fileToUse = injectedFile;
    }
    else {
      editorToUse = editor;
      fileToUse = file;
    }
    if (actionInGroup.getAction().isAvailable(project, editorToUse, fileToUse)) {
      outList.add(actionInGroup);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:46,代码来源:ShowIntentionsPass.java


注:本文中的com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil.getInjectedEditorForInjectedFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。