private void addNestedNamespaces(List<CsmNamespace> list, CsmNamespace nmsp) { Iterator<CsmNamespace> iter = nmsp.getNestedNamespaces().iterator(); while (iter.hasNext()) { CsmNamespace n = iter.next(); list.add(n); addNestedNamespaces(list, n); } }
/** * Finds all namespaces visible in given namespace (unnamed, inlined or through "using" directives). * * @param namespace namespace of interest * @return unmodifiable collection of namespaces visible in given namespace though "using" directives */ @Override public Collection<CsmNamespace> findVisibleNamespaces(CsmNamespace namespace, CsmProject startPrj) { List<CsmNamespace> res = new ArrayList<>(); if (!namespace.isGlobal()) { for (CsmNamespace ns : namespace.getNestedNamespaces()) { if (ns.getName().length() == 0 || ns.isInline()) { res.add(ns); } } } res.addAll(extractNamespaces(findUsingDirectives(namespace), startPrj)); return res; }
private void processNamespace(CsmNamespace nsp, CsmSelect.CsmFilter filter, NameMatcher matcher) { checkCancelled(); for (Iterator<CsmOffsetableDeclaration> iter = CsmSelect.getDeclarations(nsp, filter); iter.hasNext();) { checkCancelled(); CsmDeclaration declaration = iter.next(); processDeclaration(declaration, matcher); } for (CsmNamespace child : nsp.getNestedNamespaces()) { checkCancelled(); processNamespace(child, filter, matcher); } }
private Map<CharSequence, CsmNamespace> getNestedNamespaces(CsmNamespace ns, String strPrefix, boolean match, Set<CsmNamespace> handledNS) { Map<CharSequence, CsmNamespace> res = new LinkedHashMap<CharSequence, CsmNamespace>(); // order is important if(ns != null) { handledNS.add(ns); CsmProject nsProject = ns.getProject(); if(nsProject != null) { // handle all nested namespaces for (CsmProject lib : nsProject.getLibraries()) { CsmNamespace n = lib.findNamespace(ns.getQualifiedName()); if (n != null && !handledNS.contains(n)) { res.putAll(getNestedNamespaces(n, strPrefix, match, handledNS)); } } for (Iterator it = ns.getNestedNamespaces().iterator(); it.hasNext();) { CsmNamespace nestedNs = (CsmNamespace) it.next(); // TODO: consider when we add nested namespaces if ((nestedNs.getName().length() != 0) && matchName(nestedNs.getName(), strPrefix, match)) { res.put(nestedNs.getQualifiedName(), nestedNs); // TODO: Think if we really need nested namespaces here if (nestedNs.isInline()) { res.putAll(getNestedNamespaces(nestedNs, strPrefix, match, handledNS)); } } } } } return res; }
private void resolveContext(CsmNamespace context, CharSequence qualifiedName[], int current, Collection<CsmObject> result) { CharSequence[] cnn = qualifiedName; if (current >= cnn.length - 1) { result.add(context); return; } CsmSelect.CsmFilter filter = createNamespaceFilter(qualifiedName[current]); Iterator<CsmOffsetableDeclaration> decls = CsmSelect.getDeclarations(context, filter); if (!decls.hasNext() && hasTemplateSuffix(qualifiedName[current])) { filter = createNamespaceFilter(trimTemplateSuffix(qualifiedName[current])); decls = CsmSelect.getDeclarations(context, filter); } handleNamespaceDecls(decls, cnn, current, result); if (!hasTemplateSuffix(qualifiedName[current])) { Set<CsmNamespace> handledNamespaces = new HashSet<>(); for (CsmNamespace nested : context.getNestedNamespaces()) { if (!handledNamespaces.contains(nested)) { handledNamespaces.add(nested); if (qualifiedName[current].toString().equals(nested.getName().toString())) { resolveContext(nested, qualifiedName, current + 1, result); } } } } }
Collection<CsmNamespace> namespacesToSearchIn = searchNestedUnnamedNamespaces ? ns.getNestedNamespaces() : ns.getInlinedNamespaces();
for (CsmNamespace child : namespace.getNestedNamespaces()) { if (cancelled.get()) { break;
CsmNamespace namespace = getNamespace(); if (namespace != null) { for (CsmNamespace ns : namespace.getNestedNamespaces()) { PersistentKey key = PersistentKey.createKey(ns); if (key != null) {
Collection<CsmNamespace> namespaces = ns.getNestedNamespaces(); for (CsmNamespace namespace : namespaces) { if (namespace.getName().toString().equals(name.toString())) {