• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LanguageSubstitutors类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



LanguageSubstitutors类属于com.intellij.psi包,在下文中一共展示了LanguageSubstitutors类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getTemplateDataLanguage

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@NotNull
private static Language getTemplateDataLanguage(PsiManager manager, VirtualFile file) {
    Language dataLang = TemplateDataLanguageMappings.getInstance(manager.getProject()).getMapping(file);
    if (dataLang == null) {
        dataLang = RythmLanguage.getDefaultTemplateLang().getLanguage();
    }
    Language substituteLang = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang, file, manager.getProject());

    //Test for Java implementation
/* if (dataLang == null) {
        dataLang = RythmLanguage.getLanguage().getLanguage();
    }
    Language substituteLang = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang, file, manager.getProject());
*/

    if (TemplateDataLanguageMappings.getTemplateableLanguages().contains(substituteLang)) {
        dataLang = substituteLang;
    }
    return dataLang;
}
 
开发者ID:scireum-incubator,项目名称:rythm_plugin,代码行数:21,代码来源:RythmFileViewProvider.java


示例2: substituteFileType

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@NotNull
public static FileType substituteFileType(@NotNull VirtualFile file, @NotNull FileType fileType, Project project) {
  if (project == null) {
    return fileType;
  }
  if (fileType instanceof LanguageFileType) {
    final Language language = ((LanguageFileType)fileType).getLanguage();
    final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project);
    LanguageFileType substFileType = substitutedLanguage.getAssociatedFileType();
    if (!substitutedLanguage.equals(language) && substFileType != null) {
      return new SubstitutedFileType(fileType, substFileType, substitutedLanguage);
    }
  }

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


示例3: getPsiFile

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
/**
 * @return psiFile associated with the content. If the file was not set on FileContentCreation, it will be created on the spot
 */
@NotNull
@Override
public PsiFile getPsiFile() {
  PsiFile psi = getUserData(IndexingDataKeys.PSI_FILE);

  if (psi == null) {
    psi = getUserData(CACHED_PSI);
  }

  if (psi == null) {
    Project project = getProject();
    if (project == null) {
      project = DefaultProjectFactory.getInstance().getDefaultProject();
    }
    final Language language = ((LanguageFileType)getFileTypeWithoutSubstitution()).getLanguage();
    final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, getFile(), project);
    psi = PsiFileFactory.getInstance(project).createFileFromText(getFileName(), substitutedLanguage, getContentAsText(), false, false, true);

    psi.putUserData(IndexingDataKeys.VIRTUAL_FILE, getFile());
    putUserData(CACHED_PSI, psi);
  }
  return psi;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:FileContentImpl.java


示例4: substituteFileType

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@NotNull
public static FileType substituteFileType(VirtualFile file, @NotNull FileType fileType, Project project) {
  if (project == null) {
    return fileType;
  }
  if (fileType instanceof LanguageFileType) {
    final Language language = ((LanguageFileType)fileType).getLanguage();
    final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project);
    LanguageFileType substFileType = substitutedLanguage.getAssociatedFileType();
    if (!substitutedLanguage.equals(language) && substFileType != null && !substFileType.equals(fileType)) {
      return new SubstitutedFileType(fileType, substFileType);
    }
  }

  return fileType;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:SubstitutedFileType.java


示例5: substituteFileType

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@Nonnull
public static FileType substituteFileType(VirtualFile file, @Nonnull FileType fileType, Project project) {
  if (project == null) {
    return fileType;
  }
  if (fileType instanceof LanguageFileType) {
    final Language language = ((LanguageFileType)fileType).getLanguage();
    final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project);
    LanguageFileType substFileType = substitutedLanguage.getAssociatedFileType();
    if (!substitutedLanguage.equals(language) && substFileType != null) {
      return new SubstitutedFileType(fileType, substFileType, substitutedLanguage);
    }
  }

  return fileType;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:SubstitutedFileType.java


