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 72181 Details for
Bug 191908
[1.5][compiler] Missing strike through for deprecated declaration fragment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression tests
patch_191908.txt (text/plain), 11.06 KB, created by
Olivier Thomann
on 2007-06-22 10:58:34 EDT
(
hide
)
Description:
Proposed fix + regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-06-22 10:58:34 EDT
Size:
11.06 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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.83 >diff -u -r1.83 ASTNode.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 25 Apr 2007 16:59:23 -0000 1.83 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 22 Jun 2007 14:58:21 -0000 >@@ -563,12 +563,36 @@ > TypeBinding[] annotationTypes = new TypeBinding[length]; > for (int i = 0; i < length; i++) { > Annotation annotation = annotations[i]; >- annotation.recipient = recipient; >- annotationTypes[i] = annotation.resolveType(scope); >- >- // null if receiver is a package binding >- if (instances != null) >- instances[i] = annotation.getCompilerAnnotation(); >+ final Binding annotationRecipient = annotation.recipient; >+ if (annotationRecipient != null && recipient != null) { >+ // only local and field can share annnotations >+ switch (recipient.kind()) { >+ case Binding.FIELD : >+ FieldBinding field = (FieldBinding) recipient; >+ field.tagBits = ((FieldBinding) annotationRecipient).tagBits; >+ break; >+ case Binding.LOCAL : >+ LocalVariableBinding local = (LocalVariableBinding) recipient; >+ local.tagBits = ((LocalVariableBinding) annotationRecipient).tagBits; >+ break; >+ } >+ if (instances != null) { >+ // need to fill the instances array >+ instances[0] = annotation.getCompilerAnnotation(); >+ for (int j = 1; j < length; j++) { >+ Annotation annot = annotations[j]; >+ instances[j] = annot.getCompilerAnnotation(); >+ } >+ } >+ return; >+ } else { >+ annotation.recipient = recipient; >+ annotationTypes[i] = annotation.resolveType(scope); >+ // null if receiver is a package binding >+ if (instances != null) { >+ instances[i] = annotation.getCompilerAnnotation(); >+ } >+ } > } > // check duplicate annotations > for (int i = 0; i < length; i++) { >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java,v >retrieving revision 1.247 >diff -u -r1.247 ASTConverter15Test.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 11 May 2007 14:55:27 -0000 1.247 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 22 Jun 2007 14:58:22 -0000 >@@ -46,7 +46,7 @@ > } > > static { >-// TESTS_NUMBERS = new int[] { 272 }; >+ TESTS_NUMBERS = new int[] { 276 }; > // TESTS_RANGE = new int[] { 253, -1 }; > // TESTS_NAMES = new String[] {"test0204"}; > } >@@ -9098,4 +9098,102 @@ > CompilationUnit unit = (CompilationUnit) node; > assertProblemsSize(unit, 1, "The type A is not generic; it cannot be parameterized with arguments <?>"); > } >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908 >+ public void test0274() throws JavaModelException { >+ this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); >+ String contents = >+ "public class X {\n" + >+ " @Deprecated\n" + >+ " public static int x= 5, y= 10;\n" + >+ "}"; >+ ASTNode node = buildAST( >+ contents, >+ this.workingCopy, >+ true); >+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); >+ CompilationUnit unit = (CompilationUnit) node; >+ assertProblemsSize(unit, 0); >+ node = getASTNode(unit, 0, 0); >+ assertEquals("Not a field declaration", ASTNode.FIELD_DECLARATION, node.getNodeType()); >+ FieldDeclaration fieldDeclaration = (FieldDeclaration) node; >+ List fragments = fieldDeclaration.fragments(); >+ assertEquals("Wrong size", 2, fragments.size()); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ IVariableBinding binding = fragment.resolveBinding(); >+ assertTrue("Not deprecated", binding.isDeprecated()); >+ fragment = (VariableDeclarationFragment) fragments.get(1); >+ binding = fragment.resolveBinding(); >+ assertTrue("Not deprecated", binding.isDeprecated()); >+ } >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908 >+ public void test0275() throws JavaModelException { >+ this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); >+ String contents = >+ "public class X {\n" + >+ " public void foo() {\n" + >+ " @Deprecated\n" + >+ " int x= 5, y= 10;\n" + >+ " }\n" + >+ "}"; >+ ASTNode node = buildAST( >+ contents, >+ this.workingCopy, >+ true); >+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); >+ CompilationUnit unit = (CompilationUnit) node; >+ assertProblemsSize(unit, 0); >+ node = getASTNode(unit, 0, 0, 0); >+ assertEquals("Not a variable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) node; >+ List fragments = statement.fragments(); >+ assertEquals("Wrong size", 2, fragments.size()); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ IVariableBinding binding = fragment.resolveBinding(); >+ IAnnotationBinding[] annotations = binding.getAnnotations(); >+ assertEquals("Wrong size", 1, annotations.length); >+ fragment = (VariableDeclarationFragment) fragments.get(1); >+ binding = fragment.resolveBinding(); >+ annotations = binding.getAnnotations(); >+ assertEquals("Wrong size", 1, annotations.length); >+ } >+ >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=192774 >+ //Test ability to distinguish AST nodes of multiple similar annotations. >+ public void test0276() throws JavaModelException { >+ this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); >+ String contents = >+ "@interface Annot {\n" + >+ " public int value();\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " @Annot(1) String foo1() { return null; }\n" + >+ " @Annot(1) String foo2() { return null; }\n" + >+ "}"; >+ this.workingCopy.getBuffer().setContents(contents); >+ >+ class CompilationUnitRequestor extends ASTRequestor { >+ public void acceptAST(ICompilationUnit source, CompilationUnit node) { >+ MethodDeclaration methodDeclaration = (MethodDeclaration)getASTNode(node, 1, 0); >+ IMethodBinding methodBinding = methodDeclaration.resolveBinding(); >+ IAnnotationBinding annoBinding = methodBinding.getAnnotations()[0]; >+ ASTNode annoNode = node.findDeclaringNode(annoBinding); >+ int position1 = annoNode.getStartPosition(); >+ >+ methodDeclaration = (MethodDeclaration)getASTNode(node, 1, 1); >+ methodBinding = methodDeclaration.resolveBinding(); >+ IAnnotationBinding annoBinding2 = methodBinding.getAnnotations()[0]; >+ annoNode = node.findDeclaringNode(annoBinding2); >+ int position2 = annoNode.getStartPosition(); >+ assertTrue("Anno 2 position <= anno 1 position", position2 > position1); >+ } >+ } >+ >+ CompilationUnitRequestor requestor = new CompilationUnitRequestor(); >+ ASTParser parser = ASTParser.newParser(AST.JLS3); >+ parser.setResolveBindings(true); >+ parser.setProject(this.getJavaProject("Converter15")); >+ parser.setKind(ASTParser.K_COMPILATION_UNIT); >+ parser.createASTs(new ICompilationUnit[]{this.workingCopy}, new String[0], requestor, null); >+ } > } >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java,v >retrieving revision 1.31 >diff -u -r1.31 DeprecatedTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java 6 Mar 2007 04:42:12 -0000 1.31 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java 22 Jun 2007 14:58:24 -0000 >@@ -731,6 +731,45 @@ > false, > false); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191909 (1.4 variant) >+public void test019() { >+ Map customOptions = new HashMap(); >+ customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); >+ this.runNegativeTest( >+ new String[] { >+ "test1/E01.java", >+ "package test1;\n" + >+ "public class E01 {\n" + >+ " /** @deprecated */\n" + >+ " public static int x = 5, y= 10;\n" + >+ "}", >+ "test1/E02.java", >+ "package test1;\n" + >+ "public class E02 {\n" + >+ " public void foo() {\n" + >+ " System.out.println(E01.x);\n" + >+ " System.out.println(E01.y);\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in test1\\E02.java (at line 4)\n" + >+ " System.out.println(E01.x);\n" + >+ " ^\n" + >+ "The field E01.x is deprecated\n" + >+ "----------\n" + >+ "2. ERROR in test1\\E02.java (at line 5)\n" + >+ " System.out.println(E01.y);\n" + >+ " ^\n" + >+ "The field E01.y is deprecated\n" + >+ "----------\n", >+ null, >+ true, >+ customOptions, >+ true, >+ false, >+ false); >+} > public static Class testClass() { > return DeprecatedTest.class; > } >Index: src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java,v >retrieving revision 1.6 >diff -u -r1.6 Deprecated15Test.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java 6 Mar 2007 04:42:12 -0000 1.6 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java 22 Jun 2007 14:58:24 -0000 >@@ -187,6 +187,45 @@ > customOptions, > null); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191909 >+public void test004() { >+ Map customOptions = new HashMap(); >+ customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); >+ this.runNegativeTest( >+ new String[] { >+ "test1/E01.java", >+ "package test1;\n" + >+ "public class E01 {\n" + >+ " @Deprecated\n" + >+ " public static int x = 5, y= 10;\n" + >+ "}", >+ "test1/E02.java", >+ "package test1;\n" + >+ "public class E02 {\n" + >+ " public void foo() {\n" + >+ " System.out.println(E01.x);\n" + >+ " System.out.println(E01.y);\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in test1\\E02.java (at line 4)\n" + >+ " System.out.println(E01.x);\n" + >+ " ^\n" + >+ "The field E01.x is deprecated\n" + >+ "----------\n" + >+ "2. ERROR in test1\\E02.java (at line 5)\n" + >+ " System.out.println(E01.y);\n" + >+ " ^\n" + >+ "The field E01.y is deprecated\n" + >+ "----------\n", >+ null, >+ true, >+ customOptions, >+ true, >+ false, >+ false); >+} > public static Class testClass() { > return Deprecated15Test.class; > }
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 191908
:
71360
|
71362
|
72181
|
72190