public NamespaceResultItem(CsmNamespace pkg, boolean displayFullNamespacePath, int priotity) { super(pkg, priotity); this.pkg = pkg; this.displayFullNamespacePath = displayFullNamespacePath; this.pkgName = pkg.getName(); }
@Override public CharSequence getName() { return wrapped.getName(); }
@Override public String getItemText() { return displayFullNamespacePath ? pkg.getQualifiedName().toString() : pkg.getName().toString(); }
/** * 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; }
buf.append(":NS=").append(context.getContainingNamespace().getName()); // NOI18N
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; }
public static CharSequence getNamespaceDisplayName(CsmNamespace ns){ CharSequence displayName = ns.getName(); if (displayName.length() == 0) { Collection<CsmNamespaceDefinition> definitions = ns.getDefinitions(); CharSequence fileName = null; if (definitions.size() == 1) { CsmNamespaceDefinition def = definitions.iterator().next(); CsmScope file = def.getScope(); if (file instanceof CsmFile) { fileName = ((CsmFile)file).getName(); } } displayName = ns.getQualifiedName(); int scope = CharSequenceUtils.lastIndexOf(displayName, "::"); // NOI18N if (scope != -1) { displayName = displayName.subSequence(scope + 2, displayName.length()); } int start = CharSequenceUtils.indexOf(displayName, '<'); int end = CharSequenceUtils.indexOf(displayName, '>'); if (start >=0 && end >= 0 && start < end && fileName != null) { CharSequence name = displayName.subSequence(start+1, end); displayName = name+" ("+fileName+")"; // NOI18N } else { if (CharSequenceUtils.indexOf(displayName, '<') >=0 || CharSequenceUtils.indexOf(displayName, '>') >=0) { // NOI18N displayName = displayName.toString().replace('<', ' ').replace('>', ' '); // NOI18N } } } return NameCache.getManager().getString(displayName); }
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); } } } } }
CsmNamespace nestedNs = (CsmNamespace) it.next(); boolean goDeeper = (searchNestedUnnamedNamespaces && nestedNs.getName().length() == 0) || nestedNs.isInline(); handledNS.add(parentNS); strPrefix = ns.getName() + SCOPE + strPrefix; // NOI18N filterDeclarations(parentNS, res, kinds, strPrefix, match, returnUnnamedInParentNs);
} else if (CsmKindUtilities.isNamespaceDefinition(enclScope)) { CsmNamespace ns = ((CsmNamespaceDefinition) enclScope).getNamespace(); if (ns != null && ns.getName().length() == 0) {
Collection<CsmNamespace> namespaces = ns.getNestedNamespaces(); for (CsmNamespace namespace : namespaces) { if (namespace.getName().toString().equals(name.toString())) { newNs = namespace; break;