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 125400 Details for
Bug 264443
[parser] ASTParser.createASTs and IVariableBinding
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression tests
patch_264443+tests.txt (text/plain), 10.40 KB, created by
Olivier Thomann
on 2009-02-11 11:03:01 EST
(
hide
)
Description:
Proposed fix + regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2009-02-11 11:03:01 EST
Size:
10.40 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java,v >retrieving revision 1.154 >diff -u -r1.154 ASTConverterTestAST3_2.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 29 Nov 2008 22:35:14 -0000 1.154 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 11 Feb 2009 16:01:31 -0000 >@@ -122,7 +122,7 @@ > static { > // TESTS_NAMES = new String[] {"test0602"}; > // TESTS_RANGE = new int[] { 670, -1 }; >-// TESTS_NUMBERS = new int[] { 697, 698 }; >+// TESTS_NUMBERS = new int[] { 699, 700, 701 }; > } > public static Test suite() { > return buildModelTestSuite(ASTConverterTestAST3_2.class); >@@ -9977,4 +9977,131 @@ > } > } > } >+ >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=264443 >+ public void test0699() throws JavaModelException { >+ ICompilationUnit workingCopy = null; >+ try { >+ workingCopy = getWorkingCopy("/Converter/src/example/Test.java", true/*resolve*/); >+ String contents = >+ "package example;\n" + >+ "public class Test {\n" + >+ " public void test() throws Throwable {\n" + >+ " B /*start*/b = new B()/*end*/;\n" + >+ " }\n" + >+ "}"; >+ >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) buildAST(contents, workingCopy, false, true, true); >+ IVariableBinding variableBinding = fragment.resolveBinding(); >+ final String key = variableBinding.getKey(); >+ ASTParser parser = ASTParser.newParser(AST.JLS3); >+ parser.setProject(workingCopy.getJavaProject()); >+ parser.setResolveBindings(true); >+ parser.setKind(ASTParser.K_COMPILATION_UNIT); >+ >+ parser.createASTs( >+ new ICompilationUnit[] { workingCopy }, >+ new String[] { key }, >+ new ASTRequestor() { >+ public void acceptBinding(String bindingKey, >+ IBinding binding) { >+ assertEquals("Wrong key", key, bindingKey); >+ assertTrue("Not a variable binding", binding.getKind() == IBinding.VARIABLE); >+ } >+ >+ public void acceptAST(ICompilationUnit source, >+ CompilationUnit astCompilationUnit) { >+ } >+ }, null); >+ } finally { >+ if (workingCopy != null) { >+ workingCopy.discardWorkingCopy(); >+ } >+ } >+ } >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=264443 >+ public void test0700() throws JavaModelException { >+ ICompilationUnit workingCopy = null; >+ try { >+ workingCopy = getWorkingCopy("/Converter/src/example/Test.java", true/*resolve*/); >+ String contents = >+ "package example;\n" + >+ "import java.io.IOException;\n" + >+ "public class Test {\n" + >+ " public void test() throws IOException, RuntimeException {\n" + >+ " B /*start*/b = new B()/*end*/;\n" + >+ " }\n" + >+ "}"; >+ >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) buildAST(contents, workingCopy, false, true, true); >+ IVariableBinding variableBinding = fragment.resolveBinding(); >+ final String key = variableBinding.getKey(); >+ ASTParser parser = ASTParser.newParser(AST.JLS3); >+ parser.setProject(workingCopy.getJavaProject()); >+ parser.setResolveBindings(true); >+ parser.setKind(ASTParser.K_COMPILATION_UNIT); >+ >+ parser.createASTs( >+ new ICompilationUnit[] { workingCopy }, >+ new String[] { key }, >+ new ASTRequestor() { >+ public void acceptBinding(String bindingKey, >+ IBinding binding) { >+ assertEquals("Wrong key", key, bindingKey); >+ assertTrue("Not a variable binding", binding.getKind() == IBinding.VARIABLE); >+ } >+ >+ public void acceptAST(ICompilationUnit source, >+ CompilationUnit astCompilationUnit) { >+ } >+ }, null); >+ } finally { >+ if (workingCopy != null) { >+ workingCopy.discardWorkingCopy(); >+ } >+ } >+ } >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=264443 >+ //no thrown exceptions >+ public void test0701() throws JavaModelException { >+ ICompilationUnit workingCopy = null; >+ try { >+ workingCopy = getWorkingCopy("/Converter/src/example/Test.java", true/*resolve*/); >+ String contents = >+ "package example;\n" + >+ "import java.io.IOException;\n" + >+ "public class Test {\n" + >+ " public void test() {\n" + >+ " B /*start*/b = new B()/*end*/;\n" + >+ " }\n" + >+ "}"; >+ >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) buildAST(contents, workingCopy, false, true, true); >+ IVariableBinding variableBinding = fragment.resolveBinding(); >+ final String key = variableBinding.getKey(); >+ ASTParser parser = ASTParser.newParser(AST.JLS3); >+ parser.setProject(workingCopy.getJavaProject()); >+ parser.setResolveBindings(true); >+ parser.setKind(ASTParser.K_COMPILATION_UNIT); >+ >+ parser.createASTs( >+ new ICompilationUnit[] { workingCopy }, >+ new String[] { key }, >+ new ASTRequestor() { >+ public void acceptBinding(String bindingKey, >+ IBinding binding) { >+ assertEquals("Wrong key", key, bindingKey); >+ assertTrue("Not a variable binding", binding.getKind() == IBinding.VARIABLE); >+ } >+ >+ public void acceptAST(ICompilationUnit source, >+ CompilationUnit astCompilationUnit) { >+ } >+ }, null); >+ } finally { >+ if (workingCopy != null) { >+ workingCopy.discardWorkingCopy(); >+ } >+ } >+ } > } >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/util/BindingKeyParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BindingKeyParser.java,v >retrieving revision 1.38 >diff -u -r1.38 BindingKeyParser.java >--- model/org/eclipse/jdt/internal/core/util/BindingKeyParser.java 22 Jan 2009 11:22:55 -0000 1.38 >+++ model/org/eclipse/jdt/internal/core/util/BindingKeyParser.java 11 Feb 2009 16:01:32 -0000 >@@ -743,10 +743,10 @@ > } > > private void parseLocalVariable() { >- if (this.scanner.nextToken() != Scanner.LOCAL_VAR) { >- malformedKey(); >+ if (this.scanner.nextToken() != Scanner.LOCAL_VAR) { >+ malformedKey(); > return; >- } >+ } > char[] varName = this.scanner.getTokenSource(); > if (Character.isDigit(varName[0])) { > int index = Integer.parseInt(new String(varName)); >@@ -759,34 +759,40 @@ > } else { > int occurrenceCount = 0; > if (this.scanner.isAtLocalVariableStart()) { >- if (this.scanner.nextToken() != Scanner.LOCAL_VAR) { >- malformedKey(); >+ if (this.scanner.nextToken() != Scanner.LOCAL_VAR) { >+ malformedKey(); > return; >- } >+ } > char[] occurrence = this.scanner.getTokenSource(); > occurrenceCount = Integer.parseInt(new String(occurrence)); > } >- consumeLocalVar(varName, occurrenceCount); >+ consumeLocalVar(varName, occurrenceCount); > } >- } >+ } > > private void parseMethod() { >- char[] selector = this.scanner.getTokenSource(); >- this.scanner.skipMethodSignature(); >- char[] signature = this.scanner.getTokenSource(); >- consumeMethod(selector, signature); >- if (this.scanner.isAtThrownStart()) { >+ char[] selector = this.scanner.getTokenSource(); >+ this.scanner.skipMethodSignature(); >+ char[] signature = this.scanner.getTokenSource(); >+ consumeMethod(selector, signature); >+ if (this.scanner.isAtThrownStart()) { > parseThrownExceptions(); >- } >+ } > if (this.scanner.isAtParametersStart()) > parseParameterizedMethod(); > } > > private void parseAnnotation() { >+ /* >+ * The call parser.parse() might have a side-effect on the current token type >+ * See bug 264443 >+ */ >+ int token = this.scanner.token; > BindingKeyParser parser = newParser(); > parser.parse(); > consumeParser(parser); > consumeAnnotation(); >+ this.scanner.token = token; > } > > private void parseCapture() { >@@ -803,9 +809,15 @@ > } > > private void parseCaptureWildcard() { >+ /* >+ * The call parser.parse() might have a side-effect on the current token type >+ * See bug 264443 >+ */ >+ int token = this.scanner.token; > BindingKeyParser parser = newParser(); > parser.parse(); > consumeParser(parser); >+ this.scanner.token = token; > } > > private void parseField() { >@@ -815,6 +827,11 @@ > } > > private void parseThrownExceptions() { >+ /* >+ * The call parser.parse() might have a side-effect on the current token type >+ * See bug 264443 >+ */ >+ int token = this.scanner.token; > while (this.scanner.isAtThrownStart()) { > this.scanner.skipThrownStart(); > BindingKeyParser parser = newParser(); >@@ -822,6 +839,7 @@ > consumeParser(parser); > consumeException(); > } >+ this.scanner.token = token; > } > > private void parseParameterizedType(char[] typeName, boolean isRaw) { >@@ -860,9 +878,15 @@ > > private void parseReturnType() { > this.scanner.index++; // skip ')' >+ /* >+ * The call parser.parse() might have a side-effect on the current token type >+ * See bug 264443 >+ */ >+ int token = this.scanner.token; > BindingKeyParser parser = newParser(); > parser.parse(); > consumeParser(parser); >+ this.scanner.token = token; > } > > private void parseSecondaryType() { >@@ -871,17 +895,29 @@ > } > > private void parseTypeArgument() { >+ /* >+ * The call parser.parse() might have a side-effect on the current token type >+ * See bug 264443 >+ */ >+ int token = this.scanner.token; > BindingKeyParser parser = newParser(); > parser.parse(); > consumeParser(parser); >+ this.scanner.token = token; > } > > private void parseTypeWithCapture() { > if (this.scanner.nextToken() != Scanner.CAPTURE) return; >+ /* >+ * The call parser.parse() might have a side-effect on the current token type >+ * See bug 264443 >+ */ >+ int token = this.scanner.token; > BindingKeyParser parser = newParser(); > parser.parse(); > consumeParser(parser); > consumeTypeWithCapture(); >+ this.scanner.token = token; > } > > private void parseTypeVariable() { >@@ -941,9 +977,15 @@ > } > > private void parseWildcardBound() { >+ /* >+ * The call parser.parse() might have a side-effect on the current token type >+ * See bug 264443 >+ */ >+ int token = this.scanner.token; > BindingKeyParser parser = newParser(); > parser.parse(); > consumeParser(parser); >+ this.scanner.token = token; > } > > }
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 264443
: 125400