mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' into upsource-master
This commit is contained in:
@@ -643,7 +643,8 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
|
||||
cmdLine.addParameter("-classpath");
|
||||
|
||||
final List<File> cp = ClasspathBootstrap.getCompileServerApplicationClasspath();
|
||||
final List<File> cp = ClasspathBootstrap.getBuildProcessApplicationClasspath();
|
||||
cp.add(ClasspathBootstrap.getResourcePath(systemCompiler.getClass())); // tools.jar
|
||||
cp.addAll(myClasspathManager.getCompileServerPluginsClasspath());
|
||||
|
||||
cmdLine.addParameter(classpathToString(cp));
|
||||
|
||||
@@ -565,14 +565,10 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
|
||||
private Process launchBuildProcess(Project project, final int port, final UUID sessionId) throws ExecutionException {
|
||||
// validate tools.jar presence
|
||||
final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (systemCompiler == null) {
|
||||
throw new ExecutionException("No system java compiler is provided by the JRE. Make sure tools.jar is present in IntelliJ IDEA classpath.");
|
||||
}
|
||||
|
||||
// choosing sdk with which the build process should be run
|
||||
Sdk projectJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
|
||||
final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
|
||||
Sdk projectJdk = internalJdk;
|
||||
final String versionString = projectJdk.getVersionString();
|
||||
if (versionString != null) {
|
||||
JavaSdkVersion sdkVersion = ((JavaSdk)projectJdk.getSdkType()).getVersion(versionString);
|
||||
@@ -600,6 +596,23 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
}
|
||||
|
||||
// validate tools.jar presence
|
||||
final File compilerPath;
|
||||
if (projectJdk.equals(internalJdk)) {
|
||||
final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (systemCompiler == null) {
|
||||
throw new ExecutionException("No system java compiler is provided by the JRE. Make sure tools.jar is present in IntelliJ IDEA classpath.");
|
||||
}
|
||||
compilerPath = ClasspathBootstrap.getResourcePath(systemCompiler.getClass());
|
||||
}
|
||||
else {
|
||||
final String path = ((JavaSdk)projectJdk.getSdkType()).getToolsPath(projectJdk);
|
||||
if (path == null) {
|
||||
throw new ExecutionException("Cannot determine path to 'tools.jar' library for " + projectJdk.getName() + " (" + projectJdk.getHomePath() + ")");
|
||||
}
|
||||
compilerPath = new File(path);
|
||||
}
|
||||
|
||||
final GeneralCommandLine cmdLine = new GeneralCommandLine();
|
||||
final String vmExecutablePath = ((JavaSdkType)projectJdk.getSdkType()).getVMExecutablePath(projectJdk);
|
||||
cmdLine.setExePath(vmExecutablePath);
|
||||
@@ -667,7 +680,8 @@ public class BuildManager implements ApplicationComponent{
|
||||
|
||||
cmdLine.addParameter("-classpath");
|
||||
|
||||
final List<File> cp = ClasspathBootstrap.getCompileServerApplicationClasspath();
|
||||
final List<File> cp = ClasspathBootstrap.getBuildProcessApplicationClasspath();
|
||||
cp.add(compilerPath);
|
||||
cp.addAll(myClasspathManager.getCompileServerPluginsClasspath());
|
||||
|
||||
cmdLine.addParameter(classpathToString(cp));
|
||||
@@ -820,13 +834,17 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
|
||||
public void addChanged(Collection<String> paths) {
|
||||
myDeleted.removeAll(paths);
|
||||
myChanged.addAll(paths);
|
||||
if (!myNeedRescan) {
|
||||
myDeleted.removeAll(paths);
|
||||
myChanged.addAll(paths);
|
||||
}
|
||||
}
|
||||
|
||||
public void addDeleted(Collection<String> paths) {
|
||||
myChanged.removeAll(paths);
|
||||
myDeleted.addAll(paths);
|
||||
if (!myNeedRescan) {
|
||||
myChanged.removeAll(paths);
|
||||
myDeleted.addAll(paths);
|
||||
}
|
||||
}
|
||||
|
||||
public CmdlineRemoteProto.Message.ControllerMessage.FSEvent createNextEvent() {
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.searches.AllOverridingMethodsSearch;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
@@ -60,6 +61,8 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
|
||||
private static final Icon IMPLEMENTED_INTERFACE_MARKER_RENDERER = IMPLEMENTED_METHOD_MARKER_RENDERER;
|
||||
private static final Icon SUBCLASSED_CLASS_MARKER_RENDERER = OVERRIDEN_METHOD_MARKER_RENDERER;
|
||||
|
||||
private static final Icon RECURSIVE_METHOD_ICON = IconLoader.getIcon("/gutter/recursiveMethod.png");
|
||||
|
||||
protected final DaemonCodeAnalyzerSettings myDaemonSettings;
|
||||
protected final EditorColorsManager myColorsManager;
|
||||
|
||||
@@ -164,6 +167,11 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
|
||||
}
|
||||
else if (element instanceof PsiClass && !(element instanceof PsiTypeParameter)) {
|
||||
collectInheritingClasses((PsiClass)element, result);
|
||||
} else if(element instanceof PsiMethodCallExpression){
|
||||
final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)element;
|
||||
if (isRecursiveMethodCall(methodCall)){
|
||||
result.add(new RecursiveMethodCallMarkerInfo(methodCall));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!methods.isEmpty()) {
|
||||
@@ -171,6 +179,14 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isRecursiveMethodCall(@NotNull PsiMethodCallExpression methodCall){
|
||||
PsiMethod referencedMethod = methodCall.resolveMethod();
|
||||
|
||||
TextRange rmRange = referencedMethod == null ? null : referencedMethod.getTextRange();
|
||||
int mcOffset = methodCall.getTextRange().getStartOffset();
|
||||
return rmRange != null && rmRange.contains(mcOffset);
|
||||
}
|
||||
|
||||
private static void collectInheritingClasses(PsiClass aClass, Collection<LineMarkerInfo> result) {
|
||||
if (aClass.hasModifierProperty(PsiModifier.FINAL)) {
|
||||
return;
|
||||
@@ -276,4 +292,36 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static class RecursiveMethodCallMarkerInfo extends MergeableLineMarkerInfo<PsiMethodCallExpression> {
|
||||
private RecursiveMethodCallMarkerInfo(@NotNull PsiMethodCallExpression methodCall) {
|
||||
super(methodCall,
|
||||
methodCall.getTextRange(),
|
||||
RECURSIVE_METHOD_ICON,
|
||||
Pass.UPDATE_OVERRIDEN_MARKERS,
|
||||
FunctionUtil.<PsiMethodCallExpression, String>constant("Recursive call"),
|
||||
null,
|
||||
GutterIconRenderer.Alignment.RIGHT
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMergeWith(@NotNull MergeableLineMarkerInfo<?> info) {
|
||||
if (!(info instanceof RecursiveMethodCallMarkerInfo)) return false;
|
||||
PsiElement otherElement = info.getElement();
|
||||
PsiElement myElement = getElement();
|
||||
return otherElement != null && myElement != null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Icon getCommonIcon(@NotNull List<MergeableLineMarkerInfo> infos) {
|
||||
return myIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<? super PsiElement, String> getCommonTooltip(@NotNull List<MergeableLineMarkerInfo> infos) {
|
||||
return FunctionUtil.<PsiElement, String>constant("Multiple recursive calls");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-23
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,6 @@ import java.util.*;
|
||||
*/
|
||||
public class GenericsHighlightUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil");
|
||||
private static final String GENERICS_ARE_NOT_SUPPORTED = JavaErrorMessages.message("generics.are.not.supported");
|
||||
private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance();
|
||||
|
||||
private GenericsHighlightUtil() {}
|
||||
@@ -102,6 +101,7 @@ public class GenericsHighlightUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkParameterizedReferenceTypeArguments(PsiElement resolved,
|
||||
final PsiJavaCodeReferenceElement referenceElement,
|
||||
final PsiSubstitutor substitutor) {
|
||||
@@ -110,17 +110,14 @@ public class GenericsHighlightUtil {
|
||||
return checkReferenceTypeArgumentList(typeParameterListOwner, referenceElement.getParameterList(), substitutor, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkReferenceTypeArgumentList(final PsiTypeParameterListOwner typeParameterListOwner,
|
||||
final PsiReferenceParameterList referenceParameterList,
|
||||
final PsiSubstitutor substitutor,
|
||||
boolean registerIntentions) {
|
||||
if (referenceParameterList != null && !PsiUtil.isLanguageLevel5OrHigher(referenceParameterList)) {
|
||||
if (referenceParameterList.getTypeParameterElements().length > 0) {
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, referenceParameterList, GENERICS_ARE_NOT_SUPPORTED);
|
||||
QuickFixAction.registerQuickFixAction(info, new ShowModulePropertiesFix(referenceParameterList));
|
||||
QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5));
|
||||
return info;
|
||||
}
|
||||
if (referenceParameterList != null) {
|
||||
HighlightInfo info = HighlightUtil.checkGenericsFeature(referenceParameterList, referenceParameterList.getTypeParameterElements().length);
|
||||
if (info != null) return info;
|
||||
}
|
||||
|
||||
PsiDiamondType.DiamondInferenceResult inferenceResult = null;
|
||||
@@ -914,15 +911,13 @@ public class GenericsHighlightUtil {
|
||||
return valueOfMethod.equals(methodSignature);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkTypeParametersList(PsiTypeParameterList parameterList) {
|
||||
PsiTypeParameter[] typeParameters = parameterList.getTypeParameters();
|
||||
if (typeParameters.length == 0) return null;
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(parameterList)) {
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, parameterList, GENERICS_ARE_NOT_SUPPORTED);
|
||||
QuickFixAction.registerQuickFixAction(info, new ShowModulePropertiesFix(parameterList));
|
||||
QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5));
|
||||
return info;
|
||||
}
|
||||
HighlightInfo info = HighlightUtil.checkGenericsFeature(parameterList, typeParameters.length);
|
||||
if (info != null) return info;
|
||||
|
||||
final PsiElement parent = parameterList.getParent();
|
||||
if (parent instanceof PsiClass && ((PsiClass)parent).isEnum()) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
@@ -1208,21 +1203,18 @@ public class GenericsHighlightUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkVarArgParameterIsLast(PsiParameter parameter) {
|
||||
PsiElement declarationScope = parameter.getDeclarationScope();
|
||||
if (declarationScope instanceof PsiMethod) {
|
||||
PsiParameter[] params = ((PsiMethod)declarationScope).getParameterList().getParameters();
|
||||
if (parameter.isVarArgs()) {
|
||||
if (!PsiUtil.getLanguageLevel(parameter).hasEnumKeywordAndAutoboxing()) {
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, parameter, JavaErrorMessages.message("varargs.prior.15"));
|
||||
QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5));
|
||||
return info;
|
||||
}
|
||||
HighlightInfo info = HighlightUtil.checkVarargFeature(parameter);
|
||||
if (info != null) return info;
|
||||
|
||||
if (params[params.length - 1] != parameter) {
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, parameter,
|
||||
JavaErrorMessages.message("vararg.not.last.parameter"));
|
||||
QuickFixAction.registerQuickFixAction(info, new MakeVarargParameterLastFix(parameter), null);
|
||||
info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, parameter, JavaErrorMessages.message("vararg.not.last.parameter"));
|
||||
QuickFixAction.registerQuickFixAction(info, new MakeVarargParameterLastFix(parameter));
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@@ -1230,6 +1222,7 @@ public class GenericsHighlightUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static List<HighlightInfo> checkEnumConstantModifierList(PsiModifierList modifierList) {
|
||||
List<HighlightInfo> list = null;
|
||||
PsiElement[] children = modifierList.getChildren();
|
||||
|
||||
+83
-5
@@ -58,6 +58,7 @@ import org.intellij.lang.annotations.Language;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -593,6 +594,7 @@ public class HighlightUtil {
|
||||
if (variable instanceof PsiLocalVariable ||
|
||||
variable instanceof PsiParameter && ((PsiParameter)variable).getDeclarationScope() instanceof PsiCatchSection ||
|
||||
variable instanceof PsiParameter && ((PsiParameter)variable).getDeclarationScope() instanceof PsiForeachStatement) {
|
||||
@SuppressWarnings("unchecked")
|
||||
PsiElement scope = PsiTreeUtil.getParentOfType(variable, PsiFile.class, PsiMethod.class, PsiClassInitializer.class, PsiResourceList.class);
|
||||
VariablesNotProcessor proc = new VariablesNotProcessor(variable, false) {
|
||||
@Override
|
||||
@@ -602,7 +604,9 @@ public class HighlightUtil {
|
||||
};
|
||||
PsiScopesUtil.treeWalkUp(proc, identifier, scope);
|
||||
if (scope instanceof PsiResourceList && proc.size() == 0) {
|
||||
scope = PsiTreeUtil.getParentOfType(variable, PsiFile.class, PsiMethod.class, PsiClassInitializer.class);
|
||||
@SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
|
||||
NavigatablePsiElement parent = PsiTreeUtil.getParentOfType(variable, PsiFile.class, PsiMethod.class, PsiClassInitializer.class);
|
||||
scope = parent;
|
||||
PsiScopesUtil.treeWalkUp(proc, identifier, scope);
|
||||
}
|
||||
if (proc.size() > 0) {
|
||||
@@ -1403,7 +1407,7 @@ public class HighlightUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkValidArrayAccessExpression(PsiExpression arrayExpression, PsiExpression indexExpression, PsiType type) {
|
||||
static HighlightInfo checkValidArrayAccessExpression(@Nullable PsiExpression arrayExpression, PsiExpression indexExpression, PsiType type) {
|
||||
PsiType arrayExpressionType = arrayExpression == null ? null : arrayExpression.getType();
|
||||
if (arrayExpressionType != null && !(arrayExpressionType instanceof PsiArrayType)) {
|
||||
String description = JavaErrorMessages.message("array.type.expected", formatType(arrayExpressionType));
|
||||
@@ -1744,9 +1748,11 @@ public class HighlightUtil {
|
||||
referencedClass = PsiUtil.resolveClassInType(type);
|
||||
}
|
||||
else if (qualifier instanceof PsiThisExpression || qualifier == null) {
|
||||
resolved = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiMember.class);
|
||||
@SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
|
||||
PsiMethod parent = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiMember.class);
|
||||
resolved = parent;
|
||||
expression = qualifier == null ? expression : qualifier;
|
||||
if (resolved instanceof PsiMethod) {
|
||||
if (resolved != null) {
|
||||
referencedClass = ((PsiMethod)resolved).getContainingClass();
|
||||
}
|
||||
}
|
||||
@@ -2452,7 +2458,7 @@ public class HighlightUtil {
|
||||
public static void registerChangeVariableTypeFixes(PsiVariable parameter, PsiType itemType, HighlightInfo highlightInfo) {
|
||||
for (ChangeVariableTypeQuickFixProvider fixProvider : Extensions.getExtensions(ChangeVariableTypeQuickFixProvider.EP_NAME)) {
|
||||
for (IntentionAction action : fixProvider.getFixes(parameter, itemType)) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, action, null);
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, action);
|
||||
}
|
||||
}
|
||||
ChangeParameterClassFix.registerQuickFixAction(parameter, itemType, highlightInfo);
|
||||
@@ -2466,4 +2472,76 @@ public class HighlightUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static enum Feature {
|
||||
GENERICS(LanguageLevel.JDK_1_5, "feature.generics"),
|
||||
ANNOTATIONS(LanguageLevel.JDK_1_5, "feature.annotations"),
|
||||
STATIC_IMPORTS(LanguageLevel.JDK_1_5, "feature.static.imports"),
|
||||
FOR_EACH(LanguageLevel.JDK_1_5, "feature.for.each"),
|
||||
VARARGS(LanguageLevel.JDK_1_5, "feature.varargs"),
|
||||
DIAMOND_TYPES(LanguageLevel.JDK_1_7, "feature.diamond.types"),
|
||||
MULTI_CATCH(LanguageLevel.JDK_1_7, "feature.multi.catch"),
|
||||
TRY_WITH_RESOURCES(LanguageLevel.JDK_1_7, "feature.try.with.resources");
|
||||
|
||||
private final LanguageLevel level;
|
||||
private final String key;
|
||||
|
||||
private Feature(final LanguageLevel level, @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) final String key) {
|
||||
this.level = level;
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static HighlightInfo checkFeature(@Nullable final PsiElement element, @NotNull final Feature feature) {
|
||||
if (element != null && !PsiUtil.getLanguageLevel(element).isAtLeast(feature.level)) {
|
||||
final String message = JavaErrorMessages.message("insufficient.language.level", JavaErrorMessages.message(feature.key));
|
||||
final HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, element, message);
|
||||
QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(feature.level));
|
||||
QuickFixAction.registerQuickFixAction(info, new ShowModulePropertiesFix(element));
|
||||
return info;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkGenericsFeature(final PsiElement parameterList, final int listSize) {
|
||||
return listSize > 0 ? checkFeature(parameterList, Feature.GENERICS) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkAnnotationFeature(final PsiElement element) {
|
||||
return checkFeature(element, Feature.ANNOTATIONS);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkForEachFeature(final PsiForeachStatement statement) {
|
||||
return checkFeature(statement, Feature.FOR_EACH);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkStaticImportFeature(final PsiImportStaticStatement statement) {
|
||||
return checkFeature(statement, Feature.STATIC_IMPORTS);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkVarargFeature(final PsiParameter parameter) {
|
||||
return checkFeature(parameter, Feature.VARARGS);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkDiamondFeature(final PsiTypeElement typeElement) {
|
||||
return typeElement.getType() instanceof PsiDiamondType ? checkFeature(typeElement.getParent(), Feature.DIAMOND_TYPES) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkMultiCatchFeature(final PsiParameter parameter) {
|
||||
return parameter.getType() instanceof PsiDisjunctionType ? checkFeature(parameter, Feature.MULTI_CATCH) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkTryWithResourcesFeature(final PsiResourceVariable resourceVariable) {
|
||||
return checkFeature(resourceVariable.getParent(), Feature.TRY_WITH_RESOURCES);
|
||||
}
|
||||
}
|
||||
|
||||
+24
-31
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,6 @@ import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.controlFlow.ControlFlowUtil;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocMethodOrFieldRef;
|
||||
@@ -170,16 +169,11 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitAnnotation(PsiAnnotation annotation) {
|
||||
@Override
|
||||
public void visitAnnotation(PsiAnnotation annotation) {
|
||||
super.visitAnnotation(annotation);
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(annotation)) {
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, annotation, JavaErrorMessages.message("annotations.prior.15"));
|
||||
QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5));
|
||||
myHolder.add(info);
|
||||
return;
|
||||
}
|
||||
|
||||
myHolder.add(AnnotationsHighlightUtil.checkApplicability(annotation));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkAnnotationFeature(annotation));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkApplicability(annotation));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkAnnotationType(annotation));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkMissingAttributes(annotation));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkTargetAnnotationDuplicates(annotation));
|
||||
@@ -187,7 +181,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkForeignInnerClassesUsed(annotation));
|
||||
}
|
||||
|
||||
@Override public void visitAnnotationArrayInitializer(PsiArrayInitializerMemberValue initializer) {
|
||||
@Override
|
||||
public void visitAnnotationArrayInitializer(PsiArrayInitializerMemberValue initializer) {
|
||||
PsiMethod method = null;
|
||||
PsiElement parent = initializer.getParent();
|
||||
if (parent instanceof PsiNameValuePair) {
|
||||
@@ -364,28 +359,24 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitField(PsiField field) {
|
||||
@Override
|
||||
public void visitField(PsiField field) {
|
||||
super.visitField(field);
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightControlFlowUtil.checkFinalFieldInitialized(field));
|
||||
}
|
||||
|
||||
@Override public void visitForeachStatement(PsiForeachStatement statement) {
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(statement)) {
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, statement.getFirstChild(), JavaErrorMessages.message("foreach.prior.15"));
|
||||
QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5));
|
||||
myHolder.add(info);
|
||||
}
|
||||
@Override
|
||||
public void visitForeachStatement(final PsiForeachStatement statement) {
|
||||
myHolder.add(HighlightUtil.checkForEachFeature(statement));
|
||||
}
|
||||
|
||||
@Override public void visitImportStaticStatement(PsiImportStaticStatement statement) {
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(statement)) {
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, statement.getFirstChild(), JavaErrorMessages.message("static.imports.prior.15"));
|
||||
QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5));
|
||||
myHolder.add(info);
|
||||
}
|
||||
@Override
|
||||
public void visitImportStaticStatement(final PsiImportStaticStatement statement) {
|
||||
myHolder.add(HighlightUtil.checkStaticImportFeature(statement));
|
||||
}
|
||||
|
||||
@Override public void visitIdentifier(PsiIdentifier identifier) {
|
||||
@Override
|
||||
public void visitIdentifier(final PsiIdentifier identifier) {
|
||||
PsiElement parent = identifier.getParent();
|
||||
final EditorColorsScheme colorsScheme = myHolder.getColorsScheme();
|
||||
if (parent instanceof PsiVariable) {
|
||||
@@ -411,10 +402,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
else if (parent instanceof PsiClass) {
|
||||
PsiClass aClass = (PsiClass)parent;
|
||||
if (aClass.isAnnotationType() && !PsiUtil.isLanguageLevel5OrHigher(aClass)) {
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, identifier, JavaErrorMessages.message("annotations.prior.15"));
|
||||
QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5));
|
||||
myHolder.add(info);
|
||||
if (aClass.isAnnotationType()) {
|
||||
myHolder.add(HighlightUtil.checkAnnotationFeature(identifier));
|
||||
}
|
||||
|
||||
myHolder.add(HighlightClassUtil.checkClassAlreadyImported(aClass, identifier));
|
||||
@@ -742,6 +731,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkForeachLoopParameterType((PsiForeachStatement)parent));
|
||||
}
|
||||
else if (parent instanceof PsiCatchSection) {
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkMultiCatchFeature(parameter));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkCatchParameterIsThrowable(parameter));
|
||||
if (!myHolder.hasErrorResults()) myHolder.addAll(GenericsHighlightUtil.checkCatchParameterIsClass(parameter));
|
||||
if (!myHolder.hasErrorResults()) myHolder.addAll(HighlightUtil.checkCatchTypeIsDisjoint(parameter));
|
||||
@@ -987,11 +977,14 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitResourceVariable(final PsiResourceVariable resourceVariable) {
|
||||
visitVariable(resourceVariable);
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkTryWithResourcesFeature(resourceVariable));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkTryResourceIsAutoCloseable(resourceVariable));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkUnhandledCloserExceptions(resourceVariable));
|
||||
}
|
||||
|
||||
@Override public void visitTypeElement(PsiTypeElement type) {
|
||||
@Override
|
||||
public void visitTypeElement(final PsiTypeElement type) {
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkDiamondFeature(type));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkIllegalType(type));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkReferenceTypeUsedAsTypeArgument(type));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkWildcardUsage(type));
|
||||
|
||||
@@ -137,7 +137,7 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{
|
||||
String idsString = SuppressManager.getInstance().getSuppressedInspectionIdsIn(owner);
|
||||
if (idsString != null && idsString.length() != 0) {
|
||||
List<String> ids = StringUtil.split(idsString, ",");
|
||||
if (IGNORE_ALL && ids.contains(SuppressionUtil.ALL)) return;
|
||||
if (IGNORE_ALL && (ids.contains(SuppressionUtil.ALL) || ids.contains(SuppressionUtil.ALL.toLowerCase()))) return;
|
||||
Collection<String> suppressed = suppressedScopes.get(owner);
|
||||
if (suppressed == null) {
|
||||
suppressed = ids;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,6 +39,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -118,7 +119,7 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
binary.getLOperand().replace(qualifier);
|
||||
List<LocalQuickFix> fixes = new SmartList<LocalQuickFix>();
|
||||
|
||||
if (PsiUtil.getLanguageLevel(qualifier).hasAssertKeyword()) {
|
||||
if (PsiUtil.getLanguageLevel(qualifier).isAtLeast(LanguageLevel.JDK_1_4)) {
|
||||
fixes.add(new AddAssertStatementFix(binary));
|
||||
}
|
||||
SurroundWithIfFix ifFix = new SurroundWithIfFix(qualifier);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,9 +34,7 @@ public class JavaHighlightingLexer extends LayeredLexer {
|
||||
registerSelfStoppingLayer(new StringLiteralLexer('\'', JavaTokenType.STRING_LITERAL),
|
||||
new IElementType[]{JavaTokenType.CHARACTER_LITERAL}, IElementType.EMPTY_ARRAY);
|
||||
|
||||
|
||||
|
||||
LayeredLexer docLexer = new LayeredLexer(new JavaDocLexer(languageLevel.hasEnumKeywordAndAutoboxing()));
|
||||
LayeredLexer docLexer = new LayeredLexer(new JavaDocLexer(languageLevel.isAtLeast(LanguageLevel.JDK_1_5)));
|
||||
|
||||
HtmlHighlightingLexer lexer = new HtmlHighlightingLexer();
|
||||
lexer.setHasNoEmbeddments(true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -53,7 +53,7 @@ public class ValueDocTagInfo implements JavadocTagInfo {
|
||||
public String checkTagValue(PsiDocTagValue value) {
|
||||
boolean hasReference = (value != null && value.getFirstChild() != null);
|
||||
if (hasReference) {
|
||||
if (!PsiUtil.getLanguageLevel(value).hasEnumKeywordAndAutoboxing()) {
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(value)) {
|
||||
return JavaErrorMessages.message("javadoc.value.tag.jdk15.required");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -82,7 +82,7 @@ public class JavaClassReferenceSet {
|
||||
|
||||
if (ch == LT || ch == COMMA) {
|
||||
if (!allowGenericsCalculated) {
|
||||
allowGenerics = !isStaticImport && PsiUtil.getLanguageLevel(element).hasEnumKeywordAndAutoboxing();
|
||||
allowGenerics = !isStaticImport && PsiUtil.isLanguageLevel5OrHigher(element);
|
||||
allowGenericsCalculated = true;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.SuggestedNameInfo;
|
||||
@@ -265,7 +266,7 @@ class IntroduceConstantDialog extends DialogWrapper {
|
||||
|
||||
final PsiManager psiManager = PsiManager.getInstance(myProject);
|
||||
if ((myTypeSelectorManager.isSuggestedType("java.lang.String") || (myLocalVariable != null && AnnotationUtil.isAnnotated(myLocalVariable, AnnotationUtil.NON_NLS, false)))&&
|
||||
LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel().hasEnumKeywordAndAutoboxing() &&
|
||||
LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5) &&
|
||||
JavaPsiFacade.getInstance(psiManager.getProject()).findClass(AnnotationUtil.NON_NLS, myParentClass.getResolveScope()) != null) {
|
||||
final PropertiesComponent component = PropertiesComponent.getInstance(myProject);
|
||||
myCbNonNls.setSelected(component.isTrueValue(NONNLS_SELECTED_PROPERTY));
|
||||
|
||||
+10
-12
@@ -80,20 +80,10 @@ public class JavaNameSuggestionProvider implements NameSuggestionProvider {
|
||||
}
|
||||
}
|
||||
final String[] strings = info != null ? info.names : ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
ArrayList<String> list = new ArrayList<String>(Arrays.asList(strings));
|
||||
final ArrayList<String> list = new ArrayList<String>(Arrays.asList(strings));
|
||||
final String[] properlyCased = suggestProperlyCasedName(element);
|
||||
if (!list.contains(initialName)) {
|
||||
list.add(0, initialName);
|
||||
}
|
||||
else {
|
||||
int i = list.indexOf(initialName);
|
||||
list.remove(i);
|
||||
list.add(0, initialName);
|
||||
}
|
||||
if (properlyCased != null) {
|
||||
for (String properlyCasedSuggestion : properlyCased) {
|
||||
list.add(1, properlyCasedSuggestion);
|
||||
}
|
||||
Collections.addAll(list, properlyCased);
|
||||
}
|
||||
if (parameterName != null && !list.contains(parameterName)) {
|
||||
list.add(parameterName);
|
||||
@@ -101,6 +91,14 @@ public class JavaNameSuggestionProvider implements NameSuggestionProvider {
|
||||
if (superMethodName != null && !list.contains(superMethodName)) {
|
||||
list.add(0, superMethodName);
|
||||
}
|
||||
if (!list.contains(initialName)) {
|
||||
list.add(initialName);
|
||||
}
|
||||
else {
|
||||
int i = list.indexOf(initialName);
|
||||
list.remove(i);
|
||||
list.add(initialName);
|
||||
}
|
||||
ContainerUtil.removeDuplicates(list);
|
||||
result.addAll(list);
|
||||
return info;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,14 +39,20 @@ public enum LanguageLevel {
|
||||
myPresentableText = presentableText;
|
||||
}
|
||||
|
||||
/** @deprecated (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public int getIndex() {
|
||||
return ordinal() + 3; // solely for backward compatibility
|
||||
}
|
||||
|
||||
/** @deprecated (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public boolean hasAssertKeyword() {
|
||||
return isAtLeast(JDK_1_4);
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain com.intellij.psi.util.PsiUtil#isLanguageLevel5OrHigher(com.intellij.psi.PsiElement)} (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public boolean hasEnumKeywordAndAutoboxing() {
|
||||
return isAtLeast(JDK_1_5);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -87,6 +87,7 @@ public interface JavaTokenType extends TokenType{
|
||||
IElementType TRY_KEYWORD = new IKeywordElementType("TRY_KEYWORD");
|
||||
IElementType VOLATILE_KEYWORD = new IKeywordElementType("VOLATILE_KEYWORD");
|
||||
IElementType THROWS_KEYWORD = new IKeywordElementType("THROWS_KEYWORD");
|
||||
IElementType NONE_KEYWORD = new IKeywordElementType("NONE_KEYWORD");
|
||||
|
||||
IElementType LPARENTH = new IJavaElementType("LPARENTH");
|
||||
IElementType RPARENTH = new IJavaElementType("RPARENTH");
|
||||
@@ -139,6 +140,9 @@ public interface JavaTokenType extends TokenType{
|
||||
IElementType GTGTEQ = new IJavaElementType("GTGTEQ");
|
||||
IElementType GTGTGTEQ = new IJavaElementType("GTGTGTEQ");
|
||||
|
||||
IElementType DOUBLE_COLON = new IJavaElementType("DOUBLE_COLON");
|
||||
IElementType ARROW = new IJavaElementType("ARROW");
|
||||
|
||||
TokenSet OPERATION_BIT_SET = TokenSet.create(
|
||||
EQ, GT, LT, EXCL, TILDE, QUEST, COLON, PLUS, MINUS, ASTERISK, DIV, AND, OR, XOR,
|
||||
PERC, EQEQ, LE, GE, NE, ANDAND, OROR, PLUSPLUS, MINUSMINUS, LTLT, GTGT, GTGTGT,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -104,7 +104,7 @@ public class PsiPrimitiveType extends PsiType {
|
||||
@Nullable
|
||||
public static PsiPrimitiveType getUnboxedType(PsiType type) {
|
||||
if (!(type instanceof PsiClassType)) return null;
|
||||
if (!((PsiClassType)type).getLanguageLevel().hasEnumKeywordAndAutoboxing()) return null;
|
||||
if (!((PsiClassType)type).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) return null;
|
||||
final PsiClass psiClass = ((PsiClassType)type).resolve();
|
||||
if (psiClass == null) return null;
|
||||
return ourQNameToUnboxed.get(psiClass.getQualifiedName());
|
||||
@@ -124,7 +124,7 @@ public class PsiPrimitiveType extends PsiType {
|
||||
@Nullable
|
||||
public PsiClassType getBoxedType(PsiElement context) {
|
||||
LanguageLevel languageLevel = PsiUtil.getLanguageLevel(context);
|
||||
if (!languageLevel.hasEnumKeywordAndAutoboxing()) return null;
|
||||
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) return null;
|
||||
final String boxedQName = getBoxedTypeName();
|
||||
|
||||
//[ven]previous call returns null for NULL, VOID
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -780,7 +780,7 @@ public class TypeConversionUtil {
|
||||
private static final Key<CachedValue<Set<String>>> POSSIBLE_BOXED_HOLDER_TYPES = Key.create("Types that may be possibly assigned from primitive ones");
|
||||
|
||||
private static boolean isBoxable(final PsiClassType left, final PsiPrimitiveType right) {
|
||||
if (!left.getLanguageLevel().hasEnumKeywordAndAutoboxing()) return false;
|
||||
if (!left.getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) return false;
|
||||
final PsiClass psiClass = left.resolve();
|
||||
if (psiClass == null) return false;
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
psi.error.attempt.to.edit.class.file=Cannot modify compiled element
|
||||
|
||||
#language levels
|
||||
jdk.1.3.language.level.description=1.3 - Plain old Java
|
||||
jdk.1.4.language.level.description=1.4 - 'assert' keyword
|
||||
jdk.1.5.language.level.description=5.0 - 'enum' keyword, autoboxing, etc.
|
||||
jdk.1.5.language.level.description=5.0 - 'enum' keyword, autoboxing etc.
|
||||
jdk.1.6.language.level.description=6.0 - @Override in interfaces
|
||||
jdk.1.7.language.level.description=7.0 - Diamonds, ARM, multi-catch, etc.
|
||||
jdk.1.8.language.level.description=8.0 - Type annotations
|
||||
jdk.1.7.language.level.description=7.0 - Diamonds, ARM, multi-catch etc.
|
||||
jdk.1.8.language.level.description=8.0 - Lambdas, type annotations etc.
|
||||
|
||||
@@ -671,15 +671,14 @@ public class ExpressionParser {
|
||||
final PsiBuilder.Marker newExpr = (start != null ? start.precede() : builder.mark());
|
||||
builder.advanceLexer();
|
||||
|
||||
final boolean parseDiamonds = areDiamondsSupported(builder);
|
||||
myReferenceParser.parseReferenceParameterList(builder, false, parseDiamonds);
|
||||
myReferenceParser.parseReferenceParameterList(builder, false, true);
|
||||
|
||||
final PsiBuilder.Marker refOrType;
|
||||
final boolean parseAnnotations = areTypeAnnotationsSupported(builder) && builder.getTokenType() == JavaTokenType.AT;
|
||||
|
||||
final IElementType tokenType = builder.getTokenType();
|
||||
if (tokenType == JavaTokenType.IDENTIFIER || parseAnnotations) {
|
||||
refOrType = myReferenceParser.parseJavaCodeReference(builder, true, true, parseAnnotations, true, parseDiamonds);
|
||||
refOrType = myReferenceParser.parseJavaCodeReference(builder, true, true, parseAnnotations, true, true);
|
||||
if (refOrType == null) {
|
||||
error(builder, JavaErrorMessages.message("expected.identifier"));
|
||||
newExpr.done(JavaElementType.NEW_EXPRESSION);
|
||||
|
||||
@@ -133,17 +133,6 @@ public class JavaParserUtil {
|
||||
builder.putUserDataUnprotected(LANG_LEVEL_KEY, level);
|
||||
}
|
||||
|
||||
// todo[r.sh] join all JDK 7 check clauses into single method (IDEA 11)
|
||||
public static boolean areDiamondsSupported(final PsiBuilder builder) {
|
||||
return getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_1_7);
|
||||
}
|
||||
public static boolean areMultiCatchSupported(final PsiBuilder builder) {
|
||||
return getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_1_7);
|
||||
}
|
||||
public static boolean areTryWithResourcesSupported(final PsiBuilder builder) {
|
||||
return getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_1_7);
|
||||
}
|
||||
|
||||
public static boolean areTypeAnnotationsSupported(final PsiBuilder builder) {
|
||||
return getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_1_8);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -622,9 +622,8 @@ public class StatementParser {
|
||||
final PsiBuilder.Marker statement = builder.mark();
|
||||
builder.advanceLexer();
|
||||
|
||||
boolean hasResourceList = false;
|
||||
if (areTryWithResourcesSupported(builder) && builder.getTokenType() == JavaTokenType.LPARENTH) {
|
||||
hasResourceList = true;
|
||||
final boolean hasResourceList = builder.getTokenType() == JavaTokenType.LPARENTH;
|
||||
if (hasResourceList) {
|
||||
myDeclarationParser.parseResourceList(builder);
|
||||
}
|
||||
|
||||
@@ -667,7 +666,7 @@ public class StatementParser {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PsiBuilder.Marker param = myDeclarationParser.parseParameter(builder, false, areMultiCatchSupported(builder));
|
||||
final PsiBuilder.Marker param = myDeclarationParser.parseParameter(builder, false, true);
|
||||
if (param == null) {
|
||||
error(builder, JavaErrorMessages.message("expected.parameter"));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,50 +23,51 @@ import com.intellij.psi.impl.source.tree.JavaDocElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
public class JavaLexer extends LexerBase {
|
||||
private JavaLexer(boolean isAssertKeywordEnabled, boolean isJDK15) {
|
||||
myTable = getTable(isAssertKeywordEnabled, isJDK15);
|
||||
myFlexLexer = new _JavaLexer(isAssertKeywordEnabled, isJDK15);
|
||||
}
|
||||
private static final HashTable[] TABLES = new HashTable[]{
|
||||
new HashTable(LanguageLevel.JDK_1_8),
|
||||
new HashTable(LanguageLevel.JDK_1_5),
|
||||
new HashTable(LanguageLevel.JDK_1_4),
|
||||
new HashTable(LanguageLevel.JDK_1_3)
|
||||
};
|
||||
|
||||
public JavaLexer(LanguageLevel level) {
|
||||
this(level.hasAssertKeyword(), level.hasEnumKeywordAndAutoboxing());
|
||||
private static HashTable getTable(final LanguageLevel level) {
|
||||
for (HashTable table : TABLES) {
|
||||
if (level.isAtLeast(table.myLevel)) {
|
||||
return table;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unsupported level: " + level);
|
||||
}
|
||||
|
||||
private static HashTable getTable(boolean isAssertKeywordEnabled, boolean isJDK15) {
|
||||
return isAssertKeywordEnabled
|
||||
? isJDK15 ? ourTableWithAssertAndJDK15 : ourTableWithAssert
|
||||
: isJDK15 ? ourTableWithJDK15 : ourTableWithoutAssert;
|
||||
}
|
||||
|
||||
private static HashTable getTable(LanguageLevel level) {
|
||||
return getTable(level.hasAssertKeyword(), level.hasEnumKeywordAndAutoboxing());
|
||||
}
|
||||
|
||||
|
||||
public static boolean isKeyword(String id, LanguageLevel level) {
|
||||
return getTable(level).contains(id);
|
||||
}
|
||||
|
||||
private final _JavaLexer myFlexLexer;
|
||||
private final HashTable myTable;
|
||||
private CharSequence myBuffer;
|
||||
private char[] myBufferArray;
|
||||
private int myBufferIndex;
|
||||
private int myBufferEndOffset;
|
||||
|
||||
private int myTokenEndOffset; // positioned after the last symbol of the current token
|
||||
private IElementType myTokenType;
|
||||
private _JavaLexer myFlexLexer;
|
||||
|
||||
//Positioned after the last symbol of the current token
|
||||
private int myTokenEndOffset;
|
||||
public JavaLexer(@NotNull final LanguageLevel level) {
|
||||
myFlexLexer = new _JavaLexer(level);
|
||||
myTable = getTable(level);
|
||||
}
|
||||
|
||||
private static final class HashTable {
|
||||
private static final int NUM_ENTRIES = 999;
|
||||
private static final Logger LOG = Logger.getInstance("com.intellij.Lexer.JavaLexer");
|
||||
|
||||
private final LanguageLevel myLevel;
|
||||
private final char[][] myTable = new char[NUM_ENTRIES][];
|
||||
private final IElementType[] myKeywords = new IElementType[NUM_ENTRIES];
|
||||
private final Set<String> myKeywordsInSet = new THashSet<String>();
|
||||
@@ -111,12 +112,16 @@ public class JavaLexer extends LexerBase {
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
private HashTable(boolean isAssertKeywordEnabled, boolean isJDK15) {
|
||||
if (isAssertKeywordEnabled) {
|
||||
private HashTable(final LanguageLevel level) {
|
||||
myLevel = level;
|
||||
if (level.isAtLeast(LanguageLevel.JDK_1_4)) {
|
||||
add("assert", JavaTokenType.ASSERT_KEYWORD);
|
||||
}
|
||||
if (isJDK15) {
|
||||
add("enum", JavaTokenType.ENUM_KEYWORD);
|
||||
if (level.isAtLeast(LanguageLevel.JDK_1_5)) {
|
||||
add("enum", JavaTokenType.ENUM_KEYWORD);
|
||||
if (level.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
add("none", JavaTokenType.NONE_KEYWORD);
|
||||
}
|
||||
}
|
||||
}
|
||||
add("abstract", JavaTokenType.ABSTRACT_KEYWORD);
|
||||
add("default", JavaTokenType.DEFAULT_KEYWORD);
|
||||
@@ -172,12 +177,6 @@ public class JavaLexer extends LexerBase {
|
||||
}
|
||||
}
|
||||
|
||||
private final HashTable myTable;
|
||||
private static final HashTable ourTableWithoutAssert = new HashTable(false, false);
|
||||
private static final HashTable ourTableWithAssert = new HashTable(true, false);
|
||||
private static final HashTable ourTableWithAssertAndJDK15 = new HashTable(true, true);
|
||||
private static final HashTable ourTableWithJDK15 = new HashTable(false, true);
|
||||
|
||||
@Override
|
||||
public final void start(CharSequence buffer, int startOffset, int endOffset, int initialState) {
|
||||
myBuffer = buffer;
|
||||
|
||||
+16
-9
@@ -1,6 +1,8 @@
|
||||
/* It's an automatically generated code. Do not modify it. */
|
||||
package com.intellij.lexer;
|
||||
import com.intellij.psi.*;
|
||||
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.impl.source.tree.JavaDocElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
@@ -8,13 +10,15 @@ import com.intellij.psi.tree.IElementType;
|
||||
%%
|
||||
|
||||
%{
|
||||
private boolean myAssertKeywordEnabled;
|
||||
private boolean myJdk15Enabled;
|
||||
private boolean myAssertKeyword;
|
||||
private boolean myEnumKeyword;
|
||||
private boolean myNoneKeyword;
|
||||
|
||||
public _JavaLexer(boolean isAssertKeywordEnabled, boolean jdk15Enabled){
|
||||
public _JavaLexer(LanguageLevel level) {
|
||||
this((java.io.Reader)null);
|
||||
myAssertKeywordEnabled = isAssertKeywordEnabled;
|
||||
myJdk15Enabled = jdk15Enabled;
|
||||
myAssertKeyword = level.isAtLeast(LanguageLevel.JDK_1_4);
|
||||
myEnumKeyword = level.isAtLeast(LanguageLevel.JDK_1_5);
|
||||
myNoneKeyword = level.isAtLeast(LanguageLevel.JDK_1_8);
|
||||
}
|
||||
|
||||
public void goTo(int offset) {
|
||||
@@ -101,7 +105,7 @@ ESCAPE_SEQUENCE=\\[^\r\n]
|
||||
<YYINITIAL> "null" { return JavaTokenType.NULL_KEYWORD; }
|
||||
|
||||
<YYINITIAL> "abstract" { return JavaTokenType.ABSTRACT_KEYWORD; }
|
||||
<YYINITIAL> "assert" { return myAssertKeywordEnabled ? JavaTokenType.ASSERT_KEYWORD : JavaTokenType.IDENTIFIER; }
|
||||
<YYINITIAL> "assert" { return myAssertKeyword ? JavaTokenType.ASSERT_KEYWORD : JavaTokenType.IDENTIFIER; }
|
||||
<YYINITIAL> "boolean" { return JavaTokenType.BOOLEAN_KEYWORD; }
|
||||
<YYINITIAL> "break" { return JavaTokenType.BREAK_KEYWORD; }
|
||||
<YYINITIAL> "byte" { return JavaTokenType.BYTE_KEYWORD; }
|
||||
@@ -115,7 +119,7 @@ ESCAPE_SEQUENCE=\\[^\r\n]
|
||||
<YYINITIAL> "do" { return JavaTokenType.DO_KEYWORD; }
|
||||
<YYINITIAL> "double" { return JavaTokenType.DOUBLE_KEYWORD; }
|
||||
<YYINITIAL> "else" { return JavaTokenType.ELSE_KEYWORD; }
|
||||
<YYINITIAL> "enum" { return myJdk15Enabled ? JavaTokenType.ENUM_KEYWORD : JavaTokenType.IDENTIFIER; }
|
||||
<YYINITIAL> "enum" { return myEnumKeyword ? JavaTokenType.ENUM_KEYWORD : JavaTokenType.IDENTIFIER; }
|
||||
<YYINITIAL> "extends" { return JavaTokenType.EXTENDS_KEYWORD; }
|
||||
<YYINITIAL> "final" { return JavaTokenType.FINAL_KEYWORD; }
|
||||
<YYINITIAL> "finally" { return JavaTokenType.FINALLY_KEYWORD; }
|
||||
@@ -150,6 +154,7 @@ ESCAPE_SEQUENCE=\\[^\r\n]
|
||||
<YYINITIAL> "try" { return JavaTokenType.TRY_KEYWORD; }
|
||||
<YYINITIAL> "volatile" { return JavaTokenType.VOLATILE_KEYWORD; }
|
||||
<YYINITIAL> "throws" { return JavaTokenType.THROWS_KEYWORD; }
|
||||
<YYINITIAL> "none" { return myNoneKeyword ? JavaTokenType.NONE_KEYWORD : JavaTokenType.IDENTIFIER; }
|
||||
|
||||
<YYINITIAL> {IDENTIFIER} { return JavaTokenType.IDENTIFIER; }
|
||||
|
||||
@@ -201,5 +206,7 @@ ESCAPE_SEQUENCE=\\[^\r\n]
|
||||
<YYINITIAL> "%" { return JavaTokenType.PERC; }
|
||||
<YYINITIAL> "@" { return JavaTokenType.AT; }
|
||||
|
||||
<YYINITIAL> . { return JavaTokenType.BAD_CHARACTER; }
|
||||
<YYINITIAL> "::" { return JavaTokenType.DOUBLE_COLON; }
|
||||
<YYINITIAL> "->" { return JavaTokenType.ARROW; }
|
||||
|
||||
<YYINITIAL> . { return JavaTokenType.BAD_CHARACTER; }
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,7 +41,6 @@ annotation.target.PACKAGE=package
|
||||
generics.holder.type=Type
|
||||
generics.holder.method=Method
|
||||
|
||||
generics.are.not.supported=Generics are not supported at this language level
|
||||
generics.inferred.type.for.type.parameter.is.not.within.its.bound.extend=Inferred type ''{2}'' for type parameter ''{0}'' is not within its bound; should extend ''{1}''
|
||||
generics.inferred.type.for.type.parameter.is.not.within.its.bound.implement=Inferred type ''{2}'' for type parameter ''{0}'' is not within its bound; should implement ''{1}''
|
||||
generics.type.parameter.is.not.within.its.bound.extend=Type parameter ''{0}'' is not within its bound; should extend ''{1}''
|
||||
@@ -83,7 +82,6 @@ generics.type.arguments.on.raw.type=Type arguments given on a raw type
|
||||
generics.type.arguments.on.raw.method=Type arguments given on a raw method
|
||||
classes.extends.enum=Classes cannot directly extend 'java.lang.Enum'
|
||||
unchecked.overriding.incompatible.return.type=Unchecked overriding: return type requires unchecked conversion. Found ''{0}'', required ''{1}''
|
||||
unchecked.overriding=Unchecked overriding
|
||||
local.enum=Enum must not be local
|
||||
|
||||
interface.expected=Interface expected here
|
||||
@@ -237,10 +235,6 @@ static.member.accessed.via.instance.reference=Static member ''{0}.{1}'' accessed
|
||||
unresolved.label=Undefined label: ''{0}''
|
||||
deprecated.symbol=''{0}'' is deprecated
|
||||
cannot.resolve.symbol=Cannot resolve symbol ''{0}''
|
||||
static.imports.prior.15=Static imports are not supported at this language level
|
||||
varargs.prior.15=Variable arity methods are not supported at this language level
|
||||
foreach.prior.15=Foreach loops are not supported at this language level
|
||||
annotations.prior.15=Annotations are not supported at this language level
|
||||
class.is.already.defined.in.single.static.import=Class ''{0}'' is already defined in a single static import
|
||||
class.is.ambiguous.in.single.static.import=Class ''{0}'' is ambiguous in a single static import
|
||||
field.is.already.defined.in.single.static.import=Field ''{0}'' is already defined in a single static import
|
||||
@@ -264,8 +258,6 @@ private.inner.interface.is.not.used=Private inner interface ''{0}'' is never use
|
||||
type.parameter.is.not.used=Type parameter ''{0}'' is never used
|
||||
local.class.is.not.used=Local class ''{0}'' is never used
|
||||
class.is.not.used=Class ''{0}'' is never used
|
||||
uidesigned.field.is.overwritten.by.generated.code=Field ''{0}'' is overwritten by generated code
|
||||
uidesigner.bound.field.type.mismatch=Types of GUI component (''{0}'') and bound field (''{1}'') do not match
|
||||
|
||||
hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit=Hexadecimal numbers must contain at least one hexadecimal digit
|
||||
binary.numbers.must.contain.at.least.one.hexadecimal.digit=Binary numbers must contain at least one binary digit
|
||||
@@ -322,7 +314,6 @@ expected.resource=Resource definition expected
|
||||
expected.type.parameter=Type parameter expected
|
||||
expected.comma=',' expected
|
||||
expected.comma.or.rparen=',' or ')' expected
|
||||
unexpected.tokens.beyond.the.end.of.expression=Unexpected token(s) beyond the end of expression
|
||||
expected.colon=':' expected
|
||||
expected.type=Type expected
|
||||
expected.lbracket='[' expected
|
||||
@@ -352,3 +343,13 @@ cannot.resolve.package=Cannot resolve package {0}
|
||||
override.not.allowed.in.interfaces=@Override is not allowed when implementing interface method
|
||||
wildcard.not.expected=Unexpected wildcard
|
||||
bound.not.expected=Unexpected bound
|
||||
|
||||
feature.generics=Generics
|
||||
feature.annotations=Annotations
|
||||
feature.static.imports=Static imports
|
||||
feature.for.each=For-each loops
|
||||
feature.varargs=Variable arity methods
|
||||
feature.diamond.types=Diamond types
|
||||
feature.try.with.resources=Try-with-resources
|
||||
feature.multi.catch=Multi-catches
|
||||
insufficient.language.level={0} are not supported at this language level
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
<error descr="Static imports are not supported at this language level">import static java.lang.Math.*;</error>
|
||||
|
||||
@interface <error descr="Annotations are not supported at this language level">Anno</error> { }
|
||||
|
||||
<error descr="Annotations are not supported at this language level">@Anno</error>
|
||||
class UnsupportedFeatures {
|
||||
void m(<error descr="Variable arity methods are not supported at this language level">String... args</error>) throws Exception {
|
||||
<error descr="For-each loops are not supported at this language level">for (String s : args) { System.out.println(s); }</error>
|
||||
|
||||
List<error descr="Generics are not supported at this language level"><String></error> list =
|
||||
new ArrayList<error descr="Diamond types are not supported at this language level"><></error>();
|
||||
|
||||
for (<error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">String s : list</error>) {}
|
||||
Arrays.asList<error descr="'asList(java.lang.String...)' in 'java.util.Arrays' cannot be applied to '(java.lang.String)'">("")</error>;
|
||||
<error descr="Incompatible types. Found: 'boolean', required: 'java.lang.Boolean'">Boolean b = true;</error>
|
||||
<error descr="Incompatible types. Found: 'java.lang.Boolean', required: 'boolean'">boolean b1 = Boolean.TRUE;</error>
|
||||
|
||||
try { Reader r = new FileReader("/dev/null"); }
|
||||
catch (<error descr="Multi-catches are not supported at this language level">FileNotFoundException | IOException e</error>) { e.printStackTrace(); }
|
||||
|
||||
try <error descr="Try-with-resources are not supported at this language level">(Reader r = new FileReader("/dev/null"))</error> { }
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import java.util.List;
|
||||
import static java.lang.Math.min;
|
||||
|
||||
class a {
|
||||
List<String> l;
|
||||
|
||||
private void asList(Object... objects) {}
|
||||
|
||||
void foo() {
|
||||
for (String s : l) {}
|
||||
|
||||
for (Object o : l) {}
|
||||
|
||||
asList("");
|
||||
|
||||
Boolean b = true;
|
||||
|
||||
boolean b1 = Boolean.TRUE;
|
||||
}
|
||||
|
||||
enum e {}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Remove redundant arguments to match 'method(int, Integer)'" "true"
|
||||
// "Remove redundant arguments to call 'method(int, Integer)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(new Integer(5), 5);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Remove redundant arguments to match 'method(int, T)'" "true"
|
||||
// "Remove redundant arguments to call 'method(int, T)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(5, new Exception());
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Remove redundant arguments to match 'method(int, String)'" "true"
|
||||
// "Remove redundant arguments to call 'method(int, String)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(5, "");
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Remove redundant arguments to match 'method(int, Integer)'" "true"
|
||||
// "Remove redundant arguments to call 'method(int, Integer)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(new Integer(5), 5,<caret> "", new String());
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Remove redundant arguments to match 'method(int, T)'" "true"
|
||||
// "Remove redundant arguments to call 'method(int, T)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(5,<caret> new Exception(), new Exception(), "", 3);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Remove redundant arguments to match 'method(int, String)'" "true"
|
||||
// "Remove redundant arguments to call 'method(int, String)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(5, "",<caret> 10);
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@
|
||||
* Time: 17:43
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
@Ann({A.class})
|
||||
@Ann(A.class)
|
||||
public class Annotated {
|
||||
}
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
PsiJavaFile:New15.java
|
||||
PsiMethodCallExpression:new C<?>.B()
|
||||
PsiReferenceExpression:new C<?>.B
|
||||
PsiNewExpression:new C<?>
|
||||
PsiKeyword:new('new')
|
||||
PsiNewExpression:new C<?>.B()
|
||||
PsiKeyword:new('new')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:C<?>.B
|
||||
PsiJavaCodeReferenceElement:C<?>
|
||||
PsiIdentifier:C('C')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:C<?>
|
||||
PsiIdentifier:C('C')
|
||||
PsiReferenceParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeElement:?
|
||||
PsiJavaToken:QUEST('?')
|
||||
PsiJavaToken:GT('>')
|
||||
PsiErrorElement:'(' or '[' expected
|
||||
<empty list>
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeElement:?
|
||||
PsiJavaToken:QUEST('?')
|
||||
PsiJavaToken:GT('>')
|
||||
PsiJavaToken:DOT('.')
|
||||
PsiIdentifier:B('B')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:B('B')
|
||||
PsiExpressionList
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
@@ -1,10 +0,0 @@
|
||||
class Anonymous {
|
||||
int num1;
|
||||
int num2;
|
||||
Object o = new Object(){
|
||||
int num = 1;
|
||||
};
|
||||
|
||||
Anonymous() {}
|
||||
void foo() {}
|
||||
}
|
||||
+5
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,6 +57,10 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
};
|
||||
}
|
||||
|
||||
public void testAllJava15Features() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testEnumSyntheticMethods() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
+14
-19
@@ -40,6 +40,7 @@ import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
@@ -161,7 +162,7 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testQualifiedNew() throws Exception { doTest(false, false); }
|
||||
public void testEnclosingInstance() throws Exception { doTest(false, false); }
|
||||
|
||||
public void testStaticViaInstance() throws Exception { doTest(true, false); } // static via instabnce
|
||||
public void testStaticViaInstance() throws Exception { doTest(true, false); } // static via instance
|
||||
public void testQualifiedThisSuper() throws Exception { doTest(true, false); } //illegal qualified this or super
|
||||
|
||||
public void testAmbiguousMethodCall() throws Exception { doTest(false, false); }
|
||||
@@ -230,19 +231,13 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(boolean selected) {
|
||||
|
||||
}
|
||||
public void setSelected(boolean selected) { }
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) {
|
||||
|
||||
}
|
||||
public void readExternal(Element element) { }
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) {
|
||||
|
||||
}
|
||||
public void writeExternal(Element element) { }
|
||||
};
|
||||
|
||||
point.registerExtension(extension);
|
||||
@@ -265,9 +260,13 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PsiFile txt = myFile.getParent().createFile("x.txt");
|
||||
PsiDirectory directory = myFile.getParent();
|
||||
assertNotNull(myFile.toString(), directory);
|
||||
PsiFile txt = directory.createFile("x.txt");
|
||||
VirtualFile vFile = txt.getVirtualFile();
|
||||
assertNotNull(txt.toString(), vFile);
|
||||
try {
|
||||
VfsUtil.saveText(txt.getVirtualFile(), "XXX");
|
||||
VfsUtil.saveText(vFile, "XXX");
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -356,11 +355,7 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doHighlighting();
|
||||
}
|
||||
|
||||
public void testClassicRethrow() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testRegexp() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
public void testClassicRethrow() throws Exception { doTest(false, false); }
|
||||
public void testRegexp() throws Exception { doTest(false, false); }
|
||||
public void testUnsupportedFeatures() throws Exception { doTest(false, false); }
|
||||
}
|
||||
|
||||
@@ -134,6 +134,11 @@ public class JavaLexerTest extends LexerTestCase {
|
||||
"WHITE_SPACE (' ')\nINTEGER_LITERAL ('0')\nRPARENTH (')')\n");
|
||||
}
|
||||
|
||||
public void testJava8Tokens() {
|
||||
doTest("none :: ->",
|
||||
"NONE_KEYWORD ('none')\nWHITE_SPACE (' ')\nDOUBLE_COLON ('::')\nWHITE_SPACE (' ')\nARROW ('->')");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Lexer createLexer() {
|
||||
return new JavaLexer(LanguageLevel.HIGHEST);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,11 +15,7 @@
|
||||
*/
|
||||
package com.intellij.lang.java.parser;
|
||||
|
||||
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
public class ExpressionParsingTest extends JavaParsingTestCase {
|
||||
|
||||
public ExpressionParsingTest() {
|
||||
super("parser-full/expressionParsing");
|
||||
}
|
||||
@@ -75,11 +71,7 @@ public class ExpressionParsingTest extends JavaParsingTestCase {
|
||||
public void testNew12() { doTest(true); }
|
||||
public void testNew13() { doTest(true); }
|
||||
public void testNew14() { doTest(true); }
|
||||
public void testNew15() {
|
||||
withLevel(LanguageLevel.JDK_1_7, new Runnable() { @Override public void run() {
|
||||
doTest(true);
|
||||
}});
|
||||
}
|
||||
public void testNew15() { doTest(true); }
|
||||
|
||||
public void testExprList0() { doTest(true); }
|
||||
public void testExprList1() { doTest(true); }
|
||||
|
||||
+1
-7
@@ -18,10 +18,8 @@ package com.intellij.lang.java.parser.partial;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.java.parser.JavaParsers;
|
||||
import com.intellij.lang.java.parser.JavaParsingTestCase;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
|
||||
public class ExpressionParserTest extends JavaParsingTestCase {
|
||||
public ExpressionParserTest() {
|
||||
super("parser-partial/expressions");
|
||||
@@ -77,11 +75,7 @@ public class ExpressionParserTest extends JavaParsingTestCase {
|
||||
public void testNew13() { doParserTest("new int[1][][2]"); }
|
||||
public void testNew14() { doParserTest("Q.new A()"); }
|
||||
public void testNew15() { doParserTest("new C<?>.B()"); }
|
||||
public void testNew16() {
|
||||
withLevel(LanguageLevel.JDK_1_7,
|
||||
new Runnable() { @Override
|
||||
public void run() { doParserTest("new C<>()"); } });
|
||||
}
|
||||
public void testNew16() { doParserTest("new C<>()"); }
|
||||
|
||||
public void testExprList0() { doParserTest("f(1,2)"); }
|
||||
public void testExprList1() { doParserTest("f("); }
|
||||
|
||||
+27
-40
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,8 +18,6 @@ package com.intellij.lang.java.parser.partial;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.java.parser.JavaParsers;
|
||||
import com.intellij.lang.java.parser.JavaParsingTestCase;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
|
||||
public class StatementParserTest extends JavaParsingTestCase {
|
||||
public StatementParserTest() {
|
||||
@@ -119,10 +117,10 @@ public class StatementParserTest extends JavaParsingTestCase {
|
||||
public void testTryNormal0() { doParserTest("try{}catch(E e){}"); }
|
||||
public void testTryNormal1() { doParserTest("try{}catch(final E e){}finally{}"); }
|
||||
public void testTryNormal2() { doParserTest("try{}finally{}"); }
|
||||
public void testTryNormal3() { doParserTestJDK7("try{}catch(A|B e){}"); }
|
||||
public void testTryNormal4() { doParserTestJDK7("try(R r = 0){}"); }
|
||||
public void testTryNormal5() { doParserTestJDK7("try(R1 r1 = 1; R2 r2 = 2){}"); }
|
||||
public void testTryNormal6() { doParserTestJDK7("try(R r = 0;){}"); }
|
||||
public void testTryNormal3() { doParserTest("try{}catch(A|B e){}"); }
|
||||
public void testTryNormal4() { doParserTest("try(R r = 0){}"); }
|
||||
public void testTryNormal5() { doParserTest("try(R1 r1 = 1; R2 r2 = 2){}"); }
|
||||
public void testTryNormal6() { doParserTest("try(R r = 0;){}"); }
|
||||
public void testTryIncomplete0() { doParserTest("try"); }
|
||||
public void testTryIncomplete1() { doParserTest("try{}"); }
|
||||
public void testTryIncomplete2() { doParserTest("try{}catch"); }
|
||||
@@ -131,16 +129,16 @@ public class StatementParserTest extends JavaParsingTestCase {
|
||||
public void testTryIncomplete5() { doParserTest("try{}catch(E e"); }
|
||||
public void testTryIncomplete6() { doParserTest("try{}catch(E e)"); }
|
||||
public void testTryIncomplete7() { doParserTest("try{}finally"); }
|
||||
public void testTryIncomplete8() { doParserTestJDK7("try{}catch(A|)"); }
|
||||
public void testTryIncomplete9() { doParserTestJDK7("try{}catch(A|B)"); }
|
||||
public void testTryIncomplete10() { doParserTestJDK7("try({}"); }
|
||||
public void testTryIncomplete11() { doParserTestJDK7("try(){}"); }
|
||||
public void testTryIncomplete12() { doParserTestJDK7("try(;){}"); }
|
||||
public void testTryIncomplete13() { doParserTestJDK7("try(final ){}"); }
|
||||
public void testTryIncomplete14() { doParserTestJDK7("try(int){}"); }
|
||||
public void testTryIncomplete15() { doParserTestJDK7("try(R r){}"); }
|
||||
public void testTryIncomplete16() { doParserTestJDK7("try(R r =){}"); }
|
||||
public void testTryIncomplete17() { doParserTestJDK7("try(R r = 0;;){}"); }
|
||||
public void testTryIncomplete8() { doParserTest("try{}catch(A|)"); }
|
||||
public void testTryIncomplete9() { doParserTest("try{}catch(A|B)"); }
|
||||
public void testTryIncomplete10() { doParserTest("try({}"); }
|
||||
public void testTryIncomplete11() { doParserTest("try(){}"); }
|
||||
public void testTryIncomplete12() { doParserTest("try(;){}"); }
|
||||
public void testTryIncomplete13() { doParserTest("try(final ){}"); }
|
||||
public void testTryIncomplete14() { doParserTest("try(int){}"); }
|
||||
public void testTryIncomplete15() { doParserTest("try(R r){}"); }
|
||||
public void testTryIncomplete16() { doParserTest("try(R r =){}"); }
|
||||
public void testTryIncomplete17() { doParserTest("try(R r = 0;;){}"); }
|
||||
|
||||
public void testWhileNormal() { doParserTest("while (true) foo();"); }
|
||||
public void testWhileIncomplete0() { doParserTest("while"); }
|
||||
@@ -151,33 +149,22 @@ public class StatementParserTest extends JavaParsingTestCase {
|
||||
public void testWhileIncomplete5() { doParserTest("while() foo();"); }
|
||||
|
||||
private void doBlockParserTest(final String text) {
|
||||
doParserTest(text, new MyTestParser1());
|
||||
doParserTest(text, new MyBlockTestParser());
|
||||
}
|
||||
|
||||
private void doParserTest(final String text) {
|
||||
doParserTest(text, new MyTestParser2());
|
||||
}
|
||||
|
||||
private void doParserTestJDK7(final String text) {
|
||||
withLevel(LanguageLevel.JDK_1_7, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doParserTest(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class MyTestParser2 implements TestParser {
|
||||
@Override
|
||||
public void parse(final PsiBuilder builder) {
|
||||
JavaParsers.STATEMENT_PARSER.parseStatements(builder);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyTestParser1 implements TestParser {
|
||||
private static class MyBlockTestParser implements TestParser {
|
||||
@Override
|
||||
public void parse(final PsiBuilder builder) {
|
||||
JavaParsers.STATEMENT_PARSER.parseCodeBlockDeep(builder, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void doParserTest(final String text) {
|
||||
doParserTest(text, new MyStatementsTestParser());
|
||||
}
|
||||
private static class MyStatementsTestParser implements TestParser {
|
||||
@Override
|
||||
public void parse(final PsiBuilder builder) {
|
||||
JavaParsers.STATEMENT_PARSER.parseStatements(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-12
@@ -1,8 +1,21 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.lang.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.lang.java.parser.JavaParsingTestCase;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
|
||||
public class TryParsingTest extends JavaParsingTestCase {
|
||||
public TryParsingTest() {
|
||||
@@ -12,11 +25,7 @@ public class TryParsingTest extends JavaParsingTestCase {
|
||||
public void testNormal1() { doTest(true); }
|
||||
public void testNormal2() { doTest(true); }
|
||||
public void testNormal3() { doTest(true); }
|
||||
public void testNormal4() {
|
||||
withLevel(LanguageLevel.JDK_1_7, new Runnable() { @Override public void run() {
|
||||
doTest(true);
|
||||
}});
|
||||
}
|
||||
public void testNormal4() { doTest(true); }
|
||||
|
||||
public void testIncomplete1() { doTest(true); }
|
||||
public void testIncomplete2() { doTest(true); }
|
||||
@@ -26,9 +35,5 @@ public class TryParsingTest extends JavaParsingTestCase {
|
||||
public void testIncomplete6() { doTest(true); }
|
||||
public void testIncomplete7() { doTest(true); }
|
||||
public void testIncomplete8() { doTest(true); }
|
||||
public void testIncomplete9() {
|
||||
withLevel(LanguageLevel.JDK_1_7, new Runnable() { @Override public void run() {
|
||||
doTest(true);
|
||||
}});
|
||||
}
|
||||
public void testIncomplete9() { doTest(true); }
|
||||
}
|
||||
Reference in New Issue
Block a user