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


Java InjectedLanguageUtil.findInjectedPsiNoCommit方法代码示例

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


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

示例1: createCompletionContext

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static CompletionContext createCompletionContext(PsiFile hostCopy,
                                                         int hostStartOffset,
                                                         OffsetMap hostMap, PsiFile originalFile) {
  CompletionAssertions.assertHostInfo(hostCopy, hostMap);

  InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(hostCopy.getProject());
  CompletionContext context;
  PsiFile injected = InjectedLanguageUtil.findInjectedPsiNoCommit(hostCopy, hostStartOffset);
  if (injected != null) {
    if (injected instanceof PsiFileImpl) {
      ((PsiFileImpl)injected).setOriginalFile(originalFile);
    }
    DocumentWindow documentWindow = InjectedLanguageUtil.getDocumentWindow(injected);
    CompletionAssertions.assertInjectedOffsets(hostStartOffset, injectedLanguageManager, injected, documentWindow);

    context = new CompletionContext(injected, translateOffsetMapToInjected(hostMap, documentWindow));
  } else {
    context = new CompletionContext(hostCopy, hostMap);
  }

  CompletionAssertions.assertFinalOffsets(originalFile, context, injected);

  return context;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CodeCompletionHandlerBase.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: invokeImpl

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static void invokeImpl(Project project, Editor editor, PsiFile file) {
  final PsiFile psiFile = InjectedLanguageUtil.findInjectedPsiNoCommit(file, editor.getCaretModel().getOffset());
  if (psiFile == null) return;
  final PsiLanguageInjectionHost host = InjectedLanguageManager.getInstance(project).getInjectionHost(psiFile);
  if (host == null) return;
  final LanguageInjectionSupport support = psiFile.getUserData(LanguageInjectionSupport.SETTINGS_EDITOR);
  if (support == null) return;
  try {
    if (!support.editInjectionInPlace(host)) {
      ShowSettingsUtil.getInstance().editConfigurable(project, new InjectionsSettingsUI(project, Configuration.getProjectInstance(project)));
    }
  }
  finally {
    FileContentUtil.reparseFiles(project, Collections.<VirtualFile>emptyList(), true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EditInjectionSettingsAction.java

示例4: createCompletionContext

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static CompletionContext createCompletionContext(PsiFile hostCopy,
                                                         int hostStartOffset,
                                                         OffsetMap hostMap, PsiFile originalFile) {
  CompletionAssertions.assertHostInfo(hostCopy, hostMap);

  InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(hostCopy.getProject());
  CompletionContext context;
  PsiFile injected = InjectedLanguageUtil.findInjectedPsiNoCommit(hostCopy, hostStartOffset);
  if (injected != null) {
    if (injected instanceof PsiFileImpl && injectedLanguageManager.isInjectedFragment(originalFile)) {
      ((PsiFileImpl)injected).setOriginalFile(originalFile);
    }
    DocumentWindow documentWindow = InjectedLanguageUtil.getDocumentWindow(injected);
    CompletionAssertions.assertInjectedOffsets(hostStartOffset, injectedLanguageManager, injected, documentWindow);

    context = new CompletionContext(injected, translateOffsetMapToInjected(hostMap, documentWindow));
  } else {
    context = new CompletionContext(hostCopy, hostMap);
  }

  CompletionAssertions.assertFinalOffsets(originalFile, context, injected);

  return context;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:CodeCompletionHandlerBase.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: isAvailable

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
  final int offset = editor.getCaretModel().getOffset();
  final PsiFile psiFile = InjectedLanguageUtil.findInjectedPsiNoCommit(file, offset);
  if (psiFile == null) return false;
  final LanguageInjectionSupport support = psiFile.getUserData(LanguageInjectionSupport.SETTINGS_EDITOR);
  return support != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:EditInjectionSettingsAction.java

示例7: isAvailable

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
  final int offset = editor.getCaretModel().getOffset();
  PsiElement element = InjectedLanguageUtil.findInjectedPsiNoCommit(file, offset);
  if (element == null) {
    return InjectedReferencesContributor.isInjected(file.findReferenceAt(offset));
  }
  return element.getUserData(LanguageInjectionSupport.INJECTOR_SUPPORT) != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:UnInjectLanguageAction.java

示例8: 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

示例9: 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

示例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.findInjectedPsiNoCommit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。