Java Code Examples for org.eclipse.jdt.core.compiler.IProblem#MethodReducesVisibility

The following examples show how to use org.eclipse.jdt.core.compiler.IProblem#MethodReducesVisibility . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VisibilityQuickFixTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testMethodReducesVisibility() throws Exception {
	int problem = IProblem.MethodReducesVisibility;
	IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);

	StringBuilder bufB = new StringBuilder();
	bufB.append("package test1;\n");
	bufB.append("public class B {\n");
	bufB.append("    public void foo() {\n");
	bufB.append("    }\n");
	bufB.append("}\n");
	pack1.createCompilationUnit("B.java", bufB.toString(), false, null);

	StringBuilder buf = new StringBuilder();
	buf.append("package test1;\n");
	buf.append("import B;\n");
	buf.append("public class A extends B {\n");
	buf.append("    private void foo() {\n");
	buf.append("    }\n");
	buf.append("}\n");
	ICompilationUnit cu = pack1.createCompilationUnit("A.java", buf.toString(), false, null);

	buf = new StringBuilder();
	buf.append("package test1;\n");
	buf.append("import B;\n");
	buf.append("public class A extends B {\n");
	buf.append("    public void foo() {\n");
	buf.append("    }\n");
	buf.append("}\n");

	Expected e1 = new Expected("Change visibility of 'A.foo' to 'public'", buf.toString());

	assertCodeActions(cu, e1);

}