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


Java FileViewProvider類代碼示例

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


FileViewProvider類屬於com.intellij.psi包,在下文中一共展示了FileViewProvider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processRoot

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
private void processRoot(final List<InferenceCapable> files, VirtualFile f) {
    LuaFileUtil.iterateLuaFilesRecursively(f, new ContentIterator() {
        @Override
        public boolean processFile(VirtualFile fileOrDir) {
            ProgressManager.checkCanceled();

            log.debug("process " + fileOrDir.getName());
            if (fileOrDir.isDirectory()) return true;

            indicator.setText2(fileOrDir.getPresentableName());
            final FileViewProvider viewProvider = p.findViewProvider(fileOrDir);
            if (viewProvider == null) return true;

            final PsiFile psiFile = viewProvider.getPsi(viewProvider.getBaseLanguage());
            if (!(psiFile instanceof InferenceCapable)) return true;

            indicator.setText2(fileOrDir.getName());
            log.debug("forcing inference for: " + fileOrDir.getName());

            files.add((InferenceCapable) psiFile);

            return true;
        }
    });
}
 
開發者ID:internetisalie,項目名稱:lua-for-idea,代碼行數:26,代碼來源:LuaPsiManager.java

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

示例3: getRootBlock

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
protected Block getRootBlock(PsiElement element, FileViewProvider viewProvider, CodeStyleSettings settings) {
  ASTNode node = element.getNode();
  if (node == null) {
    return createDummyBlock(node);
  }
  if (viewProvider instanceof TemplateLanguageFileViewProvider) {
    final Language dataLanguage = ((TemplateLanguageFileViewProvider)viewProvider).getTemplateDataLanguage();
    final FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forLanguage(dataLanguage);
    if (builder instanceof DelegatingFormattingModelBuilder && ((DelegatingFormattingModelBuilder)builder).dontFormatMyModel()) {
      return createDummyBlock(node);
    }
    if (builder != null) {
      final FormattingModel model = builder.createModel(viewProvider.getPsi(dataLanguage), settings);
      List<DataLanguageBlockWrapper> childWrappers = buildChildWrappers(model.getRootBlock());
      if (childWrappers.size() == 1) {
        childWrappers = buildChildWrappers(childWrappers.get(0).getOriginal());
      }
      return createTemplateLanguageBlock(node, Wrap.createWrap(WrapType.NONE, false), null,
                                         filterBlocksByRange(childWrappers, node.getTextRange()), settings);
    }
  }
  return createTemplateLanguageBlock(node,  Wrap.createWrap(WrapType.NONE, false), null, Collections.<DataLanguageBlockWrapper>emptyList(), settings);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:TemplateLanguageFormattingModelBuilder.java

示例4: checkFile

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
@Override
@Nullable
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
  if (InjectedLanguageManager.getInstance(file.getProject()).isInjectedFragment(file)) return null;
  if (!file.isPhysical()) return null;
  FileViewProvider viewProvider = file.getViewProvider();
  if (viewProvider.getBaseLanguage() != file.getLanguage()) return null;
  VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) return null;
  if (!virtualFile.isInLocalFileSystem()) return null;
  CharSequence text = viewProvider.getContents();
  Charset charset = LoadTextUtil.extractCharsetFromFileContent(file.getProject(), virtualFile, text);

  // no sense in checking transparently decoded file: all characters there are already safely encoded
  if (charset instanceof Native2AsciiCharset) return null;

  List<ProblemDescriptor> descriptors = new SmartList<ProblemDescriptor>();
  boolean ok = checkFileLoadedInWrongEncoding(file, manager, isOnTheFly, virtualFile, charset, descriptors);
  if (ok) {
    checkIfCharactersWillBeLostAfterSave(file, manager, isOnTheFly, text, charset, descriptors);
  }

  return descriptors.toArray(new ProblemDescriptor[descriptors.size()]);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:LossyEncodingInspection.java

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

