Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 70465 Details for
Bug 190970
[javadoc] "field never read locally" analysis should not consider javadoc
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
[file]: patch with new Javadoc comment
b190970_on_top_v770_V03.txt (text/plain), 5.32 KB, created by
Eric Jodet
on 2007-06-07 02:29:14 EDT
(
hide
)
Description:
[file]: patch with new Javadoc comment
Filename:
MIME Type:
Creator:
Eric Jodet
Created:
2007-06-07 02:29:14 EDT
Size:
5.32 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java,v >retrieving revision 1.24 >diff -u -r1.24 JavadocFieldReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java 27 Apr 2007 15:51:38 -0000 1.24 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java 7 Jun 2007 06:15:41 -0000 >@@ -11,6 +11,7 @@ > package org.eclipse.jdt.internal.compiler.ast; > > import org.eclipse.jdt.internal.compiler.ASTVisitor; >+import org.eclipse.jdt.internal.compiler.env.AccessRestriction; > import org.eclipse.jdt.internal.compiler.impl.Constant; > import org.eclipse.jdt.internal.compiler.lookup.*; > >@@ -95,7 +96,7 @@ > } > this.binding = (FieldBinding) fieldBinding; > >- if (isFieldUseDeprecated(this.binding, scope, (this.bits & IsStrictlyAssigned) != 0)) { >+ if (fieldCanBeUsedAsReference(this.binding, scope, (this.bits & IsStrictlyAssigned) != 0)) { > scope.problemReporter().javadocDeprecatedField(this.binding, this, scope.getDeclarationModifiers()); > } > return this.resolvedType = this.binding.type; >@@ -144,4 +145,32 @@ > } > visitor.endVisit(this, scope); > } >+ >+ /** >+ * Same implementation than {@link ASTNode#isFieldUseDeprecated(FieldBinding, Scope, boolean)} without >+ * touching the {@link ExtraCompilerModifiers#AccLocallyUsed} to keep private >+ * fields unused when they are only referenced in javadoc comments. >+ * >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=190970" >+ */ >+ private final boolean fieldCanBeUsedAsReference(FieldBinding field, Scope scope, boolean isStrictlyAssigned) { >+ >+ if ((field.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) { >+ AccessRestriction restriction = >+ scope.environment().getAccessRestriction(field.declaringClass.erasure()); >+ if (restriction != null) { >+ scope.problemReporter().forbiddenReference(field, this, >+ restriction.getFieldAccessMessageTemplate(), restriction.getProblemId()); >+ } >+ } >+ >+ if (!field.isViewedAsDeprecated()) return false; >+ >+ // inside same unit - no report >+ if (scope.isDefinedInSameUnit(field.declaringClass)) return false; >+ >+ // if context is deprecated, may avoid reporting >+ if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false; >+ return true; >+ } > } >#P org.eclipse.jdt.core.tests >Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java >=================================================================== >RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java,v >retrieving revision 1.303 >diff -u -r1.303 NegativeTest.java >--- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java 26 Mar 2007 17:16:04 -0000 1.303 >+++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java 7 Jun 2007 06:16:23 -0000 >@@ -16235,4 +16235,66 @@ > ); > > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=190970 >+public void test445() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runNegativeTest(new String[] { >+ "pkg/X.java", >+ "package pkg;\n" + >+ "\n" + >+ "public class X {\n" + >+ "private int unused;" + >+ "/**" + >+ "* Same value as {@link #unused}" + >+ "*/" + >+ "private int unused2;" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in pkg\\X.java (at line 4)\n" + >+ " private int unused;/*** Same value as {@link #unused}*/private int unused2;}\n" + >+ " ^^^^^^\n" + >+ "The field X.unused is never read locally\n" + >+ "----------\n" + >+ "2. WARNING in pkg\\X.java (at line 4)\n" + >+ " private int unused;/*** Same value as {@link #unused}*/private int unused2;}\n" + >+ " ^^^^^^^\n" + >+ "The field X.unused2 is never read locally\n" + >+ "----------\n" >+); >+ >+} >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=190970 >+public void test446() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runNegativeTest(new String[] { >+ "pkg/X.java", >+ "package pkg;\n" + >+ "\n" + >+ "public class X {\n" + >+ "/**" + >+ "* Same value as {@link #unused}" + >+ "*/" + >+ "private int unused;" + >+ "private int unused2;" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in pkg\\X.java (at line 4)\n" + >+ " /*** Same value as {@link #unused}*/private int unused;private int unused2;}\n" + >+ " ^^^^^^\n" + >+ "The field X.unused is never read locally\n" + >+ "----------\n" + >+ "2. WARNING in pkg\\X.java (at line 4)\n" + >+ " /*** Same value as {@link #unused}*/private int unused;private int unused2;}\n" + >+ " ^^^^^^^\n" + >+ "The field X.unused2 is never read locally\n" + >+ "----------\n" >+); >+ >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 190970
:
70372
|
70450
|
70465
|
77111
|
77238
|
77558
|
79473