/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package net.sourceforge.phpdt.internal.compiler.problem;
+import net.sourceforge.phpdt.core.compiler.CharOperation;
import net.sourceforge.phpdt.core.compiler.IProblem;
-import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
import net.sourceforge.phpdt.core.compiler.InvalidInputException;
-import net.sourceforge.phpdt.internal.compiler.*;
-import net.sourceforge.phpdt.internal.compiler.ast.*;
-import net.sourceforge.phpdt.internal.compiler.lookup.*;
-import net.sourceforge.phpdt.internal.compiler.parser.*;
-import net.sourceforge.phpdt.internal.compiler.util.*;
-import net.sourceforge.phpdt.internal.compiler.impl.*;
+import net.sourceforge.phpdt.internal.compiler.CompilationResult;
+import net.sourceforge.phpdt.internal.compiler.IErrorHandlingPolicy;
+import net.sourceforge.phpdt.internal.compiler.IProblemFactory;
+import net.sourceforge.phpdt.internal.compiler.impl.Constant;
+import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext;
+import net.sourceforge.phpdt.internal.compiler.lookup.Binding;
+import net.sourceforge.phpdt.internal.compiler.lookup.CompilerModifiers;
+import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding;
+import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding;
+import net.sourceforge.phpdt.internal.compiler.lookup.MethodBinding;
+import net.sourceforge.phpdt.internal.compiler.lookup.ProblemMethodBinding;
+import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReasons;
+import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReferenceBinding;
+import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding;
+import net.sourceforge.phpdt.internal.compiler.lookup.SourceTypeBinding;
+import net.sourceforge.phpdt.internal.compiler.lookup.SyntheticArgumentBinding;
+import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
+import net.sourceforge.phpdt.internal.compiler.lookup.TypeConstants;
+import net.sourceforge.phpdt.internal.compiler.parser.Parser;
+import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
+import net.sourceforge.phpdt.internal.compiler.util.Util;
+import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
+import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractVariableDeclaration;
+import net.sourceforge.phpeclipse.internal.compiler.ast.AllocationExpression;
+import net.sourceforge.phpeclipse.internal.compiler.ast.Argument;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ArrayAllocationExpression;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ArrayReference;
+import net.sourceforge.phpeclipse.internal.compiler.ast.Assignment;
+import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.BinaryExpression;
+import net.sourceforge.phpeclipse.internal.compiler.ast.BranchStatement;
+import net.sourceforge.phpeclipse.internal.compiler.ast.Case;
+import net.sourceforge.phpeclipse.internal.compiler.ast.CastExpression;
+import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
+import net.sourceforge.phpeclipse.internal.compiler.ast.CompoundAssignment;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ConstructorDeclaration;
+import net.sourceforge.phpeclipse.internal.compiler.ast.DefaultCase;
+import net.sourceforge.phpeclipse.internal.compiler.ast.EqualExpression;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ExplicitConstructorCall;
+import net.sourceforge.phpeclipse.internal.compiler.ast.Expression;
+import net.sourceforge.phpeclipse.internal.compiler.ast.FieldDeclaration;
+import net.sourceforge.phpeclipse.internal.compiler.ast.FieldReference;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ImportReference;
+import net.sourceforge.phpeclipse.internal.compiler.ast.InstanceOfExpression;
+import net.sourceforge.phpeclipse.internal.compiler.ast.IntLiteral;
+import net.sourceforge.phpeclipse.internal.compiler.ast.Literal;
+import net.sourceforge.phpeclipse.internal.compiler.ast.LocalDeclaration;
+import net.sourceforge.phpeclipse.internal.compiler.ast.LongLiteral;
+import net.sourceforge.phpeclipse.internal.compiler.ast.MessageSend;
+import net.sourceforge.phpeclipse.internal.compiler.ast.MethodDeclaration;
+import net.sourceforge.phpeclipse.internal.compiler.ast.NameReference;
+import net.sourceforge.phpeclipse.internal.compiler.ast.NumberLiteral;
+import net.sourceforge.phpeclipse.internal.compiler.ast.QualifiedNameReference;
+import net.sourceforge.phpeclipse.internal.compiler.ast.Reference;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ReturnStatement;
+import net.sourceforge.phpeclipse.internal.compiler.ast.SingleNameReference;
+import net.sourceforge.phpeclipse.internal.compiler.ast.Statement;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ThisReference;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ThrowStatement;
+import net.sourceforge.phpeclipse.internal.compiler.ast.TryStatement;
+import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration;
+import net.sourceforge.phpeclipse.internal.compiler.ast.TypeReference;
+import net.sourceforge.phpeclipse.internal.compiler.ast.UnaryExpression;
public class ProblemReporter extends ProblemHandler implements ProblemReasons {
public ReferenceContext referenceContext;
-public ProblemReporter(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory) {
- super(policy, options, problemFactory);
+public ProblemReporter(IErrorHandlingPolicy policy, IProblemFactory problemFactory) {
+//CompilerOptions options, IProblemFactory problemFactory) {
+ super(policy, problemFactory);//options, problemFactory);
}
public void abortDueToInternalError(String errorMessage) {
+ String[] arguments = new String[] {errorMessage};
this.handle(
IProblem.Unclassified,
- new String[] {errorMessage},
+ arguments,
+ arguments,
Error | Abort,
0,
0);
}
public void abortDueToInternalError(String errorMessage, AstNode location) {
+ String[] arguments = new String[] {errorMessage};
this.handle(
IProblem.Unclassified,
- new String[] {errorMessage},
+ arguments,
+ arguments,
Error | Abort,
location.sourceStart,
location.sourceEnd);
this.handle(
// %1 must be abstract since it cannot override the inherited package-private abstract method %2
IProblem.AbstractMethodCannotBeOverridden,
- new String[] {new String(type.sourceName()), new String(concreteMethod.readableName())},
+ new String[] {
+ new String(type.sourceName()),
+ new String(
+ CharOperation.concat(
+ concreteMethod.declaringClass.readableName(),
+ concreteMethod.readableName(),
+ '.'))},
+ new String[] {
+ new String(type.sourceName()),
+ new String(
+ CharOperation.concat(
+ concreteMethod.declaringClass.shortReadableName(),
+ concreteMethod.shortReadableName(),
+ '.'))},
type.sourceStart(),
type.sourceEnd());
}
public void abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
+
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.AbstractMethodInAbstractClass,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
abstractMethod.declaringClass.readableName(),
abstractMethod.readableName(),
'.'))},
+ new String[] {
+ new String(
+ CharOperation.concat(
+ abstractMethod.declaringClass.shortReadableName(),
+ abstractMethod.shortReadableName(),
+ '.'))},
type.sourceStart(),
type.sourceEnd());
}
public void abstractMethodNeedingNoBody(AbstractMethodDeclaration method) {
this.handle(
IProblem.BodyForAbstractMethod,
- new String[0],
+ NoArgument,
+ NoArgument,
method.sourceStart,
method.sourceEnd,
method,
method.compilationResult());
}
public void alreadyDefinedLabel(char[] labelName, AstNode location) {
+ String[] arguments = new String[] {new String(labelName)};
this.handle(
IProblem.DuplicateLabel,
- new String[] {new String(labelName)},
- location.sourceStart,
+ arguments,
+ arguments,
+ location.sourceStart,
location.sourceEnd);
}
public void anonymousClassCannotExtendFinalClass(Expression expression, TypeBinding type) {
this.handle(
IProblem.AnonymousClassCannotExtendFinalClass,
new String[] {new String(type.readableName())},
+ new String[] {new String(type.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
public void argumentTypeCannotBeVoid(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg) {
+ String[] arguments = new String[] {new String(methodDecl.selector), new String(arg.name)};
this.handle(
IProblem.ArgumentTypeCannotBeVoid,
- new String[] {new String(methodDecl.selector), new String(arg.name)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void argumentTypeCannotBeVoidArray(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg) {
+ String[] arguments = new String[] {new String(methodDecl.selector), new String(arg.name)};
this.handle(
IProblem.ArgumentTypeCannotBeVoidArray,
- new String[] {new String(methodDecl.selector), new String(arg.name)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
this.handle(
id,
new String[] {new String(methodDecl.selector), arg.name(), new String(expectedType.readableName())},
+ new String[] {new String(methodDecl.selector), arg.name(), new String(expectedType.shortReadableName())},
arg.type.sourceStart,
arg.type.sourceEnd);
}
public void arrayConstantsOnlyInArrayInitializers(int sourceStart, int sourceEnd) {
this.handle(
IProblem.ArrayConstantsOnlyInArrayInitializers,
- new String[0],
+ NoArgument,
+ NoArgument,
sourceStart,
sourceEnd);
}
+public void assignmentHasNoEffect(Assignment assignment, char[] name){
+ String[] arguments = new String[] { new String(name) };
+ this.handle(
+ IProblem.AssignmentHasNoEffect,
+ arguments,
+ arguments,
+ assignment.sourceStart,
+ assignment.sourceEnd);
+}
public void attemptToReturnNonVoidExpression(ReturnStatement returnStatement, TypeBinding expectedType) {
this.handle(
IProblem.VoidMethodReturnsValue,
new String[] {new String(expectedType.readableName())},
+ new String[] {new String(expectedType.shortReadableName())},
returnStatement.sourceStart,
returnStatement.sourceEnd);
}
public void attemptToReturnVoidValue(ReturnStatement returnStatement) {
this.handle(
IProblem.MethodReturnsVoid,
- new String[] {},
+ NoArgument,
+ NoArgument,
returnStatement.sourceStart,
returnStatement.sourceEnd);
}
-public void bytecodeExceeds64KLimit(AbstractMethodDeclaration location) {
- this.handle(
- IProblem.BytecodeExceeds64KLimit,
- new String[] {new String(location.selector)},
- Error | Abort,
- location.sourceStart,
- location.sourceEnd);
-}
+//public void bytecodeExceeds64KLimit(AbstractMethodDeclaration location) {
+// String[] arguments = new String[] {new String(location.selector), parametersAsString(location.binding)};
+// if (location.isConstructor()) {
+// this.handle(
+// IProblem.BytecodeExceeds64KLimitForConstructor,
+// arguments,
+// arguments,
+// Error | Abort,
+// location.sourceStart,
+// location.sourceEnd);
+// } else {
+// this.handle(
+// IProblem.BytecodeExceeds64KLimit,
+// arguments,
+// arguments,
+// Error | Abort,
+// location.sourceStart,
+// location.sourceEnd);
+// }
+//}
public void bytecodeExceeds64KLimit(TypeDeclaration location) {
this.handle(
IProblem.BytecodeExceeds64KLimitForClinit,
- new String[0],
+ NoArgument,
+ NoArgument,
Error | Abort,
location.sourceStart,
location.sourceEnd);
public void cannotAllocateVoidArray(Expression expression) {
this.handle(
IProblem.CannotAllocateVoidArray,
- new String[] {},
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
new String[] {
(field.declaringClass == null ? "array" : new String(field.declaringClass.readableName())), //$NON-NLS-1$
new String(field.readableName())},
+ new String[] {
+ (field.declaringClass == null ? "array" : new String(field.declaringClass.shortReadableName())), //$NON-NLS-1$
+ new String(field.shortReadableName())},
+ location.sourceStart,
+ location.sourceEnd);
+}
+public void cannotAssignToFinalLocal(LocalVariableBinding local, AstNode location) {
+ String[] arguments = new String[] { new String(local.readableName())};
+ this.handle(
+ IProblem.NonBlankFinalLocalAssignment,
+ arguments,
+ arguments,
location.sourceStart,
location.sourceEnd);
}
public void cannotAssignToFinalOuterLocal(LocalVariableBinding local, AstNode location) {
+ String[] arguments = new String[] {new String(local.readableName())};
this.handle(
IProblem.FinalOuterLocalAssignment,
- new String[] {new String(local.readableName())},
+ arguments,
+ arguments,
location.sourceStart,
location.sourceEnd);
}
public void cannotDeclareLocalInterface(char[] interfaceName, int sourceStart, int sourceEnd) {
+ String[] arguments = new String[] {new String(interfaceName)};
this.handle(
IProblem.CannotDefineInterfaceInLocalType,
- new String[] {new String(interfaceName)},
+ arguments,
+ arguments,
sourceStart,
sourceEnd);
}
public void cannotDefineDimensionsAndInitializer(ArrayAllocationExpression expresssion) {
this.handle(
IProblem.CannotDefineDimensionExpressionsWithInit,
- new String[0],
+ NoArgument,
+ NoArgument,
expresssion.sourceStart,
expresssion.sourceEnd);
}
this.handle(
IProblem.DirectInvocationOfAbstractMethod,
new String[] {new String(method.declaringClass.readableName()), new String(method.selector), parametersAsString(method)},
+ new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), parametersAsShortString(method)},
messageSend.sourceStart,
messageSend.sourceEnd);
}
public void cannotImportPackage(ImportReference importRef) {
+ String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
this.handle(
IProblem.CannotImportPackage,
- new String[] {CharOperation.toString(importRef.tokens)},
+ arguments,
+ arguments,
importRef.sourceStart,
importRef.sourceEnd);
}
this.handle(
IProblem.InvalidClassInstantiation,
new String[] {new String(type.readableName())},
+ new String[] {new String(type.shortReadableName())},
typeRef.sourceStart,
typeRef.sourceEnd);
}
public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, AstNode location) {
+ String[] arguments =new String[]{ new String(local.readableName())};
this.handle(
IProblem.OuterLocalMustBeFinal,
- new String[] {new String(local.readableName())},
+ arguments,
+ arguments,
location.sourceStart,
location.sourceEnd);
}
public void cannotReturnInInitializer(AstNode location) {
this.handle(
IProblem.CannotReturnInInitializer,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
public void cannotThrowNull(ThrowStatement statement) {
this.handle(
IProblem.CannotThrowNull,
- new String[0],
+ NoArgument,
+ NoArgument,
statement.sourceStart,
statement.sourceEnd);
}
this.handle(
IProblem.CannotThrowType,
new String[] {new String(expectedType.readableName())},
+ new String[] {new String(expectedType.shortReadableName())},
exceptionType.sourceStart,
exceptionType.sourceEnd);
}
public void cannotUseSuperInJavaLangObject(AstNode reference) {
this.handle(
IProblem.ObjectHasNoSuperclass,
- new String[0],
+ NoArgument,
+ NoArgument,
reference.sourceStart,
reference.sourceEnd);
}
public void cannotUseSuperInCodeSnippet(int start, int end) {
this.handle(
IProblem.CannotUseSuperInCodeSnippet,
- new String[0],
+ NoArgument,
+ NoArgument,
Error | Abort,
start,
end);
public void caseExpressionMustBeConstant(Expression expression) {
this.handle(
IProblem.NonConstantExpression,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
public void classExtendFinalClass(SourceTypeBinding type, TypeReference superclass, TypeBinding expectedType) {
+ String name = new String(type.sourceName());
+ String expectedFullName = new String(expectedType.readableName());
+ String expectedShortName = new String(expectedType.shortReadableName());
+ if (expectedShortName.equals(name)) expectedShortName = expectedFullName;
this.handle(
IProblem.ClassExtendFinalClass,
- new String[] {new String(expectedType.readableName()), new String(type.sourceName())},
+ new String[] {expectedFullName, name},
+ new String[] {expectedShortName, name},
superclass.sourceStart,
superclass.sourceEnd);
}
public void codeSnippetMissingClass(String missing, int start, int end) {
+ String[] arguments = new String[]{missing};
this.handle(
IProblem.CodeSnippetMissingClass,
- new String[]{ missing },
+ arguments,
+ arguments,
Error | Abort,
start,
end);
}
public void codeSnippetMissingMethod(String className, String missingMethod, String argumentTypes, int start, int end) {
+ String[] arguments = new String[]{ className, missingMethod, argumentTypes };
this.handle(
IProblem.CodeSnippetMissingMethod,
- new String[]{ className, missingMethod, argumentTypes },
+ arguments,
+ arguments,
Error | Abort,
start,
end);
* falls into:
* Error | Warning | Ignore
*/
-public int computeSeverity(int problemId){
-
- // severity can have been preset on the problem
-// if ((problem.severity & Fatal) != 0){
-// return Error;
+//public int computeSeverity(int problemId){
+//
+// // severity can have been preset on the problem
+//// if ((problem.severity & Fatal) != 0){
+//// return Error;
+//// }
+//
+// // if not then check whether it is a configurable problem
+// int errorThreshold = options.errorThreshold;
+// int warningThreshold = options.warningThreshold;
+//
+// switch(problemId){
+//
+// case IProblem.UnreachableCatch :
+// case IProblem.CodeCannotBeReached :
+// if ((errorThreshold & CompilerOptions.UnreachableCode) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.UnreachableCode) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+// case IProblem.MaskedCatch :
+// if ((errorThreshold & CompilerOptions.MaskedCatchBlock) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.MaskedCatchBlock) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+///*
+// case Never Used :
+// if ((errorThreshold & ParsingOptionalError) != 0){
+// return Error;
+// }
+// if ((warningThreshold & ParsingOptionalError) != 0){
+// return Warning;
+// }
+// return Ignore;
+//*/
+// case IProblem.ImportNotFound :
+// case IProblem.ImportNotVisible :
+// case IProblem.ImportAmbiguous :
+// case IProblem.ImportInternalNameProvided :
+// case IProblem.ImportInheritedNameHidesEnclosingName :
+// case IProblem.DuplicateImport :
+// case IProblem.ConflictingImport :
+// case IProblem.CannotImportPackage :
+// if ((errorThreshold & CompilerOptions.ImportProblem) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.ImportProblem) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+// case IProblem.UnusedImport :
+// // if import problem are disabled, then ignore
+// if ((errorThreshold & CompilerOptions.ImportProblem) == 0
+// && (warningThreshold & CompilerOptions.ImportProblem) == 0){
+// return Ignore;
+// }
+// if ((errorThreshold & CompilerOptions.UnusedImport) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.UnusedImport) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+// case IProblem.MethodButWithConstructorName :
+// if ((errorThreshold & CompilerOptions.MethodWithConstructorName) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.MethodWithConstructorName) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+// case IProblem.OverridingNonVisibleMethod :
+// if ((errorThreshold & CompilerOptions.OverriddenPackageDefaultMethod) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.OverriddenPackageDefaultMethod) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+// case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod :
+// case IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod :
+// if ((errorThreshold & CompilerOptions.IncompatibleNonInheritedInterfaceMethod) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.IncompatibleNonInheritedInterfaceMethod) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+// case IProblem.OverridingDeprecatedMethod :
+// case IProblem.UsingDeprecatedType :
+// case IProblem.UsingDeprecatedMethod :
+// case IProblem.UsingDeprecatedConstructor :
+// case IProblem.UsingDeprecatedField :
+// if ((errorThreshold & CompilerOptions.UsingDeprecatedAPI) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.UsingDeprecatedAPI) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+// case IProblem.LocalVariableIsNeverUsed :
+// if ((errorThreshold & CompilerOptions.UnusedLocalVariable) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.UnusedLocalVariable) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+// case IProblem.ArgumentIsNeverUsed :
+// if ((errorThreshold & CompilerOptions.UnusedArgument) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.UnusedArgument) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+// case IProblem.NoImplicitStringConversionForCharArrayExpression :
+// if ((errorThreshold & CompilerOptions.NoImplicitStringConversion) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.NoImplicitStringConversion) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+// case IProblem.NeedToEmulateFieldReadAccess :
+// case IProblem.NeedToEmulateFieldWriteAccess :
+// case IProblem.NeedToEmulateMethodAccess :
+// case IProblem.NeedToEmulateConstructorAccess :
+// if ((errorThreshold & CompilerOptions.AccessEmulation) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.AccessEmulation) != 0){
+// return Warning;
+// }
+// return Ignore;
+// case IProblem.NonExternalizedStringLiteral :
+// if ((errorThreshold & CompilerOptions.NonExternalizedString) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.NonExternalizedString) != 0){
+// return Warning;
+// }
+// return Ignore;
+// case IProblem.UseAssertAsAnIdentifier :
+// if ((errorThreshold & CompilerOptions.AssertUsedAsAnIdentifier) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.AssertUsedAsAnIdentifier) != 0){
+// return Warning;
+// }
+// return Ignore;
+// case IProblem.NonStaticAccessToStaticMethod :
+// case IProblem.NonStaticAccessToStaticField :
+// if ((errorThreshold & CompilerOptions.StaticAccessReceiver) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.StaticAccessReceiver) != 0){
+// return Warning;
+// }
+// return Ignore;
+// case IProblem.AssignmentHasNoEffect:
+// if ((errorThreshold & CompilerOptions.NoEffectAssignment) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.NoEffectAssignment) != 0){
+// return Warning;
+// }
+// return Ignore;
+// case IProblem.UnusedPrivateConstructor:
+// case IProblem.UnusedPrivateMethod:
+// case IProblem.UnusedPrivateField:
+// case IProblem.UnusedPrivateType:
+// if ((errorThreshold & CompilerOptions.UnusedPrivateMember) != 0){
+// return Error;
+// }
+// if ((warningThreshold & CompilerOptions.UnusedPrivateMember) != 0){
+// return Warning;
+// }
+// return Ignore;
+//
+// case IProblem.Task :
+// return Warning;
+// default:
+// return Error;
// }
-
- // if not then check whether it is a configurable problem
- int errorThreshold = options.errorThreshold;
- int warningThreshold = options.warningThreshold;
-
- switch(problemId){
-
- case IProblem.UnreachableCatch :
- case IProblem.CodeCannotBeReached :
- if ((errorThreshold & CompilerOptions.UnreachableCode) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.UnreachableCode) != 0){
- return Warning;
- }
- return Ignore;
-
- case IProblem.MaskedCatch :
- if ((errorThreshold & CompilerOptions.MaskedCatchBlock) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.MaskedCatchBlock) != 0){
- return Warning;
- }
- return Ignore;
-
-/*
- case Never Used :
- if ((errorThreshold & ParsingOptionalError) != 0){
- return Error;
- }
- if ((warningThreshold & ParsingOptionalError) != 0){
- return Warning;
- }
- return Ignore;
-*/
- case IProblem.ImportNotFound :
- case IProblem.ImportNotVisible :
- case IProblem.ImportAmbiguous :
- case IProblem.ImportInternalNameProvided :
- case IProblem.ImportInheritedNameHidesEnclosingName :
- case IProblem.DuplicateImport :
- case IProblem.ConflictingImport :
- case IProblem.CannotImportPackage :
- if ((errorThreshold & CompilerOptions.ImportProblem) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.ImportProblem) != 0){
- return Warning;
- }
- return Ignore;
-
- case IProblem.UnusedImport :
- // if import problem are disabled, then ignore
- if ((errorThreshold & CompilerOptions.ImportProblem) == 0
- && (warningThreshold & CompilerOptions.ImportProblem) == 0){
- return Ignore;
- }
- if ((errorThreshold & CompilerOptions.UnusedImport) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.UnusedImport) != 0){
- return Warning;
- }
- return Ignore;
-
-/*
- case UnnecessaryEnclosingInstanceSpecification :
- if ((errorThreshold & UnnecessaryEnclosingInstance) != 0){
- return Error;
- }
- if ((warningThreshold & UnnecessaryEnclosingInstance) != 0){
- return Warning;
- }
- return Ignore;
-*/
- case IProblem.MethodButWithConstructorName :
- if ((errorThreshold & CompilerOptions.MethodWithConstructorName) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.MethodWithConstructorName) != 0){
- return Warning;
- }
- return Ignore;
-
- case IProblem.OverridingNonVisibleMethod :
- if ((errorThreshold & CompilerOptions.OverriddenPackageDefaultMethod) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.OverriddenPackageDefaultMethod) != 0){
- return Warning;
- }
- return Ignore;
-
- case IProblem.OverridingDeprecatedMethod :
- case IProblem.UsingDeprecatedType :
- case IProblem.UsingDeprecatedMethod :
- case IProblem.UsingDeprecatedConstructor :
- case IProblem.UsingDeprecatedField :
- if ((errorThreshold & CompilerOptions.UsingDeprecatedAPI) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.UsingDeprecatedAPI) != 0){
- return Warning;
- }
- return Ignore;
-
- case IProblem.LocalVariableIsNeverUsed :
- if ((errorThreshold & CompilerOptions.UnusedLocalVariable) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.UnusedLocalVariable) != 0){
- return Warning;
- }
- return Ignore;
-
- case IProblem.ArgumentIsNeverUsed :
- if ((errorThreshold & CompilerOptions.UnusedArgument) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.UnusedArgument) != 0){
- return Warning;
- }
- return Ignore;
-
- case IProblem.NoImplicitStringConversionForCharArrayExpression :
- if ((errorThreshold & CompilerOptions.NoImplicitStringConversion) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.NoImplicitStringConversion) != 0){
- return Warning;
- }
- return Ignore;
-
- case IProblem.NeedToEmulateFieldReadAccess :
- case IProblem.NeedToEmulateFieldWriteAccess :
- case IProblem.NeedToEmulateMethodAccess :
- case IProblem.NeedToEmulateConstructorAccess :
- if ((errorThreshold & CompilerOptions.AccessEmulation) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.AccessEmulation) != 0){
- return Warning;
- }
- return Ignore;
- case IProblem.NonExternalizedStringLiteral :
- if ((errorThreshold & CompilerOptions.NonExternalizedString) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.NonExternalizedString) != 0){
- return Warning;
- }
- return Ignore;
- case IProblem.UseAssertAsAnIdentifier :
- if ((errorThreshold & CompilerOptions.AssertUsedAsAnIdentifier) != 0){
- return Error;
- }
- if ((warningThreshold & CompilerOptions.AssertUsedAsAnIdentifier) != 0){
- return Warning;
- }
- return Ignore;
- default:
- return Error;
- }
-}
-public void conditionalArgumentsIncompatibleTypes(ConditionalExpression expression, TypeBinding trueType, TypeBinding falseType) {
- this.handle(
- IProblem.IncompatibleTypesInConditionalOperator,
- new String[] {new String(trueType.readableName()), new String(falseType.readableName())},
- expression.sourceStart,
- expression.sourceEnd);
-}
+//}
+//public void conditionalArgumentsIncompatibleTypes(ConditionalExpression expression, TypeBinding trueType, TypeBinding falseType) {
+// this.handle(
+// IProblem.IncompatibleTypesInConditionalOperator,
+// new String[] {new String(trueType.readableName()), new String(falseType.readableName())},
+// new String[] {new String(trueType.sourceName()), new String(falseType.sourceName())},
+// expression.sourceStart,
+// expression.sourceEnd);
+//}
public void conflictingImport(ImportReference importRef) {
+ String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
this.handle(
IProblem.ConflictingImport,
- new String[] {CharOperation.toString(importRef.tokens)},
+ arguments,
+ arguments,
importRef.sourceStart,
importRef.sourceEnd);
}
break label;
}
}
+ String[] arguments = new String[] {Radix + " " + new String(source) + " (digit " + new String(new char[] {source[place]}) + ")"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
this.handle(
IProblem.NumericValueOutOfRange,
- new String[] {Radix + " " + new String(source) + " (digit " + new String(new char[] {source[place]}) + ")"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ arguments,
+ arguments,
lit.sourceStart,
lit.sourceEnd);
return;
public void constantOutOfRange(Literal lit) {
// lit is some how out of range of it declared type
// example 9999999999999999999999999999999999999999999999999999999999999999999
-
+ String[] arguments = new String[] {new String(lit.source())};
this.handle(
IProblem.NumericValueOutOfRange,
- new String[] {new String(lit.source())},
+ arguments,
+ arguments,
lit.sourceStart,
lit.sourceEnd);
}
this.handle(
IProblem.UsingDeprecatedField,
new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
+ new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
location.sourceStart,
location.sourceEnd);
}
this.handle(
IProblem.UsingDeprecatedConstructor,
new String[] {new String(method.declaringClass.readableName()), parametersAsString(method)},
+ new String[] {new String(method.declaringClass.shortReadableName()), parametersAsShortString(method)},
location.sourceStart,
location.sourceEnd);
else
this.handle(
IProblem.UsingDeprecatedMethod,
new String[] {new String(method.declaringClass.readableName()), new String(method.selector), parametersAsString(method)},
+ new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), parametersAsShortString(method)},
location.sourceStart,
location.sourceEnd);
}
this.handle(
IProblem.UsingDeprecatedType,
new String[] {new String(type.readableName())},
+ new String[] {new String(type.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void duplicateCase(Case statement, Constant constant) {
+ String[] arguments = new String[] {String.valueOf(constant.intValue())};
this.handle(
IProblem.DuplicateCase,
- new String[] {String.valueOf(constant.intValue())},
+ arguments,
+ arguments,
statement.sourceStart,
statement.sourceEnd);
}
public void duplicateDefaultCase(DefaultCase statement) {
this.handle(
IProblem.DuplicateDefaultCase,
- new String[0],
+ NoArgument,
+ NoArgument,
statement.sourceStart,
statement.sourceEnd);
}
this.handle(
IProblem.DuplicateField,
new String[] {new String(type.sourceName()), fieldDecl.name()},
+ new String[] {new String(type.shortReadableName()), fieldDecl.name()},
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void duplicateImport(ImportReference importRef) {
+ String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
this.handle(
IProblem.DuplicateImport,
- new String[] {CharOperation.toString(importRef.tokens)},
+ arguments,
+ arguments,
importRef.sourceStart,
importRef.sourceEnd);
}
public void duplicateInitializationOfBlankFinalField(FieldBinding field, Reference reference) {
+ String[] arguments = new String[]{ new String(field.readableName())};
this.handle(
IProblem.DuplicateBlankFinalFieldInitialization,
- new String[] {new String(field.readableName())},
+ arguments,
+ arguments,
reference.sourceStart,
reference.sourceEnd);
}
-public void duplicateInitializationOfFinalLocal(LocalVariableBinding local, NameReference reference) {
+public void duplicateInitializationOfFinalLocal(LocalVariableBinding local, AstNode location) {
+ String[] arguments = new String[] { new String(local.readableName())};
this.handle(
IProblem.DuplicateFinalLocalInitialization,
- new String[] {new String(local.readableName())},
- reference.sourceStart,
- reference.sourceEnd);
+ arguments,
+ arguments,
+ location.sourceStart,
+ location.sourceEnd);
}
public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(methodDecl.selector), new String(type.sourceName())};
this.handle(
IProblem.DuplicateMethod,
- new String[] {new String(methodDecl.selector), new String(type.sourceName())},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
fieldDecl.modifiers.sourceStart,
fieldDecl.modifiers.sourceEnd));
*/
-
+ String[] arguments = new String[] {fieldDecl.name()};
this.handle(
IProblem.DuplicateModifierForField,
- new String[] {fieldDecl.name()},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
this.handle(
IProblem.DuplicateModifierForMethod,
new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ new String[] {new String(type.shortReadableName()), new String(methodDecl.selector)},
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void duplicateModifierForType(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.DuplicateModifierForType,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void duplicateModifierForVariable(LocalDeclaration localDecl, boolean complainForArgument) {
+ String[] arguments = new String[] {localDecl.name()};
this.handle(
complainForArgument
- ? IProblem.DuplicateModifierForArgument
+ ? IProblem.DuplicateModifierForArgument
: IProblem.DuplicateModifierForVariable,
- new String[] {localDecl.name()},
+ arguments,
+ arguments,
localDecl.sourceStart,
localDecl.sourceEnd);
}
public void duplicateNestedType(TypeDeclaration typeDecl) {
+ String[] arguments = new String[] {new String(typeDecl.name)};
this.handle(
IProblem.DuplicateNestedType,
- new String[] {new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
new String[] {
new String(superType.readableName()),
new String(type.sourceName())},
+ new String[] {
+ new String(superType.shortReadableName()),
+ new String(type.sourceName())},
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
public void duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
+ String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
this.handle(
IProblem.DuplicateTypes,
- new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd,
compUnitDecl.compilationResult);
}
public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
StringBuffer buffer = new StringBuffer();
+ StringBuffer shortBuffer = new StringBuffer();
for (int i = 0, length = params.length; i < length; i++) {
- if (i != 0)
+ if (i != 0){
buffer.append(", "); //$NON-NLS-1$
+ shortBuffer.append(", "); //$NON-NLS-1$
+ }
buffer.append(new String(params[i].readableName()));
+ shortBuffer.append(new String(params[i].shortReadableName()));
}
this.handle(
recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType,
new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
+ new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
messageSend.sourceStart,
messageSend.sourceEnd);
}
public void errorThisSuperInStatic(AstNode reference) {
+ String[] arguments = new String[] {reference.isSuper() ? "super" : "this"}; //$NON-NLS-2$ //$NON-NLS-1$
this.handle(
IProblem.ThisInStaticContext,
- new String[] {reference.isSuper() ? "super" : "this"}, //$NON-NLS-2$ //$NON-NLS-1$
+ arguments,
+ arguments,
reference.sourceStart,
reference.sourceEnd);
}
this.handle(
id,
new String[] {new String(methodDecl.selector), new String(expectedType.readableName())},
+ new String[] {new String(methodDecl.selector), new String(expectedType.shortReadableName())},
exceptionType.sourceStart,
exceptionType.sourceEnd);
}
+public void expressionShouldBeAVariable(Expression expression) {
+ this.handle(
+ IProblem.ExpressionShouldBeAVariable,
+ NoArgument,
+ NoArgument,
+ expression.sourceStart,
+ expression.sourceEnd);
+}
public void fieldsOrThisBeforeConstructorInvocation(ThisReference reference) {
this.handle(
IProblem.ThisSuperDuringConstructorInvocation,
- new String[0],
+ NoArgument,
+ NoArgument,
reference.sourceStart,
reference.sourceEnd);
}
this.handle(
id,
new String[] {fieldDecl.name(), new String(type.sourceName()), new String(expectedType.readableName())},
+ new String[] {fieldDecl.name(), new String(type.sourceName()), new String(expectedType.shortReadableName())},
fieldDecl.type.sourceStart,
fieldDecl.type.sourceEnd);
}
// 8.4.3.3 - Final methods cannot be overridden or hidden.
IProblem.FinalMethodCannotBeOverridden,
new String[] {new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
}
public void forwardReference(Reference reference, int indexInQualification, TypeBinding type) {
this.handle(
IProblem.ReferenceToForwardField,
- new String[] {},
+ NoArgument,
+ NoArgument,
reference.sourceStart,
reference.sourceEnd);
}
private void handle(
int problemId,
String[] problemArguments,
+ String[] messageArguments,
int problemStartPosition,
int problemEndPosition){
this.handle(
problemId,
problemArguments,
+ messageArguments,
problemStartPosition,
problemEndPosition,
referenceContext,
private void handle(
int problemId,
String[] problemArguments,
+ String[] messageArguments,
int severity,
int problemStartPosition,
int problemEndPosition){
this.handle(
problemId,
problemArguments,
+ messageArguments,
severity,
problemStartPosition,
problemEndPosition,
private void handle(
int problemId,
String[] problemArguments,
+ String[] messageArguments,
int problemStartPosition,
int problemEndPosition,
CompilationResult unitResult){
this.handle(
problemId,
problemArguments,
+ messageArguments,
problemStartPosition,
problemEndPosition,
referenceContext,
referenceContext = null;
}
public void hidingEnclosingType(TypeDeclaration typeDecl) {
+ String[] arguments = new String[] {new String(typeDecl.name)};
this.handle(
IProblem.HidingEnclosingType,
- new String[] {new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
int start = 0;
int end = 0;
String typeName = ""; //$NON-NLS-1$
+ String shortTypeName = ""; //$NON-NLS-1$
if (reference == null) { // can only happen when java.lang.Object is busted
start = sourceType.sourceStart();
end = sourceType.sourceEnd();
typeName = new String(superType.readableName());
+ shortTypeName = new String(superType.sourceName());
} else {
start = reference.sourceStart;
end = reference.sourceEnd;
- typeName = CharOperation.toString(reference.getTypeName());
+ char[][] qName = reference.getTypeName();
+ typeName = CharOperation.toString(qName);
+ shortTypeName = new String(qName[qName.length-1]);
}
if (sourceType == superType)
this.handle(
IProblem.HierarchyCircularitySelfReference,
new String[] {new String(sourceType.sourceName()), typeName},
+ new String[] {new String(sourceType.sourceName()), shortTypeName},
start,
end);
else
this.handle(
IProblem.HierarchyCircularity,
new String[] {new String(sourceType.sourceName()), typeName},
+ new String[] {new String(sourceType.sourceName()), shortTypeName},
start,
end);
}
public void hierarchyHasProblems(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.HierarchyHasProblems,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalAbstractModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.IllegalAbstractModifierCombinationForMethod,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void illegalModifierCombinationFinalAbstractForClass(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierCombinationFinalAbstractForClass,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierCombinationFinalVolatileForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {fieldDecl.name()};
+
this.handle(
IProblem.IllegalModifierCombinationFinalVolatileForField,
- new String[] {fieldDecl.name()},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void illegalModifierForClass(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierForClass,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {fieldDecl.name()};
this.handle(
IProblem.IllegalModifierForField,
- new String[] {fieldDecl.name()},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void illegalModifierForInterface(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierForInterface,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierForInterfaceField(ReferenceBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {fieldDecl.name()};
this.handle(
IProblem.IllegalModifierForInterfaceField,
- new String[] {fieldDecl.name()},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void illegalModifierForInterfaceMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.IllegalModifierForInterfaceMethod,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void illegalModifierForLocalClass(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierForLocalClass,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierForMemberClass(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierForMemberClass,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierForMemberInterface(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierForMemberInterface,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.IllegalModifierForMethod,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument) {
+ String[] arguments = new String[] {localDecl.name()};
this.handle(
complainAsArgument
? IProblem.IllegalModifierForArgument
: IProblem.IllegalModifierForVariable,
- new String[] {localDecl.name()},
+ arguments,
+ arguments,
localDecl.sourceStart,
localDecl.sourceEnd);
}
this.handle(
IProblem.IllegalPrimitiveOrArrayTypeForEnclosingInstance,
new String[] {new String(enclosingType.readableName())},
+ new String[] {new String(enclosingType.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalStaticModifierForMemberType,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalVisibilityModifierCombinationForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {new String(fieldDecl.name())};
this.handle(
IProblem.IllegalVisibilityModifierCombinationForField,
- new String[] {new String(fieldDecl.name())},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void illegalVisibilityModifierCombinationForMemberType(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalVisibilityModifierCombinationForMemberType,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalVisibilityModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.IllegalVisibilityModifierCombinationForMethod,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void illegalVisibilityModifierForInterfaceMemberType(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalVisibilityModifierForInterfaceMemberType,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalVoidExpression(AstNode location) {
this.handle(
IProblem.InvalidVoidExpression,
- new String[] {},
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
} else {
argument = CharOperation.toString(importRef.tokens);
}
- this.handle(id, new String[] {argument}, importRef.sourceStart, importRef.sourceEnd);
+ String[] arguments = new String[]{argument};
+ this.handle(id, arguments, arguments, importRef.sourceStart, importRef.sourceEnd);
}
public void incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType) {
- if (type == currentMethod.declaringClass)
+ if (type == currentMethod.declaringClass) {
+ int id;
+ if (currentMethod.declaringClass.isInterface()
+ && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
+ id = IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod;
+ } else {
+ id = IProblem.IncompatibleExceptionInThrowsClause;
+ }
this.handle(
// Exception %1 is not compatible with throws clause in %2
// 9.4.4 - The type of exception in the throws clause is incompatible.
- IProblem.IncompatibleExceptionInThrowsClause,
+ id,
new String[] {
new String(exceptionType.sourceName()),
new String(
inheritedMethod.declaringClass.readableName(),
inheritedMethod.readableName(),
'.'))},
+ new String[] {
+ new String(exceptionType.sourceName()),
+ new String(
+ CharOperation.concat(
+ inheritedMethod.declaringClass.shortReadableName(),
+ inheritedMethod.shortReadableName(),
+ '.'))},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
- else
+ } else
this.handle(
// Exception %1 in throws clause of %2 is not compatible with %3
// 9.4.4 - The type of exception in the throws clause is incompatible.
inheritedMethod.declaringClass.readableName(),
inheritedMethod.readableName(),
'.'))},
+ new String[] {
+ new String(exceptionType.sourceName()),
+ new String(
+ CharOperation.concat(
+ currentMethod.declaringClass.sourceName(),
+ currentMethod.shortReadableName(),
+ '.')),
+ new String(
+ CharOperation.concat(
+ inheritedMethod.declaringClass.shortReadableName(),
+ inheritedMethod.shortReadableName(),
+ '.'))},
type.sourceStart(),
type.sourceEnd());
}
.append('.')
.append(inheritedMethod.readableName());
+ StringBuffer shortSignature = new StringBuffer();
+ shortSignature
+ .append(inheritedMethod.declaringClass.shortReadableName())
+ .append('.')
+ .append(inheritedMethod.shortReadableName());
+
+ int id;
+ if (currentMethod.declaringClass.isInterface()
+ && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
+ id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod;
+ } else {
+ id = IProblem.IncompatibleReturnType;
+ }
this.handle(
- // Return type is incompatible with %1
- // 9.4.2 - The return type from the method is incompatible with the declaration.
- IProblem.IncompatibleReturnType,
+ id,
new String[] {methodSignature.toString()},
+ new String[] {shortSignature.toString()},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
}
-public void incorrectEnclosingInstanceReference(
- QualifiedThisReference reference,
- TypeBinding qualificationType) {
-
- this.handle(
- IProblem.IncorrectEnclosingInstanceReference,
- new String[] { new String(qualificationType.readableName())},
- reference.sourceStart,
- reference.sourceEnd);
-}
public void incorrectLocationForEmptyDimension(ArrayAllocationExpression expression, int index) {
this.handle(
IProblem.IllegalDimension,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.dimensions[index + 1].sourceStart,
expression.dimensions[index + 1].sourceEnd);
}
this.handle(
IProblem.IncorrectSwitchType,
new String[] {new String(testType.readableName())},
+ new String[] {new String(testType.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
.append(concreteMethod.declaringClass.readableName())
.append('.')
.append(concreteMethod.readableName());
+ StringBuffer shortSignature = new StringBuffer();
+ shortSignature
+ .append(concreteMethod.declaringClass.shortReadableName())
+ .append('.')
+ .append(concreteMethod.shortReadableName());
this.handle(
// The inherited method %1 cannot hide the public abstract method in %2
IProblem.InheritedMethodReducesVisibility,
new String[] {
new String(concreteSignature.toString()),
new String(abstractMethods[0].declaringClass.readableName())},
+ new String[] {
+ new String(shortSignature.toString()),
+ new String(abstractMethods[0].declaringClass.shortReadableName())},
type.sourceStart(),
type.sourceEnd());
}
public void inheritedMethodsHaveIncompatibleReturnTypes(SourceTypeBinding type, MethodBinding[] inheritedMethods, int length) {
StringBuffer methodSignatures = new StringBuffer();
+ StringBuffer shortSignatures = new StringBuffer();
for (int i = length; --i >= 0;) {
methodSignatures
.append(inheritedMethods[i].declaringClass.readableName())
.append('.')
.append(inheritedMethods[i].readableName());
- if (i != 0)
+ shortSignatures
+ .append(inheritedMethods[i].declaringClass.shortReadableName())
+ .append('.')
+ .append(inheritedMethods[i].shortReadableName());
+ if (i != 0){
methodSignatures.append(", "); //$NON-NLS-1$
+ shortSignatures.append(", "); //$NON-NLS-1$
+ }
}
this.handle(
// 9.4.2 - The return type from the method is incompatible with the declaration.
IProblem.IncompatibleReturnType,
new String[] {methodSignatures.toString()},
+ new String[] {shortSignatures.toString()},
type.sourceStart(),
type.sourceEnd());
}
public void initializerMustCompleteNormally(FieldDeclaration fieldDecl) {
this.handle(
IProblem.InitializerMustCompleteNormally,
- new String[0],
+ NoArgument,
+ NoArgument,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
this.handle(
IProblem.CannotDefineStaticInitializerInLocalType,
new String[] {new String(innerType.readableName())},
+ new String[] {new String(innerType.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void interfaceCannotHaveConstructors(ConstructorDeclaration constructor) {
this.handle(
IProblem.InterfaceCannotHaveConstructors,
- new String[0],
+ NoArgument,
+ NoArgument,
constructor.sourceStart,
constructor.sourceEnd,
constructor,
constructor.compilationResult());
}
public void interfaceCannotHaveInitializers(SourceTypeBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {new String(type.sourceName())};
+
this.handle(
IProblem.InterfaceCannotHaveInitializers,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void invalidBreak(AstNode location) {
this.handle(
IProblem.InvalidBreak,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
this.handle(
flag,
new String[] {new String(targetConstructor.declaringClass.readableName()), parametersAsString(targetConstructor)},
+ new String[] {new String(targetConstructor.declaringClass.shortReadableName()), parametersAsShortString(targetConstructor)},
statement.sourceStart,
statement.sourceEnd);
}
public void invalidContinue(AstNode location) {
this.handle(
IProblem.InvalidContinue,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
-public void invalidEnclosingType(Expression expression, TypeBinding type, TypeBinding enclosingType) {
+public void invalidEnclosingType(Expression expression, TypeBinding type, ReferenceBinding enclosingType) {
+ if (enclosingType.isAnonymousType()) enclosingType = enclosingType.superclass();
int flag = IProblem.UndefinedType; // default
switch (type.problemId()) {
case NotFound : // 1
this.handle(
flag,
new String[] {new String(enclosingType.readableName()) + "." + new String(type.readableName())}, //$NON-NLS-1$
+ new String[] {new String(enclosingType.shortReadableName()) + "." + new String(type.shortReadableName())}, //$NON-NLS-1$
expression.sourceStart,
expression.sourceEnd);
}
public void invalidExpressionAsStatement(Expression expression){
this.handle(
IProblem.InvalidExpressionAsStatement,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
case InheritedNameHidesEnclosingName :
flag = IProblem.InheritedFieldHidesEnclosingName;
break;
+ case ReceiverTypeNotVisible :
+ this.handle(
+ IProblem.NotVisibleType,
+ new String[] {new String(searchedType.leafComponentType().readableName())},
+ new String[] {new String(searchedType.leafComponentType().shortReadableName())},
+ fieldRef.receiver.sourceStart,
+ fieldRef.receiver.sourceEnd);
+ return;
+
case NoError : // 0
default :
needImplementation(); // want to fail to see why we were here...
break;
}
+ String[] arguments = new String[] {new String(field.readableName())};
this.handle(
flag,
- new String[] {new String(field.readableName())},
+ arguments,
+ arguments,
severity,
fieldRef.sourceStart,
fieldRef.sourceEnd);
case InheritedNameHidesEnclosingName :
flag = IProblem.InheritedFieldHidesEnclosingName;
break;
+ case ReceiverTypeNotVisible :
+ this.handle(
+ IProblem.NotVisibleType,
+ new String[] {new String(field.declaringClass.leafComponentType().readableName())},
+ new String[] {new String(field.declaringClass.leafComponentType().shortReadableName())},
+ nameRef.sourceStart,
+ nameRef.sourceEnd);
+ return;
case NoError : // 0
default :
needImplementation(); // want to fail to see why we were here...
break;
}
+ String[] arguments = new String[] {new String(field.readableName())};
this.handle(
flag,
- new String[] {new String(field.readableName())},
+ arguments,
+ arguments,
nameRef.sourceStart,
nameRef.sourceEnd);
}
new String(searchedType.readableName()),
CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
new String(nameRef.tokens[index])},
+ new String[] {
+ new String(searchedType.sourceName()),
+ CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
+ new String(nameRef.tokens[index])},
nameRef.sourceStart,
nameRef.sourceEnd);
return;
case InheritedNameHidesEnclosingName :
flag = IProblem.InheritedFieldHidesEnclosingName;
break;
+ case ReceiverTypeNotVisible :
+ this.handle(
+ IProblem.NotVisibleType,
+ new String[] {new String(searchedType.leafComponentType().readableName())},
+ new String[] {new String(searchedType.leafComponentType().shortReadableName())},
+ nameRef.sourceStart,
+ nameRef.sourceEnd);
+ return;
case NoError : // 0
default :
needImplementation(); // want to fail to see why we were here...
break;
}
+ String[] arguments = new String[] {CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index + 1))};
this.handle(
flag,
- new String[] {CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index + 1))},
+ arguments,
+ arguments,
nameRef.sourceStart,
nameRef.sourceEnd);
}
case NonStaticReferenceInStaticContext :
flag = IProblem.StaticMethodRequested;
break;
+ case ReceiverTypeNotVisible :
+ this.handle(
+ IProblem.NotVisibleType,
+ new String[] {new String(method.declaringClass.leafComponentType().readableName())},
+ new String[] {new String(method.declaringClass.leafComponentType().shortReadableName())},
+ messageSend.receiver.sourceStart,
+ messageSend.receiver.sourceEnd);
+ return;
+
case NoError : // 0
default :
needImplementation(); // want to fail to see why we were here...
if (flag == IProblem.UndefinedMethod) {
ProblemMethodBinding problemMethod = (ProblemMethodBinding) method;
if (problemMethod.closestMatch != null) {
+ String closestParameterTypeNames = parametersAsString(problemMethod.closestMatch);
+ String parameterTypeNames = parametersAsString(method);
+ String closestParameterTypeShortNames = parametersAsShortString(problemMethod.closestMatch);
+ String parameterTypeShortNames = parametersAsShortString(method);
+ if (closestParameterTypeShortNames.equals(parameterTypeShortNames)){
+ closestParameterTypeShortNames = closestParameterTypeNames;
+ parameterTypeShortNames = parameterTypeNames;
+ }
this.handle(
IProblem.ParameterMismatch,
new String[] {
new String(problemMethod.closestMatch.declaringClass.readableName()),
new String(problemMethod.closestMatch.selector),
- parametersAsString(problemMethod.closestMatch),
- parametersAsString(method)},
+ closestParameterTypeNames,
+ parameterTypeNames
+ },
+ new String[] {
+ new String(problemMethod.closestMatch.declaringClass.shortReadableName()),
+ new String(problemMethod.closestMatch.selector),
+ closestParameterTypeShortNames,
+ parameterTypeShortNames
+ },
(int) (messageSend.nameSourcePosition >>> 32),
(int) messageSend.nameSourcePosition);
return;
new String[] {
new String(method.declaringClass.readableName()),
new String(method.selector), parametersAsString(method)},
+ new String[] {
+ new String(method.declaringClass.shortReadableName()),
+ new String(method.selector), parametersAsShortString(method)},
(int) (messageSend.nameSourcePosition >>> 32),
(int) messageSend.nameSourcePosition);
}
public void invalidNullToSynchronize(Expression expression) {
this.handle(
IProblem.InvalidNullToSynchronized,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
public void invalidOperator(BinaryExpression expression, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.InvalidOperator,
new String[] {
expression.operatorToString(),
- new String(leftType.readableName()) + ", " + new String(rightType.readableName())}, //$NON-NLS-1$
+ leftName + ", " + rightName}, //$NON-NLS-1$
+ new String[] {
+ expression.operatorToString(),
+ leftShortName + ", " + rightShortName}, //$NON-NLS-1$
expression.sourceStart,
expression.sourceEnd);
}
public void invalidOperator(CompoundAssignment assign, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.InvalidOperator,
new String[] {
assign.operatorToString(),
- new String(leftType.readableName()) + ", " + new String(rightType.readableName())}, //$NON-NLS-1$
+ leftName + ", " + rightName}, //$NON-NLS-1$
+ new String[] {
+ assign.operatorToString(),
+ leftShortName + ", " + rightShortName}, //$NON-NLS-1$
assign.sourceStart,
assign.sourceEnd);
}
this.handle(
IProblem.InvalidOperator,
new String[] {expression.operatorToString(), new String(type.readableName())},
+ new String[] {expression.operatorToString(), new String(type.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
+public void invalidParenthesizedExpression(AstNode reference) {
+ this.handle(
+ IProblem.InvalidParenthesizedExpression,
+ NoArgument,
+ NoArgument,
+ reference.sourceStart,
+ reference.sourceEnd);
+}
public void invalidSuperclass(SourceTypeBinding type, TypeReference superclassRef, ReferenceBinding expectedType) {
int problemId = expectedType.problemId();
int id;
this.handle(
id,
new String[] {new String(expectedType.readableName()), new String(type.sourceName())},
+ new String[] {new String(expectedType.shortReadableName()), new String(type.sourceName())},
superclassRef.sourceStart,
superclassRef.sourceEnd);
}
this.handle(
id,
new String[] {new String(expectedType.readableName()), new String(type.sourceName())},
+ new String[] {new String(expectedType.shortReadableName()), new String(type.sourceName())},
superinterfaceRef.sourceStart,
superinterfaceRef.sourceEnd);
}
this.handle(
flag,
new String[] {new String(type.readableName())},
+ new String[] {new String(type.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void invalidTypeReference(Expression expression) {
this.handle(
IProblem.InvalidTypeExpression,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
this.handle(
IProblem.InvalidTypeToSynchronized,
new String[] {new String(type.readableName())},
+ new String[] {new String(type.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
public void invalidUnaryExpression(Expression expression) {
this.handle(
IProblem.InvalidUnaryExpression,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl) {
referenceContext = compUnitDecl;
+ String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
this.handle(
IProblem.IsClassPathCorrect,
- new String[] {CharOperation.toString(wellKnownTypeName)},
+ arguments,
+ arguments,
AbortCompilation | Error,
compUnitDecl == null ? 0 : compUnitDecl.sourceStart,
compUnitDecl == null ? 1 : compUnitDecl.sourceEnd);
public void maskedExceptionHandler(ReferenceBinding exceptionType, AstNode location) {
this.handle(
IProblem.MaskedCatch,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
public void methodNeedingAbstractModifier(MethodDeclaration methodDecl) {
this.handle(
IProblem.MethodRequiresBody,
- new String[0],
+ NoArgument,
+ NoArgument,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void methodNeedingNoBody(MethodDeclaration methodDecl) {
this.handle(
- ((methodDecl.modifiers & CompilerModifiers.AccNative) != 0) ? IProblem.BodyForNativeMethod : IProblem.BodyForAbstractMethod,
- new String[0],
+// ((methodDecl.modifiers & CompilerModifiers.AccNative) != 0) ? IProblem.BodyForNativeMethod : IProblem.BodyForAbstractMethod,
+ IProblem.BodyForAbstractMethod,
+ NoArgument,
+ NoArgument,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void methodWithConstructorName(MethodDeclaration methodDecl) {
this.handle(
IProblem.MethodButWithConstructorName,
- new String[0],
+ NoArgument,
+ NoArgument,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
-public void missingEnclosingInstanceSpecification(ReferenceBinding enclosingType, AstNode location) {
- boolean insideConstructorCall =
- (location instanceof ExplicitConstructorCall)
- && (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper);
-
- this.handle(
- insideConstructorCall
- ? IProblem.MissingEnclosingInstanceForConstructorCall
- : IProblem.MissingEnclosingInstance,
- new String[] {new String(enclosingType.readableName())},
- location.sourceStart,
- location.sourceEnd);
-}
+//public void missingEnclosingInstanceSpecification(ReferenceBinding enclosingType, AstNode location) {
+// boolean insideConstructorCall =
+// (location instanceof ExplicitConstructorCall)
+// && (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper);
+//
+// this.handle(
+// insideConstructorCall
+// ? IProblem.MissingEnclosingInstanceForConstructorCall
+// : IProblem.MissingEnclosingInstance,
+// new String[] {new String(enclosingType.readableName())},
+// new String[] {new String(enclosingType.shortReadableName())},
+// location.sourceStart,
+// location.sourceEnd);
+//}
public void missingReturnType(AbstractMethodDeclaration methodDecl) {
this.handle(
IProblem.MissingReturnType,
- new String[0],
+ NoArgument,
+ NoArgument,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
+public void missingSemiColon(Expression expression){
+ this.handle(
+ IProblem.MissingSemiColon,
+ NoArgument,
+ NoArgument,
+ expression.sourceStart,
+ expression.sourceEnd);
+}
public void mustDefineDimensionsOrInitializer(ArrayAllocationExpression expression) {
this.handle(
IProblem.MustDefineEitherDimensionExpressionsOrInitializer,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
public void mustSpecifyPackage(CompilationUnitDeclaration compUnitDecl) {
+ String[] arguments = new String[] {new String(compUnitDecl.getFileName())};
this.handle(
IProblem.MustSpecifyPackage,
- new String[] {new String(compUnitDecl.getFileName())},
+ arguments,
+ arguments,
compUnitDecl.sourceStart,
compUnitDecl.sourceStart + 1);
}
this.handle(
IProblem.StaticMethodRequested,
new String[] {new String(method.declaringClass.readableName()), new String(method.selector), parametersAsString(method)},
+ new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), parametersAsShortString(method)},
messageSend.sourceStart,
messageSend.sourceEnd);
}
+
public void nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.NativeMethodsCannotBeStrictfp,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
this.handle(
IProblem.NeedToEmulateFieldReadAccess,
new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
+ new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
location.sourceStart,
location.sourceEnd);
}
this.handle(
IProblem.NeedToEmulateFieldWriteAccess,
new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
+ new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
location.sourceStart,
location.sourceEnd);
}
new String(method.declaringClass.readableName()),
parametersAsString(method)
},
+ new String[] {
+ new String(method.declaringClass.shortReadableName()),
+ parametersAsShortString(method)
+ },
location.sourceStart,
location.sourceEnd);
else
new String(method.selector),
parametersAsString(method)
},
+ new String[] {
+ new String(method.declaringClass.shortReadableName()),
+ new String(method.selector),
+ parametersAsShortString(method)
+ },
location.sourceStart,
location.sourceEnd);
}
public void nestedClassCannotDeclareInterface(TypeDeclaration typeDecl) {
+ String[] arguments = new String[] {new String(typeDecl.name)};
this.handle(
IProblem.CannotDefineInterfaceInLocalType,
- new String[] {new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
public void noMoreAvailableSpaceForArgument(LocalVariableBinding local, AstNode location) {
+ String[] arguments = new String[]{ new String(local.name) };
this.handle(
- IProblem.TooManyArgumentSlots,
- new String[]{ new String(local.name) },
+ local instanceof SyntheticArgumentBinding
+ ? IProblem.TooManySyntheticArgumentSlots
+ : IProblem.TooManyArgumentSlots,
+ arguments,
+ arguments,
Abort | Error,
location.sourceStart,
location.sourceEnd);
}
public void noMoreAvailableSpaceForLocal(LocalVariableBinding local, AstNode location) {
+ String[] arguments = new String[]{ new String(local.name) };
this.handle(
IProblem.TooManyLocalVariableSlots,
- new String[]{ new String(local.name) },
+ arguments,
+ arguments,
Abort | Error,
location.sourceStart,
location.sourceEnd);
}
+public void noSuchEnclosingInstance(TypeBinding targetType, AstNode location, boolean isConstructorCall) {
+
+ int id;
+
+ if (isConstructorCall) {
+ //28 = No enclosing instance of type {0} is available due to some intermediate constructor invocation
+ id = IProblem.EnclosingInstanceInConstructorCall;
+ } else if ((location instanceof ExplicitConstructorCall)
+ && ((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper) {
+ //20 = No enclosing instance of type {0} is accessible to invoke the super constructor. Must define a constructor and explicitly qualify its super constructor invocation with an instance of {0} (e.g. x.super() where x is an instance of {0}).
+ id = IProblem.MissingEnclosingInstanceForConstructorCall;
+ } else if (location instanceof AllocationExpression
+ && (((AllocationExpression) location).binding.declaringClass.isMemberType()
+ || (((AllocationExpression) location).binding.declaringClass.isAnonymousType()
+ && ((AllocationExpression) location).binding.declaringClass.superclass().isMemberType()))) {
+ //21 = No enclosing instance of type {0} is accessible. Must qualify the allocation with an enclosing instance of type {0} (e.g. x.new A() where x is an instance of {0}).
+ id = IProblem.MissingEnclosingInstance;
+ } else { // default
+ //22 = No enclosing instance of the type {0} is accessible in scope
+ id = IProblem.IncorrectEnclosingInstanceReference;
+ }
+
+ this.handle(
+ id,
+ new String[] { new String(targetType.readableName())},
+ new String[] { new String(targetType.shortReadableName())},
+ location.sourceStart,
+ location.sourceEnd);
+}
public void notCompatibleTypesError(EqualExpression expression, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.IncompatibleTypesInEqualityOperator,
- new String[] {new String(leftType.readableName()), new String(rightType.readableName())},
+ new String[] {leftName, rightName },
+ new String[] {leftShortName, rightShortName },
expression.sourceStart,
expression.sourceEnd);
}
public void notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.IncompatibleTypesInConditionalOperator,
- new String[] {new String(leftType.readableName()), new String(rightType.readableName())},
+ new String[] {leftName, rightName },
+ new String[] {leftShortName, rightShortName },
expression.sourceStart,
expression.sourceEnd);
}
+public void objectCannotHaveSuperTypes(SourceTypeBinding type) {
+ this.handle(
+ IProblem.ObjectCannotHaveSuperTypes,
+ NoArgument,
+ NoArgument,
+ type.sourceStart(),
+ type.sourceEnd());
+}
public void operatorOnlyValidOnNumericType(CompoundAssignment assignment, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.TypeMismatch,
- new String[] {new String(leftType.readableName()), new String(rightType.readableName())},
+ new String[] {leftName, rightName },
+ new String[] {leftShortName, rightShortName },
assignment.sourceStart,
assignment.sourceEnd);
}
-public void overridesDeprecatedMethod(MethodBinding currentMethod, MethodBinding inheritedMethod) {
+public void overridesDeprecatedMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
this.handle(
IProblem.OverridingDeprecatedMethod,
- new String[] {new String(inheritedMethod.declaringClass.readableName())},
- currentMethod.sourceStart(),
- currentMethod.sourceEnd());
+ new String[] {
+ new String(
+ CharOperation.concat(
+ localMethod.declaringClass.readableName(),
+ localMethod.readableName(),
+ '.')),
+ new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {
+ new String(
+ CharOperation.concat(
+ localMethod.declaringClass.shortReadableName(),
+ localMethod.shortReadableName(),
+ '.')),
+ new String(inheritedMethod.declaringClass.shortReadableName())},
+ localMethod.sourceStart(),
+ localMethod.sourceEnd());
}
public void overridesPackageDefaultMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
this.handle(
localMethod.readableName(),
'.')),
new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {
+ new String(
+ CharOperation.concat(
+ localMethod.declaringClass.shortReadableName(),
+ localMethod.shortReadableName(),
+ '.')),
+ new String(inheritedMethod.declaringClass.shortReadableName())},
localMethod.sourceStart(),
localMethod.sourceEnd());
}
public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) {
+ String[] arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)};
this.handle(
IProblem.PackageCollidesWithType,
- new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)},
+ arguments,
+ arguments,
compUnitDecl.currentPackage.sourceStart,
compUnitDecl.currentPackage.sourceEnd);
}
public void packageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl) {
+ String[] arguments = new String[] {CharOperation.toString(compUnitDecl.compilationResult.compilationUnit.getPackageName())};
this.handle(
IProblem.PackageIsNotExpectedPackage,
- new String[] {CharOperation.toString(compUnitDecl.compilationResult.compilationUnit.getPackageName())},
+ arguments,
+ arguments,
compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceStart,
compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceEnd);
}
}
return buffer.toString();
}
+private String parametersAsShortString(MethodBinding method) {
+ TypeBinding[] params = method.parameters;
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0, length = params.length; i < length; i++) {
+ if (i != 0)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append(new String(params[i].shortReadableName()));
+ }
+ return buffer.toString();
+}
public void parseError(
int startPosition,
int endPosition,
if (possibleTokens.length == 0) { //no suggestion available
if (isKeyword(currentTokenSource)) {
+ String[] arguments = new String[] {new String(currentTokenSource)};
this.handle(
IProblem.ParsingErrorOnKeywordNoSuggestion,
- new String[] {new String(currentTokenSource)},
+ arguments,
+ arguments,
// this is the current -invalid- token position
startPosition,
endPosition);
return;
} else {
+ String[] arguments = new String[] {errorTokenName};
this.handle(
IProblem.ParsingErrorNoSuggestion,
- new String[] {errorTokenName},
+ arguments,
+ arguments,
// this is the current -invalid- token position
startPosition,
endPosition);
}
if (isKeyword(currentTokenSource)) {
+ String[] arguments = new String[] {new String(currentTokenSource), list.toString()};
this.handle(
IProblem.ParsingErrorOnKeyword,
- new String[] {new String(currentTokenSource), list.toString()},
+ arguments,
+ arguments,
// this is the current -invalid- token position
startPosition,
endPosition);
errorTokenName = new String(currentTokenSource);
}
+ String[] arguments = new String[] {errorTokenName, list.toString()};
this.handle(
IProblem.ParsingError,
- new String[] {errorTokenName, list.toString()},
+ arguments,
+ arguments,
// this is the current -invalid- token position
startPosition,
endPosition);
}
public void publicClassMustMatchFileName(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
+ String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
this.handle(
IProblem.PublicClassMustMatchFileName,
- new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd,
compUnitDecl.compilationResult);
}
-/*
- * Flag all constructors involved in a cycle, we know we have a cycle.
- */
-public void recursiveConstructorInvocation(TypeDeclaration typeDeclaration) {
-
- // propagate the reference count, negative counts means leading to a super constructor invocation (directly or indirectly)
- boolean hasChanged;
- AbstractMethodDeclaration[] methods = typeDeclaration.methods;
- int max = methods.length;
- do {
- hasChanged = false;
- for(int i = 0; i < max; i++){
- if (methods[i].isConstructor()){
- ConstructorDeclaration constructor = (ConstructorDeclaration) methods[i];
- if (constructor.referenceCount > 0){
- ConstructorDeclaration targetConstructor = constructor.constructorCall == null
- ? null
- : (ConstructorDeclaration)(typeDeclaration.declarationOf(constructor.constructorCall.binding));
- if ((targetConstructor == null) || (targetConstructor.referenceCount < 0)){
- hasChanged = true;
- constructor.referenceCount = -1;
- }
- }
- }
- }
- } while (hasChanged);
+public void recursiveConstructorInvocation(ExplicitConstructorCall constructorCall) {
- // all remaining constructors with a positive count are still involved in a cycle
- for(int i = 0; i < max; i++){
- if (methods[i].isConstructor()){
- ConstructorDeclaration constructor = (ConstructorDeclaration) methods[i];
- if (constructor.referenceCount > 0){
- this.referenceContext = constructor;
- this.handle(
- IProblem.RecursiveConstructorInvocation,
- new String[] {
- new String(constructor.constructorCall.binding.declaringClass.readableName()),
- parametersAsString(constructor.constructorCall.binding)
- },
- constructor.constructorCall.sourceStart,
- constructor.constructorCall.sourceEnd);
- }
- }
- }
+ this.handle(
+ IProblem.RecursiveConstructorInvocation,
+ new String[] {
+ new String(constructorCall.binding.declaringClass.readableName()),
+ parametersAsString(constructorCall.binding)
+ },
+ new String[] {
+ new String(constructorCall.binding.declaringClass.shortReadableName()),
+ parametersAsShortString(constructorCall.binding)
+ },
+ constructorCall.sourceStart,
+ constructorCall.sourceEnd);
}
+
public void redefineArgument(Argument arg) {
+ String[] arguments = new String[] {new String(arg.name)};
this.handle(
IProblem.RedefinedArgument,
- new String[] {new String(arg.name)},
+ arguments,
+ arguments,
arg.sourceStart,
arg.sourceEnd);
}
public void redefineLocal(LocalDeclaration localDecl) {
+ String[] arguments = new String[] {new String(localDecl.name)};
this.handle(
IProblem.RedefinedLocal,
- new String[] {new String(localDecl.name)},
+ arguments,
+ arguments,
localDecl.sourceStart,
localDecl.sourceEnd);
}
this.handle(
IProblem.ArrayReferenceRequired,
new String[] {new String(arrayType.readableName())},
+ new String[] {new String(arrayType.shortReadableName())},
arrayRef.sourceStart,
arrayRef.sourceEnd);
}
public void returnTypeCannotBeVoidArray(SourceTypeBinding type, MethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(methodDecl.selector)};
this.handle(
IProblem.ReturnTypeCannotBeVoidArray,
- new String[] {new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
this.handle(
id,
new String[] {new String(methodDecl.selector), new String(expectedType.readableName())},
+ new String[] {new String(methodDecl.selector), new String(expectedType.shortReadableName())},
methodDecl.returnType.sourceStart,
methodDecl.returnType.sourceEnd);
}
if (errorTokenName.equals(Scanner.INVALID_CHAR_IN_STRING))
flag = IProblem.UnterminatedString;
+ String[] arguments = flag == IProblem.ParsingErrorNoSuggestion
+ ? new String[] {errorTokenName}
+ : NoArgument;
this.handle(
flag,
- flag == IProblem.ParsingErrorNoSuggestion
- ? new String[] {errorTokenName}
- : new String[0],
+ arguments,
+ arguments,
// this is the current -invalid- token position
startPos,
scanner.currentPosition - 1,
this.handle(
IProblem.ShouldReturnValue,
new String[] { new String (returnType.readableName())},
+ new String[] { new String (returnType.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void signalNoImplicitStringConversionForCharArrayExpression(Expression expression) {
this.handle(
IProblem.NoImplicitStringConversionForCharArrayExpression,
- new String[] {},
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
// 8.4.6.4 - If a class inherits more than one method with the same signature a static (non-abstract) method cannot hide an instance method.
IProblem.CannotHideAnInstanceMethodWithAStaticMethod,
new String[] {new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
else
// 8.4.6.4 - If a class inherits more than one method with the same signature an instance (non-abstract) method cannot override a static method.
IProblem.CannotOverrideAStaticMethodWithAnInstanceMethod,
new String[] {new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
}
public void staticFieldAccessToNonStaticVariable(FieldReference fieldRef, FieldBinding field) {
+ String[] arguments = new String[] {new String(field.readableName())};
this.handle(
IProblem.NonStaticFieldFromStaticInvocation,
- new String[] {new String(field.readableName())},
+ arguments,
+ arguments,
fieldRef.sourceStart,
fieldRef.sourceEnd);
}
public void staticFieldAccessToNonStaticVariable(QualifiedNameReference nameRef, FieldBinding field){
+ String[] arguments = new String[] {new String(field.readableName())};
this.handle(
IProblem.NonStaticFieldFromStaticInvocation,
- new String[] { new String(field.readableName())},
+ arguments,
+ arguments,
nameRef.sourceStart,
nameRef.sourceEnd);
}
public void staticFieldAccessToNonStaticVariable(SingleNameReference nameRef, FieldBinding field) {
+ String[] arguments = new String[] {new String(field.readableName())};
this.handle(
IProblem.NonStaticFieldFromStaticInvocation,
- new String[] {new String(field.readableName())},
+ arguments,
+ arguments,
nameRef.sourceStart,
nameRef.sourceEnd);
}
new String[] {
new String(concreteMethod.readableName()),
new String(abstractMethods[0].declaringClass.readableName())},
+ new String[] {
+ new String(concreteMethod.readableName()),
+ new String(abstractMethods[0].declaringClass.shortReadableName())},
type.sourceStart(),
type.sourceEnd());
}
public void stringConstantIsExceedingUtf8Limit(AstNode location) {
this.handle(
IProblem.StringConstantIsExceedingUtf8Limit,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
this.handle(
IProblem.SuperclassMustBeAClass,
new String[] {new String(superType.readableName()), new String(type.sourceName())},
+ new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
superclassRef.sourceStart,
superclassRef.sourceEnd);
}
this.handle(
IProblem.SuperInterfaceMustBeAnInterface,
new String[] {new String(superType.readableName()), new String(type.sourceName())},
+ new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
+public void task(String tag, String message, String priority, int start, int end){
+ this.handle(
+ IProblem.Task,
+ new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/},
+ new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/},
+ start,
+ end);
+}
+public void tooManyDimensions(AstNode expression) {
+ this.handle(
+ IProblem.TooManyArrayDimensions,
+ NoArgument,
+ NoArgument,
+ expression.sourceStart,
+ expression.sourceEnd);
+}
+public void tooManyFields(TypeDeclaration typeDeclaration) {
+ this.handle(
+ IProblem.TooManyFields,
+ new String[]{ new String(typeDeclaration.binding.readableName())},
+ new String[]{ new String(typeDeclaration.binding.shortReadableName())},
+ Abort | Error,
+ typeDeclaration.sourceStart,
+ typeDeclaration.sourceEnd);
+}
+public void tooManyMethods(TypeDeclaration typeDeclaration) {
+ this.handle(
+ IProblem.TooManyMethods,
+ new String[]{ new String(typeDeclaration.binding.readableName())},
+ new String[]{ new String(typeDeclaration.binding.shortReadableName())},
+ Abort | Error,
+ typeDeclaration.sourceStart,
+ typeDeclaration.sourceEnd);
+}
public void typeCastError(CastExpression expression, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.IllegalCast,
- new String[] {new String(rightType.readableName()), new String(leftType.readableName())},
+ new String[] { rightName, leftName },
+ new String[] { rightShortName, leftShortName },
expression.sourceStart,
expression.sourceEnd);
}
public void typeCollidesWithPackage(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
+ String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
this.handle(
IProblem.TypeCollidesWithPackage,
- new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd,
compUnitDecl.compilationResult);
}
public void typeMismatchError(TypeBinding resultType, TypeBinding expectedType, AstNode location) {
+ String resultTypeName = new String(resultType.readableName());
+ String expectedTypeName = new String(expectedType.readableName());
+ String resultTypeShortName = new String(resultType.shortReadableName());
+ String expectedTypeShortName = new String(expectedType.shortReadableName());
+ if (resultTypeShortName.equals(expectedTypeShortName)){
+ resultTypeShortName = resultTypeName;
+ expectedTypeShortName = expectedTypeName;
+ }
this.handle(
IProblem.TypeMismatch,
- new String[] {new String(resultType.readableName()), new String(expectedType.readableName())},
+ new String[] {resultTypeName, expectedTypeName},
+ new String[] {resultTypeShortName, expectedTypeShortName},
location.sourceStart,
location.sourceEnd);
}
public void typeMismatchErrorActualTypeExpectedType(Expression expression, TypeBinding constantType, TypeBinding expectedType) {
+ String constantTypeName = new String(constantType.readableName());
+ String expectedTypeName = new String(expectedType.readableName());
+ String constantTypeShortName = new String(constantType.shortReadableName());
+ String expectedTypeShortName = new String(expectedType.shortReadableName());
+ if (constantTypeShortName.equals(expectedTypeShortName)){
+ constantTypeShortName = constantTypeName;
+ expectedTypeShortName = expectedTypeName;
+ }
this.handle(
IProblem.TypeMismatch,
- new String[] {new String(constantType.readableName()), new String(expectedType.readableName())},
+ new String[] {constantTypeName, expectedTypeName},
+ new String[] {constantTypeShortName, expectedTypeShortName},
expression.sourceStart,
expression.sourceEnd);
}
public void undefinedLabel(BranchStatement statement) {
+ String[] arguments = new String[] {new String(statement.label)};
this.handle(
IProblem.UndefinedLabel,
- new String[] {new String(statement.label)},
+ arguments,
+ arguments,
statement.sourceStart,
statement.sourceEnd);
}
public void unexpectedStaticModifierForField(SourceTypeBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {fieldDecl.name()};
this.handle(
IProblem.UnexpectedStaticModifierForField,
- new String[] {fieldDecl.name()},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void unexpectedStaticModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.UnexpectedStaticModifierForMethod,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
? IProblem.UndefinedConstructorInImplicitConstructorCall
: IProblem.UnhandledException),
new String[] {new String(exceptionType.readableName())},
+ new String[] {new String(exceptionType.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void uninitializedBlankFinalField(FieldBinding binding, AstNode location) {
+ String[] arguments = new String[] {new String(binding.readableName())};
this.handle(
IProblem.UninitializedBlankFinalField,
- new String[] {new String(binding.readableName())},
+ arguments,
+ arguments,
location.sourceStart,
location.sourceEnd);
}
public void uninitializedLocalVariable(LocalVariableBinding binding, AstNode location) {
+ String[] arguments = new String[] {new String(binding.readableName())};
this.handle(
IProblem.UninitializedLocalVariable,
- new String[] {new String(binding.readableName())},
+ arguments,
+ arguments,
location.sourceStart,
location.sourceEnd);
}
this.handle(
IProblem.UnmatchedBracket,
- new String[] {},
+ NoArgument,
+ NoArgument,
position,
position,
context,
this.handle(
IProblem.IllegalEnclosingInstanceSpecification,
new String[]{ new String(targetType.readableName())},
+ new String[]{ new String(targetType.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
+public void unnecessaryReceiverForStaticMethod(AstNode location, MethodBinding method) {
+ this.handle(
+ IProblem.NonStaticAccessToStaticMethod,
+ new String[] {new String(method.declaringClass.readableName()), new String(method.selector), parametersAsString(method)},
+ new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), parametersAsShortString(method)},
+ location.sourceStart,
+ location.sourceEnd);
+}
+public void unnecessaryReceiverForStaticField(AstNode location, FieldBinding field) {
+ this.handle(
+ IProblem.NonStaticAccessToStaticField,
+ new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
+ new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
+ location.sourceStart,
+ location.sourceEnd);
+}
public void unreachableCode(Statement statement) {
this.handle(
IProblem.CodeCannotBeReached,
- new String[0],
+ NoArgument,
+ NoArgument,
statement.sourceStart,
statement.sourceEnd);
}
public void unreachableExceptionHandler(ReferenceBinding exceptionType, AstNode location) {
this.handle(
IProblem.UnreachableCatch,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
severity = SecondaryError;
}
*/
+ String[] arguments = new String[] {new String(binding.readableName())};
this.handle(
IProblem.UndefinedName,
- new String[] {new String(binding.readableName())},
+ arguments,
+ arguments,
severity,
nameRef.sourceStart,
nameRef.sourceEnd);
}
public void unusedArgument(LocalDeclaration localDecl) {
+
+ String[] arguments = new String[] {localDecl.name()};
this.handle(
IProblem.ArgumentIsNeverUsed,
- new String[] {localDecl.name()},
+ arguments,
+ arguments,
localDecl.sourceStart,
localDecl.sourceEnd);
}
public void unusedImport(ImportReference importRef) {
+ String[] arguments = new String[] { CharOperation.toString(importRef.tokens) };
this.handle(
IProblem.UnusedImport,
- new String[] { CharOperation.toString(importRef.tokens) },
+ arguments,
+ arguments,
importRef.sourceStart,
importRef.sourceEnd);
}
public void unusedLocalVariable(LocalDeclaration localDecl) {
+ String[] arguments = new String[] {localDecl.name()};
this.handle(
IProblem.LocalVariableIsNeverUsed,
- new String[] {localDecl.name()},
+ arguments,
+ arguments,
localDecl.sourceStart,
localDecl.sourceEnd);
}
+public void unusedPrivateConstructor(ConstructorDeclaration constructorDecl) {
+
+ if (computeSeverity(IProblem.UnusedPrivateConstructor) == Ignore) return;
+
+ // no complaint for no-arg constructors (or default ones) - known pattern to block instantiation
+ if (constructorDecl.arguments == null || constructorDecl.arguments.length == 0) return;
+
+ MethodBinding constructor = constructorDecl.binding;
+ this.handle(
+ IProblem.UnusedPrivateConstructor,
+ new String[] {
+ new String(constructor.declaringClass.readableName()),
+ parametersAsString(constructor)
+ },
+ new String[] {
+ new String(constructor.declaringClass.shortReadableName()),
+ parametersAsShortString(constructor)
+ },
+ constructorDecl.sourceStart,
+ constructorDecl.sourceEnd);
+}
+public void unusedPrivateField(FieldDeclaration fieldDecl) {
+
+ if (computeSeverity(IProblem.UnusedPrivateField) == Ignore) return;
+
+ FieldBinding field = fieldDecl.binding;
+
+ if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
+ && field.isStatic()
+ && field.isFinal()
+ && TypeBinding.LongBinding == field.type) {
+ return; // do not report unused serialVersionUID field
+ }
+ this.handle(
+ IProblem.UnusedPrivateField,
+ new String[] {
+ new String(field.declaringClass.readableName()),
+ new String(field.name),
+ },
+ new String[] {
+ new String(field.declaringClass.shortReadableName()),
+ new String(field.name),
+ },
+ fieldDecl.sourceStart,
+ fieldDecl.sourceEnd);
+}
+public void unusedPrivateMethod(AbstractMethodDeclaration methodDecl) {
+
+ if (computeSeverity(IProblem.UnusedPrivateMethod) == Ignore) return;
+
+ MethodBinding method = methodDecl.binding;
+
+ // no report for serialization support 'void readObject(ObjectInputStream)'
+ if (!method.isStatic()
+ && TypeBinding.VoidBinding == method.returnType
+ && method.parameters.length == 1
+ && method.parameters[0].dimensions() == 0
+ && CharOperation.equals(method.selector, TypeConstants.READOBJECT)
+ && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTINPUTSTREAM, method.parameters[0].readableName())) {
+ return;
+ }
+ // no report for serialization support 'void writeObject(ObjectOutputStream)'
+ if (!method.isStatic()
+ && TypeBinding.VoidBinding == method.returnType
+ && method.parameters.length == 1
+ && method.parameters[0].dimensions() == 0
+ && CharOperation.equals(method.selector, TypeConstants.WRITEOBJECT)
+ && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTOUTPUTSTREAM, method.parameters[0].readableName())) {
+ return;
+ }
+ // no report for serialization support 'Object readResolve()'
+ if (!method.isStatic()
+ && TypeBinding.T_Object == method.returnType.id
+ && method.parameters.length == 0
+ && CharOperation.equals(method.selector, TypeConstants.READRESOLVE)) {
+ return;
+ }
+ // no report for serialization support 'Object writeReplace()'
+ if (!method.isStatic()
+ && TypeBinding.T_Object == method.returnType.id
+ && method.parameters.length == 0
+ && CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) {
+ return;
+ }
+ this.handle(
+ IProblem.UnusedPrivateMethod,
+ new String[] {
+ new String(method.declaringClass.readableName()),
+ new String(method.selector),
+ parametersAsString(method)
+ },
+ new String[] {
+ new String(method.declaringClass.shortReadableName()),
+ new String(method.selector),
+ parametersAsShortString(method)
+ },
+ methodDecl.sourceStart,
+ methodDecl.sourceEnd);
+}
+public void unusedPrivateType(TypeDeclaration typeDecl) {
+
+ if (computeSeverity(IProblem.UnusedPrivateType) == Ignore) return;
+ ReferenceBinding type = typeDecl.binding;
+ this.handle(
+ IProblem.UnusedPrivateType,
+ new String[] {
+ new String(type.readableName()),
+ },
+ new String[] {
+ new String(type.shortReadableName()),
+ },
+ typeDecl.sourceStart,
+ typeDecl.sourceEnd);
+}
public void useAssertAsAnIdentifier(int sourceStart, int sourceEnd) {
this.handle(
IProblem.UseAssertAsAnIdentifier,
- new String[0],
+ NoArgument,
+ NoArgument,
sourceStart,
sourceEnd);
}
public void variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl) {
+ String[] arguments = new String[] {new String(varDecl.name)};
this.handle(
IProblem.VariableTypeCannotBeVoid,
- new String[] {new String(varDecl.name)},
+ arguments,
+ arguments,
varDecl.sourceStart,
varDecl.sourceEnd);
}
public void variableTypeCannotBeVoidArray(AbstractVariableDeclaration varDecl) {
+ String[] arguments = new String[] {new String(varDecl.name)};
this.handle(
IProblem.VariableTypeCannotBeVoidArray,
- new String[] {new String(varDecl.name)},
+ arguments,
+ arguments,
varDecl.sourceStart,
varDecl.sourceEnd);
}
// 8.4.6.3 - The access modifier of an overiding method must provide at least as much access as the overriden method.
IProblem.MethodReducesVisibility,
new String[] {new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
}
//the two catch block under and upper are in an incorrect order.
//under should be define BEFORE upper in the source
- //notice that the compiler could arrange automatically the
- //correct order - and the only error would be on cycle ....
- //on this one again , java is compiler-driven instead of being
- //user-driven .....
-
TypeReference typeRef = statement.catchArguments[under].type;
this.handle(
IProblem.UnreachableCatch,
- new String[0],
+ NoArgument,
+ NoArgument,
typeRef.sourceStart,
typeRef.sourceEnd);
}
public void nonExternalizedStringLiteral(AstNode location) {
this.handle(
IProblem.NonExternalizedStringLiteral,
- new String[] {},
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
+public void noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration) {
+ this.handle(
+ IProblem.TooManyBytesForStringConstant,
+ new String[]{ new String(typeDeclaration.binding.readableName())},
+ new String[]{ new String(typeDeclaration.binding.shortReadableName())},
+ Abort | Error,
+ typeDeclaration.sourceStart,
+ typeDeclaration.sourceEnd);
+}
+
public void noMoreAvailableSpaceInConstantPool(TypeDeclaration typeDeclaration) {
this.handle(
IProblem.TooManyConstantsInConstantPool,
new String[]{ new String(typeDeclaration.binding.readableName())},
+ new String[]{ new String(typeDeclaration.binding.shortReadableName())},
Abort | Error,
typeDeclaration.sourceStart,
typeDeclaration.sourceEnd);
return false;
}
int nextToken= scanner.getNextToken();
- if (nextToken == ITerminalSymbols.TokenNameEOF
+ if (nextToken == Scanner.TokenNameEOF
&& scanner.startPosition == scanner.source.length) { // to handle case where we had an ArrayIndexOutOfBoundsException
// while reading the last token
switch(token) {
} else {
return false;
}
- case Scanner.TokenNameas:
- case Scanner.TokenNameand:
-// case Scanner.TokenNameabstract:
+ case Scanner.TokenNameabstract:
// case Scanner.TokenNameassert:
// case Scanner.TokenNamebyte:
case Scanner.TokenNamebreak:
// case Scanner.TokenNameboolean:
case Scanner.TokenNamecase:
// case Scanner.TokenNamechar:
-// case Scanner.TokenNamecatch:
+ case Scanner.TokenNamecatch:
case Scanner.TokenNameclass:
case Scanner.TokenNamecontinue:
case Scanner.TokenNamedo:
// case Scanner.TokenNamedouble:
case Scanner.TokenNamedefault:
- case Scanner.TokenNameecho:
- case Scanner.TokenNameendif:
- case Scanner.TokenNameendfor:
- case Scanner.TokenNameendforeach:
- case Scanner.TokenNameendswitch:
- case Scanner.TokenNameendwhile:
case Scanner.TokenNameelse:
case Scanner.TokenNameextends:
case Scanner.TokenNamefor:
// case Scanner.TokenNamefinal:
// case Scanner.TokenNamefloat:
case Scanner.TokenNamefalse:
-// case Scanner.TokenNamefinally:
- case Scanner.TokenNameglobal:
+ case Scanner.TokenNamefinally:
case Scanner.TokenNameif:
- case Scanner.TokenNameinclude:
- case Scanner.TokenNameinclude_once:
// case Scanner.TokenNameint:
// case Scanner.TokenNameimport:
-// case Scanner.TokenNameinterface:
-// case Scanner.TokenNameimplements:
-// case Scanner.TokenNameinstanceof:
- case Scanner.TokenNamelist:
+ case Scanner.TokenNameinterface:
+ case Scanner.TokenNameimplements:
+ case Scanner.TokenNameinstanceof:
// case Scanner.TokenNamelong:
case Scanner.TokenNamenew:
case Scanner.TokenNamenull:
// case Scanner.TokenNamenative:
- case Scanner.TokenNameold_function:
- case Scanner.TokenNameor:
- case Scanner.TokenNameprint:
-// case Scanner.TokenNamepublic:
+ case Scanner.TokenNamepublic:
// case Scanner.TokenNamepackage:
-// case Scanner.TokenNameprivate:
-// case Scanner.TokenNameprotected:
- case Scanner.TokenNamerequire:
- case Scanner.TokenNamerequire_once:
+ case Scanner.TokenNameprivate:
+ case Scanner.TokenNameprotected:
case Scanner.TokenNamereturn:
// case Scanner.TokenNameshort:
-// case Scanner.TokenNamesuper:
+ case Scanner.TokenNamesuper:
case Scanner.TokenNamestatic:
case Scanner.TokenNameswitch:
// case Scanner.TokenNamestrictfp:
// case Scanner.TokenNamesynchronized:
-// case Scanner.TokenNametry:
-// case Scanner.TokenNamethis:
+ case Scanner.TokenNametry:
+ case Scanner.TokenNamethis:
case Scanner.TokenNametrue:
-// case Scanner.TokenNamethrow:
+ case Scanner.TokenNamethrow:
// case Scanner.TokenNamethrows:
// case Scanner.TokenNametransient:
- case Scanner.TokenNamevar:
// case Scanner.TokenNamevoid:
// case Scanner.TokenNamevolatile:
case Scanner.TokenNamewhile:
- case Scanner.TokenNamexor:
return true;
default:
return false;
}
}
+// jsurfer start
+public void phpParsingError(String[] messageArguments, int problemStartPosition, int problemEndPosition, ReferenceContext context, CompilationResult compilationResult) {
+
+ this.handle(
+ IProblem.PHPParsingError,
+ NoArgument,
+ messageArguments,
+ problemStartPosition,
+ problemEndPosition,
+ context,
+ compilationResult);
+}
}