當前位置: 首頁>>代碼示例>>Java>>正文


Java FileViewProvider.getLanguages方法代碼示例

本文整理匯總了Java中com.intellij.psi.FileViewProvider.getLanguages方法的典型用法代碼示例。如果您正苦於以下問題:Java FileViewProvider.getLanguages方法的具體用法?Java FileViewProvider.getLanguages怎麽用?Java FileViewProvider.getLanguages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.FileViewProvider的用法示例。


在下文中一共展示了FileViewProvider.getLanguages方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

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

示例4: getRootLanguage

import com.intellij.psi.FileViewProvider; //導入方法依賴的package包/類
@NotNull
public static Language getRootLanguage(@NotNull PsiElement element) {
  final FileViewProvider provider = element.getContainingFile().getViewProvider();
  final Set<Language> languages = provider.getLanguages();
  if (languages.size() > 1) {
    PsiElement current = element;
    while (current != null) {
      final Language language = current.getLanguage();
      if (languages.contains(language)) return language;
      current = current.getParent();
    }
  }
  return provider.getBaseLanguage();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:LanguageUtil.java

示例5: findLanguage

import com.intellij.psi.FileViewProvider; //導入方法依賴的package包/類
private static Language findLanguage(Language baseLanguage, FileViewProvider viewProvider) {
  final Set<Language> languages = viewProvider.getLanguages();
  for (final Language actualLanguage : languages) {
    if (actualLanguage.isKindOf(baseLanguage)) {
      return actualLanguage;
    }
  }
  throw new AssertionError(
      "Language " + baseLanguage + " doesn't participate in view provider " + viewProvider + ": " + new ArrayList<Language>(languages));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:PsiFileBase.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: 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

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

示例9: doCollectInformation

import com.intellij.psi.FileViewProvider; //導入方法依賴的package包/類
@Override
public void doCollectInformation(@NotNull ProgressIndicator progress) {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    return;
  }

  if (!WebEditorOptions.getInstance().isTagTreeHighlightingEnabled()) {
    return;
  }

  final int offset = myEditor.getCaretModel().getOffset();
  PsiElement[] elements = BreadcrumbsXmlWrapper.getLinePsiElements(offset,
                                                                   myFile.getVirtualFile(),
                                                                   myProject, myInfoProvider);

  if (elements == null || elements.length == 0 || !XmlTagTreeHighlightingUtil.containsTagsWithSameName(elements)) {
    elements = PsiElement.EMPTY_ARRAY;
    final FileViewProvider provider = myFile.getViewProvider();
    for (Language language : provider.getLanguages()) {
      PsiElement element = provider.findElementAt(offset, language);
      if (!isTagStartOrEnd(element)) {
        element = null;
      }
      if (element == null && offset > 0) {
        element = provider.findElementAt(offset - 1, language);
        if (!isTagStartOrEnd(element)) element = null;
      }

      final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
      if (tag != null) {
        elements = new PsiElement[] {tag};
      }
    }
  }

  for (int i = elements.length - 1; i >= 0; i--) {
    if (elements[i] instanceof XmlTag) {
      myPairsToHighlight.add(getTagRanges((XmlTag)elements[i]));
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:42,代碼來源:XmlTagTreeHighlightingPass.java


注:本文中的com.intellij.psi.FileViewProvider.getLanguages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。