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 79473 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]
[proposed patch + test case] on top v815 - all jdt.core tests OK
b190970_on_top_v815_V09.txt (text/plain), 6.03 KB, created by
Eric Jodet
on 2007-10-01 09:23:43 EDT
(
hide
)
Description:
[proposed patch + test case] on top v815 - all jdt.core tests OK
Filename:
MIME Type:
Creator:
Eric Jodet
Created:
2007-10-01 09:23:43 EDT
Size:
6.03 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java,v >retrieving revision 1.36 >diff -u -r1.36 JavadocBugsTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 16 Mar 2007 18:31:22 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 1 Oct 2007 11:10:58 -0000 >@@ -5773,4 +5773,103 @@ > "Javadoc: Missing tag for parameter anotherInt\n" + > "----------\n"); > } >+ >+ /** >+ * @bug 190970: [javadoc] "field never read locally" analysis should not consider javadoc >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=190970" >+ */ >+ public void testBug190970a() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING); >+ this.runNegativeTest(new String[] { >+ "pkg/X.java", >+ "public class X {\n" + >+ "private int unused1;\n" + >+ "\n" + >+ "/**\n" + >+ " * Same value as {@link #unused1}\n" + >+ " */\n" + >+ "private int unused2;\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in pkg\\X.java (at line 2)\n" + >+ " private int unused1;\n" + >+ " ^^^^^^^\n" + >+ "The field X.unused1 is never read locally\n" + >+ "----------\n" + >+ "2. WARNING in pkg\\X.java (at line 7)\n" + >+ " private int unused2;\n" + >+ " ^^^^^^^\n" + >+ "The field X.unused2 is never read locally\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions >+ ); >+ } >+ // test unused methods >+ public void testBug190970b() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING); >+ this.runNegativeTest(new String[] { >+ "pkg/X.java", >+ "package pkg;\n" + >+ "\n" + >+ "public class X {\n" + >+ "private void unused1() {}\n" + >+ "/**\n" + >+ " * Same value as {@link #unused1()}\n" + >+ " */\n" + >+ "private void unused2() {}\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in pkg\\X.java (at line 4)\n" + >+ " private void unused1() {}\n" + >+ " ^^^^^^^^^\n" + >+ "The method unused1() from the type X is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in pkg\\X.java (at line 8)\n" + >+ " private void unused2() {}\n" + >+ " ^^^^^^^^^\n" + >+ "The method unused2() from the type X is never used locally\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions >+ ); >+ } >+ // test unused types >+ public void testBug190970c() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING); >+ this.runNegativeTest(new String[] { >+ "pkg/X.java", >+ "package pkg;\n" + >+ "\n" + >+ "public class X {\n" + >+ "private class unused1 {}\n" + >+ "/**\n" + >+ " * {@link X.unused1}\n" + >+ " */\n" + >+ "private class unused2 {}\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in pkg\\X.java (at line 4)\n" + >+ " private class unused1 {}\n" + >+ " ^^^^^^^\n" + >+ "The type X.unused1 is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in pkg\\X.java (at line 8)\n" + >+ " private class unused2 {}\n" + >+ " ^^^^^^^\n" + >+ "The type X.unused2 is never used locally\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions >+ ); >+ } > } >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v >retrieving revision 1.85 >diff -u -r1.85 ASTNode.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 24 Sep 2007 22:49:54 -0000 1.85 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 1 Oct 2007 11:11:00 -0000 >@@ -338,8 +338,10 @@ > } > > public final boolean isFieldUseDeprecated(FieldBinding field, Scope scope, boolean isStrictlyAssigned) { >- >- if (!isStrictlyAssigned && (field.isPrivate() || (field.declaringClass != null && field.declaringClass.isLocalType())) && !scope.isDefinedInField(field)) { >+ // ignore references insing Javadoc comments >+ if ((this.bits & ASTNode.InsideJavadoc) ==0 && >+ !isStrictlyAssigned && >+ (field.isPrivate() || (field.declaringClass != null && field.declaringClass.isLocalType())) && !scope.isDefinedInField(field)) { > // ignore cases where field is used from within inside itself > field.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; > } >@@ -373,7 +375,9 @@ > */ > public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope, > boolean isExplicitUse) { >- if ((method.isPrivate() || method.declaringClass.isLocalType()) && !scope.isDefinedInMethod(method)) { >+ // ignore references insing Javadoc comments >+ if ((this.bits & ASTNode.InsideJavadoc) ==0 && >+ (method.isPrivate() || method.declaringClass.isLocalType()) && !scope.isDefinedInMethod(method)) { > // ignore cases where method is used from within inside itself (e.g. direct recursions) > method.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; > } >@@ -436,8 +440,9 @@ > return false; > > ReferenceBinding refType = (ReferenceBinding) type; >- >- if ((refType.isPrivate() || refType.isLocalType()) && !scope.isDefinedInType(refType)) { >+ // ignore references insing Javadoc comments >+ if ((this.bits & ASTNode.InsideJavadoc) ==0 && >+ (refType.isPrivate() || refType.isLocalType()) && !scope.isDefinedInType(refType)) { > // ignore cases where type is used from within inside itself > ((ReferenceBinding)refType.erasure()).modifiers |= ExtraCompilerModifiers.AccLocallyUsed; > }
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