@Override public CsmObject getCsmObject() { if (!object.isValid()) { CsmDeclaration d = project.findDeclaration(uin); if (d instanceof CsmClass) { object = (CsmClass) d; } } return object; }
private CsmFunction findDeclaration(CsmProject prj, String uname){ Collection<CsmDeclaration> decls = new ArrayList<>(1); for(CsmOffsetableDeclaration candidate : prj.findDeclarations(uname)) { if ((candidate.getKind() == CsmDeclaration.Kind.FUNCTION || candidate.getKind() == CsmDeclaration.Kind.FUNCTION_FRIEND)) { if (FunctionImpl.isObjectVisibleInFile(getContainingFile(), candidate)) { decls.add(candidate); } } } CsmDeclaration decl = chooseDeclaration(decls); if( decl != null) { return (CsmFunction) decl; } FunctionParameterListImpl parameterList = getParameterList(); if (parameterList != null && !parameterList.isEmpty()) { CsmFile file = getContainingFile(); if (!Utils.isCppFile(file)){ uname = uname.substring(0,uname.indexOf('('))+"()"; // NOI18N decl = prj.findDeclaration(uname); if( (decl instanceof FunctionImpl<?>) && !((FunctionImpl<?>)decl).isVoidParameterList()) { return (CsmFunction) decl; } } } return null; }
public Object getObject(){ switch(kind){ case UID: return ((CsmUID)key).getObject(); case DECLARATION: return project.findDeclaration((CharSequence)key); } return null; }
public Object getObject(){ int maskKind = kind & MASK; switch(maskKind){ case UID: return ((CsmUID)key).getObject(); case NAMESPACE: return project.findNamespace((CharSequence)key); case DECLARATION: return project.findDeclaration((CharSequence)key); case PROJECT: return project; case PROJECT_LIBS: return project; } return null; }
private boolean findGlobal(CsmProject project, String uname, Collection<CsmProject> processedProjects) { if (processedProjects.contains(project)) { return false; } processedProjects.add(project); final CsmDeclaration decl = project.findDeclaration(uname); if (decl != null && CsmIncludeResolver.getDefault().isObjectVisible(file, decl)) { return true; } for (CsmProject lib : project.getLibraries()) { if (findGlobal(lib, uname, processedProjects)) { return true; } } return false; }
CharSequence uniqueName = decl.getUniqueName(); CsmProject project = decl.getContainingFile().getProject(); CsmOffsetableDeclaration duplicated = (CsmOffsetableDeclaration) project.findDeclaration(uniqueName); if (duplicated != null) { changed.put(decl, duplicated);
private void removeFunctionDeclaration(final CsmOffsetableDeclaration decl) { CsmFunction fun = (CsmFunction)decl; CsmFile file = fun.getContainingFile(); if (file != null && file.isValid()){ CsmOffsetableDeclaration other = (CsmOffsetableDeclaration) file.getProject().findDeclaration(fun.getUniqueName()); if (other != null) { PersistentKey otherKey = PersistentKey.createKey(other); if (!myKeys.containsKey(otherKey)) { myKeys.put(otherKey,getSortedName(other)); myChanges.remove(otherKey); return; } } } CsmFunctionDefinition def = fun.getDefinition(); if (def != null && def != decl){ file = fun.getContainingFile(); if (file != null && file.isValid() && file.getProject().findDeclaration(def.getUniqueName()) != null){ PersistentKey defKey = PersistentKey.createKey(def); if (!myKeys.containsKey(defKey)) { myKeys.put(defKey,getSortedName(def)); myChanges.remove(defKey); } } } }
if (j > 0) { String simplyfiedFQN = leftPartOfFQN + " " + rightPartOfFQN.substring(j + 2); // NOI18N result = prj.findDeclaration(simplyfiedFQN);
@Override public CsmVariableDefinition getDefinition() { if (!isValid()) { return null; } String uname = ""+Utils.getCsmDeclarationKindkey(CsmDeclaration.Kind.VARIABLE_DEFINITION) + UNIQUE_NAME_SEPARATOR + getQualifiedName();//NOI18N CsmDeclaration def = getContainingFile().getProject().findDeclaration(uname); return (def == null) ? null : (CsmVariableDefinition) def; }
private void removeFunctionDefinition(final CsmOffsetableDeclaration decl) { CsmFunctionDefinition def = (CsmFunctionDefinition) decl; CsmFunction fun = def.getDeclaration(); if (fun != null && fun != decl){ CsmFile file = fun.getContainingFile(); if (file != null && file.isValid()){ CsmOffsetableDeclaration other = (CsmOffsetableDeclaration) file.getProject().findDeclaration(fun.getUniqueName()); if (other != null) { PersistentKey otherKey = PersistentKey.createKey(other); if (!myKeys.containsKey(otherKey)) { myKeys.put(otherKey,getSortedName(other)); myChanges.remove(otherKey); return; } } } } CsmFile file = def.getContainingFile(); if (file != null && file.isValid()){ CsmOffsetableDeclaration other = (CsmOffsetableDeclaration) file.getProject().findDeclaration(def.getUniqueName()); if (other != null) { PersistentKey otherKey = PersistentKey.createKey(other); if (!myKeys.containsKey(otherKey)) { myKeys.put(otherKey,getSortedName(other)); myChanges.remove(otherKey); } } } }
private CsmFunction getFunction() { if (!project.isValid()) { return null; } CsmFunction root = (CsmFunction) project.findDeclaration(functionUin); if (root != null) { return root; } CsmFile file = fileUid.getObject(); if (!file.isValid()) { return null; } for (CsmDeclaration d : file.getDeclarations()) { root = findFunction(d); if (root != null){ return root; } } return null; }
CsmDeclaration decl = proj.findDeclaration(fqn.toString()); if(decl instanceof ClassImplSpecialization && CsmIncludeResolver.getDefault().isObjectVisible(contextFile, decl)) { specialization = (CsmClassifier) decl;
private CsmVariable findDeclaration() { if (!isValid()) { return null; } String uname = CharSequenceUtils.toString(CsmDeclaration.Kind.VARIABLE.toString(), UNIQUE_NAME_SEPARATOR, getQualifiedName()); CsmDeclaration def = getContainingFile().getProject().findDeclaration(uname); if( def == null ) { CsmObject owner = findOwner(); if( owner instanceof CsmClass ) { CsmFilter filter = CsmSelect.getFilterBuilder().createNameFilter(getName(), true, true, false); def = findByName(CsmSelect.getClassMembers((CsmClass)owner, filter), getName()); } else if( owner instanceof CsmNamespace ) { CsmFilter filter = CsmSelect.getFilterBuilder().createCompoundFilter( CsmSelect.getFilterBuilder().createKindFilter(CsmDeclaration.Kind.VARIABLE), CsmSelect.getFilterBuilder().createNameFilter(getName(), true, true, false)); Iterator<CsmOffsetableDeclaration> it = CsmSelect.getDeclarations(((CsmNamespace)owner), filter); while (it.hasNext()) { def = it.next(); } } } return (CsmVariable) def; }