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 29313 Details for
Bug 114909
AST: String concatenation represented as single node
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Regression test
114909_org.eclipse.jdt.core.tests.model.txt (text/plain), 5.52 KB, created by
Jerome Lanneluc
on 2005-11-04 04:29:06 EST
(
hide
)
Description:
Regression test
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2005-11-04 04:29:06 EST
Size:
5.52 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java,v >retrieving revision 1.159 >diff -u -r1.159 ASTConverterTest2.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 25 Aug 2005 11:13:49 -0000 1.159 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 4 Nov 2005 09:29:14 -0000 >@@ -42,7 +42,7 @@ > } > > static { >-// TESTS_NAMES = new String[] {"test0576"}; >+// TESTS_NAMES = new String[] {"test0577"}; > // TESTS_NUMBERS = new int[] { 606 }; > } > public static Test suite() { >@@ -5366,6 +5366,28 @@ > } > } > >+ /* >+ * Ensures that strings are not optimized when creating the AST through a reconcile >+ * even if the working copy was consistent. >+ * (regression test for bug 114909 AST: String concatenation represented as single node) >+ */ >+ public void test0577() throws CoreException { >+ ICompilationUnit workingCopy = null; >+ try { >+ workingCopy = getWorkingCopy( >+ "/Converter/src/X.java", >+ "public class X {\n" + >+ " String s = /*start*/\"a\" + \"b\"/*end*/;\n" + >+ "}", >+ true/*resolve*/); >+ ASTNode string = buildAST(workingCopy); >+ assertEquals("Unexpected node type", ASTNode.INFIX_EXPRESSION, string.getNodeType()); >+ } finally { >+ if (workingCopy != null) >+ workingCopy.discardWorkingCopy(); >+ } >+ } >+ > public void test0606() throws JavaModelException { > ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0606", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ > ASTNode result = runConversion(sourceUnit, true); >Index: src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java,v >retrieving revision 1.21 >diff -u -r1.21 AbstractASTTests.java >--- src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java 24 Aug 2005 15:02:59 -0000 1.21 >+++ src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java 4 Nov 2005 09:29:14 -0000 >@@ -240,13 +240,17 @@ > > return findNode(unit, markerInfo); > } >+ >+ protected ASTNode buildAST(ICompilationUnit cu) throws JavaModelException { >+ return buildAST(null/*use existing contenst*/, cu, true/*report errors*/); >+ } > >- protected ASTNode buildAST(String contents, ICompilationUnit cu) throws JavaModelException { >- return buildAST(contents, cu, true); >+ protected ASTNode buildAST(String newContents, ICompilationUnit cu) throws JavaModelException { >+ return buildAST(newContents, cu, true/*report errors*/); > } > > protected ASTNode buildAST(MarkerInfo markerInfo, IClassFile classFile) throws JavaModelException { >- return buildAST(markerInfo, classFile, true); >+ return buildAST(markerInfo, classFile, true/*report errors*/); > } > > /* >@@ -254,8 +258,8 @@ > * builds an AST from the resulting source, and returns the AST node that was delimited > * by "*start*" and "*end*". > */ >- protected ASTNode buildAST(String contents, ICompilationUnit cu, boolean reportErrors) throws JavaModelException { >- ASTNode[] nodes = buildASTs(contents, cu, reportErrors); >+ protected ASTNode buildAST(String newContents, ICompilationUnit cu, boolean reportErrors) throws JavaModelException { >+ ASTNode[] nodes = buildASTs(newContents, cu, reportErrors); > if (nodes.length == 0) return null; > return nodes[0]; > } >@@ -265,19 +269,26 @@ > } > > /* >- * Removes the marker comments "*start?*" and "*end?*" from the given contents >- * (where ? is either empty or a number). >+ * Removes the marker comments "*start?*" and "*end?*" from the given new contents >+ * (where ? is either empty or a number), or use the current contents if the given new contents is null. > * Builds an AST from the resulting source. > * For each of the pairs, returns the AST node that was delimited by "*start?*" and "*end?*". > */ >- protected ASTNode[] buildASTs(String contents, ICompilationUnit cu, boolean reportErrors) throws JavaModelException { >- MarkerInfo markerInfo = new MarkerInfo(contents); >- contents = markerInfo.source; >- >- cu.getBuffer().setContents(contents); >+ protected ASTNode[] buildASTs(String newContents, ICompilationUnit cu, boolean reportErrors) throws JavaModelException { >+ MarkerInfo markerInfo; >+ if (newContents == null) { >+ markerInfo = new MarkerInfo(cu.getSource()); >+ newContents = markerInfo.source; >+ cu.getBuffer().setContents(newContents); >+ cu.makeConsistent(null); >+ } else { >+ markerInfo = new MarkerInfo(newContents); >+ newContents = markerInfo.source; >+ cu.getBuffer().setContents(newContents); >+ } > CompilationUnit unit; > if (cu.isWorkingCopy()) >- unit = cu.reconcile(AST.JLS3, false, null, null); >+ unit = cu.reconcile(AST.JLS3, reportErrors, null, null); > else { > ASTParser parser = ASTParser.newParser(AST.JLS3); > parser.setSource(cu); >@@ -289,7 +300,7 @@ > StringBuffer buffer = new StringBuffer(); > IProblem[] problems = unit.getProblems(); > for (int i = 0, length = problems.length; i < length; i++) >- Util.appendProblem(buffer, problems[i], contents.toCharArray(), i+1); >+ Util.appendProblem(buffer, problems[i], newContents.toCharArray(), i+1); > if (buffer.length() > 0) > System.err.println(buffer.toString()); > }
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 114909
:
29274
| 29313