当前位置: 首页>>代码示例>>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;未经允许,请勿转载。