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 44997 Details for
Bug 147877
source end of array access isn't correct
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
patch001.txt (text/plain), 7.71 KB, created by
David Audel
on 2006-06-21 10:29:10 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
David Audel
Created:
2006-06-21 10:29:10 EDT
Size:
7.71 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v >retrieving revision 1.346 >diff -u -r1.346 Parser.java >--- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 29 Mar 2006 02:47:34 -0000 1.346 >+++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 21 Jun 2006 14:30:14 -0000 >@@ -1369,7 +1369,7 @@ > this.expressionStack[this.expressionPtr], > this.expressionStack[this.expressionPtr + 1]); > } >- exp.sourceEnd = this.endPosition; >+ exp.sourceEnd = this.endStatementPosition; > } > protected void consumeArrayCreationExpressionWithInitializer() { > // ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer >@@ -1392,7 +1392,7 @@ > length); > arrayAllocation.sourceStart = this.intStack[this.intPtr--]; > if (arrayAllocation.initializer == null) { >- arrayAllocation.sourceEnd = this.endPosition; >+ arrayAllocation.sourceEnd = this.endStatementPosition; > } else { > arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ; > } >@@ -1416,7 +1416,7 @@ > length); > arrayAllocation.sourceStart = this.intStack[this.intPtr--]; > if (arrayAllocation.initializer == null) { >- arrayAllocation.sourceEnd = this.endPosition; >+ arrayAllocation.sourceEnd = this.endStatementPosition; > } else { > arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ; > } >#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.96 >diff -u -r1.96 ASTConverterTestAST3_2.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 8 Jun 2006 13:09:33 -0000 1.96 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 21 Jun 2006 14:30:22 -0000 >@@ -7801,5 +7801,149 @@ > if (workingCopy != null) > workingCopy.discardWorkingCopy(); > } >- } >+ } >+ >+ /** >+ * http://dev.eclipse.org/bugs/show_bug.cgi?id=147877 >+ */ >+ public void test0648() throws JavaModelException { >+ ICompilationUnit workingCopy = null; >+ try { >+ String contents = >+ "public class X {\n" + >+ " public void foo(int[] a) {\n" + >+ " int i = a[0];\n" + >+ " }\n" + >+ "}"; >+ workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/); >+ ASTNode node = buildAST( >+ contents, >+ workingCopy, >+ false, >+ 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 vaviable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) node; >+ List fragments = statement.fragments(); >+ assertEquals("Wrong size", 1, fragments.size()); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ Expression expression = fragment.getInitializer(); >+ assertNotNull("No initializer", expression); >+ checkSourceRange(expression, "a[0]", contents); >+ } finally { >+ if (workingCopy != null) >+ workingCopy.discardWorkingCopy(); >+ } >+ } >+ >+ /** >+ * http://dev.eclipse.org/bugs/show_bug.cgi?id=147877 >+ */ >+ public void test0649() throws JavaModelException { >+ ICompilationUnit workingCopy = null; >+ try { >+ String contents = >+ "public class X {\n" + >+ " public void foo(int[] a) {\n" + >+ " int i = a[0\\u005D;\n" + >+ " }\n" + >+ "}"; >+ workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/); >+ ASTNode node = buildAST( >+ contents, >+ workingCopy, >+ false, >+ 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 vaviable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) node; >+ List fragments = statement.fragments(); >+ assertEquals("Wrong size", 1, fragments.size()); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ Expression expression = fragment.getInitializer(); >+ assertNotNull("No initializer", expression); >+ checkSourceRange(expression, "a[0\\u005D", contents); >+ } finally { >+ if (workingCopy != null) >+ workingCopy.discardWorkingCopy(); >+ } >+ } >+ >+ /** >+ * http://dev.eclipse.org/bugs/show_bug.cgi?id=147877 >+ */ >+ public void test0650() throws JavaModelException { >+ ICompilationUnit workingCopy = null; >+ try { >+ String contents = >+ "public class X {\n" + >+ " public void foo(int[] a) {\n" + >+ " int[] i = new int[0];\n" + >+ " }\n" + >+ "}"; >+ workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/); >+ ASTNode node = buildAST( >+ contents, >+ workingCopy, >+ false, >+ 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 vaviable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) node; >+ List fragments = statement.fragments(); >+ assertEquals("Wrong size", 1, fragments.size()); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ Expression expression = fragment.getInitializer(); >+ assertNotNull("No initializer", expression); >+ checkSourceRange(expression, "new int[0]", contents); >+ } finally { >+ if (workingCopy != null) >+ workingCopy.discardWorkingCopy(); >+ } >+ } >+ >+ /** >+ * http://dev.eclipse.org/bugs/show_bug.cgi?id=147877 >+ */ >+ public void test0651() throws JavaModelException { >+ ICompilationUnit workingCopy = null; >+ try { >+ String contents = >+ "public class X {\n" + >+ " public void foo(int[] a) {\n" + >+ " int[] i = new int[0\\u005D;\n" + >+ " }\n" + >+ "}"; >+ workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/); >+ ASTNode node = buildAST( >+ contents, >+ workingCopy, >+ false, >+ 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 vaviable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); >+ VariableDeclarationStatement statement = (VariableDeclarationStatement) node; >+ List fragments = statement.fragments(); >+ assertEquals("Wrong size", 1, fragments.size()); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ Expression expression = fragment.getInitializer(); >+ assertNotNull("No initializer", expression); >+ checkSourceRange(expression, "new int[0\\u005D", contents); >+ } finally { >+ if (workingCopy != null) >+ workingCopy.discardWorkingCopy(); >+ } >+ } > } >\ No newline at end of file
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 147877
: 44997