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


Java LanguageLevelUtil类代码示例

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


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

示例1: checkComponentProperties

import com.intellij.openapi.module.LanguageLevelUtil; //导入依赖的package包/类
protected void checkComponentProperties(Module module, final IComponent component, final FormErrorCollector collector) {
  final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
  final PsiManager psiManager = PsiManager.getInstance(module.getProject());
  final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
  if (aClass == null) {
    return;
  }

  for(final IProperty prop: component.getModifiedProperties()) {
    final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, prop.getName(), false, true);
    if (getter == null) continue;
    final LanguageLevel languageLevel = LanguageLevelUtil.getEffectiveLanguageLevel(module);
    if (Java15APIUsageInspection.isForbiddenApiUsage(getter, languageLevel)) {
      registerError(component, collector, prop, "@since " + Java15APIUsageInspection.getShortName(languageLevel));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:Java15FormInspection.java

示例2: getLanguageLevelInner

import com.intellij.openapi.module.LanguageLevelUtil; //导入依赖的package包/类
private static LanguageLevel getLanguageLevelInner(@NotNull PsiDirectory dir) {
  final VirtualFile virtualFile = dir.getVirtualFile();
  final Project project = dir.getProject();
  final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile);
  if (module != null) {
    return LanguageLevelUtil.getEffectiveLanguageLevel(module);
  }

  return LanguageLevelProjectExtension.getInstance(project).getLanguageLevel();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:JavaDirectoryServiceImpl.java

示例3: update

import com.intellij.openapi.module.LanguageLevelUtil; //导入依赖的package包/类
@Override
public void update(final AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setVisible(false);
  presentation.setEnabled(false);
  final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
  if (project == null) {
    return;
  }
  final ErrorTreeElement errorTreeElement = getSelectedErrorTreeElement();
  if (errorTreeElement instanceof NavigatableMessageElement) {
    final NavigatableMessageElement messageElement = (NavigatableMessageElement)errorTreeElement;
    final String[] text = messageElement.getText();
    if (text.length > 0) {
      if (text[0].startsWith("[") && text[0].indexOf("]") != -1) {
        final Navigatable navigatable = messageElement.getNavigatable();
        if (navigatable instanceof OpenFileDescriptor) {
          final OpenFileDescriptor fileDescriptor = (OpenFileDescriptor)navigatable;
          final VirtualFile virtualFile = fileDescriptor.getFile();
          final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
          if (module == null) {
            return;
          }
          final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
          if (jdk == null) {
            return;
          }
          final boolean is_1_5 = JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_5);
          if (!is_1_5) {
            return;
          }
          final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
          if (psiFile == null) {
            return;
          }
          if (LanguageLevelUtil.getEffectiveLanguageLevel(module).compareTo(LanguageLevel.JDK_1_5) < 0) return;
          final PsiElement context = psiFile.findElementAt(fileDescriptor.getOffset());
          if (context == null) {
            return;
          }
          final String id = text[0].substring(1, text[0].indexOf("]"));
          final SuppressFix suppressInspectionFix = getSuppressAction(id);
          final boolean available = suppressInspectionFix.isAvailable(project, context);
          presentation.setEnabled(available);
          presentation.setVisible(available);
          if (available) {
            presentation.setText(suppressInspectionFix.getText());
          }
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:CompilerErrorTreeView.java

示例4: getImmediateValue

import com.intellij.openapi.module.LanguageLevelUtil; //导入依赖的package包/类
@Override
public LanguageLevel getImmediateValue(@NotNull Module module) {
  return LanguageLevelUtil.getEffectiveLanguageLevel(module);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:5,代码来源:JavaLanguageLevelPusher.java

示例5: getSyntaxHighlighter

import com.intellij.openapi.module.LanguageLevelUtil; //导入依赖的package包/类
/**
 * SyntaxHighlighterFactory implementation (for Java source files).
 */
@Override
@NotNull
public SyntaxHighlighter getSyntaxHighlighter(@Nullable Project project, @Nullable VirtualFile file) {
  return new JavaFileHighlighter(LanguageLevelUtil.getLanguageLevelForFile(file));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:JavaSyntaxHighlighterFactory.java

示例6: update

import com.intellij.openapi.module.LanguageLevelUtil; //导入依赖的package包/类
@Override
public void update(final AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setVisible(false);
  presentation.setEnabled(false);
  final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
  if (project == null) {
    return;
  }
  final ErrorTreeElement errorTreeElement = getSelectedErrorTreeElement();
  if (errorTreeElement instanceof NavigatableMessageElement) {
    final NavigatableMessageElement messageElement = (NavigatableMessageElement)errorTreeElement;
    final String[] text = messageElement.getText();
    if (text.length > 0) {
      if (text[0].startsWith("[") && text[0].indexOf("]") != -1) {
        final Navigatable navigatable = messageElement.getNavigatable();
        if (navigatable instanceof OpenFileDescriptor) {
          final OpenFileDescriptor fileDescriptor = (OpenFileDescriptor)navigatable;
          final VirtualFile virtualFile = fileDescriptor.getFile();
          final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
          if (module == null) {
            return;
          }
          final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
          if (jdk == null) {
            return;
          }
          final boolean is_1_5 = JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_5);
          if (!is_1_5) {
            return;
          }
          final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
          if (psiFile == null) {
            return;
          }
          if (LanguageLevelUtil.getEffectiveLanguageLevel(module).compareTo(LanguageLevel.JDK_1_5) < 0) return;
          final PsiElement context = psiFile.findElementAt(fileDescriptor.getOffset());
          if (context == null) {
            return;
          }
          final String id = text[0].substring(1, text[0].indexOf("]"));
          final SuppressFix suppressInspectionFix = getSuppressAction(id);
          final boolean available = suppressInspectionFix.isAvailable(project, context);
          presentation.setEnabled(available);
          presentation.setVisible(available);
          if (available) {
            presentation.setText(suppressInspectionFix.getText());
          }
        }
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:54,代码来源:CompilerErrorTreeView.java

示例7: getLanguageLevel

import com.intellij.openapi.module.LanguageLevelUtil; //导入依赖的package包/类
public LanguageLevel getLanguageLevel() {
  return LanguageLevelUtil.getEffectiveLanguageLevel(getNodes().iterator().next());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:ModuleChunk.java


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