Search in sources :

Example 66 with Element

use of org.jdom.Element in project intellij-community by JetBrains.

the class MavenProject method getAnnotationProcessorOptions.

public Map<String, String> getAnnotationProcessorOptions() {
    Element compilerConfig = getCompilerConfig();
    if (compilerConfig == null) {
        return Collections.emptyMap();
    }
    if (getProcMode() != MavenProject.ProcMode.NONE) {
        return getAnnotationProcessorOptionsFromCompilerConfig(compilerConfig);
    }
    MavenPlugin bscMavenPlugin = findPlugin("org.bsc.maven", "maven-processor-plugin");
    if (bscMavenPlugin != null) {
        return getAnnotationProcessorOptionsFromProcessorPlugin(bscMavenPlugin);
    }
    return Collections.emptyMap();
}
Also used : Element(org.jdom.Element)

Example 67 with Element

use of org.jdom.Element in project intellij-community by JetBrains.

the class MavenProject method getAnnotationProcessorOptionsFromCompilerConfig.

private static Map<String, String> getAnnotationProcessorOptionsFromCompilerConfig(Element compilerConfig) {
    Map<String, String> res = new LinkedHashMap<>();
    String compilerArgument = compilerConfig.getChildText("compilerArgument");
    addAnnotationProcessorOptionFomrParametersString(compilerArgument, res);
    Element compilerArgs = compilerConfig.getChild("compilerArgs");
    if (compilerArgs != null) {
        for (Element e : compilerArgs.getChildren()) {
            if (!StringUtil.equals(e.getName(), "arg"))
                continue;
            String arg = e.getTextTrim();
            addAnnotationProcessorOption(arg, res);
        }
    }
    Element compilerArguments = compilerConfig.getChild("compilerArguments");
    if (compilerArguments != null) {
        for (Element e : compilerArguments.getChildren()) {
            String name = e.getName();
            name = StringUtil.trimStart(name, "-");
            if (name.length() > 1 && name.charAt(0) == 'A') {
                res.put(name.substring(1), e.getTextTrim());
            }
        }
    }
    return res;
}
Also used : Element(org.jdom.Element)

Example 68 with Element

use of org.jdom.Element in project intellij-community by JetBrains.

the class MavenProject method getFilterPropertiesFiles.

public List<String> getFilterPropertiesFiles() {
    List<String> res = getCachedValue(FILTERS_CACHE_KEY);
    if (res == null) {
        Element propCfg = getPluginGoalConfiguration("org.codehaus.mojo", "properties-maven-plugin", "read-project-properties");
        if (propCfg != null) {
            Element files = propCfg.getChild("files");
            if (files != null) {
                res = new ArrayList<>();
                for (Element file : files.getChildren("file")) {
                    File f = new File(file.getValue());
                    if (!f.isAbsolute()) {
                        f = new File(getDirectory(), file.getValue());
                    }
                    res.add(f.getAbsolutePath());
                }
            }
        }
        if (res == null) {
            res = getFilters();
        } else {
            res.addAll(getFilters());
        }
        res = putCachedValue(FILTERS_CACHE_KEY, res);
    }
    return res;
}
Also used : Element(org.jdom.Element) VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Example 69 with Element

use of org.jdom.Element in project intellij-community by JetBrains.

the class MavenProjectReader method doReadProjectModel.

private RawModelReadResult doReadProjectModel(VirtualFile file, boolean headerOnly) {
    MavenModel result = null;
    Collection<MavenProjectProblem> problems = MavenProjectProblem.createProblemsList();
    Set<String> alwaysOnProfiles = new THashSet<>();
    String fileExtension = file.getExtension();
    if (!"pom".equalsIgnoreCase(fileExtension) && !"xml".equalsIgnoreCase(fileExtension)) {
        File basedir = getBaseDir(file);
        MavenEmbeddersManager manager = MavenProjectsManager.getInstance(myProject).getEmbeddersManager();
        MavenEmbedderWrapper embedder = manager.getEmbedder(MavenEmbeddersManager.FOR_MODEL_READ, basedir.getPath(), basedir.getPath());
        try {
            result = embedder.readModel(VfsUtilCore.virtualToIoFile(file));
        } catch (MavenProcessCanceledException ignore) {
        } finally {
            manager.release(embedder);
        }
        if (result == null) {
            result = new MavenModel();
            result.setPackaging(MavenConstants.TYPE_JAR);
            return new RawModelReadResult(result, problems, alwaysOnProfiles);
        } else {
            return new RawModelReadResult(result, problems, alwaysOnProfiles);
        }
    }
    result = new MavenModel();
    Element xmlProject = readXml(file, problems, MavenProjectProblem.ProblemType.SYNTAX);
    if (xmlProject == null || !"project".equals(xmlProject.getName())) {
        result.setPackaging(MavenConstants.TYPE_JAR);
        return new RawModelReadResult(result, problems, alwaysOnProfiles);
    }
    MavenParent parent;
    if (MavenJDOMUtil.hasChildByPath(xmlProject, "parent")) {
        parent = new MavenParent(new MavenId(MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.groupId", UNKNOWN), MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.artifactId", UNKNOWN), MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.version", UNKNOWN)), MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.relativePath", "../pom.xml"));
        result.setParent(parent);
    } else {
        parent = new MavenParent(new MavenId(UNKNOWN, UNKNOWN, UNKNOWN), "../pom.xml");
    }
    result.setMavenId(new MavenId(MavenJDOMUtil.findChildValueByPath(xmlProject, "groupId", parent.getMavenId().getGroupId()), MavenJDOMUtil.findChildValueByPath(xmlProject, "artifactId", UNKNOWN), MavenJDOMUtil.findChildValueByPath(xmlProject, "version", parent.getMavenId().getVersion())));
    if (headerOnly)
        return new RawModelReadResult(result, problems, alwaysOnProfiles);
    result.setPackaging(MavenJDOMUtil.findChildValueByPath(xmlProject, "packaging", MavenConstants.TYPE_JAR));
    result.setName(MavenJDOMUtil.findChildValueByPath(xmlProject, "name"));
    readModelBody(result, result.getBuild(), xmlProject);
    result.setProfiles(collectProfiles(file, xmlProject, problems, alwaysOnProfiles));
    return new RawModelReadResult(result, problems, alwaysOnProfiles);
}
Also used : MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) Element(org.jdom.Element) MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper) THashSet(gnu.trove.THashSet) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 70 with Element

