Search in sources :

Example 11 with Element

use of org.jdom.Element in project freud by LMAX-Exchange.

the class JavaSourceJdom method parseAnnotations.

//////////////////////////////////////////////////////////////////////////////////////////////////
public static List<Annotation> parseAnnotations(final Element element) {
    final List<Annotation> annotations;
    JXPathContext context = JXPathContext.newContext(element);
    List annotationList = context.selectNodes("/" + JavaSourceTokenType.MODIFIER_LIST.getName() + "/" + JavaSourceTokenType.AT.getName());
    annotations = new ArrayList<Annotation>(annotationList.size());
    for (Object annotationElement : annotationList) {
        annotations.add(new AnnotationJdom((Element) annotationElement));
    }
    return annotations;
}
Also used : JXPathContext(org.apache.commons.jxpath.JXPathContext) Element(org.jdom.Element) Collections.emptyList(java.util.Collections.emptyList) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.freud.analysed.javasource.Annotation)

Example 12 with Element

use of org.jdom.Element in project freud by LMAX-Exchange.

the class JavaSourceJdom method parseClassDeclaration.

///////////////////////////////////////////////////////////////////////////////////////////////////////
private ClassDeclaration parseClassDeclaration() {
    JXPathContext context = JXPathContext.newContext(root);
    for (JavaSourceTokenType tokenType : POSSIBLE_CLASS_DECLARATION_TYPES) {
        try {
            final String tokenName = tokenType.name();
            final Element element = (Element) context.selectSingleNode("/" + JAVA_SOURCE_ROOT_ELEMENT_NAME + "/" + tokenName);
            if (element != null) {
                classDeclaration = new ClassDeclarationJdom(element, getDeclarationType(tokenType), null);
            }
        } catch (JXPathException e) {
        // ignore and try another path
        }
    }
    if (classDeclaration == null) {
        throw new IllegalStateException("Internal: could not find class declaration in: " + this);
    }
    return classDeclaration;
}
Also used : JXPathContext(org.apache.commons.jxpath.JXPathContext) Element(org.jdom.Element) JXPathException(org.apache.commons.jxpath.JXPathException) JavaSourceTokenType(org.freud.analysed.javasource.parser.JavaSourceTokenType) JdomTreeAdaptor.documentToString(org.freud.core.parser.JdomTreeAdaptor.documentToString)

Example 13 with Element

use of org.jdom.Element in project freud by LMAX-Exchange.

the class MethodDeclarationJdom method getParametersDeclarations.

@Override
@SuppressWarnings("unchecked")
public List<ParamDeclaration> getParametersDeclarations() {
    if (paramDeclarations == null) {
        final List<Element> paramListChildren = methodDeclElement.getChild(JavaSourceTokenType.FORMAL_PARAM_LIST.getName()).getChildren();
        paramDeclarations = new ArrayList<ParamDeclaration>(paramListChildren.size());
        for (Element paramDecl : paramListChildren) {
            paramDeclarations.add(new ParamDeclarationJdom(paramDecl));
        }
    }
    return paramDeclarations;
}
Also used : Element(org.jdom.Element) ParamDeclaration(org.freud.analysed.javasource.ParamDeclaration)

Example 14 with Element

use of org.jdom.Element in project freud by LMAX-Exchange.

the class CssRuleJdom method parseSelectors.

@SuppressWarnings("unchecked")
private void parseSelectors() {
    cssSelectorList = new ArrayList<CssSelector>();
    final List<Element> children = ruleElement.getChildren();
    int index = 0;
    CssSelector.Combinator combinator = null;
    for (Element child : children) {
        if (CssTokenType.COMMA.name().equals(child.getName())) {
            index++;
        } else if (getCommaSeparatedSelectorListIndex() == index) {
            if (CssSelector.Type.isType(child.getName())) {
                final String selectorString = child.getAttributeValue(JdomTreeAdaptor.ID_ATTR);
                CssSelector.Type selectorType = CssSelector.Type.valueOf(child.getName());
                if (selectorString != null) {
                    Iterable<String> selectors = breakIdentToSelectors(selectorString);
                    for (String selector : selectors) {
                        cssSelectorList.add(new CssSelectorJdom(this, selector, selectorType, combinator));
                        combinator = CssSelector.Combinator.DESCENDANT;
                        selectorType = CssSelector.Type.CLASS;
                    }
                } else {
                    cssSelectorList.add(new CssSelectorJdom(this, null, selectorType, combinator));
                    combinator = CssSelector.Combinator.DESCENDANT;
                }
            } else if (CssSelector.Combinator.isCombinator(child.getName())) {
                combinator = CssSelector.Combinator.valueOf(child.getName());
            }
        }
    }
}
Also used : CssTokenType(org.freud.analysed.css.parser.CssTokenType) CssSelector(org.freud.analysed.css.rule.selector.CssSelector) Element(org.jdom.Element)

Example 15 with Element

use of org.jdom.Element in project freud by LMAX-Exchange.

the class CssRuleJdom method parseDeclarations.

@SuppressWarnings("unchecked")
private void parseDeclarations() {
    cssDeclarationList = new ArrayList<CssDeclaration>();
    JXPathContext context = JXPathContext.newContext(ruleElement);
    List<Element> cssSelectorElementList = (List<Element>) context.selectNodes("/" + CssTokenType.PROPERTY.name());
    for (Element element : cssSelectorElementList) {
        cssDeclarationList.add(new CssDeclarationJdom(this, element));
    }
}
Also used : CssDeclaration(org.freud.analysed.css.rule.declaration.CssDeclaration) JXPathContext(org.apache.commons.jxpath.JXPathContext) Element(org.jdom.Element) List(java.util.List) LinkedList(java.util.LinkedList) ArrayList(java.util.ArrayList)

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