Search in sources :

Example 1 with MavenProjectProblem

use of org.jetbrains.idea.maven.model.MavenProjectProblem in project intellij-community by JetBrains.

the class InvalidProjectImportingTest method assertProblems.

private static void assertProblems(MavenProject project, String... expectedProblems) {
    List<String> actualProblems = new ArrayList<>();
    for (MavenProjectProblem each : project.getProblems()) {
        actualProblems.add(each.getDescription());
    }
    assertOrderedElementsAreEqual(actualProblems, expectedProblems);
}
Also used : MavenProjectProblem(org.jetbrains.idea.maven.model.MavenProjectProblem) ArrayList(java.util.ArrayList)

Example 2 with MavenProjectProblem

use of org.jetbrains.idea.maven.model.MavenProjectProblem in project intellij-community by JetBrains.

the class MavenDomAnnotator method addProblems.

private static void addProblems(DomElement element, MavenDomProjectModel model, DomElementAnnotationHolder holder, MavenProjectProblem.ProblemType... types) {
    MavenProject mavenProject = MavenDomUtil.findProject(model);
    if (mavenProject != null) {
        for (MavenProjectProblem each : mavenProject.getProblems()) {
            MavenProjectProblem.ProblemType type = each.getType();
            if (!Arrays.asList(types).contains(type))
                continue;
            VirtualFile problemFile = LocalFileSystem.getInstance().findFileByPath(each.getPath());
            LocalQuickFix[] fixes = LocalQuickFix.EMPTY_ARRAY;
            if (problemFile != null && !Comparing.equal(mavenProject.getFile(), problemFile)) {
                fixes = new LocalQuickFix[] { new OpenProblemFileFix(problemFile) };
            }
            holder.createProblem(element, HighlightSeverity.ERROR, each.getDescription(), fixes);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenProjectProblem(org.jetbrains.idea.maven.model.MavenProjectProblem) LocalQuickFix(com.intellij.codeInspection.LocalQuickFix)

Example 3 with MavenProjectProblem

use of org.jetbrains.idea.maven.model.MavenProjectProblem in project intellij-community by JetBrains.

the class MiscImportingTest method testClearUnresolvedPluginsAfterPluginResolution.

public void testClearUnresolvedPluginsAfterPluginResolution() throws Exception {
    try {
        File repo = new File(myDir, "repo");
        setRepositoryPath(repo.getPath());
        importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "" + "<build>" + "  <plugins>" + "    <plugin>" + "      <artifactId>maven-surefire-plugin</artifactId>" + "    </plugin>" + "  </plugins>" + "</build>");
        List<MavenProjectProblem> problems = myProjectsTree.getRootProjects().get(0).getProblems();
        assertTrue(problems.size() > 0);
        for (MavenProjectProblem problem : problems) {
            assertTrue(problem.getDescription(), problem.getDescription().contains("Unresolved plugin"));
        }
        resolvePlugins();
        assertEquals(0, myProjectsTree.getRootProjects().get(0).getProblems().size());
    } finally {
        // do not lock files by maven process
        MavenServerManager.getInstance().shutdown(true);
    }
}
Also used : MavenProjectProblem(org.jetbrains.idea.maven.model.MavenProjectProblem) File(java.io.File)

Aggregations

MavenProjectProblem (org.jetbrains.idea.maven.model.MavenProjectProblem)3 LocalQuickFix (com.intellij.codeInspection.LocalQuickFix)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 MavenProject (org.jetbrains.idea.maven.project.MavenProject)1