use of org.jdom.Element in project intellij-community by JetBrains.

the class MavenProjectReader method collectProfiles.

private void collectProfiles(List<Element> xmlProfiles, List<MavenProfile> result, String source) {
    for (Element each : xmlProfiles) {
        String id = MavenJDOMUtil.findChildValueByPath(each, "id");
        if (isEmptyOrSpaces(id))
            continue;
        MavenProfile profile = new MavenProfile(id, source);
        if (!addProfileIfDoesNotExist(profile, result))
            continue;
        Element xmlActivation = MavenJDOMUtil.findChildByPath(each, "activation");
        if (xmlActivation != null) {
            MavenProfileActivation activation = new MavenProfileActivation();
            activation.setActiveByDefault("true".equals(MavenJDOMUtil.findChildValueByPath(xmlActivation, "activeByDefault")));
            Element xmlOS = MavenJDOMUtil.findChildByPath(xmlActivation, "os");
            if (xmlOS != null) {
                activation.setOs(new MavenProfileActivationOS(MavenJDOMUtil.findChildValueByPath(xmlOS, "name"), MavenJDOMUtil.findChildValueByPath(xmlOS, "family"), MavenJDOMUtil.findChildValueByPath(xmlOS, "arch"), MavenJDOMUtil.findChildValueByPath(xmlOS, "version")));
            }
            activation.setJdk(MavenJDOMUtil.findChildValueByPath(xmlActivation, "jdk"));
            Element xmlProperty = MavenJDOMUtil.findChildByPath(xmlActivation, "property");
            if (xmlProperty != null) {
                activation.setProperty(new MavenProfileActivationProperty(MavenJDOMUtil.findChildValueByPath(xmlProperty, "name"), MavenJDOMUtil.findChildValueByPath(xmlProperty, "value")));
            }
            Element xmlFile = MavenJDOMUtil.findChildByPath(xmlActivation, "file");
            if (xmlFile != null) {
                activation.setFile(new MavenProfileActivationFile(MavenJDOMUtil.findChildValueByPath(xmlFile, "exists"), MavenJDOMUtil.findChildValueByPath(xmlFile, "missing")));
            }
            profile.setActivation(activation);
        }
        readModelBody(profile, profile.getBuild(), each);
    }
}
Also used : Element(org.jdom.Element)

Aggregations

Element (org.jdom.Element)1994 BioPaxObject (org.vcell.pathway.BioPaxObject)143 ArrayList (java.util.ArrayList)141 NotNull (org.jetbrains.annotations.NotNull)103 IOException (java.io.IOException)102 Document (org.jdom.Document)102 Nullable (org.jetbrains.annotations.Nullable)98 List (java.util.List)84 File (java.io.File)78 GroupObject (org.vcell.pathway.GroupObject)75 VirtualFile (com.intellij.openapi.vfs.VirtualFile)67 JDOMException (org.jdom.JDOMException)57 Expression (cbit.vcell.parser.Expression)47 SAXBuilder (org.jdom.input.SAXBuilder)47 ExpressionException (cbit.vcell.parser.ExpressionException)45 Iterator (java.util.Iterator)45 PsiElement (com.intellij.psi.PsiElement)44 Attribute (org.jdom.Attribute)42 XMLOutputter (org.jdom.output.XMLOutputter)34 Namespace (org.jdom.Namespace)32