本文整理汇总了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));
}
}
}
示例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();
}
示例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());
}
}
}
}
}
}
示例4: getImmediateValue
import com.intellij.openapi.module.LanguageLevelUtil; //导入依赖的package包/类
@Override
public LanguageLevel getImmediateValue(@NotNull Module module) {
return LanguageLevelUtil.getEffectiveLanguageLevel(module);
}
示例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));
}
示例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());
}
}
}
}
}
}
示例7: getLanguageLevel
import com.intellij.openapi.module.LanguageLevelUtil; //导入依赖的package包/类
public LanguageLevel getLanguageLevel() {
return LanguageLevelUtil.getEffectiveLanguageLevel(getNodes().iterator().next());
}