use of org.freud.analysed.javasource.parser.JavaSourceTokenType 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;
}
use of org.freud.analysed.javasource.parser.JavaSourceTokenType in project freud by LMAX-Exchange.
the class ClassDeclarationJdom method getInnerClassDeclarationByNameMap.
@SuppressWarnings("unchecked")
public Map<String, ClassDeclaration> getInnerClassDeclarationByNameMap() {
if (innerClassDeclarationByNameMap == null) {
JXPathContext context = JXPathContext.newContext(classDeclElement);
innerClassDeclarationByNameMap = new LinkedHashMap<String, ClassDeclaration>();
for (JavaSourceTokenType tokenType : POSSIBLE_CLASS_DECLARATION_TYPES) {
final String tokenName = tokenType.getName();
List<Element> innerClassElementList = context.selectNodes("/" + CLASS_TOP_LEVEL_SCOPE.getName() + "/" + tokenName);
for (Element innerClassElement : innerClassElementList) {
ClassDeclaration innerClass = new ClassDeclarationJdom(innerClassElement, DeclarationType.valueOf(tokenName), this);
innerClassDeclarationByNameMap.put(innerClass.getName(), innerClass);
}
}
}
return innerClassDeclarationByNameMap;
}
Aggregations