@Override public boolean visit(TypeDeclaration s) throws Exception { if (!isSymfonySource) return false; if (s instanceof ClassDeclaration) { currentClass = (ClassDeclaration) s; for (Object o : currentClass.getSuperClasses().getChilds()) { if (o instanceof FullyQualifiedReference) { FullyQualifiedReference superReference = (FullyQualifiedReference) o; // TODO: find a way to check against the FQCN // via the UseStatement if ( /*superReference.getNamespace().equals(SymfonyCoreConstants.CONTROLLER_NS) && */ superReference.getName().equals(SymfonyCoreConstants.CONTROLLER_CLASS)) { // the ControllerIndexer does the actual work of parsing the // the relevant elements inside the controller // which are then being collected in the endVisit() method inController = true; } } } } return true; }
private String processNameNode(ASTNode nameNode) { if (nameNode instanceof FullyQualifiedReference) { String name; FullyQualifiedReference fullyQualifiedName = (FullyQualifiedReference) nameNode; name = fullyQualifiedName.getFullyQualifiedName(); if (fullyQualifiedName.getNamespace() != null) { String namespace = fullyQualifiedName.getNamespace().getName(); String subnamespace = ""; // $NON-NLS-1$ if (namespace.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR && namespace.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0) { int firstNSLocation = namespace.indexOf(NamespaceReference.NAMESPACE_SEPARATOR); subnamespace = namespace.substring(firstNSLocation); namespace = namespace.substring(0, firstNSLocation); } if (name.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) { name = name.substring(1); } else if (fLastUseParts.containsKey(namespace)) { name = new StringBuilder(fLastUseParts.get(namespace).getNamespace().getFullyQualifiedName()) .append(subnamespace) .append(NamespaceReference.NAMESPACE_SEPARATOR) .append(fullyQualifiedName.getName()) .toString(); } else if (fLastNamespace != null) { name = new StringBuilder(fLastNamespace.getName()) .append(NamespaceReference.NAMESPACE_SEPARATOR) .append(name) .toString(); } } else if (fLastUseParts.containsKey(name)) { name = fLastUseParts.get(name).getNamespace().getFullyQualifiedName(); if (name.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) { name = name.substring(1); } } else { if (fLastNamespace != null) { name = new StringBuilder(fLastNamespace.getName()) .append(NamespaceReference.NAMESPACE_SEPARATOR) .append(name) .toString(); } } return name; } else if (nameNode instanceof SimpleReference) { return ((SimpleReference) nameNode).getName(); } return null; }
public boolean visit(FullyQualifiedReference s) throws Exception { Map<String, String> parameters = createInitialParameters(s); parameters.put("name", s.getFullyQualifiedName()); xmlWriter.startTag("FullyQualifiedReference", parameters); return true; }
protected String[] processSuperClasses(TypeDeclaration type) { ASTListNode superClasses = type.getSuperClasses(); if (superClasses == null) { return new String[] {}; } List<ASTNode> superClassNames = superClasses.getChilds(); List<String> result = new ArrayList<String>(superClassNames.size()); Iterator<ASTNode> iterator = superClassNames.iterator(); while (iterator.hasNext()) { ASTNode nameNode = iterator.next(); String name; if (nameNode instanceof FullyQualifiedReference) { FullyQualifiedReference fullyQualifiedName = (FullyQualifiedReference) nameNode; name = fullyQualifiedName.getFullyQualifiedName(); if (fullyQualifiedName.getNamespace() != null) { String namespace = fullyQualifiedName.getNamespace().getName(); String subnamespace = ""; // $NON-NLS-1$ if (namespace.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR && namespace.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0) { int firstNSLocation = namespace.indexOf(NamespaceReference.NAMESPACE_SEPARATOR); subnamespace = namespace.substring(firstNSLocation); namespace = namespace.substring(0, firstNSLocation); } if (name.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) { name = name.substring(1); } else if (fLastUseParts.containsKey(namespace)) { name = new StringBuilder( fLastUseParts.get(namespace).getNamespace().getFullyQualifiedName()) .append(subnamespace) .append(NamespaceReference.NAMESPACE_SEPARATOR) .append(fullyQualifiedName.getName()) .toString(); } else if (fCurrentNamespace != null) { name = new StringBuilder(fCurrentNamespace.getName()) .append(NamespaceReference.NAMESPACE_SEPARATOR) .append(name) .toString(); } } else if (fLastUseParts.containsKey(name)) { name = fLastUseParts.get(name).getNamespace().getFullyQualifiedName(); if (name.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) { name = name.substring(1); } } else { if (fCurrentNamespace != null) { name = new StringBuilder(fCurrentNamespace.getName()) .append(NamespaceReference.NAMESPACE_SEPARATOR) .append(name) .toString(); } } result.add(name); } else if (nameNode instanceof SimpleReference) { result.add(((SimpleReference) nameNode).getName()); } } return (String[]) result.toArray(new String[result.size()]); }