X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java index 8e8ed0a..d2842a0 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java @@ -13,6 +13,46 @@ import net.sourceforge.phpdt.core.compiler.InvalidInputException; 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.ast.ASTNode; +import net.sourceforge.phpdt.internal.compiler.ast.AbstractMethodDeclaration; +import net.sourceforge.phpdt.internal.compiler.ast.AbstractVariableDeclaration; +import net.sourceforge.phpdt.internal.compiler.ast.AllocationExpression; +import net.sourceforge.phpdt.internal.compiler.ast.Argument; +import net.sourceforge.phpdt.internal.compiler.ast.ArrayAllocationExpression; +import net.sourceforge.phpdt.internal.compiler.ast.ArrayReference; +import net.sourceforge.phpdt.internal.compiler.ast.Assignment; +import net.sourceforge.phpdt.internal.compiler.ast.BinaryExpression; +import net.sourceforge.phpdt.internal.compiler.ast.CaseStatement; +import net.sourceforge.phpdt.internal.compiler.ast.CastExpression; +import net.sourceforge.phpdt.internal.compiler.ast.CompilationUnitDeclaration; +import net.sourceforge.phpdt.internal.compiler.ast.CompoundAssignment; +import net.sourceforge.phpdt.internal.compiler.ast.ConstructorDeclaration; +import net.sourceforge.phpdt.internal.compiler.ast.DefaultCase; +import net.sourceforge.phpdt.internal.compiler.ast.EqualExpression; +import net.sourceforge.phpdt.internal.compiler.ast.ExplicitConstructorCall; +import net.sourceforge.phpdt.internal.compiler.ast.Expression; +import net.sourceforge.phpdt.internal.compiler.ast.FieldDeclaration; +import net.sourceforge.phpdt.internal.compiler.ast.FieldReference; +import net.sourceforge.phpdt.internal.compiler.ast.InstanceOfExpression; +import net.sourceforge.phpdt.internal.compiler.ast.IntLiteral; +import net.sourceforge.phpdt.internal.compiler.ast.Literal; +import net.sourceforge.phpdt.internal.compiler.ast.LocalDeclaration; +import net.sourceforge.phpdt.internal.compiler.ast.LongLiteral; +import net.sourceforge.phpdt.internal.compiler.ast.MessageSend; +import net.sourceforge.phpdt.internal.compiler.ast.MethodDeclaration; +import net.sourceforge.phpdt.internal.compiler.ast.NameReference; +import net.sourceforge.phpdt.internal.compiler.ast.NumberLiteral; +import net.sourceforge.phpdt.internal.compiler.ast.QualifiedNameReference; +import net.sourceforge.phpdt.internal.compiler.ast.Reference; +import net.sourceforge.phpdt.internal.compiler.ast.ReturnStatement; +import net.sourceforge.phpdt.internal.compiler.ast.SingleNameReference; +import net.sourceforge.phpdt.internal.compiler.ast.Statement; +import net.sourceforge.phpdt.internal.compiler.ast.ThisReference; +import net.sourceforge.phpdt.internal.compiler.ast.ThrowStatement; +import net.sourceforge.phpdt.internal.compiler.ast.TryStatement; +import net.sourceforge.phpdt.internal.compiler.ast.TypeDeclaration; +import net.sourceforge.phpdt.internal.compiler.ast.TypeReference; +import net.sourceforge.phpdt.internal.compiler.ast.UnaryExpression; import net.sourceforge.phpdt.internal.compiler.env.IConstants; import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions; import net.sourceforge.phpdt.internal.compiler.impl.Constant; @@ -32,47 +72,6 @@ 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.ASTNode; -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.BinaryExpression; -import net.sourceforge.phpeclipse.internal.compiler.ast.BranchStatement; -import net.sourceforge.phpeclipse.internal.compiler.ast.CaseStatement; -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.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; @@ -97,7 +96,8 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { 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()), + IProblem.AbstractMethodCannotBeOverridden, new String[] { + new String(type.sourceName()), new String(CharOperation.concat(concreteMethod.declaringClass.readableName(), concreteMethod.readableName(), '.')) }, new String[] { new String(type.sourceName()), @@ -262,10 +262,13 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { } public void cannotDireclyInvokeAbstractMethod(MessageSend messageSend, MethodBinding method) { - 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); + 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) { @@ -350,6 +353,11 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { case IProblem.PHPBadStyleUppercaseIdentifierWarning: return this.options.getSeverity(CompilerOptions.PHPBadStyleUppercaseIdentifierWarning); + case IProblem.UninitializedLocalVariable: + return this.options.getSeverity(CompilerOptions.UninitializedLocalVariableWarning); + case IProblem.CodeCannotBeReached: + return this.options.getSeverity(CompilerOptions.CodeCannotBeReachedWarning); + case IProblem.MaskedCatch: return this.options.getSeverity(CompilerOptions.MaskedCatchBlock); @@ -574,21 +582,27 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { } public void deprecatedField(FieldBinding field, ASTNode location) { - this.handle(IProblem.UsingDeprecatedField, new String[] { new String(field.declaringClass.readableName()), + 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); } public void deprecatedMethod(MethodBinding method, ASTNode location) { if (method.isConstructor()) - this.handle(IProblem.UsingDeprecatedConstructor, new String[] { new String(method.declaringClass.readableName()), - parametersAsString(method) }, new String[] { new String(method.declaringClass.shortReadableName()), + 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.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); } public void deprecatedType(TypeBinding type, ASTNode location) { @@ -609,7 +623,8 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { public void duplicateFieldInType(SourceTypeBinding type, FieldDeclaration fieldDecl) { this.handle(IProblem.DuplicateField, new String[] { new String(type.sourceName()), fieldDecl.name() }, new String[] { - new String(type.shortReadableName()), fieldDecl.name() }, fieldDecl.sourceStart, fieldDecl.sourceEnd); + new String(type.shortReadableName()), + fieldDecl.name() }, fieldDecl.sourceStart, fieldDecl.sourceEnd); } // public void duplicateImport(ImportReference importRef) { @@ -644,7 +659,8 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { public void duplicateModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) { 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); + new String(type.shortReadableName()), + new String(methodDecl.selector) }, methodDecl.sourceStart, methodDecl.sourceEnd); } public void duplicateModifierForType(SourceTypeBinding type) { @@ -664,7 +680,8 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { } public void duplicateSuperinterface(SourceTypeBinding type, TypeDeclaration typeDecl, ReferenceBinding superType) { - this.handle(IProblem.DuplicateSuperInterface, new String[] { new String(superType.readableName()), + this.handle(IProblem.DuplicateSuperInterface, new String[] { + new String(superType.readableName()), new String(type.sourceName()) }, new String[] { new String(superType.shortReadableName()), new String(type.sourceName()) }, typeDecl.sourceStart, typeDecl.sourceEnd); } @@ -690,9 +707,12 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { 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); + 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) { @@ -733,8 +753,8 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { return; } 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); + new String(methodDecl.selector), + new String(expectedType.shortReadableName()) }, exceptionType.sourceStart, exceptionType.sourceEnd); } public void expressionShouldBeAVariable(Expression expression) { @@ -856,7 +876,8 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { 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); + new String(sourceType.sourceName()), + shortTypeName }, start, end); } public void hierarchyHasProblems(SourceTypeBinding type) { @@ -1091,8 +1112,10 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { 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()), + 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()); } @@ -1181,8 +1204,10 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { // here... break; } - this.handle(flag, new String[] { new String(targetConstructor.declaringClass.readableName()), - parametersAsString(targetConstructor) }, new String[] { new String(targetConstructor.declaringClass.shortReadableName()), + 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); } @@ -1315,11 +1340,13 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { //NotVisibleField //AmbiguousField if (searchedType.isBaseType()) { - this.handle(IProblem.NoFieldOnBaseType, new String[] { 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); + this.handle(IProblem.NoFieldOnBaseType, new String[] { + 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; } int flag = IProblem.UndefinedField; @@ -1417,18 +1444,24 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { parameterTypeShortNames = parameterTypeNames; } this.handle(IProblem.ParameterMismatch, new String[] { - new String(problemMethod.closestMatch.declaringClass.readableName()), new String(problemMethod.closestMatch.selector), - closestParameterTypeNames, parameterTypeNames }, new String[] { + new String(problemMethod.closestMatch.declaringClass.readableName()), + new String(problemMethod.closestMatch.selector), + closestParameterTypeNames, + parameterTypeNames }, new String[] { new String(problemMethod.closestMatch.declaringClass.shortReadableName()), - new String(problemMethod.closestMatch.selector), closestParameterTypeShortNames, parameterTypeShortNames }, - (int) (messageSend.nameSourcePosition >>> 32), (int) messageSend.nameSourcePosition); + new String(problemMethod.closestMatch.selector), + closestParameterTypeShortNames, + parameterTypeShortNames }, (int) (messageSend.nameSourcePosition >>> 32), (int) messageSend.nameSourcePosition); return; } } - this.handle(flag, 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); + this.handle(flag, 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) { @@ -1505,8 +1538,8 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { return; } 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); + new String(expectedType.shortReadableName()), + new String(type.sourceName()) }, superclassRef.sourceStart, superclassRef.sourceEnd); } public void invalidSuperinterface(SourceTypeBinding type, TypeReference superinterfaceRef, ReferenceBinding expectedType) { @@ -1541,8 +1574,8 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { return; } 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); + new String(expectedType.shortReadableName()), + new String(type.sourceName()) }, superinterfaceRef.sourceStart, superinterfaceRef.sourceEnd); } public void invalidType(ASTNode location, TypeBinding type) { @@ -1594,402 +1627,402 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons { : compUnitDecl.sourceStart, compUnitDecl == null ? 1 : compUnitDecl.sourceEnd); } - public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd){ - this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd); -} -public void javadocDeprecatedField(FieldBinding field, ASTNode location, int modifiers) { - if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { - this.handle( - IProblem.JavadocUsingDeprecatedField, - 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 javadocDeprecatedMethod(MethodBinding method, ASTNode location, int modifiers) { - if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { - if (method.isConstructor()) { - this.handle( - IProblem.JavadocUsingDeprecatedConstructor, - 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.JavadocUsingDeprecatedMethod, - 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 javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers) { - if (location == null) return; // 1G828DN - no type ref for synthetic arguments - if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { - this.handle( - IProblem.JavadocUsingDeprecatedType, - new String[] {new String(type.readableName())}, - new String[] {new String(type.shortReadableName())}, - location.sourceStart, - location.sourceEnd); - } -} -//public void javadocDuplicatedParamTag(JavadocSingleNameReference param, int modifiers) { -// if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { -// String[] arguments = new String[] {String.valueOf(param.token)}; -// this.handle(IProblem.JavadocDuplicateParamName, arguments, arguments, param.sourceStart, param.sourceEnd); -// } -//} -public void javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers) { - if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { - String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())}; - this.handle(IProblem.JavadocDuplicateThrowsClassName, arguments, arguments, typeReference.sourceStart, typeReference.sourceEnd); - } -} -public void javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers) { - StringBuffer buffer = new StringBuffer(); - StringBuffer shortBuffer = new StringBuffer(); - for (int i = 0, length = params.length; i < length; i++) { - 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())); - } - - int id = recType.isArrayType() ? IProblem.JavadocNoMessageSendOnArrayType : IProblem.JavadocNoMessageSendOnBaseType; - if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { - this.handle( - id, - 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 javadocInvalidConstructor(Statement statement, MethodBinding targetConstructor, int modifiers) { - - if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { - return; - } -// boolean insideDefaultConstructor = -// (this.referenceContext instanceof ConstructorDeclaration) -// && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor(); -// boolean insideImplicitConstructorCall = -// (statement instanceof ExplicitConstructorCall) -// && (((ExplicitConstructorCall) statement).accessMode == ExplicitConstructorCall.ImplicitSuper); - - int id = IProblem.JavadocUndefinedConstructor; //default... - switch (targetConstructor.problemId()) { - case NotFound : -// if (insideDefaultConstructor){ -// id = IProblem.JavadocUndefinedConstructorInDefaultConstructor; -// } else if (insideImplicitConstructorCall){ -// id = IProblem.JavadocUndefinedConstructorInImplicitConstructorCall; -// } else { - id = IProblem.JavadocUndefinedConstructor; -// } - break; - case NotVisible : -// if (insideDefaultConstructor){ -// id = IProblem.JavadocNotVisibleConstructorInDefaultConstructor; -// } else if (insideImplicitConstructorCall){ -// id = IProblem.JavadocNotVisibleConstructorInImplicitConstructorCall; -// } else { - id = IProblem.JavadocNotVisibleConstructor; -// } - break; - case Ambiguous : -// if (insideDefaultConstructor){ -// id = IProblem.AmbiguousConstructorInDefaultConstructor; -// } else if (insideImplicitConstructorCall){ -// id = IProblem.AmbiguousConstructorInImplicitConstructorCall; -// } else { - id = IProblem.JavadocAmbiguousConstructor; -// } - break; - case NoError : // 0 - default : - needImplementation(); // want to fail to see why we were here... - break; - } - - this.handle( - id, - new String[] {new String(targetConstructor.declaringClass.readableName()), parametersAsString(targetConstructor)}, - new String[] {new String(targetConstructor.declaringClass.shortReadableName()), parametersAsShortString(targetConstructor)}, - statement.sourceStart, - statement.sourceEnd); -} -public void javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, Binding fieldBinding, int modifiers) { - int id = IProblem.JavadocAmbiguousMethodReference; - if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { - String[] arguments = new String[] {new String(fieldBinding.readableName())}; - handle(id, arguments, arguments, sourceStart, sourceEnd); - } -} -/* - * Similar implementation than invalidField(FieldReference...) - * Note that following problem id cannot occur for Javadoc: - * - NonStaticReferenceInStaticContext : - * - NonStaticReferenceInConstructorInvocation : - * - ReceiverTypeNotVisible : - */ -public void javadocInvalidField(int sourceStart, int sourceEnd, Binding fieldBinding, TypeBinding searchedType, int modifiers) { - int id = IProblem.JavadocUndefinedField; - switch (fieldBinding.problemId()) { - case NotFound : - id = IProblem.JavadocUndefinedField; - break; - case NotVisible : - id = IProblem.JavadocNotVisibleField; - break; - case Ambiguous : - id = IProblem.JavadocAmbiguousField; - break; - case InheritedNameHidesEnclosingName : - id = IProblem.JavadocInheritedFieldHidesEnclosingName; - break; - case NoError : // 0 - default : - needImplementation(); // want to fail to see why we were here... - break; - } - - if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { - String[] arguments = new String[] {new String(fieldBinding.readableName())}; - handle(id, arguments, arguments, sourceStart, sourceEnd); - } -} -/* - * Similar implementation than invalidMethod(MessageSend...) - * Note that following problem id cannot occur for Javadoc: - * - NonStaticReferenceInStaticContext : - * - NonStaticReferenceInConstructorInvocation : - * - ReceiverTypeNotVisible : - */ -public void javadocInvalidMethod(MessageSend messageSend, MethodBinding method, int modifiers) { - if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { - return; - } - int id = IProblem.JavadocUndefinedMethod; //default... - switch (method.problemId()) { - case NotFound : - id = IProblem.JavadocUndefinedMethod; - break; - case NotVisible : - id = IProblem.JavadocNotVisibleMethod; - break; - case Ambiguous : - id = IProblem.JavadocAmbiguousMethod; - break; - case InheritedNameHidesEnclosingName : - id = IProblem.JavadocInheritedMethodHidesEnclosingName; - break; - case NoError : // 0 - default : - needImplementation(); // want to fail to see why we were here... - break; - } - - if (id == IProblem.JavadocUndefinedMethod) { - 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.JavadocParameterMismatch, - new String[] { - new String(problemMethod.closestMatch.declaringClass.readableName()), - new String(problemMethod.closestMatch.selector), - 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; - } - } - - this.handle( - id, - 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 javadocInvalidParamName(JavadocSingleNameReference param, int modifiers) { -// if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { -// String[] arguments = new String[] {String.valueOf(param.token)}; -// this.handle(IProblem.JavadocInvalidParamName, arguments, arguments, param.sourceStart, param.sourceEnd); -// } -//} -public void javadocInvalidSeeReference(int sourceStart, int sourceEnd) { - this.handle(IProblem.JavadocInvalidSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd); -} -public void javadocInvalidSeeReferenceArgs(int sourceStart, int sourceEnd) { - this.handle(IProblem.JavadocInvalidSeeArgs, NoArgument, NoArgument, sourceStart, sourceEnd); -} -public void javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd) { - this.handle(IProblem.JavadocInvalidSeeHref, NoArgument, NoArgument, sourceStart, sourceEnd); -} -public void javadocInvalidTag(int sourceStart, int sourceEnd) { - this.handle(IProblem.JavadocInvalidTag, NoArgument, NoArgument, sourceStart, sourceEnd); -} -public void javadocInvalidThrowsClass(int sourceStart, int sourceEnd) { - this.handle(IProblem.JavadocInvalidThrowsClass, NoArgument, NoArgument, sourceStart, sourceEnd); -} -public void javadocInvalidThrowsClassName(TypeReference typeReference, int modifiers) { - if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { - String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())}; - this.handle(IProblem.JavadocInvalidThrowsClassName, arguments, arguments, typeReference.sourceStart, typeReference.sourceEnd); - } -} -public void javadocInvalidType(ASTNode location, TypeBinding type, int modifiers) { - if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { - int id = IProblem.JavadocUndefinedType; // default - switch (type.problemId()) { - case NotFound : - id = IProblem.JavadocUndefinedType; - break; - case NotVisible : - id = IProblem.JavadocNotVisibleType; - break; - case Ambiguous : - id = IProblem.JavadocAmbiguousType; - break; - case InternalNameProvided : - id = IProblem.JavadocInternalTypeNameProvided; - break; - case InheritedNameHidesEnclosingName : - id = IProblem.JavadocInheritedNameHidesEnclosingTypeName; - break; - case NoError : // 0 - default : - needImplementation(); // want to fail to see why we were here... - break; - } - this.handle( - id, - new String[] {new String(type.readableName())}, - new String[] {new String(type.shortReadableName())}, - location.sourceStart, - location.sourceEnd); - } -} -public void javadocMalformedSeeReference(int sourceStart, int sourceEnd) { - this.handle(IProblem.JavadocMalformedSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd); -} -public void javadocMissing(int sourceStart, int sourceEnd, int modifiers){ - boolean overriding = (modifiers & (CompilerModifiers.AccImplementing+CompilerModifiers.AccOverriding)) != 0; - boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocComments) != ProblemSeverities.Ignore) - && (!overriding || this.options.reportMissingJavadocCommentsOverriding); - if (report) { - String arg = javadocVisibilityArgument(this.options.reportMissingJavadocCommentsVisibility, modifiers); - if (arg != null) { - String[] arguments = new String[] { arg }; - this.handle(IProblem.JavadocMissing, arguments, arguments, sourceStart, sourceEnd); - } - } -} -public void javadocMissingParamName(int sourceStart, int sourceEnd){ - this.handle(IProblem.JavadocMissingParamName, NoArgument, NoArgument, sourceStart, sourceEnd); -} -public void javadocMissingParamTag(Argument param, int modifiers) { - boolean overriding = (modifiers & (CompilerModifiers.AccImplementing+CompilerModifiers.AccOverriding)) != 0; - boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore) - && (!overriding || this.options.reportMissingJavadocTagsOverriding); - if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) { - String[] arguments = new String[] { String.valueOf(param.name) }; - this.handle(IProblem.JavadocMissingParamTag, arguments, arguments, param.sourceStart, param.sourceEnd); - } -} -public void javadocMissingReturnTag(int sourceStart, int sourceEnd, int modifiers){ - boolean overriding = (modifiers & (CompilerModifiers.AccImplementing+CompilerModifiers.AccOverriding)) != 0; - boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore) - && (!overriding || this.options.reportMissingJavadocTagsOverriding); - if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) { - this.handle(IProblem.JavadocMissingReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd); - } -} -public void javadocMissingSeeReference(int sourceStart, int sourceEnd){ - this.handle(IProblem.JavadocMissingSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd); -} -public void javadocMissingThrowsClassName(int sourceStart, int sourceEnd){ - this.handle(IProblem.JavadocMissingThrowsClassName, NoArgument, NoArgument, sourceStart, sourceEnd); -} -public void javadocMissingThrowsTag(TypeReference typeRef, int modifiers){ - boolean overriding = (modifiers & (CompilerModifiers.AccImplementing+CompilerModifiers.AccOverriding)) != 0; - boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore) - && (!overriding || this.options.reportMissingJavadocTagsOverriding); - if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) { - String[] arguments = new String[] { String.valueOf(typeRef.resolvedType.sourceName()) }; - this.handle(IProblem.JavadocMissingThrowsTag, arguments, arguments, typeRef.sourceStart, typeRef.sourceEnd); - } -} -public void javadocUnexpectedTag(int sourceStart, int sourceEnd) { - this.handle(IProblem.JavadocUnexpectedTag, NoArgument, NoArgument, sourceStart, sourceEnd); -} -public void javadocUnterminatedInlineTag(int sourceStart, int sourceEnd) { - this.handle(IProblem.JavadocUnterminatedInlineTag, NoArgument, NoArgument, sourceStart, sourceEnd); -} -private boolean javadocVisibility(int visibility, int modifiers) { - switch (modifiers & CompilerModifiers.AccVisibilityMASK) { - case IConstants.AccPublic : - return true; - case IConstants.AccProtected: - return (visibility != IConstants.AccPublic); -// case IConstants.AccDefault: -// return (visibility == IConstants.AccDefault || visibility == IConstants.AccPrivate); - case IConstants.AccPrivate: - return (visibility == IConstants.AccPrivate); - } - return true; -} -private String javadocVisibilityArgument(int visibility, int modifiers) { - String argument = null; - switch (modifiers & CompilerModifiers.AccVisibilityMASK) { - case IConstants.AccPublic : - argument = CompilerOptions.PUBLIC; - break; - case IConstants.AccProtected: - if (visibility != IConstants.AccPublic) { - argument = CompilerOptions.PROTECTED; - } - break; -// case IConstants.AccDefault: -// if (visibility == IConstants.AccDefault || visibility == IConstants.AccPrivate) { -// argument = CompilerOptions.DEFAULT; -// } -// break; - case IConstants.AccPrivate: - if (visibility == IConstants.AccPrivate) { - argument = CompilerOptions.PRIVATE; - } - break; - } - return argument; -} + public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + public void javadocDeprecatedField(FieldBinding field, ASTNode location, int modifiers) { + if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + this.handle(IProblem.JavadocUsingDeprecatedField, 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 javadocDeprecatedMethod(MethodBinding method, ASTNode location, int modifiers) { + if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + if (method.isConstructor()) { + this.handle(IProblem.JavadocUsingDeprecatedConstructor, 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.JavadocUsingDeprecatedMethod, 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 javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers) { + if (location == null) + return; // 1G828DN - no type ref for synthetic arguments + if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + this.handle(IProblem.JavadocUsingDeprecatedType, new String[] { new String(type.readableName()) }, new String[] { new String( + type.shortReadableName()) }, location.sourceStart, location.sourceEnd); + } + } + + //public void javadocDuplicatedParamTag(JavadocSingleNameReference param, int modifiers) { + // if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + // String[] arguments = new String[] {String.valueOf(param.token)}; + // this.handle(IProblem.JavadocDuplicateParamName, arguments, arguments, param.sourceStart, param.sourceEnd); + // } + //} + public void javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers) { + if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + String[] arguments = new String[] { String.valueOf(typeReference.resolvedType.sourceName()) }; + this.handle(IProblem.JavadocDuplicateThrowsClassName, arguments, arguments, typeReference.sourceStart, + typeReference.sourceEnd); + } + } + + public void javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers) { + StringBuffer buffer = new StringBuffer(); + StringBuffer shortBuffer = new StringBuffer(); + for (int i = 0, length = params.length; i < length; i++) { + 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())); + } + + int id = recType.isArrayType() ? IProblem.JavadocNoMessageSendOnArrayType : IProblem.JavadocNoMessageSendOnBaseType; + if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + this.handle(id, 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 javadocInvalidConstructor(Statement statement, MethodBinding targetConstructor, int modifiers) { + + if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + return; + } + // boolean insideDefaultConstructor = + // (this.referenceContext instanceof ConstructorDeclaration) + // && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor(); + // boolean insideImplicitConstructorCall = + // (statement instanceof ExplicitConstructorCall) + // && (((ExplicitConstructorCall) statement).accessMode == ExplicitConstructorCall.ImplicitSuper); + + int id = IProblem.JavadocUndefinedConstructor; //default... + switch (targetConstructor.problemId()) { + case NotFound: + // if (insideDefaultConstructor){ + // id = IProblem.JavadocUndefinedConstructorInDefaultConstructor; + // } else if (insideImplicitConstructorCall){ + // id = IProblem.JavadocUndefinedConstructorInImplicitConstructorCall; + // } else { + id = IProblem.JavadocUndefinedConstructor; + // } + break; + case NotVisible: + // if (insideDefaultConstructor){ + // id = IProblem.JavadocNotVisibleConstructorInDefaultConstructor; + // } else if (insideImplicitConstructorCall){ + // id = IProblem.JavadocNotVisibleConstructorInImplicitConstructorCall; + // } else { + id = IProblem.JavadocNotVisibleConstructor; + // } + break; + case Ambiguous: + // if (insideDefaultConstructor){ + // id = IProblem.AmbiguousConstructorInDefaultConstructor; + // } else if (insideImplicitConstructorCall){ + // id = IProblem.AmbiguousConstructorInImplicitConstructorCall; + // } else { + id = IProblem.JavadocAmbiguousConstructor; + // } + break; + case NoError: // 0 + default: + needImplementation(); // want to fail to see why we were here... + break; + } + + this.handle(id, new String[] { + new String(targetConstructor.declaringClass.readableName()), + parametersAsString(targetConstructor) }, new String[] { + new String(targetConstructor.declaringClass.shortReadableName()), + parametersAsShortString(targetConstructor) }, statement.sourceStart, statement.sourceEnd); + } + + public void javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, Binding fieldBinding, int modifiers) { + int id = IProblem.JavadocAmbiguousMethodReference; + if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + String[] arguments = new String[] { new String(fieldBinding.readableName()) }; + handle(id, arguments, arguments, sourceStart, sourceEnd); + } + } + + /* + * Similar implementation than invalidField(FieldReference...) Note that following problem id cannot occur for Javadoc: - + * NonStaticReferenceInStaticContext : - NonStaticReferenceInConstructorInvocation : - ReceiverTypeNotVisible : + */ + public void javadocInvalidField(int sourceStart, int sourceEnd, Binding fieldBinding, TypeBinding searchedType, int modifiers) { + int id = IProblem.JavadocUndefinedField; + switch (fieldBinding.problemId()) { + case NotFound: + id = IProblem.JavadocUndefinedField; + break; + case NotVisible: + id = IProblem.JavadocNotVisibleField; + break; + case Ambiguous: + id = IProblem.JavadocAmbiguousField; + break; + case InheritedNameHidesEnclosingName: + id = IProblem.JavadocInheritedFieldHidesEnclosingName; + break; + case NoError: // 0 + default: + needImplementation(); // want to fail to see why we were here... + break; + } + + if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + String[] arguments = new String[] { new String(fieldBinding.readableName()) }; + handle(id, arguments, arguments, sourceStart, sourceEnd); + } + } + + /* + * Similar implementation than invalidMethod(MessageSend...) Note that following problem id cannot occur for Javadoc: - + * NonStaticReferenceInStaticContext : - NonStaticReferenceInConstructorInvocation : - ReceiverTypeNotVisible : + */ + public void javadocInvalidMethod(MessageSend messageSend, MethodBinding method, int modifiers) { + if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + return; + } + int id = IProblem.JavadocUndefinedMethod; //default... + switch (method.problemId()) { + case NotFound: + id = IProblem.JavadocUndefinedMethod; + break; + case NotVisible: + id = IProblem.JavadocNotVisibleMethod; + break; + case Ambiguous: + id = IProblem.JavadocAmbiguousMethod; + break; + case InheritedNameHidesEnclosingName: + id = IProblem.JavadocInheritedMethodHidesEnclosingName; + break; + case NoError: // 0 + default: + needImplementation(); // want to fail to see why we were here... + break; + } + + if (id == IProblem.JavadocUndefinedMethod) { + 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.JavadocParameterMismatch, new String[] { + new String(problemMethod.closestMatch.declaringClass.readableName()), + new String(problemMethod.closestMatch.selector), + 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; + } + } + + this.handle(id, 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 javadocInvalidParamName(JavadocSingleNameReference param, int modifiers) { + // if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + // String[] arguments = new String[] {String.valueOf(param.token)}; + // this.handle(IProblem.JavadocInvalidParamName, arguments, arguments, param.sourceStart, param.sourceEnd); + // } + //} + public void javadocInvalidSeeReference(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocInvalidSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + public void javadocInvalidSeeReferenceArgs(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocInvalidSeeArgs, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + public void javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocInvalidSeeHref, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + public void javadocInvalidTag(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocInvalidTag, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + public void javadocInvalidThrowsClass(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocInvalidThrowsClass, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + public void javadocInvalidThrowsClassName(TypeReference typeReference, int modifiers) { + if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + String[] arguments = new String[] { String.valueOf(typeReference.resolvedType.sourceName()) }; + this.handle(IProblem.JavadocInvalidThrowsClassName, arguments, arguments, typeReference.sourceStart, typeReference.sourceEnd); + } + } + + public void javadocInvalidType(ASTNode location, TypeBinding type, int modifiers) { + if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + int id = IProblem.JavadocUndefinedType; // default + switch (type.problemId()) { + case NotFound: + id = IProblem.JavadocUndefinedType; + break; + case NotVisible: + id = IProblem.JavadocNotVisibleType; + break; + case Ambiguous: + id = IProblem.JavadocAmbiguousType; + break; + case InternalNameProvided: + id = IProblem.JavadocInternalTypeNameProvided; + break; + case InheritedNameHidesEnclosingName: + id = IProblem.JavadocInheritedNameHidesEnclosingTypeName; + break; + case NoError: // 0 + default: + needImplementation(); // want to fail to see why we were here... + break; + } + this.handle(id, new String[] { new String(type.readableName()) }, new String[] { new String(type.shortReadableName()) }, + location.sourceStart, location.sourceEnd); + } + } + + public void javadocMalformedSeeReference(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocMalformedSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + public void javadocMissing(int sourceStart, int sourceEnd, int modifiers) { + boolean overriding = (modifiers & (CompilerModifiers.AccImplementing + CompilerModifiers.AccOverriding)) != 0; + boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocComments) != ProblemSeverities.Ignore) + && (!overriding || this.options.reportMissingJavadocCommentsOverriding); + if (report) { + String arg = javadocVisibilityArgument(this.options.reportMissingJavadocCommentsVisibility, modifiers); + if (arg != null) { + String[] arguments = new String[] { arg }; + this.handle(IProblem.JavadocMissing, arguments, arguments, sourceStart, sourceEnd); + } + } + } + + public void javadocMissingParamName(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocMissingParamName, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + public void javadocMissingParamTag(Argument param, int modifiers) { + boolean overriding = (modifiers & (CompilerModifiers.AccImplementing + CompilerModifiers.AccOverriding)) != 0; + boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore) + && (!overriding || this.options.reportMissingJavadocTagsOverriding); + if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) { + String[] arguments = new String[] { String.valueOf(param.name) }; + this.handle(IProblem.JavadocMissingParamTag, arguments, arguments, param.sourceStart, param.sourceEnd); + } + } + + public void javadocMissingReturnTag(int sourceStart, int sourceEnd, int modifiers) { + boolean overriding = (modifiers & (CompilerModifiers.AccImplementing + CompilerModifiers.AccOverriding)) != 0; + boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore) + && (!overriding || this.options.reportMissingJavadocTagsOverriding); + if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) { + this.handle(IProblem.JavadocMissingReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd); + } + } + + public void javadocMissingSeeReference(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocMissingSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + public void javadocMissingThrowsClassName(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocMissingThrowsClassName, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + public void javadocMissingThrowsTag(TypeReference typeRef, int modifiers) { + boolean overriding = (modifiers & (CompilerModifiers.AccImplementing + CompilerModifiers.AccOverriding)) != 0; + boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore) + && (!overriding || this.options.reportMissingJavadocTagsOverriding); + if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) { + String[] arguments = new String[] { String.valueOf(typeRef.resolvedType.sourceName()) }; + this.handle(IProblem.JavadocMissingThrowsTag, arguments, arguments, typeRef.sourceStart, typeRef.sourceEnd); + } + } + + public void javadocUnexpectedTag(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocUnexpectedTag, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + public void javadocUnterminatedInlineTag(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocUnterminatedInlineTag, NoArgument, NoArgument, sourceStart, sourceEnd); + } + + private boolean javadocVisibility(int visibility, int modifiers) { + switch (modifiers & CompilerModifiers.AccVisibilityMASK) { + case IConstants.AccPublic: + return true; + case IConstants.AccProtected: + return (visibility != IConstants.AccPublic); + // case IConstants.AccDefault: + // return (visibility == IConstants.AccDefault || visibility == IConstants.AccPrivate); + case IConstants.AccPrivate: + return (visibility == IConstants.AccPrivate); + } + return true; + } + + private String javadocVisibilityArgument(int visibility, int modifiers) { + String argument = null; + switch (modifiers & CompilerModifiers.AccVisibilityMASK) { + case IConstants.AccPublic: + argument = CompilerOptions.PUBLIC; + break; + case IConstants.AccProtected: + if (visibility != IConstants.AccPublic) { + argument = CompilerOptions.PROTECTED; + } + break; + // case IConstants.AccDefault: + // if (visibility == IConstants.AccDefault || visibility == IConstants.AccPrivate) { + // argument = CompilerOptions.DEFAULT; + // } + // break; + case IConstants.AccPrivate: + if (visibility == IConstants.AccPrivate) { + argument = CompilerOptions.PRIVATE; + } + break; + } + return argument; + } public void methodNeedingAbstractModifier(MethodDeclaration methodDecl) { this.handle(IProblem.MethodRequiresBody, NoArgument, NoArgument, methodDecl.sourceStart, methodDecl.sourceEnd); @@ -2041,10 +2074,13 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { } public void mustUseAStaticMethod(MessageSend messageSend, MethodBinding method) { - 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); + 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) { @@ -2057,27 +2093,34 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { } public void needToEmulateFieldReadAccess(FieldBinding field, ASTNode location) { - this.handle(IProblem.NeedToEmulateFieldReadAccess, new String[] { new String(field.declaringClass.readableName()), + 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); } public void needToEmulateFieldWriteAccess(FieldBinding field, ASTNode location) { - this.handle(IProblem.NeedToEmulateFieldWriteAccess, new String[] { new String(field.declaringClass.readableName()), + 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); } public void needToEmulateMethodAccess(MethodBinding method, ASTNode location) { if (method.isConstructor()) - this.handle(IProblem.NeedToEmulateConstructorAccess, new String[] { new String(method.declaringClass.readableName()), - parametersAsString(method) }, new String[] { new String(method.declaringClass.shortReadableName()), + this.handle(IProblem.NeedToEmulateConstructorAccess, 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.NeedToEmulateMethodAccess, 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.NeedToEmulateMethodAccess, 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 nestedClassCannotDeclareInterface(TypeDeclaration typeDecl) { @@ -2134,7 +2177,8 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { leftShortName = leftName; rightShortName = rightName; } - this.handle(IProblem.IncompatibleTypesInEqualityOperator, new String[] { leftName, rightName }, new String[] { leftShortName, + this.handle(IProblem.IncompatibleTypesInEqualityOperator, new String[] { leftName, rightName }, new String[] { + leftShortName, rightShortName }, expression.sourceStart, expression.sourceEnd); } @@ -2148,7 +2192,8 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { rightShortName = rightName; } this.handle(IProblem.IncompatibleTypesInConditionalOperator, new String[] { leftName, rightName }, new String[] { - leftShortName, rightShortName }, expression.sourceStart, expression.sourceEnd); + leftShortName, + rightShortName }, expression.sourceStart, expression.sourceEnd); } public void objectCannotHaveSuperTypes(SourceTypeBinding type) { @@ -2279,9 +2324,10 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { public void recursiveConstructorInvocation(ExplicitConstructorCall constructorCall) { 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); + 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) { @@ -2336,8 +2382,8 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { return; } 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); + new String(methodDecl.selector), + new String(expectedType.shortReadableName()) }, methodDecl.returnType.sourceStart, methodDecl.returnType.sourceEnd); } public void scannerError(Parser parser, String errorTokenName) { @@ -2434,10 +2480,11 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { // 8.4.6.4 - If a class inherits more than one method with the // same signature it is an error for one to be static // (non-abstract) and the other abstract. - IProblem.StaticInheritedMethodConflicts, new String[] { new String(concreteMethod.readableName()), + IProblem.StaticInheritedMethodConflicts, 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()); + new String(concreteMethod.readableName()), + new String(abstractMethods[0].declaringClass.shortReadableName()) }, type.sourceStart(), type.sourceEnd()); } public void stringConstantIsExceedingUtf8Limit(ASTNode location) { @@ -2447,12 +2494,13 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { public void superclassMustBeAClass(SourceTypeBinding type, TypeReference superclassRef, ReferenceBinding superType) { 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); + new String(superType.shortReadableName()), + new String(type.sourceName()) }, superclassRef.sourceStart, superclassRef.sourceEnd); } public void superinterfaceMustBeAnInterface(SourceTypeBinding type, TypeDeclaration typeDecl, ReferenceBinding superType) { - this.handle(IProblem.SuperInterfaceMustBeAnInterface, new String[] { new String(superType.readableName()), + 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); } @@ -2512,7 +2560,8 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { resultTypeShortName = resultTypeName; expectedTypeShortName = expectedTypeName; } - this.handle(IProblem.TypeMismatch, new String[] { resultTypeName, expectedTypeName }, new String[] { resultTypeShortName, + this.handle(IProblem.TypeMismatch, new String[] { resultTypeName, expectedTypeName }, new String[] { + resultTypeShortName, expectedTypeShortName }, location.sourceStart, location.sourceEnd); } @@ -2525,14 +2574,15 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { constantTypeShortName = constantTypeName; expectedTypeShortName = expectedTypeName; } - this.handle(IProblem.TypeMismatch, new String[] { constantTypeName, expectedTypeName }, new String[] { constantTypeShortName, + this.handle(IProblem.TypeMismatch, 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, arguments, arguments, statement.sourceStart, statement.sourceEnd); -// } + // public void undefinedLabel(BranchStatement statement) { + // String[] arguments = new String[] { new String(statement.label) }; + // this.handle(IProblem.UndefinedLabel, arguments, arguments, statement.sourceStart, statement.sourceEnd); + // } public void unexpectedStaticModifierForField(SourceTypeBinding type, FieldDeclaration fieldDecl) { String[] arguments = new String[] { fieldDecl.name() }; @@ -2560,11 +2610,6 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { this.handle(IProblem.UninitializedBlankFinalField, 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, arguments, arguments, location.sourceStart, location.sourceEnd); - } - public void unmatchedBracket(int position, ReferenceContext context, CompilationResult compilationResult) { this.handle(IProblem.UnmatchedBracket, NoArgument, NoArgument, position, position, context, compilationResult); } @@ -2575,22 +2620,22 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { } 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); + 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()), + 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, NoArgument, NoArgument, statement.sourceStart, statement.sourceEnd); - } - public void unreachableExceptionHandler(ReferenceBinding exceptionType, ASTNode location) { this.handle(IProblem.UnreachableCatch, NoArgument, NoArgument, location.sourceStart, location.sourceEnd); } @@ -2629,8 +2674,10 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { 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()), + 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); } @@ -2642,7 +2689,8 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { && TypeBinding.LongBinding == field.type) { return; // do not report unused serialVersionUID field } - this.handle(IProblem.UnusedPrivateField, new String[] { new String(field.declaringClass.readableName()), + 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); } @@ -2675,10 +2723,13 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { && 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); + 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) { @@ -2856,12 +2907,12 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { compilationResult); } - public void phpIncludeNotExistWarning(String[] messageArguments, int problemStartPosition, int problemEndPosition, ReferenceContext context, - CompilationResult compilationResult) { + public void phpIncludeNotExistWarning(String[] messageArguments, int problemStartPosition, int problemEndPosition, + ReferenceContext context, CompilationResult compilationResult) { if (computeSeverity(IProblem.PHPIncludeNotExistWarning) == Ignore) return; - this.handle(IProblem.PHPIncludeNotExistWarning, NoArgument, messageArguments, problemStartPosition, problemEndPosition, context, - compilationResult); + this.handle(IProblem.PHPIncludeNotExistWarning, NoArgument, messageArguments, problemStartPosition, problemEndPosition, + context, compilationResult); } public void phpKeywordWarning(String[] messageArguments, int problemStartPosition, int problemEndPosition, @@ -2879,4 +2930,23 @@ private String javadocVisibilityArgument(int visibility, int modifiers) { this.handle(IProblem.PHPBadStyleUppercaseIdentifierWarning, NoArgument, new String[] {}, problemStartPosition, problemEndPosition, context, compilationResult); } + + public void uninitializedLocalVariable(String token, int problemStartPosition, int problemEndPosition, ReferenceContext context, + CompilationResult compilationResult) { + if (computeSeverity(IProblem.UninitializedLocalVariable) == Ignore) + return; + // String[] arguments = new String[] { new String(binding.readableName()) }; + String[] arguments = new String[] { token }; + this.handle(IProblem.UninitializedLocalVariable, arguments, arguments, problemStartPosition, problemEndPosition, context, + compilationResult); + } + + public void unreachableCode(String token, int problemStartPosition, int problemEndPosition, ReferenceContext context, + CompilationResult compilationResult) { + if (computeSeverity(IProblem.CodeCannotBeReached) == Ignore) + return; + this.handle(IProblem.CodeCannotBeReached, NoArgument, new String[] {}, problemStartPosition, + problemEndPosition, context, compilationResult); + } + } \ No newline at end of file