use of org.eclipse.che.ide.ext.java.shared.dto.Problem in project che by eclipse.
the class JavaAnnotationModel method reportProblems.
private void reportProblems(final List<Problem> problems) {
boolean temporaryProblemsChanged = false;
if (!generatedAnnotations.isEmpty()) {
temporaryProblemsChanged = true;
super.clear();
generatedAnnotations.clear();
}
if (reportedProblems != null && !reportedProblems.isEmpty()) {
for (final Problem problem : reportedProblems) {
final Position position = createPositionFromProblem(problem);
if (position != null) {
final ProblemAnnotation annotation = new ProblemAnnotation(problem);
addAnnotation(annotation, position, false);
generatedAnnotations.add(annotation);
temporaryProblemsChanged = true;
}
}
}
if (temporaryProblemsChanged) {
fireModelChanged();
}
}
use of org.eclipse.che.ide.ext.java.shared.dto.Problem in project che by eclipse.
the class JavaQuickAssistProcessor method createProblem.
private Problem createProblem(JavaAnnotation javaAnnotation, Position pos) {
Problem problem = dtoFactory.createDto(Problem.class);
//server use only this fields
problem.setID(javaAnnotation.getId());
problem.setError(javaAnnotation.isError());
problem.setArguments(Arrays.asList(javaAnnotation.getArguments()));
problem.setSourceStart(pos.getOffset());
//TODO I don't know why but in that place source end is bugger on 1 char
problem.setSourceEnd(pos.getOffset() + pos.getLength() - 1);
return problem;
}
use of org.eclipse.che.ide.ext.java.shared.dto.Problem in project che by eclipse.
the class MavenServerService method createProblem.
private Problem createProblem(VirtualFileEntry entry, SAXParseException spe) {
Problem problem = DtoFactory.newDto(Problem.class);
problem.setError(true);
problem.setMessage(spe.getMessage());
if (entry != null) {
int lineNumber = spe.getLineNumber();
int columnNumber = spe.getColumnNumber();
try {
String content = entry.getVirtualFile().getContentAsString();
Document document = new Document(content);
int lineOffset = document.getLineOffset(lineNumber - 1);
problem.setSourceStart(lineOffset + columnNumber - 1);
problem.setSourceEnd(lineOffset + columnNumber);
} catch (ForbiddenException | ServerException | BadLocationException e) {
LOG.error(e.getMessage(), e);
}
}
return problem;
}
use of org.eclipse.che.ide.ext.java.shared.dto.Problem in project che by eclipse.
the class MavenServerService method reconcilePom.
@GET
@Path("pom/reconcile")
@ApiOperation(value = "Reconcile pom.xml file")
@ApiResponses({ @ApiResponse(code = 200, message = "OK") })
@Produces("application/json")
public List<Problem> reconcilePom(@ApiParam(value = "The paths to pom.xml file which need to be reconciled") @QueryParam("pompath") String pomPath) {
VirtualFileEntry entry = null;
List<Problem> result = new ArrayList<>();
try {
entry = cheProjectManager.getProjectsRoot().getChild(pomPath);
if (entry == null) {
return result;
}
Model.readFrom(entry.getVirtualFile());
org.eclipse.che.api.vfs.Path path = entry.getPath();
String pomContent = entry.getVirtualFile().getContentAsString();
MavenProject mavenProject = mavenProjectManager.findMavenProject(ResourcesPlugin.getWorkspace().getRoot().getProject(path.getParent().toString()));
if (mavenProject == null) {
return result;
}
List<MavenProjectProblem> problems = mavenProject.getProblems();
int start = pomContent.indexOf("<project ") + 1;
int end = start + "<project ".length();
List<Problem> problemList = problems.stream().map(mavenProjectProblem -> DtoFactory.newDto(Problem.class).withError(true).withSourceStart(start).withSourceEnd(end).withMessage(mavenProjectProblem.getDescription())).collect(Collectors.toList());
result.addAll(problemList);
} catch (ServerException | ForbiddenException | IOException e) {
LOG.error(e.getMessage(), e);
} catch (XMLTreeException exception) {
Throwable cause = exception.getCause();
if (cause != null && cause instanceof SAXParseException) {
result.add(createProblem(entry, (SAXParseException) cause));
}
}
return result;
}
use of org.eclipse.che.ide.ext.java.shared.dto.Problem in project che by eclipse.
the class PomReconcilerTest method testReconcilePomWhenPomContainsDependecyWithIncorrectVersion.
@Test
public void testReconcilePomWhenPomContainsDependecyWithIncorrectVersion() throws Exception {
String brokenDependency = " <dependency>\n" + " <groupId>junit</groupId>\n" + " <artifactId>junit</artifactId>\n" + " <version>33333333.8.1</version>\n" + " <scope>test</scope>\n" + " </dependency>\n";
MavenServerService serverService = new MavenServerService(null, projectRegistry, pm, projectManager, null, null);
FolderEntry testProject = createTestProject(PROJECT_NAME, getPomContentWithDependency(brokenDependency));
VirtualFileEntry pom = testProject.getChild("pom.xml");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
mavenWorkspace.update(Collections.singletonList(project));
mavenWorkspace.waitForUpdate();
List<Problem> problems = serverService.reconcilePom(String.format("/%s/pom.xml", PROJECT_NAME));
assertThat(problems).hasSize(1);
assertThat(problems.get(0).isError()).isTrue();
assertThat(pom).isNotNull();
}
Aggregations