當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。