Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2010-05-18 23:02:00 +0000
committerStephan Herrmann2010-05-18 23:02:00 +0000
commit0c85cd2e0525cfa4f584128d13a05a0cdf4d814f (patch)
treecf39cf4c96df443bfe8f3552acf1c38e6a967c17 /testplugins
parent32cb6da48f218fc50a22c4ae03c2dd7c21e60818 (diff)
downloadorg.eclipse.objectteams-0c85cd2e0525cfa4f584128d13a05a0cdf4d814f.tar.gz
org.eclipse.objectteams-0c85cd2e0525cfa4f584128d13a05a0cdf4d814f.tar.xz
org.eclipse.objectteams-0c85cd2e0525cfa4f584128d13a05a0cdf4d814f.zip
update jdt.ui tests to v20100513-0800 for 3.6RC1.
Diffstat (limited to 'testplugins')
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java8
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java58
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest.java357
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java76
4 files changed, 476 insertions, 23 deletions
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java
index 0b807c21b..d0b14b850 100644
--- a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,6 +16,7 @@ import junit.framework.Test;
import org.eclipse.jdt.testplugin.OrderedTestSuite;
import org.eclipse.jdt.testplugin.util.DisplayHelper;
import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.Performance;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
@@ -95,6 +96,7 @@ public class OpenTypePerfTest extends JdtPerformanceTestCase {
public void testColdException() throws Exception {
//cold
+ joinBackgroudActivities();
try {
measureOpenType("*Exception");
} finally {
@@ -110,7 +112,7 @@ public class OpenTypePerfTest extends JdtPerformanceTestCase {
measureOpenType("*Exception");
} finally {
commitMeasurements();
- assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10);
+ Performance.getDefault().assertPerformanceInAbsoluteBand(fPerformanceMeter, Dimension.ELAPSED_PROCESS, 0, 500);
}
}
@@ -147,7 +149,7 @@ public class OpenTypePerfTest extends JdtPerformanceTestCase {
measureOpenType("SWT", true);
} finally {
commitMeasurements();
- assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10);
+ Performance.getDefault().assertPerformanceInAbsoluteBand(fPerformanceMeter, Dimension.ELAPSED_PROCESS, 0, 500);
}
}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java
index 32d001393..e38fd3d54 100644
--- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java
+++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java
@@ -6559,7 +6559,7 @@ public class LocalCorrectionsQuickFixTest extends QuickFixTest {
ArrayList proposals= collectCorrections(cu, astRoot);
assertCorrectLabels(proposals);
- assertNumberOfProposals(proposals, 3);
+ assertNumberOfProposals(proposals, 4);
String[] expected= new String[1];
buf= new StringBuffer();
@@ -6599,7 +6599,7 @@ public class LocalCorrectionsQuickFixTest extends QuickFixTest {
ArrayList proposals= collectCorrections(cu, astRoot);
assertCorrectLabels(proposals);
- assertNumberOfProposals(proposals, 3);
+ assertNumberOfProposals(proposals, 4);
String[] expected= new String[1];
buf= new StringBuffer();
@@ -6783,16 +6783,16 @@ public class LocalCorrectionsQuickFixTest extends QuickFixTest {
ArrayList proposals= collectCorrections(cu, astRoot, 1);
assertCorrectLabels(proposals);
- assertNumberOfProposals(proposals, 3);
+ assertNumberOfProposals(proposals, 4);
- String[] expected= new String[2];
+ String[] expected= new String[3];
buf= new StringBuffer();
buf.append("package pack;\n");
buf.append("import java.util.List;\n");
buf.append("public class E {\n");
- buf.append(" @SuppressWarnings(\"rawtypes\")\n");
buf.append(" public void test() {\n");
+ buf.append(" @SuppressWarnings(\"rawtypes\")\n");
buf.append(" List l;\n");
buf.append(" }\n");
buf.append("}\n");
@@ -6802,12 +6802,23 @@ public class LocalCorrectionsQuickFixTest extends QuickFixTest {
buf.append("package pack;\n");
buf.append("import java.util.List;\n");
buf.append("public class E {\n");
+ buf.append(" @SuppressWarnings(\"rawtypes\")\n");
buf.append(" public void test() {\n");
- buf.append(" List<?> l;\n");
+ buf.append(" List l;\n");
buf.append(" }\n");
buf.append("}\n");
expected[1]= buf.toString();
+ buf= new StringBuffer();
+ buf.append("package pack;\n");
+ buf.append("import java.util.List;\n");
+ buf.append("public class E {\n");
+ buf.append(" public void test() {\n");
+ buf.append(" List<?> l;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ expected[2]= buf.toString();
+
assertExpectedExistInProposals(proposals, expected);
}
@@ -6831,16 +6842,16 @@ public class LocalCorrectionsQuickFixTest extends QuickFixTest {
ArrayList proposals= collectCorrections(cu, astRoot, 1);
assertCorrectLabels(proposals);
- assertNumberOfProposals(proposals, 3);
+ assertNumberOfProposals(proposals, 4);
- String[] expected= new String[2];
+ String[] expected= new String[3];
buf= new StringBuffer();
buf.append("package pack;\n");
buf.append("public class E {\n");
buf.append(" private class E1<P1, P2> {}\n");
- buf.append(" @SuppressWarnings(\"rawtypes\")\n");
buf.append(" public void test() {\n");
+ buf.append(" @SuppressWarnings(\"rawtypes\")\n");
buf.append(" E1 e1;\n");
buf.append(" }\n");
buf.append("}\n");
@@ -6850,12 +6861,23 @@ public class LocalCorrectionsQuickFixTest extends QuickFixTest {
buf.append("package pack;\n");
buf.append("public class E {\n");
buf.append(" private class E1<P1, P2> {}\n");
+ buf.append(" @SuppressWarnings(\"rawtypes\")\n");
buf.append(" public void test() {\n");
- buf.append(" E1<?, ?> e1;\n");
+ buf.append(" E1 e1;\n");
buf.append(" }\n");
buf.append("}\n");
expected[1]= buf.toString();
+ buf= new StringBuffer();
+ buf.append("package pack;\n");
+ buf.append("public class E {\n");
+ buf.append(" private class E1<P1, P2> {}\n");
+ buf.append(" public void test() {\n");
+ buf.append(" E1<?, ?> e1;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ expected[2]= buf.toString();
+
assertExpectedExistInProposals(proposals, expected);
}
@@ -7227,10 +7249,20 @@ public class LocalCorrectionsQuickFixTest extends QuickFixTest {
CompilationUnit astRoot= getASTRoot(cu);
ArrayList proposals= collectCorrections(cu, astRoot);
- assertNumberOfProposals(proposals, 2);
+ assertNumberOfProposals(proposals, 3);
assertCorrectLabels(proposals);
- String[] expected= new String[1];
+ String[] expected= new String[2];
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("import java.util.List;\n");
+ buf.append("\n");
+ buf.append("public class E1 {\n");
+ buf.append(" public void foo(@SuppressWarnings(\"rawtypes\") List<List> list) {\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ expected[0]= buf.toString();
+
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.List;\n");
@@ -7240,7 +7272,7 @@ public class LocalCorrectionsQuickFixTest extends QuickFixTest {
buf.append(" public void foo(List<List> list) {\n");
buf.append(" }\n");
buf.append("}\n");
- expected[0]= buf.toString();
+ expected[1]= buf.toString();
assertExpectedExistInProposals(proposals, expected);
}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest.java
index 7064df2fb..19af55fb4 100644
--- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest.java
+++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -2538,8 +2538,17 @@ public class ModifierCorrectionsQuickFixTest extends QuickFixTest {
CompilationUnit astRoot= getASTRoot(cu);
ArrayList proposals= collectCorrections(cu, astRoot);
- assertNumberOfProposals(proposals, 3);
+ assertNumberOfProposals(proposals, 4);
assertCorrectLabels(proposals);
+ String[] expected= new String[2];
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" static {\n");
+ buf.append(" @SuppressWarnings({\"unused\", \"nls\"}) String str= \"foo\";");
+ buf.append(" }\n");
+ buf.append("}\n");
+ expected[0]= buf.toString();
buf= new StringBuffer();
buf.append("package test1;\n");
@@ -2549,7 +2558,8 @@ public class ModifierCorrectionsQuickFixTest extends QuickFixTest {
buf.append(" @SuppressWarnings(\"unused\") String str= \"foo\";");
buf.append(" }\n");
buf.append("}\n");
- assertExpectedExistInProposals(proposals, new String[] {buf.toString()});
+ expected[1]= buf.toString();
+ assertExpectedExistInProposals(proposals, expected);
}
public void testSuppressNLSWarningAnnotation2() throws Exception {
@@ -2577,8 +2587,8 @@ public class ModifierCorrectionsQuickFixTest extends QuickFixTest {
buf= new StringBuffer();
buf.append("package test1; \n");
buf.append("public class E {\n");
- buf.append(" @SuppressWarnings(\"nls\")\n");
buf.append(" private class Q {\n");
+ buf.append(" @SuppressWarnings(\"nls\")\n");
buf.append(" String s = \"\";\n");
buf.append(" }\n");
buf.append("}\n");
@@ -2607,8 +2617,8 @@ public class ModifierCorrectionsQuickFixTest extends QuickFixTest {
buf= new StringBuffer();
buf.append("package test1; \n");
- buf.append("@SuppressWarnings(\"nls\")\n");
buf.append("public class E {\n");
+ buf.append(" @SuppressWarnings(\"nls\")\n");
buf.append(" String s = \"\";\n");
buf.append("}\n");
assertExpectedExistInProposals(proposals, new String[] {buf.toString()});
@@ -2633,8 +2643,17 @@ public class ModifierCorrectionsQuickFixTest extends QuickFixTest {
CompilationUnit astRoot= getASTRoot(cu);
ArrayList proposals= collectCorrections(cu, astRoot);
- assertNumberOfProposals(proposals, 3);
+ assertNumberOfProposals(proposals, 4);
assertCorrectLabels(proposals);
+ String[] expected= new String[2];
+ buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("public class E {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" @SuppressWarnings({\"unused\", \"nls\"}) String s = \"\";\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ expected[0]= buf.toString();
buf= new StringBuffer();
buf.append("package test1; \n");
@@ -2644,7 +2663,8 @@ public class ModifierCorrectionsQuickFixTest extends QuickFixTest {
buf.append(" @SuppressWarnings(\"unused\") String s = \"\";\n");
buf.append(" }\n");
buf.append("}\n");
- assertExpectedExistInProposals(proposals, new String[] {buf.toString()});
+ expected[1]= buf.toString();
+ assertExpectedExistInProposals(proposals, expected);
}
public void testSuppressNLSWarningAnnotation5() throws Exception {
@@ -2688,6 +2708,329 @@ public class ModifierCorrectionsQuickFixTest extends QuickFixTest {
assertExpectedExistInProposals(proposals, expected);
}
+ public void testSuppressWarningsForLocalVariables() throws Exception {
+ Hashtable options= JavaCore.getOptions();
+ options.put(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.WARNING);
+ options.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.WARNING);
+ JavaCore.setOptions(options);
+
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.ArrayList;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" @SuppressWarnings(\"unused\")\n");
+ buf.append(" ArrayList localVar= new ArrayList();");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("A.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList proposals= collectCorrections(cu, astRoot, 2);
+
+ assertCorrectLabels(proposals);
+ assertNumberOfProposals(proposals, 4);
+ String[] expected= new String[2];
+ buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.ArrayList;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" @SuppressWarnings({\"unused\", \"rawtypes\"})\n");
+ buf.append(" ArrayList localVar= new ArrayList();");
+ buf.append(" }\n");
+ buf.append("}\n");
+ expected[0]= buf.toString();
+
+ buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.ArrayList;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" @SuppressWarnings(\"rawtypes\")\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" @SuppressWarnings(\"unused\")\n");
+ buf.append(" ArrayList localVar= new ArrayList();");
+ buf.append(" }\n");
+ buf.append("}\n");
+ expected[1]= buf.toString();
+
+ assertExpectedExistInProposals(proposals, expected);
+ }
+
+ public void testSuppressWarningsForFieldVariables() throws Exception {
+ Hashtable options= JavaCore.getOptions();
+ options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.WARNING);
+ JavaCore.setOptions(options);
+
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.*;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" List<String> myList = new ArrayList();\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("A.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList proposals= collectCorrections(cu, astRoot, 1);
+
+ assertCorrectLabels(proposals);
+ assertNumberOfProposals(proposals, 3);
+
+ String[] expected= new String[1];
+ buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.*;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" @SuppressWarnings(\"unchecked\")\n");
+ buf.append(" List<String> myList = new ArrayList();\n");
+ buf.append("}\n");
+ expected[0]= buf.toString();
+
+ assertExpectedExistInProposals(proposals, expected);
+ }
+
+ public void testSuppressWarningsForFieldVariables2() throws Exception {
+ Hashtable options= JavaCore.getOptions();
+ options.put(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.WARNING);
+ options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.WARNING);
+ JavaCore.setOptions(options);
+
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.ArrayList;\n");
+ buf.append("\n");
+ buf.append("class A {\n");
+ buf.append(" @SuppressWarnings(\"rawtypes\")\n");
+ buf.append(" ArrayList array;\n");
+ buf.append(" boolean a= array.add(1), b= array.add(1);\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("A.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList proposals= collectCorrections(cu, astRoot, 2);
+
+ assertCorrectLabels(proposals);
+ assertNumberOfProposals(proposals, 3);
+
+ String[] expected= new String[1];
+ buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.ArrayList;\n");
+ buf.append("\n");
+ buf.append("class A {\n");
+ buf.append(" @SuppressWarnings(\"rawtypes\")\n");
+ buf.append(" ArrayList array;\n");
+ buf.append(" @SuppressWarnings(\"unchecked\")\n");
+ buf.append(" boolean a= array.add(1), b= array.add(1);\n");
+ buf.append("}\n");
+ expected[0]= buf.toString();
+
+ assertExpectedExistInProposals(proposals, expected);
+
+ }
+
+ public void testSuppressWarningsForMethodParameters() throws Exception {
+ Hashtable options= JavaCore.getOptions();
+ options.put(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.WARNING);
+ JavaCore.setOptions(options);
+
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.*;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" public int foo(int param1, List param2) {\n");
+ buf.append(" return param1;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("A.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList proposals= collectCorrections(cu, astRoot, 1);
+
+ assertCorrectLabels(proposals);
+ assertNumberOfProposals(proposals, 4);
+ String[] expected= new String[2];
+ buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.*;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" public int foo(int param1, @SuppressWarnings(\"rawtypes\") List param2) {\n");
+ buf.append(" return param1;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ expected[0]= buf.toString();
+
+ buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.*;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" @SuppressWarnings(\"rawtypes\")\n");
+ buf.append(" public int foo(int param1, List param2) {\n");
+ buf.append(" return param1;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ expected[1]= buf.toString();
+ assertExpectedExistInProposals(proposals, expected);
+
+ }
+
+ public void testSuppressWarningsAnonymousClass1() throws Exception {
+ Hashtable options= JavaCore.getOptions();
+ options.put(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.WARNING);
+ JavaCore.setOptions(options);
+
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.*;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" @SuppressWarnings(\"unused\")\n");
+ buf.append(" final Object object = new Object() {\n");
+ buf.append(" {\n");
+ buf.append(" for (List l = new ArrayList(), x = new Vector();;) {\n");
+ buf.append(" if (l == x)\n");
+ buf.append(" break;\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append(" };\n");
+ buf.append(" };\n");
+ buf.append("};\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("A.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList proposals= collectCorrections(cu, astRoot, 3);
+
+ assertCorrectLabels(proposals);
+ assertNumberOfProposals(proposals, 5);
+ String[] expected= new String[3];
+
+ buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.*;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" @SuppressWarnings(\"unused\")\n");
+ buf.append(" final Object object = new Object() {\n");
+ buf.append(" {\n");
+ buf.append(" for (@SuppressWarnings(\"rawtypes\")\n");
+ buf.append(" List l = new ArrayList(), x = new Vector();;) {\n");
+ buf.append(" if (l == x)\n");
+ buf.append(" break;\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append(" };\n");
+ buf.append(" };\n");
+ buf.append("};\n");
+ expected[0]= buf.toString();
+
+ buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.*;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" @SuppressWarnings({\"unused\", \"rawtypes\"})\n");
+ buf.append(" final Object object = new Object() {\n");
+ buf.append(" {\n");
+ buf.append(" for (List l = new ArrayList(), x = new Vector();;) {\n");
+ buf.append(" if (l == x)\n");
+ buf.append(" break;\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append(" };\n");
+ buf.append(" };\n");
+ buf.append("};\n");
+ expected[1]= buf.toString();
+
+ buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.*;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" @SuppressWarnings(\"rawtypes\")\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" @SuppressWarnings(\"unused\")\n");
+ buf.append(" final Object object = new Object() {\n");
+ buf.append(" {\n");
+ buf.append(" for (List l = new ArrayList(), x = new Vector();;) {\n");
+ buf.append(" if (l == x)\n");
+ buf.append(" break;\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append(" };\n");
+ buf.append(" };\n");
+ buf.append("};\n");
+ expected[1]= buf.toString();
+
+ assertExpectedExistInProposals(proposals, expected);
+ }
+
+ public void testSuppressWarningsAnonymousClass2() throws Exception {
+ Hashtable options= JavaCore.getOptions();
+ options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.WARNING);
+ JavaCore.setOptions(options);
+
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.*;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" final Runnable r= new Runnable() {\n");
+ buf.append(" public void run() {\n");
+ buf.append(" boolean b;\n");
+ buf.append(" for (b = new ArrayList().add(1);;) {\n");
+ buf.append(" if (b)\n");
+ buf.append(" return;\n");
+ buf.append(" break;\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append(" };\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("A.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList proposals= collectCorrections(cu, astRoot, 1);
+
+ assertCorrectLabels(proposals);
+ assertNumberOfProposals(proposals, 2);
+ String[] expected= new String[1];
+ buf= new StringBuffer();
+ buf.append("package test1; \n");
+ buf.append("import java.util.*;\n");
+ buf.append("\n");
+ buf.append("public class A {\n");
+ buf.append(" final Runnable r= new Runnable() {\n");
+ buf.append(" @SuppressWarnings(\"unchecked\")\n");
+ buf.append(" public void run() {\n");
+ buf.append(" boolean b;\n");
+ buf.append(" for (b = new ArrayList().add(1);;) {\n");
+ buf.append(" if (b)\n");
+ buf.append(" return;\n");
+ buf.append(" break;\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append(" };\n");
+ buf.append("}\n");
+ expected[0]= buf.toString();
+
+ assertExpectedExistInProposals(proposals, expected);
+ }
public void testMisspelledSuppressToken() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("a", false, null);
StringBuffer buf= new StringBuffer();
diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java
index f2edf15e7..591083318 100644
--- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java
+++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java
@@ -554,4 +554,80 @@ public class NLSSearchTest extends TestCase {
NLSSearchTestHelper.assertNumberOfProblems(accessor, propertiesFile, 0);
}
+
+ public void testBug306168_1() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test;\n");
+ buf.append("import java.util.MissingResourceException;\n");
+ buf.append("import java.util.ResourceBundle;\n");
+ buf.append("public class Accessor {\n");
+ buf.append(" private static final String BUNDLE_NAME = \"test.Accessor\"; //$NON-NLS-1$\n");
+ buf.append(" private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);\n");
+ buf.append(" private Accessor() {}\n");
+ buf.append(" public static String getString(String key) {\n");
+ buf.append(" try {\n");
+ buf.append(" return RESOURCE_BUNDLE.getString(key);\n");
+ buf.append(" } catch (MissingResourceException e) {\n");
+ buf.append(" return '!' + key + '!';\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit accessor= pack1.createCompilationUnit("Accessor.java", buf.toString(), false, null);
+
+ buf= new StringBuffer();
+ buf.append("package test;\n");
+ buf.append("public class Client {\n");
+ buf.append(" private static final String X =\"Main.indirect\";//$NON-NLS-1$ \n");
+ buf.append(" public static void main(String[] args) { \n");
+ buf.append(" Accessor.getString(test.Client.X); \n");
+ buf.append(" }\n");
+ buf.append("}\n");
+
+ pack1.createCompilationUnit("Client.java", buf.toString(), false, null);
+
+ buf= new StringBuffer();
+ buf.append("Main.indirect=Main.indirect\n");
+ IFile propertiesFile= write((IFolder)pack1.getCorrespondingResource(), buf.toString(), "Accessor.properties");
+
+ NLSSearchTestHelper.assertNumberOfProblems(accessor, propertiesFile, 0);
+ }
+
+ public void testBug306168_2() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test;\n");
+ buf.append("import java.util.MissingResourceException;\n");
+ buf.append("import java.util.ResourceBundle;\n");
+ buf.append("public class Accessor {\n");
+ buf.append(" private static final String BUNDLE_NAME = \"test.Accessor\"; //$NON-NLS-1$\n");
+ buf.append(" private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);\n");
+ buf.append(" private Accessor() {}\n");
+ buf.append(" public static String getString(String key) {\n");
+ buf.append(" try {\n");
+ buf.append(" return RESOURCE_BUNDLE.getString(key);\n");
+ buf.append(" } catch (MissingResourceException e) {\n");
+ buf.append(" return '!' + key + '!';\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit accessor= pack1.createCompilationUnit("Accessor.java", buf.toString(), false, null);
+
+ buf= new StringBuffer();
+ buf.append("package test;\n");
+ buf.append("public class Client {\n");
+ buf.append(" private static final String X =\"Main.undefined\";//$NON-NLS-1$ \n");
+ buf.append(" public static void main(String[] args) { \n");
+ buf.append(" Accessor.getString(test.Client.X); \n");
+ buf.append(" }\n");
+ buf.append("}\n");
+
+ pack1.createCompilationUnit("Client.java", buf.toString(), false, null);
+
+ buf= new StringBuffer();
+ IFile propertiesFile= write((IFolder)pack1.getCorrespondingResource(), buf.toString(), "Accessor.properties");
+
+ NLSSearchTestHelper.assertNumberOfProblems(accessor, propertiesFile, 1);
+ }
+
}

Back to the top