示例6: JetFileViewProvider

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
public JetFileViewProvider(PsiManager manager, VirtualFile file, boolean physical) {
    super(manager, file, physical);

    Language dataLang = TemplateDataLanguageMappings.getInstance(manager.getProject()).getMapping(file);
    if (dataLang == null) dataLang = StdFileTypes.HTML.getLanguage();

    if (dataLang instanceof TemplateLanguage) {
        myTemplateDataLanguage = PlainTextLanguage.INSTANCE;
    } else {
        myTemplateDataLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang, file, manager.getProject());
    }
}
 
开发者ID:jhsx,项目名称:GoJetPlugin,代码行数:13,代码来源:JetFileViewProvider.java


示例7: substituteFileType

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@Nullable
private static LanguageFileType substituteFileType(Language language, VirtualFile vFile, Project project) {
  LanguageFileType fileType = null;
  if (vFile != null && project != null) {
    Language substLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, vFile, project);
    if (substLanguage != language) {
      fileType = substLanguage.getAssociatedFileType();
    }
  }
  return fileType;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:EditorHighlighterFactoryImpl.java


示例8: createFileFromText

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
public PsiFile createFileFromText(@NotNull CharSequence text) {
  Project project = getProject();
  if (project == null) {
    project = DefaultProjectFactory.getInstance().getDefaultProject();
  }
  final Language language = ((LanguageFileType)getFileTypeWithoutSubstitution()).getLanguage();
  final VirtualFile file = getFile();
  final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project);
  return PsiFileFactory.getInstance(project).createFileFromText(getFileName(), substitutedLanguage, text, false, false, true, file);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:FileContentImpl.java


示例9: fileLanguage

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@NotNull
protected Function<VirtualFile, Language> fileLanguage(final Project project) {
  return new Function<VirtualFile, Language>() {
    ScratchFileService fileService = ScratchFileService.getInstance();

    @Override
    public Language fun(VirtualFile file) {
      Language lang = fileService.getScratchesMapping().getMapping(file);
      if (lang == null) {
        lang = LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)file.getFileType()).getLanguage(), file, project);
      }
      return lang;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ScratchFileActions.java


示例10: getTemplateDataLanguage

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
private Language getTemplateDataLanguage(PsiManager manager, VirtualFile file) {
    Language dataLang = TemplateDataLanguageMappings.getInstance(manager.getProject()).getMapping(file);
    if(dataLang == null) {
        dataLang = DotLanguage.getDefaultTemplateLang().getLanguage();
    }

    Language substituteLang = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang, file, manager.getProject());

    // only use a substituted language if it's templateable
    if (TemplateDataLanguageMappings.getTemplateableLanguages().contains(substituteLang)) {
        dataLang = substituteLang;
    }

    return dataLang;
}
 
开发者ID:webschik,项目名称:idea-doT,代码行数:16,代码来源:DotFileViewProvider.java


示例11: substituteFileType

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@javax.annotation.Nullable
private static LanguageFileType substituteFileType(Language language, VirtualFile vFile, Project project) {
  LanguageFileType fileType = null;
  if (vFile != null && project != null) {
    Language substLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, vFile, project);
    if (substLanguage != language) {
      fileType = substLanguage.getAssociatedFileType();
    }
  }
  return fileType;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:EditorHighlighterFactoryImpl.java


示例12: createFileFromText

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@Nonnull
@RequiredReadAction
public static PsiFile createFileFromText(@Nonnull Project project, @Nonnull CharSequence text, @Nonnull LanguageFileType fileType,
                                         @Nonnull VirtualFile file, @Nonnull String fileName) {
  final Language language = fileType.getLanguage();
  final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project);
  LanguageVersion languageVersion =
          LanguageVersionResolvers.INSTANCE.forLanguage(substitutedLanguage).getLanguageVersion(substitutedLanguage, project, file);
  return PsiFileFactory.getInstance(project).createFileFromText(fileName, languageVersion, text, false, false, true, file);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:FileContentImpl.java