示例6: update

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
@Override
public void update(final AnActionEvent e) {
  e.getPresentation().setVisible(false);

  VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
  VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
  if (files != null && files.length > 1) {
    virtualFile = null;
  }
  if (virtualFile == null || virtualFile.isDirectory()) return;

  Project project = e.getData(CommonDataKeys.PROJECT);
  if (project == null) return;

  final FileViewProvider provider = PsiManager.getInstance(project).findViewProvider(virtualFile);
  if (provider instanceof ConfigurableTemplateLanguageFileViewProvider) {
    final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)provider;

    e.getPresentation().setText(LangBundle.message("quickfix.change.template.data.language.text", viewProvider.getTemplateDataLanguage().getDisplayName()));
    e.getPresentation().setEnabled(true);
    e.getPresentation().setVisible(true);
  }

}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:ChangeTemplateDataLanguageAction.java

示例7: compute

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
@Override
public CachedValueProvider.Result<MultiHostRegistrarImpl> compute(PsiElement element) {
  PsiFile hostPsiFile = element.getContainingFile();
  if (hostPsiFile == null) return null;
  FileViewProvider viewProvider = hostPsiFile.getViewProvider();
  final DocumentEx hostDocument = (DocumentEx)viewProvider.getDocument();
  if (hostDocument == null) return null;

  PsiManager psiManager = viewProvider.getManager();
  final Project project = psiManager.getProject();
  InjectedLanguageManagerImpl injectedManager = InjectedLanguageManagerImpl.getInstanceImpl(project);

  final MultiHostRegistrarImpl result = doCompute(element, injectedManager, project, hostPsiFile);

  return CachedValueProvider.Result.create(result, PsiModificationTracker.MODIFICATION_COUNT, hostDocument);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:InjectedPsiCachedValueProvider.java

示例8: createFileViewProvider

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
@NotNull
@Override
public FileViewProvider createFileViewProvider(
    @NotNull VirtualFile virtualFile,
    Language language,
    @NotNull PsiManager psiManager,
    boolean eventSystemEnabled) {
  assert language.isKindOf(SoyLanguage.INSTANCE);
  return new SoyFileViewProvider(psiManager, virtualFile, eventSystemEnabled);
}
 
開發者ID:google,項目名稱:bamboo-soy,代碼行數:11,代碼來源:SoyFileViewProviderFactory.java

示例9: createFile

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
@Override
public PsiFile createFile(FileViewProvider fileViewProvider) {
    if (fileViewProvider != null) {
        return new MelFile(fileViewProvider);
    } else {
        throw new RuntimeException("Invalid file viewer null!!!");
    }
}
 
開發者ID:machaval,項目名稱:mule-intellij-plugins,代碼行數:9,代碼來源:MelParserDefinition.java

示例10: createFile

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
@Override
public PsiFile createFile(FileViewProvider viewProvider) {
    if (viewProvider != null) {
        return new WeaveFile(viewProvider);
    } else {
        throw new RuntimeException("Invalid file viewer null!!!");
    }
}
 
開發者ID:machaval,項目名稱:mule-intellij-plugins,代碼行數:9,代碼來源:WeaveParserDefinition.java

示例11: autoPopupXmlLookup

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
public static void autoPopupXmlLookup(final Project project, final Editor editor){
  AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, new Condition<PsiFile>() {
    @Override
    public boolean value(PsiFile file) {
      int offset = editor.getCaretModel().getOffset();

      PsiElement lastElement = InjectedLanguageUtil.findElementAtNoCommit(file, offset - 1);
      if (lastElement instanceof PsiFile) { //the very end of an injected file
        lastElement = file.findElementAt(offset - 1);
      }
      if (lastElement == null || !lastElement.isValid()) return false;

      if (doCompleteIfNeeded(offset, file, lastElement)) {
        return true;
      }

      FileViewProvider fileViewProvider = file.getViewProvider();
      Language templateDataLanguage;

      final PsiElement parent = lastElement.getParent();
      if (fileViewProvider instanceof TemplateLanguageFileViewProvider &&
          (templateDataLanguage = ((TemplateLanguageFileViewProvider)fileViewProvider).getTemplateDataLanguage()) != parent.getLanguage()) {
        lastElement = fileViewProvider.findElementAt(offset - 1, templateDataLanguage);
        if (lastElement == null || !lastElement.isValid()) return false;
        return doCompleteIfNeeded(offset, file, lastElement);
      }
      return false;
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:31,代碼來源:XmlAutoPopupHandler.java

示例12: createFileViewProvider

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
@NotNull
@Override
public FileViewProvider createFileViewProvider(@NotNull VirtualFile virtualFile,
                                               Language language,
                                               @NotNull PsiManager psiManager,
                                               boolean eventSystemEnabled){
  assert language.isKindOf(RythmLanguage.INSTANCE);
    return new RythmFileViewProvider(psiManager, virtualFile, eventSystemEnabled, language);
}
 
開發者ID:scireum-incubator,項目名稱:rythm_plugin,代碼行數:10,代碼來源:RythmFileViewProviderFactory.java

示例13: getLineExtensions

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
@Override
public Collection<LineExtensionInfo> getLineExtensions(@NotNull Project project, @NotNull VirtualFile file, int lineNumber) {
  List<LineExtensionInfo> res = ContainerUtil.newSmartList();

  PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
  final Document doc = FileDocumentManager.getInstance().getDocument(file);
  if (doc != null && lineNumber < doc.getLineCount()) {
    PsiFile psiFile = psiDocumentManager.getPsiFile(doc);
    if (psiFile != null) {
      int offset = doc.getLineStartOffset(lineNumber);
      FileViewProvider viewProvider = psiFile.getViewProvider();

      PsiElement element = viewProvider.findElementAt(offset);
      while (element != null) {
        int startOffset = element.getTextRange().getStartOffset();
        if (startOffset >= doc.getTextLength()) break;

        int startOffsetLine = doc.getLineNumber(startOffset);

        if (startOffsetLine < lineNumber) {
          element = PsiTreeUtil.nextVisibleLeaf(element);
          continue;
        }

        if (startOffsetLine > lineNumber) break;

        try {
          element = addExtensions(res, element);
        } catch (IndexNotReadyException ignored) { element = null; }
      }
    }
  }

  return res;
}
 
開發者ID:SumoLogic,項目名稱:epigraph,代碼行數:36,代碼來源:SchemaRetroTagLinePainter.java

示例14: canHandleElement

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
@Override
public boolean canHandleElement(@NotNull OpenInBrowserRequest request) {
  if (request.getVirtualFile() instanceof HttpVirtualFile) {
    return true;
  }

  // we must use base language because we serve file - not part of file, but the whole file
  // handlebars, for example, contains HTML and HBS psi trees, so, regardless of context, we should not handle such file
  FileViewProvider viewProvider = request.getFile().getViewProvider();
  return viewProvider.isPhysical() &&
         !(request.getVirtualFile() instanceof LightVirtualFile) &&
         isMyLanguage(viewProvider.getBaseLanguage());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:BuiltInWebBrowserUrlProvider.java

示例15: PsiFileBase

import com.intellij.psi.FileViewProvider; //導入依賴的package包/類
protected PsiFileBase(@NotNull FileViewProvider viewProvider, @NotNull Language language) {
  super(viewProvider);
  myLanguage = findLanguage(language, viewProvider);
  final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(myLanguage);
  if (parserDefinition == null) {
    throw new RuntimeException("PsiFileBase: language.getParserDefinition() returned null for: "+myLanguage);
  }
  myParserDefinition = parserDefinition;
  final IFileElementType nodeType = parserDefinition.getFileNodeType();
  assert nodeType.getLanguage() == myLanguage: nodeType.getLanguage() + " != " + myLanguage;
  init(nodeType, nodeType);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:PsiFileBase.java


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