当前位置: 首页>>代码示例>>Java>>正文


Java LanguageUtil.getLanguageForPsi方法代码示例

本文整理汇总了Java中com.intellij.lang.LanguageUtil.getLanguageForPsi方法的典型用法代码示例。如果您正苦于以下问题:Java LanguageUtil.getLanguageForPsi方法的具体用法?Java LanguageUtil.getLanguageForPsi怎么用?Java LanguageUtil.getLanguageForPsi使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.lang.LanguageUtil的用法示例。


在下文中一共展示了LanguageUtil.getLanguageForPsi方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateFileExtension

import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
public static void updateFileExtension(@Nonnull Project project, @Nullable VirtualFile file) throws IOException {
  ApplicationManager.getApplication().assertWriteAccessAllowed();
  if (CommandProcessor.getInstance().getCurrentCommand() == null) {
    throw new AssertionError("command required");
  }

  if (file == null) return;
  Language language = LanguageUtil.getLanguageForPsi(project, file);
  FileType expected = getFileTypeFromName(file);
  FileType actual = language == null ? null : language.getAssociatedFileType();
  if (expected == actual || actual == null) return;
  String ext = actual.getDefaultExtension();
  if (StringUtil.isEmpty(ext)) return;

  String newName = PathUtil.makeFileName(file.getNameWithoutExtension(), ext);
  VirtualFile parent = file.getParent();
  newName = parent != null && parent.findChild(newName) != null ? PathUtil.makeFileName(file.getName(), ext) : newName;
  file.rename(ScratchUtil.class, newName);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:ScratchUtil.java

示例2: calcBaseLanguage

import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
private static Language calcBaseLanguage(@Nonnull VirtualFile file, @Nonnull Project project, @Nonnull final FileType fileType) {
  if (fileType.isBinary()) return Language.ANY;
  if (isTooLargeForIntelligence(file)) return PlainTextLanguage.INSTANCE;

  Language language = LanguageUtil.getLanguageForPsi(project, file);

  return language != null ? language : PlainTextLanguage.INSTANCE;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:SingleRootFileViewProvider.java

示例3: createFileViewProvider

import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
@Override
@Nonnull
public FileViewProvider createFileViewProvider(@Nonnull final VirtualFile file, boolean eventSystemEnabled) {
  FileType fileType = file.getFileType();
  Language language = LanguageUtil.getLanguageForPsi(myManager.getProject(), file);
  FileViewProviderFactory factory = language == null
                                    ? FileTypeFileViewProviders.INSTANCE.forFileType(fileType)
                                    : LanguageFileViewProviders.INSTANCE.forLanguage(language);
  FileViewProvider viewProvider = factory == null ? null : factory.createFileViewProvider(file, language, myManager, eventSystemEnabled);

  return viewProvider == null ? new SingleRootFileViewProvider(myManager, file, eventSystemEnabled, fileType) : viewProvider;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:FileManagerImpl.java

示例4: create

import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
@Override
@Nullable
public SyntaxHighlighter create(@Nonnull FileType fileType, @Nullable Project project, @Nullable VirtualFile file) {
  if (project == null || file == null || !(fileType instanceof ScratchFileType)) return null;

  Language language = LanguageUtil.getLanguageForPsi(project, file);
  return language == null ? null : SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, file);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:ScratchFileServiceImpl.java

示例5: hasMatchingExtension

import com.intellij.lang.LanguageUtil; //导入方法依赖的package包/类
public static boolean hasMatchingExtension(@Nonnull Project project, @Nonnull VirtualFile file) {
  FileType expected = getFileTypeFromName(file);
  Language language = LanguageUtil.getLanguageForPsi(project, file);
  FileType actual = language == null ? null : language.getAssociatedFileType();
  return expected == actual && actual != null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:7,代码来源:ScratchUtil.java


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