示例13: substituteLanguage

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@Nullable
public static Language substituteLanguage(@Nonnull Project project, @Nonnull VirtualFile file) {
  RootType rootType = ScratchFileService.getInstance().getRootType(file);
  if (rootType == null) return null;
  Language language = rootType.substituteLanguage(project, file);
  Language adjusted = language != null ? language : getLanguageByFileName(file);
  return adjusted != null && adjusted != ScratchFileType.INSTANCE.getLanguage()
         ? LanguageSubstitutors.INSTANCE.substituteLanguage(adjusted, file, project)
         : adjusted;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:ScratchFileServiceImpl.java


示例14: reportStubPsiMismatch

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@Override
protected <Psi extends PsiElement> void reportStubPsiMismatch(Psi psi, VirtualFile file, Class<Psi> requiredClass) {
  if (file == null) {
    super.reportStubPsiMismatch(psi, file, requiredClass);
    return;
  }

  StringWriter writer = new StringWriter();
  //noinspection IOResourceOpenedButNotSafelyClosed
  PrintWriter out = new PrintWriter(writer);

  out.print("Invalid stub element type in index:");
  out.printf("\nfile: %s\npsiElement: %s\nrequiredClass: %s\nactualClass: %s",
             file, psi, requiredClass, psi.getClass());

  FileType fileType = file.getFileType();
  Language language = fileType instanceof LanguageFileType ?
                      LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), file, psi.getProject()) :
                      Language.ANY;
  out.printf("\nvirtualFile: size:%s; stamp:%s; modCount:%s; fileType:%s; language:%s",
             file.getLength(), file.getModificationStamp(), file.getModificationCount(),
             fileType.getName(), language.getID());

  Document document = FileDocumentManager.getInstance().getCachedDocument(file);
  if (document != null) {
    boolean committed = PsiDocumentManager.getInstance(psi.getProject()).isCommitted(document);
    boolean saved = !FileDocumentManager.getInstance().isDocumentUnsaved(document);
    out.printf("\ndocument: size:%s; stamp:%s; committed:%s; saved:%s",
               document.getTextLength(), document.getModificationStamp(), committed, saved);
  }

  PsiFile psiFile = psi.getManager().findFile(file);
  if (psiFile != null) {
    out.printf("\npsiFile: size:%s; stamp:%s; class:%s; language:%s",
               psiFile.getTextLength(), psiFile.getViewProvider().getModificationStamp(), psiFile.getClass().getName(),
               psiFile.getLanguage().getID());
  }

  StubTree stub = psiFile instanceof PsiFileWithStubSupport ? ((PsiFileWithStubSupport)psiFile).getStubTree() : null;
  FileElement treeElement = stub == null && psiFile instanceof PsiFileImpl? ((PsiFileImpl)psiFile).getTreeElement() : null;
  if (stub != null) {
    out.printf("\nstubInfo: " + stub.getDebugInfo());
  }
  else if (treeElement != null) {
    out.printf("\nfileAST: size:%s; parsed:%s", treeElement.getTextLength(), treeElement.isParsed());
  }

  out.printf("\nindexing info: " + StubUpdatingIndex.getIndexingStampInfo(file));
  LOG.error(writer.toString());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:51,代码来源:StubIndexImpl.java


示例15: substituteLanguageImpl

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@Nullable
protected static Language substituteLanguageImpl(Language language, VirtualFile file, Project project) {
  return language != null && language != ScratchFileType.INSTANCE.getLanguage() ?
         LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project) : language;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:RootType.java


示例16: getLanguageForPsi

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
@Nullable
public static Language getLanguageForPsi(@Nonnull Project project, @Nullable VirtualFile file) {
  Language language = getFileLanguage(file);
  if (language == null) return null;
  return LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:7,代码来源:LanguageUtil.java


示例17: VtlFileViewProvider

import com.intellij.psi.LanguageSubstitutors; //导入依赖的package包/类
public VtlFileViewProvider(final PsiManager manager, final VirtualFile virtualFile, final boolean physical) {
    super(manager, virtualFile, physical);
    final Language language = getTemplateDataLanguage(virtualFile, manager.getProject());
    myTemplateDataLanguage = language instanceof TemplateLanguage ? PlainTextLanguage.INSTANCE : LanguageSubstitutors.INSTANCE.substituteLanguage(language, virtualFile, manager.getProject());
}
 
开发者ID:consulo,项目名称:consulo-apache-velocity,代码行数:6,代码来源:VtlFileViewProvider.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TaskMessage类代码示例发布时间:2022-05-23
下一篇:
Java SleepInputFormat类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap