diff options
author | ptff | 2003-12-13 21:25:48 +0000 |
---|---|---|
committer | ptff | 2003-12-13 21:25:48 +0000 |
commit | 3be4aa0b7d051355f329ce1003f3f4c0f7acfab2 (patch) | |
tree | 04d27521b9b608279adc665fcff232cacdef16fd /org.eclipse.jdt.core | |
parent | cdead094a9813fdba5ccda0ce2f9f48a99552dbc (diff) | |
download | eclipse.jdt.core-3be4aa0b7d051355f329ce1003f3f4c0f7acfab2.tar.gz eclipse.jdt.core-3be4aa0b7d051355f329ce1003f3f4c0f7acfab2.tar.xz eclipse.jdt.core-3be4aa0b7d051355f329ce1003f3f4c0f7acfab2.zip |
46854-46976-47319-47940
Diffstat (limited to 'org.eclipse.jdt.core')
26 files changed, 1147 insertions, 472 deletions
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java index fb42a77df6..298cd262d0 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java @@ -100,6 +100,8 @@ public class Main implements ProblemSeverities, SuffixConstants { /** * Lookup the message with the given ID in this catalog + * @param id + * @return */ public static String bind(String id) { return bind(id, (String[]) null); @@ -108,6 +110,9 @@ public class Main implements ProblemSeverities, SuffixConstants { /** * Lookup the message with the given ID in this catalog and bind its * substitution locations with the given string. + * @param id + * @param binding + * @return */ public static String bind(String id, String binding) { return bind(id, new String[] { binding }); @@ -116,6 +121,10 @@ public class Main implements ProblemSeverities, SuffixConstants { /** * Lookup the message with the given ID in this catalog and bind its * substitution locations with the given strings. + * @param id + * @param binding1 + * @param binding2 + * @return */ public static String bind(String id, String binding1, String binding2) { return bind(id, new String[] { binding1, binding2 }); @@ -124,6 +133,9 @@ public class Main implements ProblemSeverities, SuffixConstants { /** * Lookup the message with the given ID in this catalog and bind its * substitution locations with the given string values. + * @param id + * @param bindings + * @return */ public static String bind(String id, String[] bindings) { if (id == null) @@ -804,13 +816,37 @@ public class Main implements ProblemSeverities, SuffixConstants { this.options.put( CompilerOptions.OPTION_ReportInvalidJavadoc, isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE); + this.options.put( + CompilerOptions.OPTION_ReportInvalidJavadocTags, + isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED); + this.options.put( + CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, + isEnabling ? CompilerOptions.PRIVATE : CompilerOptions.PUBLIC); + this.options.put( + CompilerOptions.OPTION_ReportMissingJavadocTags, + isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE); + this.options.put( + CompilerOptions.OPTION_ReportMissingJavadocTagsVisibility, + isEnabling ? CompilerOptions.PRIVATE : CompilerOptions.PUBLIC); } else if (token.equals("allJavadoc")) { //$NON-NLS-1$ this.options.put( CompilerOptions.OPTION_ReportInvalidJavadoc, isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE); this.options.put( - CompilerOptions.OPTION_ReportMissingJavadoc, + CompilerOptions.OPTION_ReportInvalidJavadocTags, isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED); + this.options.put( + CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, + isEnabling ? CompilerOptions.PRIVATE : CompilerOptions.PUBLIC); + this.options.put( + CompilerOptions.OPTION_ReportMissingJavadocTags, + isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE); + this.options.put( + CompilerOptions.OPTION_ReportMissingJavadocTagsVisibility, + isEnabling ? CompilerOptions.PRIVATE : CompilerOptions.PUBLIC); + this.options.put( + CompilerOptions.OPTION_ReportMissingJavadocComments, + isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE); } else if (token.startsWith("tasks")) { //$NON-NLS-1$ String taskTags = ""; //$NON-NLS-1$ int start = token.indexOf('('); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java index 8c4941fc33..fffc3f1b98 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java @@ -154,7 +154,7 @@ public interface IProblem { * Set the start position of the problem (inclusive), or -1 if unknown. * Used for shifting problem positions. * - * @param the given start position + * @param sourceStart the given start position */ void setSourceStart(int sourceStart); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java index 83db0f5f33..3a92d7ca8f 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java @@ -102,7 +102,7 @@ public SourceElementParser( public void checkComment() { super.checkComment(); - if (reportReferenceInfo && this.javadoc != null) { + if (this.reportReferenceInfo && this.javadocParser.checkJavadoc && this.javadoc != null) { // Report reference info in javadoc comment @throws/@exception tags TypeReference[] thrownExceptions = this.javadoc.thrownExceptions; int throwsTagsNbre = thrownExceptions == null ? 0 : thrownExceptions.length; @@ -110,10 +110,10 @@ public void checkComment() { TypeReference typeRef = thrownExceptions[i]; if (typeRef instanceof JavadocSingleTypeReference) { JavadocSingleTypeReference singleRef = (JavadocSingleTypeReference) typeRef; - requestor.acceptTypeReference(singleRef.token, singleRef.sourceStart); + this.requestor.acceptTypeReference(singleRef.token, singleRef.sourceStart); } else if (typeRef instanceof JavadocQualifiedTypeReference) { JavadocQualifiedTypeReference qualifiedRef = (JavadocQualifiedTypeReference) typeRef; - requestor.acceptTypeReference(qualifiedRef.tokens, qualifiedRef.sourceStart, qualifiedRef.sourceEnd); + this.requestor.acceptTypeReference(qualifiedRef.tokens, qualifiedRef.sourceStart, qualifiedRef.sourceEnd); } } @@ -124,22 +124,22 @@ public void checkComment() { Expression reference = references[i]; if (reference instanceof JavadocSingleTypeReference) { JavadocSingleTypeReference singleRef = (JavadocSingleTypeReference) reference; - requestor.acceptTypeReference(singleRef.token, singleRef.sourceStart); + this.requestor.acceptTypeReference(singleRef.token, singleRef.sourceStart); } else if (reference instanceof JavadocQualifiedTypeReference) { JavadocQualifiedTypeReference qualifiedRef = (JavadocQualifiedTypeReference) reference; - requestor.acceptTypeReference(qualifiedRef.tokens, qualifiedRef.sourceStart, qualifiedRef.sourceEnd); + this.requestor.acceptTypeReference(qualifiedRef.tokens, qualifiedRef.sourceStart, qualifiedRef.sourceEnd); } else if (reference instanceof JavadocFieldReference) { JavadocFieldReference fieldRef = (JavadocFieldReference) reference; - requestor.acceptFieldReference(fieldRef.token, fieldRef.sourceStart); + this.requestor.acceptFieldReference(fieldRef.token, fieldRef.sourceStart); } else if (reference instanceof JavadocMessageSend) { JavadocMessageSend messageSend = (JavadocMessageSend) reference; int argCount = messageSend.arguments == null ? 0 : messageSend.arguments.length; - requestor.acceptMethodReference(messageSend.selector, argCount, messageSend.sourceStart); + this.requestor.acceptMethodReference(messageSend.selector, argCount, messageSend.sourceStart); } else if (reference instanceof JavadocAllocationExpression) { JavadocAllocationExpression constructor = (JavadocAllocationExpression) reference; int argCount = constructor.arguments == null ? 0 : constructor.arguments.length; char[][] compoundName = constructor.type.getTypeName(); - requestor.acceptConstructorReference(compoundName[compoundName.length-1], argCount, constructor.sourceStart); + this.requestor.acceptConstructorReference(compoundName[compoundName.length-1], argCount, constructor.sourceStart); } } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java index 84ae4d17bb..fcaa7553ad 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java @@ -76,14 +76,14 @@ public abstract class AbstractMethodDeclaration */ public void bindArguments() { - if (arguments != null) { + if (this.arguments != null) { // by default arguments in abstract/native methods are considered to be used (no complaint is expected) - boolean used = binding == null || binding.isAbstract() || binding.isNative(); + boolean used = this.binding == null || this.binding.isAbstract() || this.binding.isNative(); - int length = arguments.length; + int length = this.arguments.length; for (int i = 0; i < length; i++) { - TypeBinding argType = binding == null ? null : binding.parameters[i]; - arguments[i].bind(scope, argType, used); + TypeBinding argType = this.binding == null ? null : this.binding.parameters[i]; + this.arguments[i].bind(this.scope, argType, used); } } } @@ -135,21 +135,23 @@ public abstract class AbstractMethodDeclaration /** * Bytecode generation for a method + * @param classScope + * @param classFile */ public void generateCode(ClassScope classScope, ClassFile classFile) { int problemResetPC = 0; classFile.codeStream.wideMode = false; // reset wideMode to false - if (ignoreFurtherInvestigation) { + if (this.ignoreFurtherInvestigation) { // method is known to have errors, dump a problem method if (this.binding == null) return; // handle methods with invalid signature or duplicates int problemsLength; IProblem[] problems = - scope.referenceCompilationUnit().compilationResult.getProblems(); + this.scope.referenceCompilationUnit().compilationResult.getProblems(); IProblem[] problemsCopy = new IProblem[problemsLength = problems.length]; System.arraycopy(problems, 0, problemsCopy, 0, problemsLength); - classFile.addProblemMethod(this, binding, problemsCopy); + classFile.addProblemMethod(this, this.binding, problemsCopy); return; } // regular code generation @@ -169,53 +171,53 @@ public abstract class AbstractMethodDeclaration } catch (AbortMethod e2) { int problemsLength; IProblem[] problems = - scope.referenceCompilationUnit().compilationResult.getAllProblems(); + this.scope.referenceCompilationUnit().compilationResult.getAllProblems(); IProblem[] problemsCopy = new IProblem[problemsLength = problems.length]; System.arraycopy(problems, 0, problemsCopy, 0, problemsLength); - classFile.addProblemMethod(this, binding, problemsCopy, problemResetPC); + classFile.addProblemMethod(this, this.binding, problemsCopy, problemResetPC); } } else { // produce a problem method accounting for this fatal error int problemsLength; IProblem[] problems = - scope.referenceCompilationUnit().compilationResult.getAllProblems(); + this.scope.referenceCompilationUnit().compilationResult.getAllProblems(); IProblem[] problemsCopy = new IProblem[problemsLength = problems.length]; System.arraycopy(problems, 0, problemsCopy, 0, problemsLength); - classFile.addProblemMethod(this, binding, problemsCopy, problemResetPC); + classFile.addProblemMethod(this, this.binding, problemsCopy, problemResetPC); } } } private void generateCode(ClassFile classFile) { - classFile.generateMethodInfoHeader(binding); + classFile.generateMethodInfoHeader(this.binding); int methodAttributeOffset = classFile.contentsOffset; - int attributeNumber = classFile.generateMethodInfoAttribute(binding); - if ((!binding.isNative()) && (!binding.isAbstract())) { + int attributeNumber = classFile.generateMethodInfoAttribute(this.binding); + if ((!this.binding.isNative()) && (!this.binding.isAbstract())) { int codeAttributeOffset = classFile.contentsOffset; classFile.generateCodeAttributeHeader(); CodeStream codeStream = classFile.codeStream; codeStream.reset(this, classFile); // initialize local positions - this.scope.computeLocalVariablePositions(binding.isStatic() ? 0 : 1, codeStream); + this.scope.computeLocalVariablePositions(this.binding.isStatic() ? 0 : 1, codeStream); // arguments initialization for local variable debug attributes - if (arguments != null) { - for (int i = 0, max = arguments.length; i < max; i++) { + if (this.arguments != null) { + for (int i = 0, max = this.arguments.length; i < max; i++) { LocalVariableBinding argBinding; - codeStream.addVisibleLocalVariable(argBinding = arguments[i].binding); + codeStream.addVisibleLocalVariable(argBinding = this.arguments[i].binding); argBinding.recordInitializationStartPC(0); } } - if (statements != null) { - for (int i = 0, max = statements.length; i < max; i++) - statements[i].generateCode(scope, codeStream); + if (this.statements != null) { + for (int i = 0, max = this.statements.length; i < max; i++) + this.statements[i].generateCode(this.scope, codeStream); } if (this.needFreeReturn) { codeStream.return_(); } // local variable attributes - codeStream.exitUserScope(scope); + codeStream.exitUserScope(this.scope); codeStream.recordPositionsFrom(0, this.declarationSourceEnd); classFile.completeCodeAttribute(codeAttributeOffset); attributeNumber++; @@ -225,13 +227,13 @@ public abstract class AbstractMethodDeclaration classFile.completeMethodInfo(methodAttributeOffset, attributeNumber); // if a problem got reported during code gen, then trigger problem method creation - if (ignoreFurtherInvestigation) { - throw new AbortMethod(scope.referenceCompilationUnit().compilationResult); + if (this.ignoreFurtherInvestigation) { + throw new AbortMethod(this.scope.referenceCompilationUnit().compilationResult); } } private void checkArgumentsSize() { - TypeBinding[] parameters = binding.parameters; + TypeBinding[] parameters = this.binding.parameters; int size = 1; // an abstact method or a native method cannot be static for (int i = 0, max = parameters.length; i < max; i++) { TypeBinding parameter = parameters[i]; @@ -241,7 +243,7 @@ public abstract class AbstractMethodDeclaration size++; } if (size > 0xFF) { - scope.problemReporter().noMoreAvailableSpaceForArgument(scope.locals[i], scope.locals[i].declaration); + this.scope.problemReporter().noMoreAvailableSpaceForArgument(this.scope.locals[i], this.scope.locals[i].declaration); } } } @@ -252,9 +254,9 @@ public abstract class AbstractMethodDeclaration public boolean isAbstract() { - if (binding != null) - return binding.isAbstract(); - return (modifiers & AccAbstract) != 0; + if (this.binding != null) + return this.binding.isAbstract(); + return (this.modifiers & AccAbstract) != 0; } public boolean isClinit() { @@ -279,20 +281,22 @@ public abstract class AbstractMethodDeclaration public boolean isNative() { - if (binding != null) - return binding.isNative(); - return (modifiers & AccNative) != 0; + if (this.binding != null) + return this.binding.isNative(); + return (this.modifiers & AccNative) != 0; } public boolean isStatic() { - if (binding != null) - return binding.isStatic(); - return (modifiers & AccStatic) != 0; + if (this.binding != null) + return this.binding.isStatic(); + return (this.modifiers & AccStatic) != 0; } /** * Fill up the method body with statement + * @param parser + * @param unit */ public abstract void parseStatements( Parser parser, @@ -301,20 +305,20 @@ public abstract class AbstractMethodDeclaration public StringBuffer print(int tab, StringBuffer output) { printIndent(tab, output); - printModifiers(modifiers, output); - printReturnType(0, output).append(selector).append('('); - if (arguments != null) { - for (int i = 0; i < arguments.length; i++) { + printModifiers(this.modifiers, output); + printReturnType(0, output).append(this.selector).append('('); + if (this.arguments != null) { + for (int i = 0; i < this.arguments.length; i++) { if (i > 0) output.append(", "); //$NON-NLS-1$ - arguments[i].print(0, output); + this.arguments[i].print(0, output); } } output.append(')'); - if (thrownExceptions != null) { + if (this.thrownExceptions != null) { output.append(" throws "); //$NON-NLS-1$ - for (int i = 0; i < thrownExceptions.length; i++) { + for (int i = 0; i < this.thrownExceptions.length; i++) { if (i > 0) output.append(", "); //$NON-NLS-1$ - thrownExceptions[i].print(0, output); + this.thrownExceptions[i].print(0, output); } } printBody(tab + 1, output); @@ -327,10 +331,10 @@ public abstract class AbstractMethodDeclaration return output.append(';'); output.append(" {"); //$NON-NLS-1$ - if (statements != null) { - for (int i = 0; i < statements.length; i++) { + if (this.statements != null) { + for (int i = 0; i < this.statements.length; i++) { output.append('\n'); - statements[i].printStatement(indent, output); + this.statements[i].printStatement(indent, output); } } output.append('\n'); //$NON-NLS-1$ @@ -345,8 +349,8 @@ public abstract class AbstractMethodDeclaration public void resolve(ClassScope upperScope) { - if (binding == null) { - ignoreFurtherInvestigation = true; + if (this.binding == null) { + this.ignoreFurtherInvestigation = true; } try { @@ -366,27 +370,25 @@ public abstract class AbstractMethodDeclaration this.javadoc.resolve(this.scope); return; } - if (this.binding.isPublic()) { - if (this.binding.declaringClass != null && !this.binding.declaringClass.isLocalType()) { - this.scope.problemReporter().javadocMissing(this.sourceStart, this.sourceEnd); - } + if (this.binding.declaringClass != null && !this.binding.declaringClass.isLocalType()) { + this.scope.problemReporter().javadocMissing(this.sourceStart, this.sourceEnd, this.binding.modifiers); } } public void resolveStatements() { - if (statements != null) { - for (int i = 0, length = statements.length; i < length; i++) { - statements[i].resolve(scope); + if (this.statements != null) { + for (int i = 0, length = this.statements.length; i < length; i++) { + this.statements[i].resolve(this.scope); } } else if ((this.bits & UndocumentedEmptyBlockMASK) != 0) { - scope.problemReporter().undocumentedEmptyBlock(this.bodyStart-1, this.bodyEnd+1); + this.scope.problemReporter().undocumentedEmptyBlock(this.bodyStart-1, this.bodyEnd+1); } } public void tagAsHavingErrors() { - ignoreFurtherInvestigation = true; + this.ignoreFurtherInvestigation = true; } public void traverse( diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java index 1e4fafca1a..43d7dd075b 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java @@ -395,8 +395,8 @@ public class ConstructorDeclaration extends AbstractMethodDeclaration { if (this.binding == null || this.javadoc != null) { super.resolveJavadoc(); - } else if (!isDefaultConstructor && this.binding.isPublic()) { - this.scope.problemReporter().javadocMissing(this.sourceStart, this.sourceEnd); + } else if (!isDefaultConstructor) { + this.scope.problemReporter().javadocMissing(this.sourceStart, this.sourceEnd, this.binding.modifiers); } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java index eb9c01f85c..0210742fc8 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java @@ -61,24 +61,24 @@ public class FieldDeclaration extends AbstractVariableDeclaration { } } // cannot define static non-constant field inside nested class - if (binding != null - && binding.isValidBinding() - && binding.isStatic() - && binding.constant == NotAConstant - && binding.declaringClass.isNestedType() - && binding.declaringClass.isClass() - && !binding.declaringClass.isStatic()) { + if (this.binding != null + && this.binding.isValidBinding() + && this.binding.isStatic() + && this.binding.constant == NotAConstant + && this.binding.declaringClass.isNestedType() + && this.binding.declaringClass.isClass() + && !this.binding.declaringClass.isStatic()) { initializationScope.problemReporter().unexpectedStaticModifierForField( - (SourceTypeBinding) binding.declaringClass, + (SourceTypeBinding) this.binding.declaringClass, this); } - if (initialization != null) { + if (this.initialization != null) { flowInfo = - initialization + this.initialization .analyseCode(initializationScope, flowContext, flowInfo) .unconditionalInits(); - flowInfo.markAsDefinitelyAssigned(binding); + flowInfo.markAsDefinitelyAssigned(this.binding); } return flowInfo; } @@ -92,25 +92,25 @@ public class FieldDeclaration extends AbstractVariableDeclaration { */ public void generateCode(BlockScope currentScope, CodeStream codeStream) { - if ((bits & IsReachableMASK) == 0) { + if ((this.bits & IsReachableMASK) == 0) { return; } // do not generate initialization code if final and static (constant is then // recorded inside the field itself). int pc = codeStream.position; boolean isStatic; - if (initialization != null - && !((isStatic = binding.isStatic()) && binding.constant != NotAConstant)) { + if (this.initialization != null + && !((isStatic = this.binding.isStatic()) && this.binding.constant != NotAConstant)) { // non-static field, need receiver if (!isStatic) codeStream.aload_0(); // generate initialization value - initialization.generateCode(currentScope, codeStream, true); + this.initialization.generateCode(currentScope, codeStream, true); // store into field if (isStatic) { - codeStream.putstatic(binding); + codeStream.putstatic(this.binding); } else { - codeStream.putfield(binding); + codeStream.putfield(this.binding); } } codeStream.recordPositionsFrom(pc, this.sourceStart); @@ -118,7 +118,7 @@ public class FieldDeclaration extends AbstractVariableDeclaration { public TypeBinding getTypeBinding(Scope scope) { - return type.getTypeBinding(scope); + return this.type.getTypeBinding(scope); } public boolean isField() { @@ -128,9 +128,9 @@ public class FieldDeclaration extends AbstractVariableDeclaration { public boolean isStatic() { - if (binding != null) - return binding.isStatic(); - return (modifiers & AccStatic) != 0; + if (this.binding != null) + return this.binding.isStatic(); + return (this.modifiers & AccStatic) != 0; } public void resolve(MethodScope initializationScope) { @@ -140,7 +140,7 @@ public class FieldDeclaration extends AbstractVariableDeclaration { // existence is not at all the same. See comment for the second one. //-------------------------------------------------------- - if (!this.hasBeenResolved && binding != null && this.binding.isValidBinding()) { + if (!this.hasBeenResolved && this.binding != null && this.binding.isValidBinding()) { this.hasBeenResolved = true; @@ -150,7 +150,7 @@ public class FieldDeclaration extends AbstractVariableDeclaration { SourceTypeBinding declaringType = classScope.enclosingSourceType(); boolean checkLocal = true; if (declaringType.superclass != null) { - Binding existingVariable = classScope.findField(declaringType.superclass, name, this, true /*resolve*/); + Binding existingVariable = classScope.findField(declaringType.superclass, this.name, this, true /*resolve*/); if (existingVariable != null && existingVariable.isValidBinding()) { initializationScope.problemReporter().fieldHiding(this, existingVariable); checkLocal = false; // already found a matching field @@ -158,7 +158,7 @@ public class FieldDeclaration extends AbstractVariableDeclaration { } if (checkLocal) { Scope outerScope = classScope.parent; - Binding existingVariable = outerScope.getBinding(name, BindingIds.VARIABLE, this, false /*do not resolve hidden field*/); + Binding existingVariable = outerScope.getBinding(this.name, BindingIds.VARIABLE, this, false /*do not resolve hidden field*/); if (existingVariable != null && existingVariable.isValidBinding()){ initializationScope.problemReporter().fieldHiding(this, existingVariable); } @@ -184,13 +184,13 @@ public class FieldDeclaration extends AbstractVariableDeclaration { TypeBinding typeBinding = this.binding.type; TypeBinding initializationTypeBinding; - if (initialization instanceof ArrayInitializer) { + if (this.initialization instanceof ArrayInitializer) { if ((initializationTypeBinding = this.initialization.resolveTypeExpecting(initializationScope, typeBinding)) != null) { ((ArrayInitializer) this.initialization).binding = (ArrayBinding) initializationTypeBinding; this.initialization.implicitWidening(typeBinding, initializationTypeBinding); } - } else if ((initializationTypeBinding = initialization.resolveType(initializationScope)) != null) { + } else if ((initializationTypeBinding = this.initialization.resolveType(initializationScope)) != null) { if (this.initialization.isConstantValueOfTypeAssignableToType(initializationTypeBinding, typeBinding) || (typeBinding.isBaseType() && BaseTypeBinding.isWidening(typeBinding.id, initializationTypeBinding.id))) { @@ -214,11 +214,14 @@ public class FieldDeclaration extends AbstractVariableDeclaration { } // Resolve Javadoc comment if one is present if (this.javadoc != null) { + /* if (classScope != null) { this.javadoc.resolve(classScope); } - } else if ((this.binding != null) && this.binding.isPublic()) { - initializationScope.problemReporter().javadocMissing(this.sourceStart, this.sourceEnd); + */ + this.javadoc.resolve(initializationScope); + } else if (this.binding != null && this.binding.declaringClass != null && !this.binding.declaringClass.isLocalType()) { + initializationScope.problemReporter().javadocMissing(this.sourceStart, this.sourceEnd, this.binding.modifiers); } } finally { initializationScope.fieldDeclarationIndex = previous; @@ -231,9 +234,9 @@ public class FieldDeclaration extends AbstractVariableDeclaration { public void traverse(ASTVisitor visitor, MethodScope scope) { if (visitor.visit(this, scope)) { - type.traverse(visitor, scope); - if (initialization != null) - initialization.traverse(visitor, scope); + this.type.traverse(visitor, scope); + if (this.initialization != null) + this.initialization.traverse(visitor, scope); } visitor.endVisit(this, scope); } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java index 9b2254172e..ed85ccfc01 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java @@ -31,18 +31,18 @@ public class JavadocAllocationExpression extends AllocationExpression { private TypeBinding internalResolveType(Scope scope) { // Propagate the type checking to the arguments, and check if the constructor is defined. - constant = NotAConstant; + this.constant = NotAConstant; if (scope.kind == Scope.CLASS_SCOPE) { - this.resolvedType = type.resolveType((ClassScope)scope); + this.resolvedType = this.type.resolveType((ClassScope)scope); } else { - this.resolvedType = type.resolveType((BlockScope)scope); + this.resolvedType = this.type.resolveType((BlockScope)scope); } // buffering the arguments' types TypeBinding[] argumentTypes = NoParameters; - if (arguments != null) { + if (this.arguments != null) { boolean argHasError = false; - int length = arguments.length; + int length = this.arguments.length; argumentTypes = new TypeBinding[length]; for (int i = 0; i < length; i++) { Expression argument = this.arguments[i]; @@ -73,21 +73,15 @@ public class JavadocAllocationExpression extends AllocationExpression { if (methodBinding.isValidBinding()) { this.binding = methodBinding; } else { - if (binding.declaringClass == null) { - binding.declaringClass = allocationType; + if (this.binding.declaringClass == null) { + this.binding.declaringClass = allocationType; } - scope.problemReporter().invalidConstructor(this, binding); + scope.problemReporter().javadocInvalidConstructor(this, this.binding, scope.getModifiers()); } return this.resolvedType; } - if (isMethodUseDeprecated(binding, scope)) { - scope.problemReporter().deprecatedMethod(binding, this); - } - - if (arguments != null) { - for (int i = 0; i < arguments.length; i++) { - arguments[i].implicitWidening(binding.parameters[i], argumentTypes[i]); - } + if (isMethodUseDeprecated(this.binding, scope)) { + scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getModifiers()); } return allocationType; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArgumentExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArgumentExpression.java index c91eb9b174..5380cb75cb 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArgumentExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArgumentExpression.java @@ -34,7 +34,7 @@ public class JavadocArgumentExpression extends Expression { * Resolves type on a Block or Class scope. */ private TypeBinding internalResolveType(Scope scope) { - constant = NotAConstant; + this.constant = NotAConstant; if (this.resolvedType != null) { // is a shared type reference which was already resolved if (!this.resolvedType.isValidBinding()) { return null; // already reported error @@ -46,11 +46,11 @@ public class JavadocArgumentExpression extends Expression { if (typeRef != null) { this.resolvedType = typeRef.getTypeBinding(scope); if (!this.resolvedType.isValidBinding()) { - scope.problemReporter().invalidType(typeRef, this.resolvedType); + scope.problemReporter().javadocInvalidType(typeRef, this.resolvedType, scope.getModifiers()); return null; } if (isTypeUseDeprecated(this.resolvedType, scope)) { - scope.problemReporter().deprecatedType(this.resolvedType, typeRef); + scope.problemReporter().javadocDeprecatedType(this.resolvedType, typeRef, scope.getModifiers()); return null; } return this.resolvedType; @@ -61,20 +61,20 @@ public class JavadocArgumentExpression extends Expression { } public StringBuffer printExpression(int indent, StringBuffer output) { - if (argument == null) { - if (token != null) { - output.append(token); + if (this.argument == null) { + if (this.token != null) { + output.append(this.token); } } else { - argument.print(indent, output); + this.argument.print(indent, output); } return output; } public void resolve(BlockScope scope) { - if (argument != null) { - argument.resolve(scope); + if (this.argument != null) { + this.argument.resolve(scope); } } @@ -93,7 +93,7 @@ public class JavadocArgumentExpression extends Expression { public void traverse(ASTVisitor visitor, BlockScope blockScope) { if (visitor.visit(this, blockScope)) { if (this.argument != null) { - argument.traverse(visitor, blockScope); + this.argument.traverse(visitor, blockScope); } } visitor.endVisit(this, blockScope); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArrayQualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArrayQualifiedTypeReference.java index 83ab22341a..2952961b30 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArrayQualifiedTypeReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArrayQualifiedTypeReference.java @@ -12,6 +12,7 @@ package org.eclipse.jdt.internal.compiler.ast; import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; +import org.eclipse.jdt.internal.compiler.lookup.Scope; @@ -22,7 +23,14 @@ public class JavadocArrayQualifiedTypeReference extends ArrayQualifiedTypeRefere public JavadocArrayQualifiedTypeReference(JavadocQualifiedTypeReference typeRef, int dim) { super(typeRef.tokens, dim, typeRef.sourcePositions); } - + + protected void reportInvalidType(Scope scope) { + scope.problemReporter().javadocInvalidType(this, this.resolvedType, scope.getModifiers()); + } + protected void reportDeprecatedType(Scope scope) { + scope.problemReporter().javadocDeprecatedType(this.resolvedType, this, scope.getModifiers()); + } + /* (non-Javadoc) * Redefine to capture javadoc specific signatures * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope) diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArraySingleTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArraySingleTypeReference.java index 4a5002ab43..2464929503 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArraySingleTypeReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArraySingleTypeReference.java @@ -12,6 +12,7 @@ package org.eclipse.jdt.internal.compiler.ast; import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; +import org.eclipse.jdt.internal.compiler.lookup.Scope; public class JavadocArraySingleTypeReference extends ArrayTypeReference { @@ -20,7 +21,14 @@ public class JavadocArraySingleTypeReference extends ArrayTypeReference { super(name, dim, pos); this.bits |= InsideJavadoc; } - + + protected void reportInvalidType(Scope scope) { + scope.problemReporter().javadocInvalidType(this, this.resolvedType, scope.getModifiers()); + } + protected void reportDeprecatedType(Scope scope) { + scope.problemReporter().javadocDeprecatedType(this.resolvedType, this, scope.getModifiers()); + } + /* (non-Javadoc) * Redefine to capture javadoc specific signatures * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope) diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java index c1e71da6f7..7fb136968a 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java @@ -27,18 +27,11 @@ public class JavadocFieldReference extends FieldReference { */ private TypeBinding internalResolveType(Scope scope) { - constant = NotAConstant; - - if (this.receiver == null) { - SourceTypeBinding sourceTypeBinding = scope.enclosingSourceType(); - this.receiverType = sourceTypeBinding; - this.receiver = new JavadocQualifiedTypeReference(sourceTypeBinding.compoundName, new long[sourceTypeBinding.compoundName.length], 0, 0); + this.constant = NotAConstant; + if (scope.kind == Scope.CLASS_SCOPE) { + this.receiverType = this.receiver.resolveType((ClassScope) scope); } else { - if (scope.kind == Scope.CLASS_SCOPE) { - this.receiverType = receiver.resolveType((ClassScope)scope); - } else { - this.receiverType = receiver.resolveType((BlockScope)scope); - } + this.receiverType = this.receiver.resolveType((BlockScope)scope); } if (this.receiverType == null) { return null; @@ -46,15 +39,14 @@ public class JavadocFieldReference extends FieldReference { this.binding = scope.getField(this.receiverType, this.token, this); if (!this.binding.isValidBinding()) { - constant = NotAConstant; - scope.problemReporter().invalidField(this, this.receiverType); + scope.problemReporter().javadocInvalidField(this, this.receiverType, scope.getModifiers()); return null; } - if (isFieldUseDeprecated(binding, scope, (this.bits & IsStrictlyAssignedMASK) != 0)) { - scope.problemReporter().deprecatedField(this.binding, this); + if (isFieldUseDeprecated(this.binding, scope, (this.bits & IsStrictlyAssignedMASK) != 0)) { + scope.problemReporter().javadocDeprecatedField(this.binding, this, scope.getModifiers()); } - return this.resolvedType = binding.type; + return this.resolvedType = this.binding.type; } /* (non-Javadoc) @@ -66,10 +58,10 @@ public class JavadocFieldReference extends FieldReference { public StringBuffer printExpression(int indent, StringBuffer output) { - if (receiver != null) { - receiver.printExpression(0, output); + if (this.receiver != null) { + this.receiver.printExpression(0, output); } - output.append('#').append(token); + output.append('#').append(this.token); return output; } @@ -94,8 +86,8 @@ public class JavadocFieldReference extends FieldReference { public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { - if (receiver != null) { - receiver.traverse(visitor, scope); + if (this.receiver != null) { + this.receiver.traverse(visitor, scope); } } visitor.endVisit(this, scope); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java index aaffa9159e..41bd6a310f 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java @@ -22,8 +22,8 @@ public class JavadocMessageSend extends MessageSend { public JavadocMessageSend(char[] name, long pos) { this.selector = name; this.nameSourcePosition = pos; - this.sourceStart = (int) (nameSourcePosition >>> 32); - this.sourceEnd = (int) nameSourcePosition; + this.sourceStart = (int) (this.nameSourcePosition >>> 32); + this.sourceEnd = (int) this.nameSourcePosition; this.bits |= InsideJavadoc; } public JavadocMessageSend(char[] name, long pos, JavadocArgumentExpression[] arguments) { @@ -37,22 +37,21 @@ public class JavadocMessageSend extends MessageSend { private TypeBinding internalResolveType(Scope scope) { // Answer the signature return type // Base type promotion - constant = NotAConstant; - if (this.receiver instanceof CastExpression) this.receiver.bits |= IgnoreNeedForCastCheckMASK; // will check later on + this.constant = NotAConstant; if (scope.kind == Scope.CLASS_SCOPE) { - this.receiverType = receiver.resolveType((ClassScope)scope); + this.receiverType = this.receiver.resolveType((ClassScope) scope); } else { - this.receiverType = receiver.resolveType((BlockScope)scope); + this.receiverType = this.receiver.resolveType((BlockScope) scope); } // will check for null after args are resolved TypeBinding[] argumentTypes = NoParameters; - if (arguments != null) { + if (this.arguments != null) { boolean argHasError = false; // typeChecks all arguments - int length = arguments.length; + int length = this.arguments.length; argumentTypes = new TypeBinding[length]; for (int i = 0; i < length; i++){ - Expression argument = arguments[i]; + Expression argument = this.arguments[i]; if (scope.kind == Scope.CLASS_SCOPE) { argumentTypes[i] = argument.resolveType((ClassScope)scope); } else { @@ -63,10 +62,6 @@ public class JavadocMessageSend extends MessageSend { } } if (argHasError) { - if(receiverType instanceof ReferenceBinding) { - // record any selector match, for clients who may still need hint about possible method match - this.codegenBinding = this.binding = scope.findMethod((ReferenceBinding)receiverType, selector, new TypeBinding[]{}, this); - } return null; } } @@ -80,37 +75,32 @@ public class JavadocMessageSend extends MessageSend { // base type cannot receive any message if (this.receiverType.isBaseType()) { - scope.problemReporter().errorNoMethodFor(this, this.receiverType, argumentTypes); + scope.problemReporter().javadocErrorNoMethodFor(this, this.receiverType, argumentTypes, scope.getModifiers()); return null; } - this.codegenBinding = this.binding = scope.getMethod(this.receiverType, selector, argumentTypes, this); - if (!binding.isValidBinding()) { - if (binding.declaringClass == null) { + this.codegenBinding = this.binding = scope.getMethod(this.receiverType, this.selector, argumentTypes, this); + if (!this.binding.isValidBinding()) { + if (this.binding.declaringClass == null) { if (this.receiverType instanceof ReferenceBinding) { - binding.declaringClass = (ReferenceBinding) this.receiverType; + this.binding.declaringClass = (ReferenceBinding) this.receiverType; } else { - scope.problemReporter().errorNoMethodFor(this, this.receiverType, argumentTypes); + scope.problemReporter().javadocErrorNoMethodFor(this, this.receiverType, argumentTypes, scope.getModifiers()); return null; } } - scope.problemReporter().invalidMethod(this, binding); + scope.problemReporter().javadocInvalidMethod(this, this.binding, scope.getModifiers()); // record the closest match, for clients who may still need hint about possible method match - if (binding instanceof ProblemMethodBinding){ - MethodBinding closestMatch = ((ProblemMethodBinding)binding).closestMatch; + if (this.binding instanceof ProblemMethodBinding){ + MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch; if (closestMatch != null) this.codegenBinding = this.binding = closestMatch; } - return this.resolvedType = binding == null ? null : binding.returnType; + return this.resolvedType = this.binding == null ? null : this.binding.returnType; } - if (arguments != null) { - for (int i = 0; i < arguments.length; i++) { - arguments[i].implicitWidening(binding.parameters[i], argumentTypes[i]); - } - } - if (isMethodUseDeprecated(binding, scope)) { - scope.problemReporter().deprecatedMethod(binding, this); + if (isMethodUseDeprecated(this.binding, scope)) { + scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getModifiers()); } - return this.resolvedType = binding.returnType; + return this.resolvedType = this.binding.returnType; } /* (non-Javadoc) @@ -122,14 +112,14 @@ public class JavadocMessageSend extends MessageSend { public StringBuffer printExpression(int indent, StringBuffer output){ - if (receiver != null) { - receiver.printExpression(0, output); + if (this.receiver != null) { + this.receiver.printExpression(0, output); } - output.append('#').append(selector).append('('); - if (arguments != null) { - for (int i = 0; i < arguments.length ; i ++) { + output.append('#').append(this.selector).append('('); + if (this.arguments != null) { + for (int i = 0; i < this.arguments.length ; i ++) { if (i > 0) output.append(", "); //$NON-NLS-1$ - arguments[i].printExpression(0, output); + this.arguments[i].printExpression(0, output); } } return output.append(')'); @@ -149,13 +139,13 @@ public class JavadocMessageSend extends MessageSend { */ public void traverse(ASTVisitor visitor, BlockScope blockScope) { if (visitor.visit(this, blockScope)) { - if (receiver != null) { - receiver.traverse(visitor, blockScope); + if (this.receiver != null) { + this.receiver.traverse(visitor, blockScope); } - if (arguments != null) { - int argumentsLength = arguments.length; + if (this.arguments != null) { + int argumentsLength = this.arguments.length; for (int i = 0; i < argumentsLength; i++) - arguments[i].traverse(visitor, blockScope); + this.arguments[i].traverse(visitor, blockScope); } } visitor.endVisit(this, blockScope); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java index 9d17ecf988..02bd8e8c1c 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java @@ -12,6 +12,7 @@ package org.eclipse.jdt.internal.compiler.ast; import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; +import org.eclipse.jdt.internal.compiler.lookup.Scope; @@ -25,7 +26,14 @@ public class JavadocQualifiedTypeReference extends QualifiedTypeReference { this.tagSourceEnd = tagEnd; this.bits |= InsideJavadoc; } - + + protected void reportInvalidType(Scope scope) { + scope.problemReporter().javadocInvalidType(this, this.resolvedType, scope.getModifiers()); + } + protected void reportDeprecatedType(Scope scope) { + scope.problemReporter().javadocDeprecatedType(this.resolvedType, this, scope.getModifiers()); + } + /* (non-Javadoc) * Redefine to capture javadoc specific signatures * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope) diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocReturnStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocReturnStatement.java index e799ee59ab..a10c7a223f 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocReturnStatement.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocReturnStatement.java @@ -32,7 +32,7 @@ public class JavadocReturnStatement extends ReturnStatement { ? null : methodBinding.returnType) : VoidBinding; - if (methodType == VoidBinding) { + if (methodType == null || methodType == VoidBinding) { scope.problemReporter().javadocUnexpectedTag(this.sourceStart, this.sourceEnd); } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleNameReference.java index 4c4c4b0257..56566aa99e 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleNameReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleNameReference.java @@ -24,12 +24,18 @@ public class JavadocSingleNameReference extends SingleNameReference { public void resolve(BlockScope scope) { - LocalVariableBinding variableBinding = scope.findVariable(token); + LocalVariableBinding variableBinding = scope.findVariable(this.token); if (variableBinding != null && variableBinding.isValidBinding() && variableBinding.isArgument) { this.binding = variableBinding; return; } - scope.problemReporter().javadocInvalidParamName(this, false); + try { + MethodScope methScope = (MethodScope) scope; + scope.problemReporter().javadocInvalidParamName(this, methScope.referenceMethod().modifiers); + } + catch (Exception e) { + scope.problemReporter().javadocInvalidParamName(this, -1); + } } /* (non-Javadoc) diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java index 22063c2a71..b77f634c66 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java @@ -12,6 +12,7 @@ package org.eclipse.jdt.internal.compiler.ast; import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; +import org.eclipse.jdt.internal.compiler.lookup.Scope; public class JavadocSingleTypeReference extends SingleTypeReference { @@ -25,6 +26,13 @@ public class JavadocSingleTypeReference extends SingleTypeReference { this.bits |= InsideJavadoc; } + protected void reportInvalidType(Scope scope) { + scope.problemReporter().javadocInvalidType(this, this.resolvedType, scope.getModifiers()); + } + protected void reportDeprecatedType(Scope scope) { + scope.problemReporter().javadocDeprecatedType(this.resolvedType, this, scope.getModifiers()); + } + /* (non-Javadoc) * Redefine to capture javadoc specific signatures * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope) diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java index cc89d1733a..544ecda1d8 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java @@ -110,7 +110,7 @@ public class TypeDeclaration } } - /** + /* * INTERNAL USE ONLY - Creates a fake method declaration for the corresponding binding. * It is used to report errors for missing abstract methods. */ @@ -871,8 +871,8 @@ public class TypeDeclaration public void resolve() { - if (binding == null) { - ignoreFurtherInvestigation = true; + if (this.binding == null) { + this.ignoreFurtherInvestigation = true; return; } try { @@ -880,50 +880,50 @@ public class TypeDeclaration this.scope.problemReporter().undocumentedEmptyBlock(this.bodyStart-1, this.bodyEnd+1); } // check superclass & interfaces - if (binding.superclass != null) // watch out for Object ! (and other roots) - if (isTypeUseDeprecated(binding.superclass, scope)) - scope.problemReporter().deprecatedType(binding.superclass, superclass); - if (superInterfaces != null) - for (int i = superInterfaces.length; --i >= 0;) - if (superInterfaces[i].resolvedType != null) - if (isTypeUseDeprecated(superInterfaces[i].resolvedType, scope)) - scope.problemReporter().deprecatedType( - superInterfaces[i].resolvedType, - superInterfaces[i]); - maxFieldCount = 0; + if (this.binding.superclass != null) // watch out for Object ! (and other roots) + if (isTypeUseDeprecated(this.binding.superclass, this.scope)) + this.scope.problemReporter().deprecatedType(this.binding.superclass, this.superclass); + if (this.superInterfaces != null) + for (int i = this.superInterfaces.length; --i >= 0;) + if (this.superInterfaces[i].resolvedType != null) + if (isTypeUseDeprecated(this.superInterfaces[i].resolvedType, this.scope)) + this.scope.problemReporter().deprecatedType( + this.superInterfaces[i].resolvedType, + this.superInterfaces[i]); + this.maxFieldCount = 0; int lastFieldID = -1; - if (fields != null) { - for (int i = 0, count = fields.length; i < count; i++) { - FieldDeclaration field = fields[i]; + if (this.fields != null) { + for (int i = 0, count = this.fields.length; i < count; i++) { + FieldDeclaration field = this.fields[i]; if (field.isField()) { if (field.binding == null) { // still discover secondary errors - if (field.initialization != null) field.initialization.resolve(field.isStatic() ? staticInitializerScope : initializerScope); - ignoreFurtherInvestigation = true; + if (field.initialization != null) field.initialization.resolve(field.isStatic() ? this.staticInitializerScope : this.initializerScope); + this.ignoreFurtherInvestigation = true; continue; } - maxFieldCount++; + this.maxFieldCount++; lastFieldID = field.binding.id; } else { // initializer ((Initializer) field).lastFieldID = lastFieldID + 1; } - field.resolve(field.isStatic() ? staticInitializerScope : initializerScope); + field.resolve(field.isStatic() ? this.staticInitializerScope : this.initializerScope); } } - if (memberTypes != null) { - for (int i = 0, count = memberTypes.length; i < count; i++) { - memberTypes[i].resolve(scope); + if (this.memberTypes != null) { + for (int i = 0, count = this.memberTypes.length; i < count; i++) { + this.memberTypes[i].resolve(this.scope); } } int missingAbstractMethodslength = this.missingAbstractMethods == null ? 0 : this.missingAbstractMethods.length; - int methodsLength = this.methods == null ? 0 : methods.length; + int methodsLength = this.methods == null ? 0 : this.methods.length; if ((methodsLength + missingAbstractMethodslength) > 0xFFFF) { - scope.problemReporter().tooManyMethods(this); + this.scope.problemReporter().tooManyMethods(this); } - if (methods != null) { - for (int i = 0, count = methods.length; i < count; i++) { - methods[i].resolve(scope); + if (this.methods != null) { + for (int i = 0, count = this.methods.length; i < count; i++) { + this.methods[i].resolve(this.scope); } } // Resolve javadoc @@ -931,8 +931,8 @@ public class TypeDeclaration if (this.scope != null) { this.javadoc.resolve(this.scope); } - } else if ((this.binding != null) && this.binding.isPublic()) { - this.scope.problemReporter().javadocMissing(this.sourceStart, this.sourceEnd); + } else if (this.binding != null && !this.binding.isLocalType()) { + this.scope.problemReporter().javadocMissing(this.sourceStart, this.sourceEnd, this.binding.modifiers); } } catch (AbortType e) { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java index 79fbef573f..3e27b185d8 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java @@ -91,37 +91,46 @@ public boolean isTypeReference() { } public TypeBinding resolveType(BlockScope blockScope) { // handle the error here - constant = NotAConstant; + this.constant = NotAConstant; if (this.resolvedType != null) { // is a shared type reference which was already resolved if (!this.resolvedType.isValidBinding()) return null; // already reported error } else { this.resolvedType = getTypeBinding(blockScope); if (!this.resolvedType.isValidBinding()) { - blockScope.problemReporter().invalidType(this, this.resolvedType); + reportInvalidType(blockScope); return null; } - if (isTypeUseDeprecated(this.resolvedType, blockScope)) - blockScope.problemReporter().deprecatedType(this.resolvedType, this); + if (isTypeUseDeprecated(this.resolvedType, blockScope)) { + reportDeprecatedType(blockScope); + } } return this.resolvedType; } + public TypeBinding resolveType(ClassScope classScope) { // handle the error here - constant = NotAConstant; + this.constant = NotAConstant; if (this.resolvedType != null) { // is a shared type reference which was already resolved if (!this.resolvedType.isValidBinding()) return null; // already reported error } else { this.resolvedType = getTypeBinding(classScope); if (!this.resolvedType.isValidBinding()) { - classScope.problemReporter().invalidType(this, this.resolvedType); + reportInvalidType(classScope); return null; } - if (isTypeUseDeprecated(this.resolvedType, classScope)) - classScope.problemReporter().deprecatedType(this.resolvedType, this); + if (isTypeUseDeprecated(this.resolvedType, classScope)) { + reportDeprecatedType(classScope); + } } return this.resolvedType; } +protected void reportInvalidType(Scope scope) { + scope.problemReporter().invalidType(this, this.resolvedType); +} +protected void reportDeprecatedType(Scope scope) { + scope.problemReporter().deprecatedType(this.resolvedType, this); +} public abstract void traverse(ASTVisitor visitor, ClassScope classScope); } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java index 33effcd435..108e531915 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java @@ -58,7 +58,14 @@ public class CompilerOptions implements ProblemReasons, ProblemSeverities, Class public static final String OPTION_ReportUnnecessaryTypeCheck = "org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck"; //$NON-NLS-1$ public static final String OPTION_ReportUndocumentedEmptyBlock = "org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock"; //$NON-NLS-1$ public static final String OPTION_ReportInvalidJavadoc = "org.eclipse.jdt.core.compiler.problem.invalidJavadoc"; //$NON-NLS-1$ - public static final String OPTION_ReportMissingJavadoc = "org.eclipse.jdt.core.compiler.problem.missingJavadoc"; //$NON-NLS-1$ + public static final String OPTION_ReportInvalidJavadocTags = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTags"; //$NON-NLS-1$ + public static final String OPTION_ReportInvalidJavadocTagsVisibility = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility"; //$NON-NLS-1$ + public static final String OPTION_ReportMissingJavadocTags = "org.eclipse.jdt.core.compiler.problem.missingJavadocTags"; //$NON-NLS-1$ + public static final String OPTION_ReportMissingJavadocTagsVisibility = "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility"; //$NON-NLS-1$ + public static final String OPTION_ReportMissingJavadocTagsOverriding = "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding"; //$NON-NLS-1$ + public static final String OPTION_ReportMissingJavadocComments = "org.eclipse.jdt.core.compiler.problem.missingJavadocComments"; //$NON-NLS-1$ + public static final String OPTION_ReportMissingJavadocCommentsVisibility = "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility"; //$NON-NLS-1$ + public static final String OPTION_ReportMissingJavadocCommentsOverriding = "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding"; //$NON-NLS-1$ public static final String OPTION_ReportFinallyBlockNotCompletingNormally = "org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally"; //$NON-NLS-1$ public static final String OPTION_ReportUnusedDeclaredThrownException = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException"; //$NON-NLS-1$ public static final String OPTION_ReportUnqualifiedFieldAccess = "org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess"; //$NON-NLS-1$ @@ -90,6 +97,10 @@ public class CompilerOptions implements ProblemReasons, ProblemSeverities, Class public static final String IGNORE = "ignore"; //$NON-NLS-1$ public static final String ENABLED = "enabled"; //$NON-NLS-1$ public static final String DISABLED = "disabled"; //$NON-NLS-1$ + public static final String PUBLIC = "public"; //$NON-NLS-1$ + public static final String PROTECTED = "protected"; //$NON-NLS-1$ + public static final String DEFAULT = "default"; //$NON-NLS-1$ + public static final String PRIVATE = "private"; //$NON-NLS-1$ /** * Bit mask for configurable problems (error/warning threshold) @@ -125,7 +136,9 @@ public class CompilerOptions implements ProblemReasons, ProblemSeverities, Class public static final long FinallyBlockNotCompleting = 0x1000000000L; public static final long UnusedDeclaredThrownException = 0x2000000000L; public static final long UnqualifiedFieldAccess = 0x4000000000L; - + public static final long MissingJavadocTags = 0x8000000000L; + public static final long MissingJavadocComments = 0x10000000000L; + // Default severity level for handlers public long errorThreshold = 0; @@ -190,9 +203,22 @@ public class CompilerOptions implements ProblemReasons, ProblemSeverities, Class // constructor/setter parameter hiding public boolean reportSpecialParameterHidingField = false; - + // check javadoc comments - public boolean reportMissingJavadoc = false; + public int reportInvalidJavadocTagsVisibility = AccPrivate; + public boolean reportInvalidJavadocTags = true; + + // check missing javadoc tags + public int reportMissingJavadocTagsVisibility = AccPrivate; + // TODO (frederic) see with jdt-ui whether we use ignore instead of report + //public boolean reportMissingJavadocTagsOverriding = true; + public boolean reportMissingJavadocTagsOverriding = false; + + // check missing javadoc comments + public int reportMissingJavadocCommentsVisibility = AccPublic; + // TODO (frederic) see with jdt-ui whether we use ignore instead of report + //public boolean reportMissingJavadocCommentsOverriding = true; + public boolean reportMissingJavadocCommentsOverriding = false; /** * Initializing the compiler options with defaults @@ -213,14 +239,14 @@ public class CompilerOptions implements ProblemReasons, ProblemSeverities, Class public Map getMap() { Map optionsMap = new HashMap(30); - optionsMap.put(OPTION_LocalVariableAttribute, (produceDebugAttributes & Vars) != 0 ? GENERATE : DO_NOT_GENERATE); - optionsMap.put(OPTION_LineNumberAttribute, (produceDebugAttributes & Lines) != 0 ? GENERATE : DO_NOT_GENERATE); - optionsMap.put(OPTION_SourceFileAttribute, (produceDebugAttributes & Source) != 0 ? GENERATE : DO_NOT_GENERATE); - optionsMap.put(OPTION_PreserveUnusedLocal, preserveAllLocalVariables ? PRESERVE : OPTIMIZE_OUT); + optionsMap.put(OPTION_LocalVariableAttribute, (this.produceDebugAttributes & Vars) != 0 ? GENERATE : DO_NOT_GENERATE); + optionsMap.put(OPTION_LineNumberAttribute, (this.produceDebugAttributes & Lines) != 0 ? GENERATE : DO_NOT_GENERATE); + optionsMap.put(OPTION_SourceFileAttribute, (this.produceDebugAttributes & Source) != 0 ? GENERATE : DO_NOT_GENERATE); + optionsMap.put(OPTION_PreserveUnusedLocal, this.preserveAllLocalVariables ? PRESERVE : OPTIMIZE_OUT); optionsMap.put(OPTION_ReportMethodWithConstructorName, getSeverityString(MethodWithConstructorName)); optionsMap.put(OPTION_ReportOverridingPackageDefaultMethod, getSeverityString(OverriddenPackageDefaultMethod)); optionsMap.put(OPTION_ReportDeprecation, getSeverityString(UsingDeprecatedAPI)); - optionsMap.put(OPTION_ReportDeprecationInDeprecatedCode, reportDeprecationInsideDeprecatedCode ? ENABLED : DISABLED); + optionsMap.put(OPTION_ReportDeprecationInDeprecatedCode, this.reportDeprecationInsideDeprecatedCode ? ENABLED : DISABLED); optionsMap.put(OPTION_ReportHiddenCatchBlock, getSeverityString(MaskedCatchBlock)); optionsMap.put(OPTION_ReportUnusedLocal, getSeverityString(UnusedLocalVariable)); optionsMap.put(OPTION_ReportUnusedParameter, getSeverityString(UnusedArgument)); @@ -241,42 +267,62 @@ public class CompilerOptions implements ProblemReasons, ProblemSeverities, Class optionsMap.put(OPTION_ReportUndocumentedEmptyBlock, getSeverityString(UndocumentedEmptyBlock)); optionsMap.put(OPTION_ReportUnnecessaryTypeCheck, getSeverityString(UnnecessaryTypeCheck)); optionsMap.put(OPTION_ReportInvalidJavadoc, getSeverityString(InvalidJavadoc)); - optionsMap.put(OPTION_ReportMissingJavadoc, reportMissingJavadoc ? ENABLED : DISABLED); + optionsMap.put(OPTION_ReportInvalidJavadocTagsVisibility, getVisibilityString(this.reportInvalidJavadocTagsVisibility)); + optionsMap.put(OPTION_ReportInvalidJavadocTags, this.reportInvalidJavadocTags? ENABLED : DISABLED); + optionsMap.put(OPTION_ReportMissingJavadocTags, getSeverityString(MissingJavadocTags)); + optionsMap.put(OPTION_ReportMissingJavadocTagsVisibility, getVisibilityString(this.reportMissingJavadocTagsVisibility)); + optionsMap.put(OPTION_ReportMissingJavadocTagsOverriding, this.reportMissingJavadocTagsOverriding ? ENABLED : DISABLED); + optionsMap.put(OPTION_ReportMissingJavadocComments, getSeverityString(MissingJavadocComments)); + optionsMap.put(OPTION_ReportMissingJavadocCommentsVisibility, getVisibilityString(this.reportMissingJavadocCommentsVisibility)); + optionsMap.put(OPTION_ReportMissingJavadocCommentsOverriding, this.reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED); optionsMap.put(OPTION_ReportFinallyBlockNotCompletingNormally, getSeverityString(FinallyBlockNotCompleting)); optionsMap.put(OPTION_ReportUnusedDeclaredThrownException, getSeverityString(UnusedDeclaredThrownException)); optionsMap.put(OPTION_ReportUnqualifiedFieldAccess, getSeverityString(UnqualifiedFieldAccess)); - optionsMap.put(OPTION_Compliance, versionFromJdkLevel(complianceLevel)); - optionsMap.put(OPTION_Source, versionFromJdkLevel(sourceLevel)); - optionsMap.put(OPTION_TargetPlatform, versionFromJdkLevel(targetJDK)); - if (defaultEncoding != null) { - optionsMap.put(OPTION_Encoding, defaultEncoding); + optionsMap.put(OPTION_Compliance, versionFromJdkLevel(this.complianceLevel)); + optionsMap.put(OPTION_Source, versionFromJdkLevel(this.sourceLevel)); + optionsMap.put(OPTION_TargetPlatform, versionFromJdkLevel(this.targetJDK)); + if (this.defaultEncoding != null) { + optionsMap.put(OPTION_Encoding, this.defaultEncoding); } optionsMap.put(OPTION_TaskTags, this.taskTags == null ? "" : new String(CharOperation.concatWith(this.taskTags,','))); //$NON-NLS-1$ optionsMap.put(OPTION_TaskPriorities, this.taskPriorites == null ? "" : new String(CharOperation.concatWith(this.taskPriorites,','))); //$NON-NLS-1$ - optionsMap.put(OPTION_ReportUnusedParameterWhenImplementingAbstract, reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED); - optionsMap.put(OPTION_ReportUnusedParameterWhenOverridingConcrete, reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED); - optionsMap.put(OPTION_ReportSpecialParameterHidingField, reportSpecialParameterHidingField ? ENABLED : DISABLED); - optionsMap.put(OPTION_MaxProblemPerUnit, String.valueOf(maxProblemsPerUnit)); + optionsMap.put(OPTION_ReportUnusedParameterWhenImplementingAbstract, this.reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED); + optionsMap.put(OPTION_ReportUnusedParameterWhenOverridingConcrete, this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED); + optionsMap.put(OPTION_ReportSpecialParameterHidingField, this.reportSpecialParameterHidingField ? ENABLED : DISABLED); + optionsMap.put(OPTION_MaxProblemPerUnit, String.valueOf(this.maxProblemsPerUnit)); return optionsMap; } public int getSeverity(long irritant) { - if((warningThreshold & irritant) != 0) + if((this.warningThreshold & irritant) != 0) return Warning; - if((errorThreshold & irritant) != 0) + if((this.errorThreshold & irritant) != 0) return Error; return Ignore; } public String getSeverityString(long irritant) { - if((warningThreshold & irritant) != 0) + if((this.warningThreshold & irritant) != 0) return WARNING; - if((errorThreshold & irritant) != 0) + if((this.errorThreshold & irritant) != 0) return ERROR; return IGNORE; } + public String getVisibilityString(int level) { + switch (level) { + case AccPublic: + return PUBLIC; + case AccProtected: + return PROTECTED; + case AccPrivate: + return PRIVATE; + default: + return DEFAULT; + } + } + public void produceReferenceInfo(boolean flag) { this.produceReferenceInfo = flag; } @@ -401,13 +447,6 @@ public class CompilerOptions implements ProblemReasons, ProblemSeverities, Class } } } - if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadoc)) != null) { - if (ENABLED.equals(optionValue)) { - this.reportMissingJavadoc = true; - } else if (DISABLED.equals(optionValue)) { - this.reportMissingJavadoc = false; - } - } if ((optionValue = optionsMap.get(OPTION_ReportMethodWithConstructorName)) != null) updateSeverity(MethodWithConstructorName, optionValue); if ((optionValue = optionsMap.get(OPTION_ReportOverridingPackageDefaultMethod)) != null) updateSeverity(OverriddenPackageDefaultMethod, optionValue); if ((optionValue = optionsMap.get(OPTION_ReportDeprecation)) != null) updateSeverity(UsingDeprecatedAPI, optionValue); @@ -430,10 +469,80 @@ public class CompilerOptions implements ProblemReasons, ProblemSeverities, Class if ((optionValue = optionsMap.get(OPTION_ReportIncompatibleNonInheritedInterfaceMethod)) != null) updateSeverity(IncompatibleNonInheritedInterfaceMethod, optionValue); if ((optionValue = optionsMap.get(OPTION_ReportUndocumentedEmptyBlock)) != null) updateSeverity(UndocumentedEmptyBlock, optionValue); if ((optionValue = optionsMap.get(OPTION_ReportUnnecessaryTypeCheck)) != null) updateSeverity(UnnecessaryTypeCheck, optionValue); - if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadoc)) != null) updateSeverity(InvalidJavadoc, optionValue); if ((optionValue = optionsMap.get(OPTION_ReportFinallyBlockNotCompletingNormally)) != null) updateSeverity(FinallyBlockNotCompleting, optionValue); if ((optionValue = optionsMap.get(OPTION_ReportUnqualifiedFieldAccess)) != null) updateSeverity(UnqualifiedFieldAccess, optionValue); if ((optionValue = optionsMap.get(OPTION_ReportNoEffectAssignment)) != null) updateSeverity(NoEffectAssignment, optionValue); + + // Javadoc options + if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadoc)) != null) { + updateSeverity(InvalidJavadoc, optionValue); + } + if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTagsVisibility)) != null) { + if (PUBLIC.equals(optionValue)) { + this.reportInvalidJavadocTagsVisibility = AccPublic; + } else if (PROTECTED.equals(optionValue)) { + this.reportInvalidJavadocTagsVisibility = AccProtected; + } else if (DEFAULT.equals(optionValue)) { + this.reportInvalidJavadocTagsVisibility = AccDefault; + } else if (PRIVATE.equals(optionValue)) { + this.reportInvalidJavadocTagsVisibility = AccPrivate; + } + } + if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTags)) != null) { + if (ENABLED.equals(optionValue)) { + this.reportInvalidJavadocTags= true; + } else if (DISABLED.equals(optionValue)) { + this.reportInvalidJavadocTags = false; + } + } + if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTags)) != null) { + updateSeverity(MissingJavadocTags, optionValue); + } + if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTagsVisibility)) != null) { + if (PUBLIC.equals(optionValue)) { + this.reportMissingJavadocTagsVisibility = AccPublic; + } else if (PROTECTED.equals(optionValue)) { + this.reportMissingJavadocTagsVisibility = AccProtected; + } else if (DEFAULT.equals(optionValue)) { + this.reportMissingJavadocTagsVisibility = AccDefault; + } else if (PRIVATE.equals(optionValue)) { + this.reportMissingJavadocTagsVisibility = AccPrivate; + } + } + if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTagsOverriding)) != null) { + // TODO (frederic) see with jdt-ui whether we use ignore instead of report + if (ENABLED.equals(optionValue)) { + //this.reportMissingJavadocTagsOverriding = true; + this.reportMissingJavadocTagsOverriding = false; + } else if (DISABLED.equals(optionValue)) { + //this.reportMissingJavadocTagsOverriding = false; + this.reportMissingJavadocTagsOverriding = true; + } + } + if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocComments)) != null) { + updateSeverity(MissingJavadocComments, optionValue); + } + if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocCommentsVisibility)) != null) { + if (PUBLIC.equals(optionValue)) { + this.reportMissingJavadocCommentsVisibility = AccPublic; + } else if (PROTECTED.equals(optionValue)) { + this.reportMissingJavadocCommentsVisibility = AccProtected; + } else if (DEFAULT.equals(optionValue)) { + this.reportMissingJavadocCommentsVisibility = AccDefault; + } else if (PRIVATE.equals(optionValue)) { + this.reportMissingJavadocCommentsVisibility = AccPrivate; + } + } + if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocCommentsOverriding)) != null) { + // TODO (frederic) see with jdt-ui whether we use ignore instead of report + if (ENABLED.equals(optionValue)) { + //this.reportMissingJavadocCommentsOverriding = true; + this.reportMissingJavadocCommentsOverriding = false; + } else if (DISABLED.equals(optionValue)) { + //this.reportMissingJavadocCommentsOverriding = false; + this.reportMissingJavadocCommentsOverriding = true; + } + } } public void setVerboseMode(boolean flag) { @@ -443,10 +552,10 @@ public class CompilerOptions implements ProblemReasons, ProblemSeverities, Class public String toString() { StringBuffer buf = new StringBuffer("CompilerOptions:"); //$NON-NLS-1$ - buf.append("\n\t- local variables debug attributes: ").append((produceDebugAttributes & Vars) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - buf.append("\n\t- line number debug attributes: ").append((produceDebugAttributes & Lines) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - buf.append("\n\t- source debug attributes: ").append((produceDebugAttributes & Source) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - buf.append("\n\t- preserve all local variables: ").append(preserveAllLocalVariables ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- local variables debug attributes: ").append((this.produceDebugAttributes & Vars) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- line number debug attributes: ").append((this.produceDebugAttributes & Lines) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- source debug attributes: ").append((this.produceDebugAttributes & Source) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- preserve all local variables: ").append(this.preserveAllLocalVariables ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ buf.append("\n\t- method with constructor name: ").append(getSeverityString(MethodWithConstructorName)); //$NON-NLS-1$ buf.append("\n\t- overridden package default method: ").append(getSeverityString(OverriddenPackageDefaultMethod)); //$NON-NLS-1$ buf.append("\n\t- deprecation: ").append(getSeverityString(UsingDeprecatedAPI)); //$NON-NLS-1$ @@ -468,23 +577,30 @@ public class CompilerOptions implements ProblemReasons, ProblemSeverities, Class buf.append("\n\t- uncommented empty block: ").append(getSeverityString(UndocumentedEmptyBlock)); //$NON-NLS-1$ buf.append("\n\t- unnecessary type check: ").append(getSeverityString(UnnecessaryTypeCheck)); //$NON-NLS-1$ buf.append("\n\t- invalid javadoc: ").append(getSeverityString(InvalidJavadoc)); //$NON-NLS-1$ - buf.append("\n\t- report missing javadoc: ").append(reportMissingJavadoc ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- report invalid javadoc tags: ").append(this.reportInvalidJavadocTags ? ENABLED : DISABLED); //$NON-NLS-1$ + buf.append("\n\t- visibility level to report invalid javadoc tags: ").append(getVisibilityString(this.reportInvalidJavadocTagsVisibility)); //$NON-NLS-1$ + buf.append("\n\t- missing javadoc tags: ").append(getSeverityString(MissingJavadocTags)); //$NON-NLS-1$ + buf.append("\n\t- visibility level to report missing javadoc tags: ").append(getVisibilityString(this.reportMissingJavadocTagsVisibility)); //$NON-NLS-1$ + buf.append("\n\t- report missing javadoc tags in overriding methods: ").append(this.reportMissingJavadocTagsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$ + buf.append("\n\t- missing javadoc comments: ").append(getSeverityString(MissingJavadocComments)); //$NON-NLS-1$ + buf.append("\n\t- visibility level to report missing javadoc comments: ").append(getVisibilityString(this.reportMissingJavadocCommentsVisibility)); //$NON-NLS-1$ + buf.append("\n\t- report missing javadoc comments in overriding methods: ").append(this.reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- finally block not completing normally: ").append(getSeverityString(FinallyBlockNotCompleting)); //$NON-NLS-1$ buf.append("\n\t- unused declared thrown exception: ").append(getSeverityString(UnusedDeclaredThrownException)); //$NON-NLS-1$ - buf.append("\n\t- JDK compliance level: "+ versionFromJdkLevel(complianceLevel)); //$NON-NLS-1$ - buf.append("\n\t- JDK source level: "+ versionFromJdkLevel(sourceLevel)); //$NON-NLS-1$ - buf.append("\n\t- JDK target level: "+ versionFromJdkLevel(targetJDK)); //$NON-NLS-1$ - buf.append("\n\t- private constructor access: ").append(isPrivateConstructorAccessChangingVisibility ? "extra argument" : "make default access"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - buf.append("\n\t- verbose : ").append(verbose ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - buf.append("\n\t- produce reference info : ").append(produceReferenceInfo ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - buf.append("\n\t- parse literal expressions as constants : ").append(parseLiteralExpressionsAsConstants ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - buf.append("\n\t- encoding : ").append(defaultEncoding == null ? "<default>" : defaultEncoding); //$NON-NLS-1$ //$NON-NLS-2$ + buf.append("\n\t- JDK compliance level: "+ versionFromJdkLevel(this.complianceLevel)); //$NON-NLS-1$ + buf.append("\n\t- JDK source level: "+ versionFromJdkLevel(this.sourceLevel)); //$NON-NLS-1$ + buf.append("\n\t- JDK target level: "+ versionFromJdkLevel(this.targetJDK)); //$NON-NLS-1$ + buf.append("\n\t- private constructor access: ").append(this.isPrivateConstructorAccessChangingVisibility ? "extra argument" : "make default access"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- verbose : ").append(this.verbose ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- produce reference info : ").append(this.produceReferenceInfo ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- parse literal expressions as constants : ").append(this.parseLiteralExpressionsAsConstants ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- encoding : ").append(this.defaultEncoding == null ? "<default>" : this.defaultEncoding); //$NON-NLS-1$ //$NON-NLS-2$ buf.append("\n\t- task tags: ").append(this.taskTags == null ? "" : new String(CharOperation.concatWith(this.taskTags,','))); //$NON-NLS-1$ //$NON-NLS-2$ buf.append("\n\t- task priorities : ").append(this.taskPriorites == null ? "" : new String(CharOperation.concatWith(this.taskPriorites,','))); //$NON-NLS-1$ //$NON-NLS-2$ - buf.append("\n\t- report deprecation inside deprecated code : ").append(reportDeprecationInsideDeprecatedCode ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - buf.append("\n\t- report unused parameter when implementing abstract method : ").append(reportUnusedParameterWhenImplementingAbstract ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - buf.append("\n\t- report unused parameter when overriding concrete method : ").append(reportUnusedParameterWhenOverridingConcrete ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(reportSpecialParameterHidingField ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- report deprecation inside deprecated code : ").append(this.reportDeprecationInsideDeprecatedCode ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- report unused parameter when implementing abstract method : ").append(this.reportUnusedParameterWhenImplementingAbstract ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- report unused parameter when overriding concrete method : ").append(this.reportUnusedParameterWhenOverridingConcrete ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(this.reportSpecialParameterHidingField ? "ENABLED" : "DISABLED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return buf.toString(); } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java index 5b6e72fcd7..d42fc865c0 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java @@ -1538,7 +1538,7 @@ public abstract class Scope } public boolean isInsideDeprecatedCode(){ - switch(kind){ + switch(this.kind){ case Scope.BLOCK_SCOPE : case Scope.METHOD_SCOPE : MethodScope methodScope = methodScope(); @@ -1577,6 +1577,44 @@ public abstract class Scope } return false; } + + public int getModifiers(){ + switch(this.kind){ + case Scope.BLOCK_SCOPE : + case Scope.METHOD_SCOPE : + MethodScope methodScope = methodScope(); + if (!methodScope.isInsideInitializer()){ + // check method modifiers to see if deprecated + MethodBinding context = ((AbstractMethodDeclaration)methodScope.referenceContext).binding; + if (context != null) { + return context.modifiers; + } + } else { + SourceTypeBinding type = ((BlockScope)this).referenceType().binding; + + // inside field declaration ? check field modifier to see if deprecated + if (methodScope.fieldDeclarationIndex != MethodScope.NotInFieldDecl) { + for (int i = 0; i < type.fields.length; i++){ + if (type.fields[i].id == methodScope.fieldDeclarationIndex) { + // currently inside this field initialization + return type.fields[i].modifiers; + } + } + } + if (type != null) { + return type.modifiers; + } + } + break; + case Scope.CLASS_SCOPE : + ReferenceBinding context = ((ClassScope)this).referenceType().binding; + if (context != null) { + return context.modifiers; + } + break; + } + return -1; + } public final boolean isJavaIoSerializable(TypeBinding tb) { return tb == getJavaIoSerializable(); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java index 817a0ccb19..6fb8ef072b 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java @@ -38,7 +38,7 @@ public class JavadocParser { // Public fields public Javadoc javadoc; - public boolean checkJavadoc; + public boolean checkJavadoc = false; public Scanner scanner; // Private fields @@ -62,7 +62,8 @@ public class JavadocParser { JavadocParser(Parser sourceParser) { this.sourceParser = sourceParser; - this.checkJavadoc = this.sourceParser.options.getSeverity(CompilerOptions.InvalidJavadoc) != ProblemSeverities.Ignore; + this.checkJavadoc = (this.sourceParser.options.getSeverity(CompilerOptions.InvalidJavadoc) != ProblemSeverities.Ignore) || + (this.sourceParser.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore); this.scanner = new Scanner(false, false, false, ClassFileConstants.JDK1_3, null, null); this.identifierStack = new char[10][]; this.identifierPositionStack = new long[10]; @@ -87,6 +88,8 @@ public class JavadocParser { this.astLengthPtr = -1; this.astPtr = -1; this.currentTokenType = -1; + } else if (this.sourceParser.options.getSeverity(CompilerOptions.MissingJavadocComments) != ProblemSeverities.Ignore) { + this.javadoc = new Javadoc(javadocStart, javadocEnd); } else { this.javadoc = null; } @@ -196,14 +199,14 @@ public class JavadocParser { int modulo = 0; // should be 2 for (Type,Type,...) or 3 for (Type arg,Type arg,...) int iToken = 0; char[] argName = null; - int ptr = astPtr; - int lptr = astLengthPtr; + int ptr = this.astPtr; + int lptr = this.astLengthPtr; // Decide whether we have a constructor or not boolean isConstructor = true; if (receiver != null) { char[][] receiverTokens = receiver.getTypeName(); - char[] memberName = identifierStack[0]; + char[] memberName = this.identifierStack[0]; isConstructor = CharOperation.equals(memberName, receiverTokens[receiverTokens.length-1]); } @@ -227,11 +230,11 @@ public class JavadocParser { if (typeRef == null) { if (firstArg && this.currentTokenType == TerminalTokens.TokenNameRPAREN) { if (isConstructor) { - JavadocAllocationExpression expr = new JavadocAllocationExpression(identifierPositionStack[0]); + JavadocAllocationExpression expr = new JavadocAllocationExpression(this.identifierPositionStack[0]); expr.type = receiver; return expr; } else { - JavadocMessageSend msg = new JavadocMessageSend(identifierStack[0], identifierPositionStack[0]); + JavadocMessageSend msg = new JavadocMessageSend(this.identifierStack[0], this.identifierPositionStack[0]); msg.receiver = receiver; return msg; } @@ -306,20 +309,20 @@ public class JavadocParser { // Create new argument JavadocArgumentExpression expr = new JavadocArgumentExpression(name, argStart, argEnd, typeRef); pushOnAstStack(expr, firstArg); - int size = astLengthStack[astLengthPtr--]; + int size = this.astLengthStack[this.astLengthPtr--]; // Build arguments array JavadocArgumentExpression[] arguments = new JavadocArgumentExpression[size]; for (int i = (size - 1); i >= 0; i--) { - arguments[i] = (JavadocArgumentExpression) astStack[astPtr--]; + arguments[i] = (JavadocArgumentExpression) this.astStack[this.astPtr--]; } // Create message send if (isConstructor) { - JavadocAllocationExpression alloc = new JavadocAllocationExpression(identifierPositionStack[0]); + JavadocAllocationExpression alloc = new JavadocAllocationExpression(this.identifierPositionStack[0]); alloc.arguments = arguments; alloc.type = receiver; return alloc; } else { - JavadocMessageSend msg = new JavadocMessageSend(identifierStack[0], identifierPositionStack[0], arguments); + JavadocMessageSend msg = new JavadocMessageSend(this.identifierStack[0], this.identifierPositionStack[0], arguments); msg.receiver = receiver; return msg; } @@ -402,7 +405,7 @@ public class JavadocParser { if (readTokenAndConsume() == TerminalTokens.TokenNameIdentifier) { pushIdentifier(true); if (readTokenAndConsume() == TerminalTokens.TokenNameLPAREN) { - start = this.scanner.currentPosition; + start = this.scanner.getCurrentTokenStartPosition(); try { return parseArguments(typeRef); } catch (InvalidInputException e) { @@ -414,7 +417,7 @@ public class JavadocParser { } return null; } - JavadocFieldReference field = new JavadocFieldReference(identifierStack[0], identifierPositionStack[0]); + JavadocFieldReference field = new JavadocFieldReference(this.identifierStack[0], this.identifierPositionStack[0]); field.receiver = typeRef; field.tagSourceStart = this.tagSourceStart; field.tagSourceEnd = this.tagSourceEnd; @@ -449,8 +452,8 @@ public class JavadocParser { //end = scanner.eofPosition-2; break; default : - start = scanner.getCurrentTokenStartPosition(); - end = scanner.getCurrentTokenEndPosition(); + start = this.scanner.getCurrentTokenStartPosition(); + end = this.scanner.getCurrentTokenEndPosition(); break; } } catch (InvalidInputException e) { @@ -524,8 +527,8 @@ public class JavadocParser { int size = this.identifierLengthStack[this.identifierLengthPtr--]; if (size == 1) { // Single Type ref typeRef = new JavadocSingleTypeReference( - identifierStack[this.identifierPtr], - identifierPositionStack[this.identifierPtr], + this.identifierStack[this.identifierPtr], + this.identifierPositionStack[this.identifierPtr], this.tagSourceStart, this.tagSourceEnd); } else if (size > 1) { // Qualified Type ref @@ -627,13 +630,13 @@ public class JavadocParser { */ private void parseReturn() { if (this.javadoc.returnStatement == null) { - this.javadoc.returnStatement = new JavadocReturnStatement(scanner.getCurrentTokenStartPosition(), - scanner.getCurrentTokenEndPosition(), - scanner.getRawTokenSourceEnd()); + this.javadoc.returnStatement = new JavadocReturnStatement(this.scanner.getCurrentTokenStartPosition(), + this.scanner.getCurrentTokenEndPosition(), + this.scanner.getRawTokenSourceEnd()); } else { - this.sourceParser.problemReporter().javadocDuplicateReturnTag( - scanner.getCurrentTokenStartPosition(), - scanner.getCurrentTokenEndPosition()); + this.sourceParser.problemReporter().javadocDuplicatedReturnTag( + this.scanner.getCurrentTokenStartPosition(), + this.scanner.getCurrentTokenEndPosition()); } } @@ -891,7 +894,7 @@ public class JavadocParser { if (ptr == SEE_TAG_EXPECTED_ORDER) { int size = this.astLengthStack[this.astLengthPtr--]; for (int i=0; i<size; i++) { - this.javadoc.references[--sizes[ptr]] = (Expression) this.astStack[astPtr--]; + this.javadoc.references[--sizes[ptr]] = (Expression) this.astStack[this.astPtr--]; } } @@ -899,7 +902,7 @@ public class JavadocParser { else if (ptr == THROWS_TAG_EXPECTED_ORDER) { int size = this.astLengthStack[this.astLengthPtr--]; for (int i=0; i<size; i++) { - this.javadoc.thrownExceptions[--sizes[ptr]] = (TypeReference) this.astStack[astPtr--]; + this.javadoc.thrownExceptions[--sizes[ptr]] = (TypeReference) this.astStack[this.astPtr--]; } } @@ -907,7 +910,7 @@ public class JavadocParser { else if (ptr == PARAM_TAG_EXPECTED_ORDER) { int size = this.astLengthStack[this.astLengthPtr--]; for (int i=0; i<size; i++) { - this.javadoc.parameters[--sizes[ptr]] = (JavadocSingleNameReference) this.astStack[astPtr--]; + this.javadoc.parameters[--sizes[ptr]] = (JavadocSingleNameReference) this.astStack[this.astPtr--]; } } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java index 108d668edd..9c136b8130 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java @@ -522,6 +522,28 @@ public int computeSeverity(int problemId){ case IProblem.UnqualifiedFieldAccess: return this.options.getSeverity(CompilerOptions.UnqualifiedFieldAccess); + /* + * Javadoc syntax errors + */ + // Javadoc explicit IDs + case IProblem.JavadocUnexpectedTag: + case IProblem.JavadocDuplicateReturnTag: + case IProblem.JavadocInvalidThrowsClass: + case IProblem.JavadocInvalidSeeReference: + case IProblem.JavadocInvalidSeeHref: + case IProblem.JavadocInvalidSeeArgs: + return this.options.getSeverity(CompilerOptions.InvalidJavadoc); + + /* + * Javadoc tags resolved references errors + */ + case IProblem.JavadocInvalidParamName: + case IProblem.JavadocDuplicateParamName: + case IProblem.JavadocMissingParamName: + case IProblem.JavadocInvalidThrowsClassName: + case IProblem.JavadocDuplicateThrowsClassName: + case IProblem.JavadocMissingThrowsClassName: + case IProblem.JavadocMissingSeeReference: // Javadoc implicit IDs for deprecatedField(...) case IProblem.Javadoc | IProblem.UsingDeprecatedField: // Javadoc implicit IDs for deprecatedMethod(...) @@ -546,28 +568,24 @@ public int computeSeverity(int problemId){ // Javadoc implicit IDs for errorNoMethodFor(...) case IProblem.Javadoc | IProblem.NoMessageSendOnArrayType: case IProblem.Javadoc | IProblem.NoMessageSendOnBaseType: - // Javadoc explicit IDs - case IProblem.JavadocUnexpectedTag: + if (!this.options.reportInvalidJavadocTags) + return ProblemSeverities.Ignore; + else + return this.options.getSeverity(CompilerOptions.InvalidJavadoc); + + /* + * Javadoc missing tags errors + */ case IProblem.JavadocMissingParamTag: - case IProblem.JavadocMissingParamName: - case IProblem.JavadocDuplicateParamName: - case IProblem.JavadocInvalidParamName: case IProblem.JavadocMissingReturnTag: - case IProblem.JavadocDuplicateReturnTag: case IProblem.JavadocMissingThrowsTag: - case IProblem.JavadocMissingThrowsClassName: - case IProblem.JavadocInvalidThrowsClass: - case IProblem.JavadocDuplicateThrowsClassName: - case IProblem.JavadocInvalidThrowsClassName: - case IProblem.JavadocMissingSeeReference: - case IProblem.JavadocInvalidSeeReference: - case IProblem.JavadocInvalidSeeHref: - case IProblem.JavadocInvalidSeeArgs: - return this.options.getSeverity(CompilerOptions.InvalidJavadoc); + return this.options.getSeverity(CompilerOptions.MissingJavadocTags); + /* + * Missing Javadoc errors + */ case IProblem.JavadocMissing: - if (!this.options.reportMissingJavadoc) return Ignore; - return this.options.getSeverity(CompilerOptions.InvalidJavadoc); + return this.options.getSeverity(CompilerOptions.MissingJavadocComments); // by default problems are errors. default: @@ -646,12 +664,8 @@ public void constantOutOfRange(Literal literal, TypeBinding literalType) { literal.sourceEnd); } public void deprecatedField(FieldBinding field, ASTNode location) { - int id = IProblem.UsingDeprecatedField; - if ((location.bits & ASTNode.InsideJavadoc) != 0) { - id |= IProblem.Javadoc; - } this.handle( - id, + 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, @@ -659,23 +673,15 @@ public void deprecatedField(FieldBinding field, ASTNode location) { } public void deprecatedMethod(MethodBinding method, ASTNode location) { if (method.isConstructor()) { - int id = IProblem.UsingDeprecatedConstructor; - if ((location.bits & ASTNode.InsideJavadoc) != 0) { - id |= IProblem.Javadoc; - } this.handle( - id, + 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 { - int id = IProblem.UsingDeprecatedMethod; - if ((location.bits & ASTNode.InsideJavadoc) != 0) { - id |= IProblem.Javadoc; - } this.handle( - id, + 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, @@ -684,12 +690,8 @@ public void deprecatedMethod(MethodBinding method, ASTNode location) { } public void deprecatedType(TypeBinding type, ASTNode location) { if (location == null) return; // 1G828DN - no type ref for synthetic arguments - int id = IProblem.UsingDeprecatedType; - if ((location.bits & ASTNode.InsideJavadoc) != 0) { - id |= IProblem.Javadoc; - } this.handle( - id, + IProblem.UsingDeprecatedType, new String[] {new String(type.readableName())}, new String[] {new String(type.shortReadableName())}, location.sourceStart, @@ -845,9 +847,12 @@ public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeB } int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType; + /* if ((messageSend.bits & ASTNode.InsideJavadoc) != 0) { id |= IProblem.Javadoc; + if (!reportInvalidJavadocTagsVisibility()) return; } + */ this.handle( id, new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()}, @@ -1001,7 +1006,6 @@ public void forwardReference(Reference reference, int indexInQualification, Type // use this private API when the compilation unit result can be found through the // reference context. Otherwise, use the other API taking a problem and a compilation result // as arguments - private void handle( int problemId, String[] problemArguments, @@ -1015,14 +1019,13 @@ private void handle( messageArguments, problemStartPosition, problemEndPosition, - referenceContext, - referenceContext == null ? null : referenceContext.compilationResult()); - referenceContext = null; + this.referenceContext, + this.referenceContext == null ? null : this.referenceContext.compilationResult()); + this.referenceContext = null; } // use this private API when the compilation unit result can be found through the // reference context. Otherwise, use the other API taking a problem and a compilation result // as arguments - private void handle( int problemId, String[] problemArguments, @@ -1038,9 +1041,9 @@ private void handle( severity, problemStartPosition, problemEndPosition, - referenceContext, - referenceContext == null ? null : referenceContext.compilationResult()); - referenceContext = null; + this.referenceContext, + this.referenceContext == null ? null : this.referenceContext.compilationResult()); + this.referenceContext = null; } // use this private API when the compilation unit result cannot be found through the // reference context. @@ -1059,9 +1062,9 @@ private void handle( messageArguments, problemStartPosition, problemEndPosition, - referenceContext, + this.referenceContext, unitResult); - referenceContext = null; + this.referenceContext = null; } public void hiddenCatchBlock(ReferenceBinding exceptionType, ASTNode location) { this.handle( @@ -1564,8 +1567,8 @@ public void invalidBreak(ASTNode location) { public void invalidConstructor(Statement statement, MethodBinding targetConstructor) { boolean insideDefaultConstructor = - (referenceContext instanceof ConstructorDeclaration) - && ((ConstructorDeclaration)referenceContext).isDefaultConstructor(); + (this.referenceContext instanceof ConstructorDeclaration) + && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor(); boolean insideImplicitConstructorCall = (statement instanceof ExplicitConstructorCall) && (((ExplicitConstructorCall) statement).accessMode == ExplicitConstructorCall.ImplicitSuper); @@ -1605,9 +1608,6 @@ public void invalidConstructor(Statement statement, MethodBinding targetConstruc break; } - if ((statement.bits & ASTNode.InsideJavadoc) != 0) { - id |= IProblem.Javadoc; - } this.handle( id, new String[] {new String(targetConstructor.declaringClass.readableName()), parametersAsString(targetConstructor)}, @@ -1713,9 +1713,6 @@ public void invalidField(FieldReference fieldRef, TypeBinding searchedType) { } String[] arguments = new String[] {new String(field.readableName())}; - if ((fieldRef.bits & ASTNode.InsideJavadoc) != 0) { - id |= IProblem.Javadoc; - } this.handle( id, arguments, @@ -1892,9 +1889,6 @@ public void invalidMethod(MessageSend messageSend, MethodBinding method) { parameterTypeShortNames = parameterTypeNames; } id = IProblem.ParameterMismatch; - if ((messageSend.bits & ASTNode.InsideJavadoc) != 0) { - id |= IProblem.Javadoc; - } this.handle( id, new String[] { @@ -1915,9 +1909,6 @@ public void invalidMethod(MessageSend messageSend, MethodBinding method) { } } - if ((messageSend.bits & ASTNode.InsideJavadoc) != 0) { - id |= IProblem.Javadoc; - } this.handle( id, new String[] { @@ -2078,10 +2069,7 @@ public void invalidType(ASTNode location, TypeBinding type) { needImplementation(); // want to fail to see why we were here... break; } - - if ((location.bits & ASTNode.InsideJavadoc) != 0) { - id |= IProblem.Javadoc; - } + int end = location.sourceEnd; if (location instanceof QualifiedNameReference) { QualifiedNameReference ref = (QualifiedNameReference) location; @@ -2120,7 +2108,7 @@ public void invalidUnaryExpression(Expression expression) { expression.sourceEnd); } public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl) { - referenceContext = compUnitDecl; + this.referenceContext = compUnitDecl; String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)}; this.handle( IProblem.IsClassPathCorrect, @@ -2130,17 +2118,229 @@ public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclar compUnitDecl == null ? 0 : compUnitDecl.sourceStart, compUnitDecl == null ? 1 : compUnitDecl.sourceEnd); } -public void javadocDuplicateReturnTag(int sourceStart, int sourceEnd){ +public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd){ this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd); } -public void javadocInvalidParamName(JavadocSingleNameReference param, boolean duplicated) { - String[] arguments = new String[] {String.valueOf(param.token)}; +public void javadocDeprecatedField(FieldBinding field, ASTNode location, int modifiers) { + if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + this.handle( + IProblem.UsingDeprecatedField|IProblem.Javadoc, + 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.UsingDeprecatedConstructor|IProblem.Javadoc, + 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|IProblem.Javadoc, + 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.UsingDeprecatedType|IProblem.Javadoc, + 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.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType; + if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + this.handle( + id|IProblem.Javadoc, + 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.UndefinedConstructor; //default... + switch (targetConstructor.problemId()) { + case NotFound : + if (insideDefaultConstructor){ + id = IProblem.UndefinedConstructorInDefaultConstructor; + } else if (insideImplicitConstructorCall){ + id = IProblem.UndefinedConstructorInImplicitConstructorCall; + } else { + id = IProblem.UndefinedConstructor; + } + break; + case NotVisible : + if (insideDefaultConstructor){ + id = IProblem.NotVisibleConstructorInDefaultConstructor; + } else if (insideImplicitConstructorCall){ + id = IProblem.NotVisibleConstructorInImplicitConstructorCall; + } else { + id = IProblem.NotVisibleConstructor; + } + break; + case Ambiguous : + if (insideDefaultConstructor){ + id = IProblem.AmbiguousConstructorInDefaultConstructor; + } else if (insideImplicitConstructorCall){ + id = IProblem.AmbiguousConstructorInImplicitConstructorCall; + } else { + id = IProblem.AmbiguousConstructor; + } + break; + case NoError : // 0 + default : + needImplementation(); // want to fail to see why we were here... + break; + } + + this.handle( + id|IProblem.Javadoc, + new String[] {new String(targetConstructor.declaringClass.readableName()), parametersAsString(targetConstructor)}, + new String[] {new String(targetConstructor.declaringClass.shortReadableName()), parametersAsShortString(targetConstructor)}, + statement.sourceStart, + statement.sourceEnd); +} +public void javadocInvalidField(FieldReference fieldRef, TypeBinding searchedType, int modifiers) { + int id = IProblem.UndefinedField; + FieldBinding field = fieldRef.binding; + switch (field.problemId()) { + case NotFound : + id = IProblem.UndefinedField; + break; + case NotVisible : + id = IProblem.NotVisibleField; + break; + case Ambiguous : + id = IProblem.AmbiguousField; + 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(field.readableName())}; + handle(id|IProblem.Javadoc, arguments, arguments, fieldRef.sourceStart, fieldRef.sourceEnd); + } +} +public void javadocInvalidMethod(MessageSend messageSend, MethodBinding method, int modifiers) { + if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) { + return; + } + int id = IProblem.UndefinedMethod; //default... + switch (method.problemId()) { + case NotFound : + id = IProblem.UndefinedMethod; + break; + case NotVisible : + id = IProblem.NotVisibleMethod; + break; + case Ambiguous : + id = IProblem.AmbiguousMethod; + break; + case NoError : // 0 + default : + needImplementation(); // want to fail to see why we were here... + break; + } + + if (id == 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|IProblem.Javadoc, + 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( - duplicated?IProblem.JavadocDuplicateParamName:IProblem.JavadocInvalidParamName, - arguments, - arguments, - param.sourceStart, - param.sourceEnd); + id|IProblem.Javadoc, + 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); @@ -2154,32 +2354,72 @@ public void javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd) { public void javadocInvalidThrowsClass(int sourceStart, int sourceEnd) { this.handle(IProblem.JavadocInvalidThrowsClass, NoArgument, NoArgument, sourceStart, sourceEnd); } -public void javadocInvalidThrowsClassName(TypeReference typeReference, boolean duplicated) { - String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())}; - this.handle( - duplicated?IProblem.JavadocDuplicateThrowsClassName:IProblem.JavadocInvalidThrowsClassName, - arguments, - arguments, - typeReference.sourceStart, - typeReference.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.UndefinedType; // default + switch (type.problemId()) { + case NotFound : + id = IProblem.UndefinedType; + break; + case NotVisible : + id = IProblem.NotVisibleType; + break; + case Ambiguous : + id = IProblem.AmbiguousType; + break; + case InternalNameProvided : + id = IProblem.InternalTypeNameProvided; + break; + case NoError : // 0 + default : + needImplementation(); // want to fail to see why we were here... + break; + } + this.handle( + id|IProblem.Javadoc, + new String[] {new String(type.readableName())}, + new String[] {new String(type.shortReadableName())}, + location.sourceStart, + location.sourceEnd); + } } -public void javadocMissing(int sourceStart, int sourceEnd){ - this.handle(IProblem.JavadocMissing, 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) { - String[] arguments = new String[] {String.valueOf(param.name)}; - this.handle( - IProblem.JavadocMissingParamTag, - arguments, - arguments, - param.sourceStart, - param.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){ - this.handle(IProblem.JavadocMissingReturnTag, NoArgument, NoArgument, sourceStart, 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); @@ -2187,13 +2427,55 @@ public void javadocMissingSeeReference(int sourceStart, int sourceEnd){ public void javadocMissingThrowsClassName(int sourceStart, int sourceEnd){ this.handle(IProblem.JavadocMissingThrowsClassName, NoArgument, NoArgument, sourceStart, sourceEnd); } -public void javadocMissingThrowsTag(TypeReference typeRef){ - String[] arguments = new String[]{String.valueOf(typeRef.resolvedType.sourceName())}; - this.handle(IProblem.JavadocMissingThrowsTag, arguments, arguments, typeRef.sourceStart, typeRef.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); } +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 localVariableHiding(LocalDeclaration local, Binding hiddenVariable, boolean isSpecialArgHidingField) { if (hiddenVariable instanceof LocalVariableBinding) { String[] arguments = new String[] {new String(local.name) }; @@ -3008,8 +3290,8 @@ public void unexpectedStaticModifierForMethod(ReferenceBinding type, AbstractMet public void unhandledException(TypeBinding exceptionType, ASTNode location) { boolean insideDefaultConstructor = - (referenceContext instanceof ConstructorDeclaration) - && ((ConstructorDeclaration)referenceContext).isDefaultConstructor(); + (this.referenceContext instanceof ConstructorDeclaration) + && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor(); boolean insideImplicitConstructorCall = (location instanceof ExplicitConstructorCall) && (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper); @@ -3577,11 +3859,11 @@ public void parseErrorUnexpectedEnd( int end){ String[] arguments; - if(referenceContext instanceof ConstructorDeclaration) { + if(this.referenceContext instanceof ConstructorDeclaration) { arguments = new String[] {Util.bind("parser.endOfConstructor")}; //$NON-NLS-1$ - } else if(referenceContext instanceof MethodDeclaration) { + } else if(this.referenceContext instanceof MethodDeclaration) { arguments = new String[] {Util.bind("parser.endOfMethod")}; //$NON-NLS-1$ - } else if(referenceContext instanceof TypeDeclaration) { + } else if(this.referenceContext instanceof TypeDeclaration) { arguments = new String[] {Util.bind("parser.endOfInitializer")}; //$NON-NLS-1$ } else { arguments = new String[] {Util.bind("parser.endOfFile")}; //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties index d8475cc5d4..ca0e72409c 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties @@ -349,5 +349,5 @@ 483 = Invalid reference 484 = Invalid URL link format 485 = Invalid parameters declaration -486 = Missing comment for public declaration +486 = Missing comment for {0} declaration 489 = Javadoc: diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java index 3a1b44f746..5920b2ff41 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java @@ -325,27 +325,80 @@ public final class JavaCore extends Plugin { public static final String COMPILER_PB_INVALID_JAVADOC = PLUGIN_ID + ".compiler.problem.invalidJavadoc"; //$NON-NLS-1$ /** * Possible configurable option ID. + * @see #COMPILER_PB_INVALID_JAVADOC + * @deprecated + * TODO (frederic) remove after 3.0 M6 + */ + public static final String COMPILER_PB_INVALID_ANNOTATION = COMPILER_PB_INVALID_JAVADOC; + public static final String OLD_COMPILER_PB_INVALID_ANNOTATION = PLUGIN_ID + ".compiler.problem.invalidAnnotation"; //$NON-NLS-1$ + /** + * Possible configurable option ID. * @see #getDefaultOptions() * @since 3.0 */ - public static final String COMPILER_PB_MISSING_JAVADOC = PLUGIN_ID + ".compiler.problem.missingJavadoc"; //$NON-NLS-1$ + public static final String COMPILER_PB_INVALID_JAVADOC_TAGS = PLUGIN_ID + ".compiler.problem.invalidJavadocTags"; //$NON-NLS-1$ /** * Possible configurable option ID. - * @see #COMPILER_PB_INVALID_JAVADOC + * @see #getDefaultOptions() + * @since 3.0 + */ + public static final String COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY = PLUGIN_ID + ".compiler.problem.invalidJavadocTagsVisibility"; //$NON-NLS-1$ + /** + * Possible configurable option ID. + * @see #getDefaultOptions() + * @since 3.0 + */ + public static final String COMPILER_PB_MISSING_JAVADOC_TAGS = PLUGIN_ID + ".compiler.problem.missingJavadocTags"; //$NON-NLS-1$ + /** + * Possible configurable option ID. + * @see #getDefaultOptions() + * @since 3.0 + */ + public static final String COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY = PLUGIN_ID + ".compiler.problem.missingJavadocTagsVisibility"; //$NON-NLS-1$ + /** + * Possible configurable option ID. + * @see #getDefaultOptions() + * @since 3.0 + */ + public static final String COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING = PLUGIN_ID + ".compiler.problem.missingJavadocTagsOverriding"; //$NON-NLS-1$ + /** + * Possible configurable option ID. + * @see #getDefaultOptions() + * @since 3.0 + */ + public static final String COMPILER_PB_MISSING_JAVADOC_COMMENTS = PLUGIN_ID + ".compiler.problem.missingJavadocComments"; //$NON-NLS-1$ + /** + * Possible configurable option ID. + * @see #getDefaultOptions() + * @since 3.0 * @deprecated + * TODO (frederic) remove after 3.0 M7 */ - public static final String COMPILER_PB_INVALID_ANNOTATION = COMPILER_PB_INVALID_JAVADOC; - public static final String OLD_COMPILER_PB_INVALID_ANNOTATION = PLUGIN_ID + ".compiler.problem.invalidAnnotation"; //$NON-NLS-1$ + public static final String COMPILER_PB_MISSING_JAVADOC = COMPILER_PB_MISSING_JAVADOC_COMMENTS; + public static final String OLD_COMPILER_PB_MISSING_JAVADOC = PLUGIN_ID + ".compiler.problem.missingJavadoc"; //$NON-NLS-1$ /** * Possible configurable option ID. * @see #COMPILER_PB_MISSING_JAVADOC * @deprecated + * TODO (frederic) after 3.0 M6 */ public static final String COMPILER_PB_MISSING_ANNOTATION = COMPILER_PB_MISSING_JAVADOC; public static final String OLD_COMPILER_PB_MISSING_ANNOTATION = PLUGIN_ID + ".compiler.problem.missingAnnotation"; //$NON-NLS-1$ /** * Possible configurable option ID. * @see #getDefaultOptions() + * @since 3.0 + */ + public static final String COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY = PLUGIN_ID + ".compiler.problem.missingJavadocCommentsVisibility"; //$NON-NLS-1$ + /** + * Possible configurable option ID. + * @see #getDefaultOptions() + * @since 3.0 + */ + public static final String COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING = PLUGIN_ID + ".compiler.problem.missingJavadocCommentsOverriding"; //$NON-NLS-1$ + /** + * Possible configurable option ID. + * @see #getDefaultOptions() * @since 2.1 */ public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$ @@ -742,6 +795,30 @@ public final class JavaCore extends Plugin { * @since 2.1 */ public static final String CLEAN = "clean"; //$NON-NLS-1$ + /** + * Possible configurable option value. + * @see #getDefaultOptions() + * @since 3.0 + */ + public static final String PUBLIC = "public"; //$NON-NLS-1$ + /** + * Possible configurable option value. + * @see #getDefaultOptions() + * @since 3.0 + */ + public static final String PROTECTED = "protected"; //$NON-NLS-1$ + /** + * Possible configurable option value. + * @see #getDefaultOptions() + * @since 3.0 + */ + public static final String DEFAULT = "default"; //$NON-NLS-1$ + /** + * Possible configurable option value. + * @see #getDefaultOptions() + * @since 3.0 + */ + public static final String PRIVATE = "private"; //$NON-NLS-1$ /** * Creates the Java core plug-in. @@ -1186,11 +1263,9 @@ public final class JavaCore extends Plugin { try { // wrap initializer call with Safe runnable in case initializer would be causing some grief Platform.run(new ISafeRunnable() { - /** @param exception */ public void handleException(Throwable exception) { Util.log(exception, "Exception occurred in classpath variable initializer: "+initializer+" while initializing variable: "+variableName); //$NON-NLS-1$ //$NON-NLS-2$ } - /** @throws Exception */ public void run() throws Exception { initializer.initialize(variableName); } @@ -1535,19 +1610,72 @@ public final class JavaCore extends Plugin { * - default: "ignore" * * COMPILER / Reporting Invalid Javadoc Comment - * When enabled, the compiler will issue an error or a warning when a javadoc comment is inconsistent, - * misses a tag entry or contains invalid references. + * This is the generic control for the severity of Javadoc problems. + * When enabled, the compiler will issue an error or a warning for a problem in Javadoc. * - option id: "org.eclipse.jdt.core.compiler.problem.invalidJavadoc" * - possible values: { "error", "warning", "ignore" } * - default: "ignore" - * - * COMPILER / Reporting Missing Javadoc Comment - * When enabled, the compiler will signal cases where public class, interface, method, constructor or field - * (considered as part of the API) has no javadoc comment. + * + * COMPILER / Visibility Level For Invalid Javadoc Tags + * Set the minimum visibility level for Javadoc tag problems. Below this level problems will be ignored. + * - option id: "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility" + * - possible values: { "public", "protected", "default", "private" } + * - default: "private" + * + * COMPILER / Reporting Invalid Javadoc Tags + * When enabled, the compiler will signal unbound or unexpected reference tags in Javadoc. + * A 'throws' tag referencing an undeclared exception would be considered as unexpected. + * <br>Note that this diagnosis can be enabled based on the visibility of the construct associated with the Javadoc; + * also see the setting "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility". + * <br> * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.invalidJavadoc". - * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadoc" + * - option id: "org.eclipse.jdt.core.compiler.problem.invalidJavadocTags" + * - possible values: { "disabled", "enabled" } + * - default: "enabled" + * + * COMPILER / Reporting Missing Javadoc Tags + * This is the generic control for the severity of Javadoc missing tag problems. + * When enabled, the compiler will issue an error or a warning when tags are missing in Javadoc comments. + * <br>Note that this diagnosis can be enabled based on the visibility of the construct associated with the Javadoc; + * also see the setting "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility". + * <br> + * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocTags" + * - possible values: { "error", "warning", "ignore" } + * - default: "ignore" + * + * COMPILER / Visibility Level For Missing Javadoc Tags + * Set the minimum visibility level for Javadoc missing tag problems. Below this level problems will be ignored. + * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility" + * - possible values: { "public", "protected", "default", "private" } + * - default: "private" + * + * COMPILER / Reporting Missing Javadoc Tags on Overriding Methods + * Specify whether the compiler will verify overriding methods in order to report Javadoc missing tag problems. + * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding" * - possible values: { "enabled", "disabled" } - * - default: "disabled" + * - default: "enabled" + * + * COMPILER / Reporting Missing Javadoc Comments + * This is the generic control for the severity of missing Javadoc comment problems. + * When enabled, the compiler will issue an error or a warning when Javadoc comments are missing. + * <br>Note that this diagnosis can be enabled based on the visibility of the construct associated with the expected Javadoc; + * also see the setting "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility". + * <br> + * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocComments" + * - possible values: { "error", "warning", "ignore" } + * - default: "ignore" + * + * COMPILER / Visibility Level For Missing Javadoc Comments + * Set the minimum visibility level for missing Javadoc problems. Below this level problems will be ignored. + * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility" + * - possible values: { "public", "protected", "default", "private" } + * - default: "public" + * + * COMPILER / Reporting Missing Javadoc Comments on Overriding Methods + * Specify whether the compiler will verify overriding methods in order to report missing Javadoc comment problems. + * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding" + * - possible values: { "enabled", "disabled" } + * - default: "enabled" * * COMPILER / Setting Source Compatibility Mode * Specify whether which source level compatibility is used. From 1.4 on, 'assert' is a keyword @@ -1876,15 +2004,6 @@ public final class JavaCore extends Plugin { return ERROR; } String propertyName = optionName; - // bug 45112 backward compatibility. - // TODO (frederic) remove for 3.0 - if (OLD_COMPILER_PB_INVALID_ANNOTATION.equals(optionName)) { - propertyName = COMPILER_PB_INVALID_JAVADOC; - } - else if (OLD_COMPILER_PB_MISSING_ANNOTATION.equals(optionName)) { - propertyName = COMPILER_PB_MISSING_JAVADOC; - } - // end bug 45112 if (JavaModelManager.OptionNames.contains(propertyName)){ Preferences preferences = getPlugin().getPluginPreferences(); return preferences.getString(propertyName).trim(); @@ -1930,18 +2049,30 @@ public final class JavaCore extends Plugin { options.put(propertyName, value); } // bug 45112 backward compatibility. - // TODO (frederic) remove for 3.0 + // TODO (frederic) remove after 3.0 M6 else if (OLD_COMPILER_PB_INVALID_ANNOTATION.equals(propertyName)) { options.put(COMPILER_PB_INVALID_JAVADOC, value); - preferences.setToDefault(OLD_COMPILER_PB_INVALID_ANNOTATION); - preferences.setValue(COMPILER_PB_INVALID_JAVADOC, value); } else if (OLD_COMPILER_PB_MISSING_ANNOTATION.equals(propertyName)) { - options.put(COMPILER_PB_MISSING_JAVADOC, value); - preferences.setToDefault(OLD_COMPILER_PB_MISSING_ANNOTATION); - preferences.setValue(COMPILER_PB_MISSING_JAVADOC, value); + if (ENABLED.equals(value)) { + value = preferences.getString(COMPILER_PB_INVALID_JAVADOC); + } else { + value = IGNORE; + } + options.put(COMPILER_PB_MISSING_JAVADOC_COMMENTS, value); } // end bug 45112 + // bug 46854 backward compatibility + // TODO (frederic) remove after 3.0 M7 + else if (OLD_COMPILER_PB_MISSING_JAVADOC.equals(propertyName)) { + if (ENABLED.equals(value)) { + value = preferences.getString(COMPILER_PB_INVALID_JAVADOC); + } else { + value = IGNORE; + } + options.put(COMPILER_PB_MISSING_JAVADOC_COMMENTS, value); + } + // end bug 46854 } // get encoding through resource plugin options.put(CORE_ENCODING, ResourcesPlugin.getEncoding()); @@ -3252,7 +3383,26 @@ public final class JavaCore extends Plugin { String value = (String)newOptions.get(key); preferences.setValue(key, value); } - + + // Backward compatibility + String[] propertyNames = preferences.propertyNames(); + for (int i = 0; i < propertyNames.length; i++){ + String propertyName = propertyNames[i]; + // bug 45112 + if (OLD_COMPILER_PB_INVALID_ANNOTATION.equals(propertyName)) { + preferences.setToDefault(OLD_COMPILER_PB_INVALID_ANNOTATION); + } + else if (OLD_COMPILER_PB_MISSING_ANNOTATION.equals(propertyName)) { + preferences.setToDefault(OLD_COMPILER_PB_MISSING_ANNOTATION); + } + // end bug 45112 + // bug 46854 + else if (OLD_COMPILER_PB_MISSING_JAVADOC.equals(propertyName)) { + preferences.setToDefault(OLD_COMPILER_PB_MISSING_JAVADOC); + } + // end bug 46854 + } + // persist options getPlugin().savePluginPreferences(); } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java index 5c9356bebc..e0574a0819 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java @@ -215,7 +215,7 @@ public class JavaProject /** * Constructor needed for <code>IProject.getNature()</code> and <code>IProject.addNature()</code>. * - * @see #setProject + * @see #setProject(IProject) */ public JavaProject() { super(null, null); @@ -223,7 +223,7 @@ public class JavaProject public JavaProject(IProject project, JavaElement parent) { super(parent, project.getName()); - fProject = project; + this.fProject = project; } /** @@ -848,7 +848,7 @@ public class JavaProject * project if they are identical or if they represent a project with * the same underlying resource and occurrence counts. * - * @see JavaElement#equals + * @see JavaElement#equals(Object) */ public boolean equals(Object o) { @@ -864,7 +864,7 @@ public class JavaProject } public boolean exists() { - if (!hasJavaNature(fProject)) return false; + if (!hasJavaNature(this.fProject)) return false; return super.exists(); } @@ -1411,15 +1411,6 @@ public class JavaProject public String getOption(String optionName, boolean inheritJavaCoreOptions) { String propertyName = optionName; - // bug 45112 backward compatibility. - // TODO (frederic) remove for 3.0 - if (JavaCore.OLD_COMPILER_PB_INVALID_ANNOTATION.equals(optionName)) { - propertyName = JavaCore.COMPILER_PB_INVALID_JAVADOC; - } - else if (JavaCore.OLD_COMPILER_PB_MISSING_ANNOTATION.equals(optionName)) { - propertyName = JavaCore.COMPILER_PB_MISSING_JAVADOC; - } - // end bug 45112 if (JavaModelManager.OptionNames.contains(propertyName)){ Preferences preferences = getPreferences(); if (preferences == null || preferences.isDefault(propertyName)) { @@ -1461,18 +1452,30 @@ public class JavaProject options.put(propertyName, value); } // bug 45112 backward compatibility. - // TODO (frederic) remove for 3.0 + // TODO (frederic) remove after 3.0 M6 else if (JavaCore.OLD_COMPILER_PB_INVALID_ANNOTATION.equals(propertyName)) { options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, value); - preferences.setToDefault(JavaCore.OLD_COMPILER_PB_INVALID_ANNOTATION); - preferences.setValue(JavaCore.COMPILER_PB_INVALID_JAVADOC, value); } else if (JavaCore.OLD_COMPILER_PB_MISSING_ANNOTATION.equals(propertyName)) { - options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC, value); - preferences.setToDefault(JavaCore.OLD_COMPILER_PB_MISSING_ANNOTATION); - preferences.setValue(JavaCore.COMPILER_PB_MISSING_JAVADOC, value); + if (JavaCore.ENABLED.equals(value)) { + value = preferences.getString(JavaCore.COMPILER_PB_INVALID_JAVADOC); + } else { + value = JavaCore.IGNORE; + } + options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, value); } // end bug 45112 + // bug 46854 backward compatibility + // TODO (frederic) remove after 3.0 M7 + else if (JavaCore.OLD_COMPILER_PB_MISSING_JAVADOC.equals(propertyName)) { + if (JavaCore.ENABLED.equals(value)) { + value = preferences.getString(JavaCore.COMPILER_PB_INVALID_JAVADOC); + } else { + value = JavaCore.IGNORE; + } + options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, value); + } + // end bug 46854 } return options; @@ -1672,7 +1675,7 @@ public class JavaProject } public JavaModelManager.PerProjectInfo getPerProjectInfo() throws JavaModelException { - return JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(fProject); + return JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(this.fProject); } /** @@ -1680,7 +1683,7 @@ public class JavaProject */ public IProject getProject() { - return fProject; + return this.fProject; } /** @@ -1749,7 +1752,7 @@ public class JavaProject return classpath; } /** - * @see IJavaProject#getRequiredProjectNames + * @see IJavaProject#getRequiredProjectNames() */ public String[] getRequiredProjectNames() throws JavaModelException { @@ -1797,7 +1800,7 @@ public class JavaProject if (perProjectInfo != null){ if (perProjectInfo.rawClasspath == null // .classpath file could not be read && generateMarkerOnError - && JavaProject.hasJavaNature(fProject)) { + && JavaProject.hasJavaNature(this.fProject)) { // flush .classpath format markers (bug 39877), but only when file cannot be read (bug 42366) this.flushClasspathProblemMarkers(false, true); this.createClasspathProblemMarker(new JavaModelStatus( @@ -1982,7 +1985,7 @@ public class JavaProject } public int hashCode() { - return fProject.hashCode(); + return this.fProject.hashCode(); } /** @@ -2132,7 +2135,7 @@ public class JavaProject } /** - * @see IJavaProject#newEvaluationContext + * @see IJavaProject#newEvaluationContext() */ public IEvaluationContext newEvaluationContext() { @@ -2468,7 +2471,26 @@ public class JavaProject preferences.setValue(key, value); } } - + + // Backward compatibility + String[] propertyNames = preferences.propertyNames(); + for (int i = 0; i < propertyNames.length; i++){ + String propertyName = propertyNames[i]; + // bug 45112 + if (JavaCore.OLD_COMPILER_PB_INVALID_ANNOTATION.equals(propertyName)) { + preferences.setToDefault(JavaCore.OLD_COMPILER_PB_INVALID_ANNOTATION); + } + else if (JavaCore.OLD_COMPILER_PB_MISSING_ANNOTATION.equals(propertyName)) { + preferences.setToDefault(JavaCore.OLD_COMPILER_PB_MISSING_ANNOTATION); + } + // end bug 45112 + // bug 46854 + else if (JavaCore.OLD_COMPILER_PB_MISSING_JAVADOC.equals(propertyName)) { + preferences.setToDefault(JavaCore.OLD_COMPILER_PB_MISSING_JAVADOC); + } + // end bug 46854 + } + // persist options savePreferences(preferences); } @@ -2503,11 +2525,11 @@ public class JavaProject * and fills in its parent and name. * Called by IProject.getNature(). * - * @see IProjectNature#setProject + * @see IProjectNature#setProject(IProject) */ public void setProject(IProject project) { - fProject = project; + this.fProject = project; this.parent = JavaModelManager.getJavaModelManager().getJavaModel(); this.name = project.getName(); } diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java index 0e8ef1b59c..d7884eca1f 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java @@ -102,7 +102,7 @@ protected MatchLocatorParser(ProblemReporter problemReporter, MatchLocator locat } public void checkComment() { super.checkComment(); - if (this.javadoc != null) { + if (this.javadocParser.checkJavadoc && this.javadoc != null) { // Search for pattern locator matches in javadoc comment @throws/@exception tags TypeReference[] thrownExceptions = this.javadoc.thrownExceptions; int throwsTagsNbre = thrownExceptions == null ? 0 : thrownExceptions.length; |