List of usage examples for org.eclipse.jdt.core JavaCore COMPILER_PB_POTENTIALLY_MISSING_STATIC_ON_METHOD
String COMPILER_PB_POTENTIALLY_MISSING_STATIC_ON_METHOD
To view the source code for org.eclipse.jdt.core JavaCore COMPILER_PB_POTENTIALLY_MISSING_STATIC_ON_METHOD.
Click Source Link
From source file:org.eclipse.che.jdt.quickfix.ModifierCorrectionsQuickFixTest.java
License:Open Source License
@Test public void testMethodCanBeStatic() throws Exception { Hashtable hashtable = JavaCore.getOptions(); hashtable.put(JavaCore.COMPILER_PB_MISSING_STATIC_ON_METHOD, JavaCore.ERROR); hashtable.put(JavaCore.COMPILER_PB_POTENTIALLY_MISSING_STATIC_ON_METHOD, JavaCore.WARNING); JavaCore.setOptions(hashtable);/*from w w w .j a v a2 s. c o m*/ IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" private void foo() {\n"); buf.append(" System.out.println(\"doesn't need class\");\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(" private static void foo() {\n"); buf.append(" System.out.println(\"doesn't need class\");\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); }
From source file:org.eclipse.che.jdt.quickfix.ModifierCorrectionsQuickFixTest.java
License:Open Source License
@Test public void testMethodCanPotentiallyBeStatic() throws Exception { Hashtable hashtable = JavaCore.getOptions(); hashtable.put(JavaCore.COMPILER_PB_MISSING_STATIC_ON_METHOD, JavaCore.ERROR); hashtable.put(JavaCore.COMPILER_PB_POTENTIALLY_MISSING_STATIC_ON_METHOD, JavaCore.WARNING); JavaCore.setOptions(hashtable);/*from w ww. ja va2 s . c o m*/ IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo() {\n"); buf.append(" System.out.println(\"doesn't need class\");\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, 2); assertCorrectLabels(proposals); String[] expected = new String[2]; buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" static void foo() {\n"); buf.append(" System.out.println(\"doesn't need class\");\n"); buf.append(" }\n"); buf.append("}\n"); expected[0] = buf.toString(); buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" @SuppressWarnings(\"static-method\")\n"); buf.append(" void foo() {\n"); buf.append(" System.out.println(\"doesn't need class\");\n"); buf.append(" }\n"); buf.append("}\n"); expected[1] = buf.toString(); assertExpectedExistInProposals(proposals, expected); }