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


Java InjectedLanguageUtil.getTopLevelFile方法代码示例

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


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

示例1: getAvailableIntentions

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
@NotNull
public List<IntentionAction> getAvailableIntentions() {
  doHighlighting();
  PsiFile file = getFile();
  Editor editor = getEditor();
  if (editor instanceof EditorWindow) {
    editor = ((EditorWindow)editor).getDelegate();
    file = InjectedLanguageUtil.getTopLevelFile(file);
  }
  return getAvailableIntentions(editor, file);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CodeInsightTestFixtureImpl.java

示例2: doHighlighting

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
@NotNull
public List<HighlightInfo> doHighlighting() {
  final Project project = getProject();
  PsiDocumentManager.getInstance(project).commitAllDocuments();

  PsiFile file = getFile();
  Editor editor = getEditor();
  if (editor instanceof EditorWindow) {
    editor = ((EditorWindow)editor).getDelegate();
    file = InjectedLanguageUtil.getTopLevelFile(file);
  }
  return instantiateAndRun(file, editor, ArrayUtil.EMPTY_INT_ARRAY, myAllowDirt);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:CodeInsightTestFixtureImpl.java

示例3: getParentDirectory

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static PsiDirectory getParentDirectory(PsiElement element) {
  PsiFile file = InjectedLanguageUtil.getTopLevelFile(element);
  if (file != null) {
    element = file;
  }
  while (element != null && !(element instanceof PsiDirectory)) {
    element = element.getParent();
  }
  return (PsiDirectory)element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:SameDirectoryWeigher.java

示例4: getAvailableIntentions

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
@Nonnull
public List<IntentionAction> getAvailableIntentions() {
  doHighlighting();
  PsiFile file = getFile();
  Editor editor = getEditor();
  if (editor instanceof EditorWindow) {
    editor = ((EditorWindow)editor).getDelegate();
    file = InjectedLanguageUtil.getTopLevelFile(file);
  }
  return getAvailableIntentions(editor, file);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:CodeInsightTestFixtureImpl.java

示例5: doHighlighting

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
@Nonnull
public List<HighlightInfo> doHighlighting() {
  final Project project = getProject();
  PsiDocumentManager.getInstance(project).commitAllDocuments();

  PsiFile file = getFile();
  Editor editor = getEditor();
  if (editor instanceof EditorWindow) {
    editor = ((EditorWindow)editor).getDelegate();
    file = InjectedLanguageUtil.getTopLevelFile(file);
  }
  return instantiateAndRun(file, editor, ArrayUtil.EMPTY_INT_ARRAY, myAllowDirt);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:15,代码来源:CodeInsightTestFixtureImpl.java

示例6: getHostFile

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private PsiFile getHostFile() {
  return InjectedLanguageUtil.getTopLevelFile(getFile());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:CodeInsightTestFixtureImpl.java

示例7: getHostFile

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private PsiFile getHostFile() {
  return InjectedLanguageUtil.getTopLevelFile(myFile);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:4,代码来源:CodeInsightTestFixtureImpl.java

示例8: checkResult

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private void checkResult(final String expectedFile, final boolean stripTrailingSpaces, final SelectionAndCaretMarkupLoader loader, String actualText) {
  assertInitialized();
  Project project = getProject();
  PsiFile file = getFile();
  Editor editor = getEditor();
  if (editor instanceof EditorWindow) {
    editor = ((EditorWindow)editor).getDelegate();
    file = InjectedLanguageUtil.getTopLevelFile(file);
  }

  project.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
  if (stripTrailingSpaces) {
    actualText = stripTrailingSpaces(actualText, project);
  }

  PsiDocumentManager.getInstance(project).commitAllDocuments();

  String newFileText1 = loader.newFileText;
  if (stripTrailingSpaces) {
    newFileText1 = stripTrailingSpaces(newFileText1, project);
  }

  actualText = StringUtil.convertLineSeparators(actualText);

  if (!Comparing.equal(newFileText1, actualText)) {
    if (loader.filePath != null) {
      throw new FileComparisonFailure(expectedFile, newFileText1, actualText, loader.filePath);
    }
    else {
      throw new ComparisonFailure(expectedFile, newFileText1, actualText);
    }
  }

  if (loader.caretMarker != null) {
    final int tabSize = CodeStyleSettingsManager.getSettings(getProject()).getIndentOptions(InternalStdFileTypes.JAVA).TAB_SIZE;

    int caretLine = StringUtil.offsetToLineNumber(loader.newFileText, loader.caretMarker.getStartOffset());
    int caretCol = EditorUtil
            .calcColumnNumber(null, loader.newFileText, StringUtil.lineColToOffset(loader.newFileText, caretLine, 0), loader.caretMarker.getStartOffset(),
                              tabSize);

    final int actualLine = editor.getCaretModel().getLogicalPosition().line;
    final int actualCol = editor.getCaretModel().getLogicalPosition().column;
    boolean caretPositionEquals = caretLine == actualLine && caretCol == actualCol;
    Assert.assertTrue("Caret position in " + expectedFile + " differs. Expected " + genCaretPositionPresentation(caretLine, caretCol) +
                      ". Actual " + genCaretPositionPresentation(actualLine, actualCol), caretPositionEquals);
  }

  if (loader.selStartMarker != null && loader.selEndMarker != null) {
    int selStartLine = StringUtil.offsetToLineNumber(loader.newFileText, loader.selStartMarker.getStartOffset());
    int selStartCol = loader.selStartMarker.getStartOffset() - StringUtil.lineColToOffset(loader.newFileText, selStartLine, 0);

    int selEndLine = StringUtil.offsetToLineNumber(loader.newFileText, loader.selEndMarker.getEndOffset());
    int selEndCol = loader.selEndMarker.getEndOffset() - StringUtil.lineColToOffset(loader.newFileText, selEndLine, 0);

    int selectionStart;
    int selectionEnd;
    selectionStart = editor.getSelectionModel().getSelectionStart();
    selectionEnd = editor.getSelectionModel().getSelectionEnd();

    final int selStartLineActual = StringUtil.offsetToLineNumber(loader.newFileText, selectionStart);
    final int selStartColActual = selectionStart - StringUtil.lineColToOffset(loader.newFileText, selStartLineActual, 0);

    final int selEndLineActual = StringUtil.offsetToLineNumber(loader.newFileText, selectionEnd);
    final int selEndColActual = selectionEnd - StringUtil.lineColToOffset(loader.newFileText, selEndLineActual, 0);

    final boolean selectionEquals = selStartCol == selStartColActual &&
                                    selStartLine == selStartLineActual &&
                                    selEndCol == selEndColActual &&
                                    selEndLine == selEndLineActual;
    Assert.assertTrue("selection in " + expectedFile +
                      " differs. Expected " + genSelectionPresentation(selStartLine, selStartCol, selEndLine, selEndCol) +
                      ". Actual " + genSelectionPresentation(selStartLineActual, selStartColActual, selEndLineActual, selEndColActual), selectionEquals);
  }
  else if (editor != null) {
    Assert.assertTrue("has no selection in " + expectedFile, !editor.getSelectionModel().hasSelection());
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:79,代码来源:CodeInsightTestFixtureImpl.java


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