@Override public boolean isGlobal() { return wrapped.isGlobal(); }
if (objContext.objNs != null) { boolean isNested = false; if (!objContext.objNs.isGlobal() && (csmFunction.objNs != null) && !csmFunction.objNs.isGlobal()) { CsmNamespace ns = csmFunction.objNs; if (ns.equals(objContext.objNs)) { isNested = true; } else { while (ns != null && !ns.isGlobal()) { if (ns.equals(objContext.objNs)) { out = XRefResultSet.DeclarationScope.NAMESPACE_PARENT; if (objContext.objNs.isGlobal()) { out = csmFunction.objPrj.equals(objContext.objPrj) ? XRefResultSet.DeclarationScope.PROJECT_GLOBAL : XRefResultSet.DeclarationScope.LIBRARY_GLOBAL; } else {
/** it's a list, not just collection because order matters */ private List<CsmNamespace> getContextNamespaces(CsmContext context) { CsmNamespace ns = CsmContextUtilities.getNamespace(context); List<CsmNamespace> out = new ArrayList<CsmNamespace>(); while (ns != null && !ns.isGlobal()) { out.add(ns); ns = ns.getParent(); } return out; }
public static CharSequence getQualifiedName(CharSequence name, CsmNamespace parent) { if (parent != null && !parent.isGlobal()) { return CharSequenceUtils.concatenate(parent.getQualifiedName(), "::", name); // NOI18N } return name; }
private void fillFileLocalIncludeNamespaceVariables(CsmNamespace ns, String strPrefix, boolean match, CsmFile file, Collection<CsmVariable> out, boolean needDeclFromUnnamedNS) { if (!ns.isGlobal()) { CsmDeclaration.Kind[] kinds = new CsmDeclaration.Kind[]{ CsmDeclaration.Kind.VARIABLE, CsmDeclaration.Kind.VARIABLE_DEFINITION }; Collection<CsmScopeElement> se = new ArrayList<CsmScopeElement>(); getFileLocalIncludeNamespaceMembers(ns, file, se, needDeclFromUnnamedNS); List<CsmVariable> vars = new ArrayList<CsmVariable>(); filterDeclarations(se.iterator(), vars, kinds, strPrefix, match, false); vars = filterVariables(vars); out.addAll(vars); } else { // Global ns doesn't have definitions, so search in file instead List<CsmVariable> allLocalDecls = new ArrayList<CsmVariable>(); fillFileLocalVariables(strPrefix, match, file, needDeclFromUnnamedNS, false, allLocalDecls); // Unlike getFileLocalIncludeNamespaceMembers (used in first branch), // fillFileLocalVariables for some reason returns not only variables without // external linkage, so need to filter results before adding to out. out.addAll(filterFileLocalStaticVariables(allLocalDecls)); } }
/** * 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; }
@Override public Collection<CsmDeclaration> findUsedDeclarations(CsmNamespace namespace) { List<CsmUsingDeclaration> res = new ArrayList<>(); Iterator<CsmOffsetableDeclaration> udecls = CsmSelect.getDeclarations( namespace, CsmSelect.getFilterBuilder().createKindFilter(CsmDeclaration.Kind.USING_DECLARATION)); while (udecls.hasNext()) { res.add((CsmUsingDeclaration) udecls.next()); } // Let's also look for similarly named namespace in libraries, // like it's done in CsmProjectContentResolver.getNamespaceMembers() if (!namespace.isGlobal()) { for(CsmProject lib : namespace.getProject().getLibraries()){ CsmNamespace ns = lib.findNamespace(namespace.getQualifiedName()); if (ns != null) { Iterator<CsmOffsetableDeclaration> it = CsmSelect.getDeclarations( ns, CsmSelect.getFilterBuilder().createKindFilter(CsmDeclaration.Kind.USING_DECLARATION)); while (it.hasNext()) { res.add((CsmUsingDeclaration) it.next()); } } } } return extractDeclarations(res); }
private CsmNamespace findNamespaceInInlined(CsmNamespace ns, CharSequence qualifiedNamePart) { CsmNamespace result = null; if (ns != null) { for (CsmNamespace inlinedNs : ns.getInlinedNamespaces()) { String fqn = (inlinedNs.isGlobal() ? "" : (inlinedNs.getQualifiedName() + "::")) + qualifiedNamePart; // NOI18N result = findNamespace(fqn); if (result == null) { result = findNamespaceInInlined(inlinedNs, qualifiedNamePart); } if (result != null) { break; } } } return result; }
if (!namespace.isGlobal()) { for(CsmProject lib : namespace.getProject().getLibraries()){ CsmNamespace ns = lib.findNamespace(namespace.getQualifiedName());
if (!CsmKindUtilities.isNamespace(scope) || !((CsmNamespace)scope).isGlobal()) { cancelled.set(true); return;
private static XRefResultSet.ContextScope classifyFunctionScope(CsmFunction fun, PrintWriter printOut) { assert fun != null; XRefResultSet.ContextScope out = XRefResultSet.ContextScope.UNRESOLVED; CsmScope outScope = fun.getScope(); if (outScope == null) { printOut.println("ERROR: no scope for function " + fun); // NOI18N return out; } if (CsmKindUtilities.isConstructor(fun)) { out = CsmBaseUtilities.isInlineFunction(fun) ? XRefResultSet.ContextScope.INLINED_CONSTRUCTOR : XRefResultSet.ContextScope.CONSTRUCTOR; } else if (CsmKindUtilities.isMethod(fun)) { out = CsmBaseUtilities.isInlineFunction(fun) ? XRefResultSet.ContextScope.INLINED_METHOD : XRefResultSet.ContextScope.METHOD; } else { if (CsmKindUtilities.isFile(outScope)) { out = XRefResultSet.ContextScope.FILE_LOCAL_FUNCTION; } else { CsmNamespace ns = CsmBaseUtilities.getFunctionNamespace(fun); if (ns != null) { out = ns.isGlobal() ? XRefResultSet.ContextScope.GLOBAL_FUNCTION : XRefResultSet.ContextScope.NAMESPACE_FUNCTION; } } } if (out == XRefResultSet.ContextScope.UNRESOLVED) { printOut.println("ERROR: non classified function " + fun); // NOI18N } return out; }
private CsmNamespace findNamespace(CsmNamespace ns, CharSequence qualifiedNamePart) { CsmNamespace result = null; if (ns == null) { result = findNamespace(qualifiedNamePart); } else { CsmNamespace containingNs = ns; while (containingNs != null && result == null) { String fqn = (containingNs.isGlobal() ? "" : (containingNs.getQualifiedName() + "::")) + qualifiedNamePart; // NOI18N result = findNamespace(fqn); if (result == null) { result = findNamespaceInInlined(containingNs, qualifiedNamePart); } containingNs = containingNs.getParent(); } } return result; }
if (ns.isGlobal()) { libNmsp = lib.getGlobalNamespace(); } else {
CsmNamespace ns = (CsmNamespace) scope; CharSequence qn; if (ns.isGlobal()) { qn = prefix; } else {
case NAMESPACE_ADDED: assert obj instanceof CsmNamespace; assert !((CsmNamespace)obj).isGlobal(); Notificator.instance().registerNewNamespace((CsmNamespace)obj); break; case NAMESPACE_REMOVED: assert obj instanceof CsmNamespace; assert !((CsmNamespace)obj).isGlobal(); Notificator.instance().registerRemovedNamespace((CsmNamespace)obj); break;
if (!currentNamespace.isGlobal()) { StringBuilder sb = new StringBuilder(currentNamespace.getQualifiedName()); sb.append(APTUtils.SCOPE);
if (!ns.isGlobal()) { htmlHeader = ns.getQualifiedName().toString();
if (CsmKindUtilities.isNamespace(scope) && !((CsmNamespace)scope).isGlobal()) {
containingFunction = fd; CsmNamespace ns = BaseUtilitiesProviderImpl.getImpl()._getFunctionNamespace(fd); if( ns != null && ! ns.isGlobal() ) { containingNamespace = ns;