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


Java FileViewProvider.getPsi方法代码示例

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


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

示例1: divideInsideAndOutside

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
public static void divideInsideAndOutside(@NotNull PsiFile file,
                                          int startOffset,
                                          int endOffset,
                                          @NotNull TextRange range,
                                          @NotNull List<PsiElement> inside,
                                          @NotNull List<ProperTextRange> insideRanges,
                                          @NotNull List<PsiElement> outside,
                                          @NotNull List<ProperTextRange> outsideRanges,
                                          boolean includeParents,
                                          @NotNull Condition<PsiFile> filter) {
  final FileViewProvider viewProvider = file.getViewProvider();
  for (Language language : viewProvider.getLanguages()) {
    final PsiFile psiRoot = viewProvider.getPsi(language);
    if (filter.value(psiRoot)) {
      divideInsideAndOutside(psiRoot, startOffset, endOffset, range, inside, insideRanges, outside, outsideRanges, includeParents);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:Divider.java

示例2: isModified

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
private boolean isModified() {
  final FileViewProvider viewProvider = myFile.getViewProvider();
  for (Language language : mySliders.keySet()) {
    JSlider slider = mySliders.get(language);
    final PsiFile root = viewProvider.getPsi(language);
    HighlightingLevelManager highlightingLevelManager = HighlightingLevelManager.getInstance(myFile.getProject());
    if (root != null && getValue(highlightingLevelManager.shouldHighlight(root), highlightingLevelManager.shouldInspect(root)) != slider.getValue()) {
      return true;
    }
  }
  for (HectorComponentPanel panel : myAdditionalPanels) {
    if (panel.isModified()) {
      return true;
    }
  }

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

示例3: doCollectInformation

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
@Override
public void doCollectInformation(@NotNull ProgressIndicator progress) {
  final FileViewProvider viewProvider = myFile.getViewProvider();
  final Set<Language> relevantLanguages = viewProvider.getLanguages();
  List<LineMarkerInfo> markers = new SmartList<LineMarkerInfo>();
  for (Language language : relevantLanguages) {
    PsiElement psiRoot = viewProvider.getPsi(language);
    if (psiRoot == null || !HighlightingLevelManager.getInstance(myProject).shouldHighlight(psiRoot)) continue;
    List<PsiElement> elements = CollectHighlightsUtil.getElementsInRange(psiRoot, myBounds.getStartOffset(), myBounds.getEndOffset());
    final List<LineMarkerProvider> providers = LineMarkersPass.getMarkerProviders(language, myProject);
    addLineMarkers(elements, providers, markers, progress);
    LineMarkersPass.collectLineMarkersForInjected(markers, elements, this, myFile, progress);
  }

  myMarkers = LineMarkersPass.mergeLineMarkers(markers, myEditor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:SlowLineMarkersPass.java

示例4: getCustomFoldingDescriptors

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
@NotNull
private static Collection<FoldingDescriptor> getCustomFoldingDescriptors(@NotNull Editor editor, @NotNull Project project) {
  Set<FoldingDescriptor> foldingDescriptors = new HashSet<FoldingDescriptor>();
  final Document document = editor.getDocument();
  PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
  PsiFile file = documentManager != null ? documentManager.getPsiFile(document) : null;
  if (file != null) {
    final FileViewProvider viewProvider = file.getViewProvider();
    for (final Language language : viewProvider.getLanguages()) {
      final PsiFile psi = viewProvider.getPsi(language);
      final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(language);
      if (psi != null) {
        for (FoldingDescriptor descriptor : LanguageFolding.buildFoldingDescriptors(foldingBuilder, psi, document, false)) {
          CustomFoldingBuilder customFoldingBuilder = getCustomFoldingBuilder(foldingBuilder, descriptor);
          if (customFoldingBuilder != null) {
            if (customFoldingBuilder.isCustomRegionStart(descriptor.getElement())) {
              foldingDescriptors.add(descriptor);
            }
          }
        }
      }
    }
  }
  return foldingDescriptors;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GotoCustomRegionAction.java

示例5: getTemplateFile

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
@Nullable
public static PsiFile getTemplateFile(PsiFile file) {
  final FileViewProvider viewProvider = file.getViewProvider();
  if (viewProvider instanceof TemplateLanguageFileViewProvider) {
    return viewProvider.getPsi(((TemplateLanguageFileViewProvider)viewProvider).getTemplateDataLanguage());
  } else {
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:TemplateLanguageUtil.java

示例6: getStubbedRoots

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
/** Order is deterministic. First element matches {@link FileViewProvider#getStubBindingRoot()} */
@NotNull
public static List<Pair<IStubFileElementType, PsiFile>> getStubbedRoots(@NotNull FileViewProvider viewProvider) {
  final List<Trinity<Language, IStubFileElementType, PsiFile>> roots =
    new SmartList<Trinity<Language, IStubFileElementType, PsiFile>>();
  final PsiFile stubBindingRoot = viewProvider.getStubBindingRoot();
  for (Language language : viewProvider.getLanguages()) {
    final PsiFile file = viewProvider.getPsi(language);
    if (file instanceof PsiFileImpl) {
      final IElementType type = ((PsiFileImpl)file).getElementTypeForStubBuilder();
      if (type != null) {
        roots.add(Trinity.create(language, (IStubFileElementType)type, file));
      }
    }
  }

  ContainerUtil.sort(roots, new Comparator<Trinity<Language, IStubFileElementType, PsiFile>>() {
    @Override
    public int compare(Trinity<Language, IStubFileElementType, PsiFile> o1, Trinity<Language, IStubFileElementType, PsiFile> o2) {
      if (o1.third == stubBindingRoot) return o2.third == stubBindingRoot ? 0 : -1;
      else if (o2.third == stubBindingRoot) return 1;
      else return StringUtil.compare(o1.first.getID(), o2.first.getID(), false);
    }
  });

  return ContainerUtil.map(roots, new Function<Trinity<Language, IStubFileElementType, PsiFile>, Pair<IStubFileElementType, PsiFile>>() {
    @Override
    public Pair<IStubFileElementType, PsiFile> fun(Trinity<Language, IStubFileElementType, PsiFile> trinity) {
      return Pair.create(trinity.second, trinity.third);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:StubTreeBuilder.java

示例7: indentLinesIn

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
private static void indentLinesIn(final Editor editor, final PsiFile file, final Document document, final Project project, RangeMarker range) {
  final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
  int line1 = editor.offsetToLogicalPosition(range.getStartOffset()).line;
  int line2 = editor.offsetToLogicalPosition(range.getEndOffset()).line;

  while (!lineContainsNonSpaces(document, line1) && line1 < line2) line1++;
  while (!lineContainsNonSpaces(document, line2) && line1 < line2) line2--;

  final FileViewProvider provider = file.getViewProvider();
  PsiFile rootToAdjustIndentIn = provider.getPsi(provider.getBaseLanguage());
  codeStyleManager.adjustLineIndent(rootToAdjustIndentIn, new TextRange(document.getLineStartOffset(line1), document.getLineStartOffset(line2)));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:MoverWrapper.java

示例8: select

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
@Override
public List<TextRange> select(PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) {
  List<TextRange> result;

  if (!(e instanceof XmlToken) ||
      XmlTokenSelectioner.shouldSelectToken((XmlToken)e) ||
      ((XmlToken)e).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
    result = super.select(e, editorText, cursorOffset, editor);
  }
  else {
    result = ContainerUtil.newArrayList();
  }

  final PsiElement parent = e.getParent();
  if (parent instanceof XmlComment) {
    result.addAll(expandToWholeLine(editorText, parent.getTextRange(), true));
  }

  PsiFile psiFile = e.getContainingFile();

  addAttributeSelection(result, editor, editorText, e);
  final FileViewProvider fileViewProvider = psiFile.getViewProvider();
  for (Language lang : fileViewProvider.getLanguages()) {
    final PsiFile langFile = fileViewProvider.getPsi(lang);
    if (langFile != psiFile) addAttributeSelection(result, editor, editorText, fileViewProvider.findElementAt(cursorOffset, lang));
  }

  EditorHighlighter highlighter = HighlighterFactory.createHighlighter(e.getProject(), psiFile.getVirtualFile());
  highlighter.setText(editorText);

  addTagSelection2(e, result);

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

示例9: processXmlFile

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
protected void processXmlFile(VirtualFile t) {
    myIndicator.setText(findBundleMessage("find.searching.for.string.in.file.progress", myExpression.expression, t.getPresentableUrl()));

    final PsiFile psiFile = myManager.findFile(t);
    if (psiFile instanceof XmlFile) {
        final XmlFile t1 = (XmlFile)psiFile;
        final XmlDocument document;
        FileViewProvider fileViewProvider = t1.getViewProvider();

        if (fileViewProvider instanceof TemplateLanguageFileViewProvider) {
            final PsiFile root = fileViewProvider.getPsi(((TemplateLanguageFileViewProvider)fileViewProvider).getTemplateDataLanguage());

            if (root instanceof XmlFile) {
                document = ((XmlFile)root).getDocument();
            } else {
                document = null;
            }
        } else {
            document = t1.getDocument();
        }
        if (document != null) {
            process(document);
        }
    }

    myIndicator.setFraction(++myFileCount / (double)myTotalFileCount);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:XPathUsageSearcher.java

示例10: findFile

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
@Override
public PsiFile findFile(@NotNull VirtualFile vFile) {
  FileViewProvider viewProvider = findViewProvider(vFile);
  return viewProvider == null ? null : viewProvider.getPsi(viewProvider.getBaseLanguage());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:EmptyFileManager.java

示例11: getDaemonCodeAnalyzerStatus

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
@NotNull
protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(@NotNull SeverityRegistrar severityRegistrar) {
  DaemonCodeAnalyzerStatus status = new DaemonCodeAnalyzerStatus();
  if (myFile == null) {
    status.reasonWhyDisabled = "No file";
    status.errorAnalyzingFinished = true;
    return status;
  }
  if (myProject != null && myProject.isDisposed()) {
    status.reasonWhyDisabled = "Project is disposed";
    status.errorAnalyzingFinished = true;
    return status;
  }
  if (!myDaemonCodeAnalyzer.isHighlightingAvailable(myFile)) {
    if (!myFile.isPhysical()) {
      status.reasonWhyDisabled = "File is generated";
      status.errorAnalyzingFinished = true;
      return status;
    }
    else if (myFile instanceof PsiCompiledElement) {
      status.reasonWhyDisabled = "File is decompiled";
      status.errorAnalyzingFinished = true;
      return status;
    }
    final FileType fileType = myFile.getFileType();
    if (fileType.isBinary()) {
      status.reasonWhyDisabled = "File is binary";
      status.errorAnalyzingFinished = true;
      return status;
    }
    status.reasonWhyDisabled = "Highlighting is disabled for this file";
    status.errorAnalyzingFinished = true;
    return status;
  }

  FileViewProvider provider = myFile.getViewProvider();
  Set<Language> languages = provider.getLanguages();
  HighlightingSettingsPerFile levelSettings = HighlightingSettingsPerFile.getInstance(myProject);
  boolean shouldHighlight = languages.isEmpty();
  for (Language language : languages) {
    PsiFile root = provider.getPsi(language);
    FileHighlightingSetting level = levelSettings.getHighlightingSettingForRoot(root);
    shouldHighlight |= level != FileHighlightingSetting.SKIP_HIGHLIGHTING;
  }
  if (!shouldHighlight) {
    status.reasonWhyDisabled = "Highlighting level is None";
    status.errorAnalyzingFinished = true;
    return status;
  }

  if (HeavyProcessLatch.INSTANCE.isRunning()) {
    status.reasonWhySuspended = StringUtil.defaultIfEmpty(HeavyProcessLatch.INSTANCE.getRunningOperationName(), "Heavy operation is running");
    status.errorAnalyzingFinished = true;
    return status;
  }

  status.errorCount = errorCount.clone();
  fillDaemonCodeAnalyzerErrorsStatus(status, severityRegistrar);
  List<TextEditorHighlightingPass> passes = myDaemonCodeAnalyzer.getPassesToShowProgressFor(myDocument);
  status.passStati = passes.isEmpty() ? Collections.<ProgressableTextEditorHighlightingPass>emptyList() :
                     new ArrayList<ProgressableTextEditorHighlightingPass>(passes.size());
  //noinspection ForLoopReplaceableByForEach
  for (int i = 0; i < passes.size(); i++) {
    TextEditorHighlightingPass tepass = passes.get(i);
    if (!(tepass instanceof ProgressableTextEditorHighlightingPass)) continue;
    ProgressableTextEditorHighlightingPass pass = (ProgressableTextEditorHighlightingPass)tepass;

    if (pass.getProgress() < 0) continue;
    status.passStati.add(pass);
  }
  status.errorAnalyzingFinished = myDaemonCodeAnalyzer.isAllAnalysisFinished(myFile);
  status.reasonWhySuspended = myDaemonCodeAnalyzer.isUpdateByTimerEnabled() ? null : "Highlighting is paused temporarily";

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

示例12: getCachedPsiFile

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
@Override
@Nullable
public PsiFile getCachedPsiFile(@NotNull VirtualFile vFile) {
  FileViewProvider provider = findCachedViewProvider(vFile);
  return provider.getPsi(provider.getBaseLanguage());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:MockFileManager.java

示例13: compute

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
public T compute(PsiFile file) {
  final FileViewProvider fileViewProvider = file.getViewProvider();
  final PsiFile baseFile = fileViewProvider.getPsi(fileViewProvider.getBaseLanguage());
  baseFile.getFirstChild(); // expand chameleon out of lock
  return get(getKey(), baseFile, null).getValue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:FileBasedUserDataCache.java

示例14: execute

import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
private void execute(Editor editor) {
    final Project project = editor.getProject();
    final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    if (psiFile == null) {
        return;
    }

    InputExpressionDialog.Context input;
    XmlElement contextNode = null;
    final Config cfg = myComponent.getConfig();
    do {
        RangeHighlighter contextHighlighter = null;
        if (cfg.isUseContextAtCursor()) {
            // find out current context node
            contextNode = MyPsiUtil.findContextNode(psiFile, editor);
            if (contextNode != null) {
                contextHighlighter = HighlighterUtil.highlightNode(editor, contextNode, cfg.getContextAttributes(), cfg);
            }
        }
        if (contextNode == null) {
            // in XPath data model, / is the document itself, including comments, PIs and the root element
            contextNode = ((XmlFile)psiFile).getDocument();
            if (contextNode == null) {
              FileViewProvider fileViewProvider = psiFile.getViewProvider();
              if (fileViewProvider instanceof TemplateLanguageFileViewProvider) {
                Language dataLanguage = ((TemplateLanguageFileViewProvider)fileViewProvider).getTemplateDataLanguage();
                PsiFile templateDataFile = fileViewProvider.getPsi(dataLanguage);
                if (templateDataFile instanceof XmlFile) contextNode = ((XmlFile)templateDataFile).getDocument();
              }
            }
        }

        input = inputXPathExpression(project, contextNode);
        if (contextHighlighter != null) {
            contextHighlighter.dispose();
        }
        if (input == null) {
            return;
        }

        HighlighterUtil.clearHighlighters(editor);
    } while (contextNode != null && evaluateExpression(input, contextNode, editor, cfg));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:XPathEvalAction.java


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