Search in sources :

Example 91 with Hashtable

use of java.util.Hashtable in project che by eclipse.

the class ModifierCorrectionsQuickFixTest method testSuppressWarningsForFieldVariables.

@Test
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);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 92 with Hashtable

use of java.util.Hashtable in project che by eclipse.

the class ModifierCorrectionsQuickFixTest method testNeedToEmulateFieldWrite.

@Test
public void testNeedToEmulateFieldWrite() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, JavaCore.ERROR);
    JavaCore.setOptions(hashtable);
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    public void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("               fCount= 2;\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    private int fCount; {\n");
    buf.append("    }\n");
    buf.append("}\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
    CompilationUnit astRoot = getASTRoot(cu);
    ArrayList proposals = collectCorrections(cu, astRoot);
    assertNumberOfProposals(proposals, 1);
    assertCorrectLabels(proposals);
    CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0);
    String preview = getPreviewContent(proposal);
    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    public void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("               fCount= 2;\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    int fCount; {\n");
    buf.append("    }\n");
    buf.append("}\n");
    assertEqualString(preview, buf.toString());
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) CUCorrectionProposal(org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 93 with Hashtable

use of java.util.Hashtable in project che by eclipse.

the class ModifierCorrectionsQuickFixTest method setUp.

//	public static Test suite() {
//		return setUpTest(new TestSuite(THIS));
//	}
//
//	public static Test setUpTest(Test test) {
//		return new ProjectTestSetup(test);
//	}
@Before
public void setUp() throws Exception {
    super.setUp();
    Hashtable options = TestOptions.getDefaultOptions();
    options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
    options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
    options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, JavaCore.DO_NOT_INSERT);
    options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR);
    options.put(JavaCore.COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD, JavaCore.ERROR);
    JavaCore.setOptions(options);
    IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
    store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
    fJProject1 = ProjectTestSetup.getProject();
    StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);
    StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
    fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
Also used : Hashtable(java.util.Hashtable) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Before(org.junit.Before)

Example 94 with Hashtable

use of java.util.Hashtable in project che by eclipse.

the class LocalCorrectionsQuickFixTest method testUnnecessaryInstanceof2.

@Test
public void testUnnecessaryInstanceof2() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.ERROR);
    JavaCore.setOptions(hashtable);
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    public void foo(String b) {\n");
    buf.append("        if  (b instanceof String && b.getClass() != null) {\n");
    buf.append("            System.out.println();\n");
    buf.append("        }\n");
    buf.append("    }\n");
    buf.append("}\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
    CompilationUnit astRoot = getASTRoot(cu);
    ArrayList proposals = collectCorrections(cu, astRoot);
    assertNumberOfProposals(proposals, 1);
    assertCorrectLabels(proposals);
    CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0);
    String preview = getPreviewContent(proposal);
    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    public void foo(String b) {\n");
    buf.append("        if  (b != null && b.getClass() != null) {\n");
    buf.append("            System.out.println();\n");
    buf.append("        }\n");
    buf.append("    }\n");
    buf.append("}\n");
    assertEqualString(preview, buf.toString());
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) CUCorrectionProposal(org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 95 with Hashtable

use of java.util.Hashtable in project che by eclipse.

the class LocalCorrectionsQuickFixTest method testUnusedVariableBug120579.

@Test
public void testUnusedVariableBug120579() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR);
    hashtable.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER, JavaCore.ERROR);
    JavaCore.setOptions(hashtable);
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E  {\n");
    buf.append("    public void foo() {\n");
    buf.append("        char[] array= new char[0];\n");
    buf.append("        for (char element: array) {}\n");
    buf.append("    }\n");
    buf.append("}\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
    CompilationUnit astRoot = getASTRoot(cu);
    ArrayList proposals = collectCorrections(cu, astRoot);
    assertNumberOfProposals(proposals, 0);
    assertCorrectLabels(proposals);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

Hashtable (java.util.Hashtable)1752 Test (org.junit.Test)374 ArrayList (java.util.ArrayList)355 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)219 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)142 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)137 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)136 HashMap (java.util.HashMap)104 IOException (java.io.IOException)91 Dictionary (java.util.Dictionary)91 Vector (java.util.Vector)88 File (java.io.File)86 Map (java.util.Map)84 Bundle (org.osgi.framework.Bundle)84 BundleContext (org.osgi.framework.BundleContext)78 Configuration (org.osgi.service.cm.Configuration)75 Enumeration (java.util.Enumeration)70 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)70 State (org.eclipse.osgi.service.resolver.State)70 ServiceRegistration (org.osgi.framework.ServiceRegistration)65