### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java,v retrieving revision 1.60 diff -u -r1.60 DietRecoveryTest.java --- src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java 7 May 2009 08:49:32 -0000 1.60 +++ src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java 29 Jun 2009 10:00:18 -0000 @@ -7832,4 +7832,227 @@ expectedFullUnitToString, expectedCompletionDietUnitToString, testName); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=201762 +public void test127() { + String s = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "\n" + + "public class Try {\n" + + "\n" + + " void main(Shell shell) {\n" + + "\n" + + " final Label label= new Label(shell, SWT.WRAP);\n" + + " label.addPaintListener(new PaintListener() {\n" + + " public void paintControl(PaintEvent e) {\n" + + " e.gc.setLineCap(SWT.CAP_); // content assist after CAP_\n" + + " }\n" + + " });\n" + + "\n" + + " shell.addControlListener(new ControlAdapter() { });\n" + + "\n" + + " while (!shell.isDisposed()) { }\n" + + " }\n" + + "}\n" + + "\n"; + + String expectedDietUnitToString = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "public class Try {\n" + + " public Try() {\n" + + " }\n" + + " void main(Shell shell) {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "public class Try {\n" + + " public Try() {\n" + + " super();\n" + + " }\n" + + " void main(Shell shell) {\n" + + " final Label label = new Label(shell, SWT.WRAP);\n" + + " label.addPaintListener(new PaintListener() {\n" + + " public void paintControl(PaintEvent e) {\n" + + " e.gc.setLineCap(SWT.CAP_);\n" + + " }\n" + + "});\n" + + " shell.addControlListener(new ControlAdapter() {\n" + + "});\n" + + " while ((! shell.isDisposed())) {\n" + + " }\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyPlusStatementsRecoveryUnitToString = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "public class Try {\n" + + " public Try() {\n" + + " super();\n" + + " }\n" + + " void main(Shell shell) {\n" + + " final Label label = new Label(shell, SWT.WRAP);\n" + + " label.addPaintListener(new PaintListener() {\n" + + " public void paintControl(PaintEvent e) {\n" + + " e.gc.setLineCap(SWT.CAP_);\n" + + " }\n" + + "});\n" + + " shell.addControlListener(new ControlAdapter() {\n" + + "});\n" + + " while ((! shell.isDisposed())) {\n" + + " }\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "public class Try {\n" + + " public Try() {\n" + + " super();\n" + + " }\n" + + " void main(Shell shell) {\n" + + " final Label label = new Label(shell, SWT.WRAP);\n" + + " label.addPaintListener(new PaintListener() {\n" + + " public void paintControl(PaintEvent e) {\n" + + " e.gc.setLineCap(SWT.CAP_);\n" + + " }\n" + + "});\n" + + " shell.addControlListener(new ControlAdapter() {\n" + + "});\n" + + " while ((! shell.isDisposed())) {\n" + + " }\n" + + " }\n" + + "}\n"; + + String expectedCompletionDietUnitToString = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "public class Try {\n" + + " public Try() {\n" + + " }\n" + + " void main(Shell shell) {\n" + + " }\n" + + "}\n"; + + String testName = "test"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedDietPlusBodyPlusStatementsRecoveryUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, testName); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=201762 +public void test128() { + String s = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "\n" + + "public class Try {\n" + + "\n" + + " void main(Shell shell) {\n" + + "\n" + + " final Label label= new Label(shell, SWT.WRAP);\n" + + " label.addPaintListener(new PaintListener() {\n" + + " public void paintControl(PaintEvent e) {\n" + + " e.gc.setLineCap(SWT.CAP_#); // content assist after CAP_\n" + + " }\n" + + " });\n" + + "\n" + + " shell.addControlListener(new ControlAdapter() { });\n" + + "\n" + + " while (!shell.isDisposed()) { }\n" + + " }\n" + + "}\n" + + "\n"; + + String expectedDietUnitToString = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "public class Try {\n" + + " public Try() {\n" + + " }\n" + + " void main(Shell shell) {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "public class Try {\n" + + " public Try() {\n" + + " super();\n" + + " }\n" + + " void main(Shell shell) {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyPlusStatementsRecoveryUnitToString = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "public class Try {\n" + + " public Try() {\n" + + " super();\n" + + " }\n" + + " void main(Shell shell) {\n" + + " final Label label = new Label(shell, SWT.WRAP);\n" + + " label.addPaintListener(new PaintListener() {\n" + + " public void paintControl(PaintEvent e) {\n" + + " e.gc.setLineCap(SWT.CAP_);\n" + + " }\n" + + "});\n" + + " shell.addControlListener(new ControlAdapter() {\n" + + "});\n" + + " while ((! shell.isDisposed())) {\n" + + " }\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "public class Try {\n" + + " public Try() {\n" + + " }\n" + + " void main(Shell shell) {\n" + + " }\n" + + "}\n"; + + String expectedCompletionDietUnitToString = + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "public class Try {\n" + + " public Try() {\n" + + " }\n" + + " void main(Shell shell) {\n" + + " }\n" + + "}\n"; + + String testName = "test"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedDietPlusBodyPlusStatementsRecoveryUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, testName); +} } Index: src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java,v retrieving revision 1.19 diff -u -r1.19 CompletionRecoveryTest.java --- src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java 28 Apr 2009 17:17:28 -0000 1.19 +++ src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java 29 Jun 2009 10:00:17 -0000 @@ -1028,4 +1028,59 @@ "" ); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=201762 +public void test26() { + this.runTestCheckMethodParse( + // compilationUnit: + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "\n" + + "public class Try {\n" + + "\n" + + " void main(Shell shell) {\n" + + "\n" + + " final Label label= new Label(shell, SWT.WRAP);\n" + + " label.addPaintListener(new PaintListener() {\n" + + " public void paintControl(PaintEvent e) {\n" + + " e.gc.setLineCap(SWT.CAP_); // content assist after CAP_\n" + + " }\n" + + " });\n" + + "\n" + + " shell.addControlListener(new ControlAdapter() { });\n" + + "\n" + + " while (!shell.isDisposed()) { }\n" + + " }\n" + + "}\n" + + "\n", + // completeBehind: + "SWT.CAP_", + // expectedCompletionNodeToString: + "", + // expectedUnitDisplayString: + "import org.eclipse.swt.*;\n" + + "import org.eclipse.swt.events.*;\n" + + "import org.eclipse.swt.widgets.*;\n" + + "public class Try {\n" + + " public Try() {\n" + + " }\n" + + " void main(Shell shell) {\n" + + " final Label label;\n" + + " new PaintListener() {\n" + + " public void paintControl(PaintEvent e) {\n" + + " e.gc.setLineCap();\n" + + " }\n" + + " };\n" + + " new ControlAdapter() {\n" + + " };\n" + + " }\n" + + "}\n", + // expectedCompletionIdentifier: + "CAP_", + // expectedReplacedSource: + "SWT.CAP_", + // test name + "" + ); +} } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java,v retrieving revision 1.27 diff -u -r1.27 RecoveredStatement.java --- compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java 16 Apr 2009 13:34:36 -0000 1.27 +++ compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java 29 Jun 2009 10:00:20 -0000 @@ -54,4 +54,11 @@ if (this.statement.sourceEnd == 0) this.statement.sourceEnd = bodyEnd; } +public RecoveredElement updateOnClosingBrace(int braceStart, int braceEnd){ + if ((--this.bracketBalance <= 0) && (this.parent != null)){ + this.updateSourceEndIfNecessary(braceStart, braceEnd); + return this.parent.updateOnClosingBrace(braceStart, braceEnd); + } + return this; +} } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java,v retrieving revision 1.204 diff -u -r1.204 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 24 Jun 2009 07:55:11 -0000 1.204 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 29 Jun 2009 10:00:26 -0000 @@ -20219,4 +20219,100 @@ requestor.getResults()); } +public void test201762() throws JavaModelException { + this.workingCopies = new ICompilationUnit[8]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test201762.java", + "import test.ControlAdapter;\n" + + "import test.Label;\n" + + "import test.PaintEvent;\n" + + "import test.PaintListener;\n" + + "import test.SWT;\n" + + "import test.Shell;\n" + + "\n" + + "public class Test201762 {\n" + + "\n" + + " void main(Shell shell) {\n" + + "\n" + + " final Label label= new Label(shell, SWT.WRAP);\n" + + " label.addPaintListener(new PaintListener() {\n" + + " public void paintControl(PaintEvent e) {\n" + + " e.gc.setLineCap(SWT.CAP_); // content assist after CAP_\n" + + " }\n" + + " });\n" + + "\n" + + " shell.addControlListener(new ControlAdapter() { });\n" + + "\n" + + " while (!shell.isDisposed()) { }\n" + + " }\n" + + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/AnObject.java", + "package test;\n" + + "public class AnObject {\n" + + " public void setLineCap(int capZz) {}\n" + + "}\n"); + + this.workingCopies[2] = getWorkingCopy( + "/Completion/src/test/ControlAdapter.java", + "package test;\n" + + "public class ControlAdapter {\n" + + "}\n"); + + this.workingCopies[3] = getWorkingCopy( + "/Completion/src/test/Label.java", + "package test;\n" + + "public class Label {\n" + + " public Label(Shell shell, int wrap) {\n" + + " }\n" + + " public void addPaintListener(PaintListener paintListener) {\n" + + " }\n" + + "}\n"); + + this.workingCopies[4] = getWorkingCopy( + "/Completion/src/test/Label.java", + "package test;\n" + + "public class PaintEvent {\n" + + " public AnObject gc;\n" + + "}\n"); + + this.workingCopies[5] = getWorkingCopy( + "/Completion/src/test/PaintListener.java", + "package test;\n" + + "public interface PaintListener {\n" + + "}\n"); + + this.workingCopies[6] = getWorkingCopy( + "/Completion/src/test/Shell.java", + "package test;\n" + + "public class Shell {\n" + + " public boolean isDisposed() {\n" + + " return false;\n" + + " }\n" + + " public void addControlListener(ControlAdapter controlAdapter) {\n" + + " }\n" + + "}\n"); + + this.workingCopies[7] = getWorkingCopy( + "/Completion/src/test/SWT.java", + "package test;\n" + + "public interface SWT {\n" + + " int WRAP = 0;\n" + + " int CAP_ZZ = 0;\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); + String str = this.workingCopies[0].getSource(); + String completeBehind = "SWT.CAP_"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + assertResults( + "CAP_ZZ[FIELD_REF]{CAP_ZZ, Ltest.SWT;, I, CAP_ZZ, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_INHERITED + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} + + + }