use of org.eclipse.jdt.ui.text.java.IProblemLocation in project liferay-ide by liferay.
the class QuickFixGradleDep method getCorrections.
@Override
public IJavaCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) {
if (ListUtil.isEmpty(locations)) {
return null;
}
IResource resource = context.getCompilationUnit().getResource();
IProject project = resource.getProject();
_gradleFile = project.getFile("build.gradle");
List<IJavaCompletionProposal> resultingCollections = new ArrayList<>();
if (FileUtil.exists(_gradleFile)) {
for (int i = 0; i < locations.length; i++) {
IProblemLocation curr = locations[i];
_process(context, curr, resultingCollections);
}
}
return resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]);
}
use of org.eclipse.jdt.ui.text.java.IProblemLocation in project bndtools by bndtools.
the class ImportPackageQuickFixProcessorTest method getCorrections_forIsClassPath_suggestsBundle.
@Test
public void getCorrections_forIsClassPath_suggestsBundle() {
List<IProblemLocation> locs = getProblems("public class Test { Test2 test = new `Test2()'; }", new ProblemLocation(0, 0, IsClassPathCorrect, new String[] { "org.osgi.framework.Clazz" }, true, JDT_PROBLEM));
assertThatContainsFrameworkBundles(proposalsFor(locs));
}
use of org.eclipse.jdt.ui.text.java.IProblemLocation in project bndtools by bndtools.
the class ImportPackageQuickFixProcessorTest method getCorrections_whenWorkspaceFails_andMultiplePackages_onlyLogsErrorOnce.
@Test
public void getCorrections_whenWorkspaceFails_andMultiplePackages_onlyLogsErrorOnce() {
Exception ex = makeSUTgetWSRepo_throwException();
List<IProblemLocation> locs = getProblems("import `org.eclipse.ui'.*; import `org.osgi.framework'.*;", new int[] { ImportNotFound, ImportNotFound });
proposalsFor(new FakeInvocationContext(7, 0), locs);
verify(logger, times(1)).logError("Error trying to fetch the repository for the current workspace", ex);
}
use of org.eclipse.jdt.ui.text.java.IProblemLocation in project bndtools by bndtools.
the class ImportPackageQuickFixProcessorTest method getCorrections_forIsClassPath_withLowerCaseClassInMainNamespace_returnsNull.
@Test
public void getCorrections_forIsClassPath_withLowerCaseClassInMainNamespace_returnsNull() {
List<IProblemLocation> locs = getProblems("package other; public class Test { Test2 test = new `Test2()'; }", new ProblemLocation(0, 0, IsClassPathCorrect, new String[] { "test" }, true, JDT_PROBLEM));
assertThat(proposalsFor(locs)).isNull();
}
use of org.eclipse.jdt.ui.text.java.IProblemLocation in project bndtools by bndtools.
the class ImportPackageQuickFixProcessorTest method testGetProblems.
@Test
public // Internal test for a fairly complicated helper method.
void testGetProblems() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> {
getProblems("import `my.pkg.*';", new int[0]);
});
List<IProblemLocation> probs = getProblems("import ``my.`p'kg'.*';", ImportNotFound, UndefinedType, AmbiguousField);
assertThat(cu.toString().trim()).as("source").isEqualTo("import my.pkg.*;");
assertThat(probs).hasSize(3);
IProblemLocation loc;
loc = probs.get(0);
assertThat(loc.getProblemId()).as("problem 0").isEqualTo(ImportNotFound);
assertThat(loc.getOffset()).as("offset 0").isEqualTo(10);
assertThat(loc.getLength()).as("length 0").isEqualTo(1);
loc = probs.get(1);
assertThat(loc.getProblemId()).as("problem 1").isEqualTo(UndefinedType);
assertThat(loc.getOffset()).as("offset 1").isEqualTo(7);
assertThat(loc.getLength()).as("length 1").isEqualTo(6);
loc = probs.get(2);
assertThat(loc.getProblemId()).as("problem 2").isEqualTo(AmbiguousField);
assertThat(loc.getOffset()).as("offset 2").isEqualTo(7);
assertThat(loc.getLength()).as("length 2").isEqualTo(8);
}
Aggregations