private static CharSequence toString(CsmFunction func) { StringBuilder sb = new StringBuilder(); sb.append(func.getClass().getSimpleName()); sb.append(' '); sb.append(func.getQualifiedName()); sb.append(" ["); // NOI18N sb.append(func.getContainingFile().getName()); sb.append(':'); sb.append(func.getStartPosition().getLine()); sb.append(']'); return sb; } }
private FunctionUIN(CsmProject project, CsmFunction root) { this.project = project; functionUin = root.getUniqueName(); fileUid = UIDs.get(root.getContainingFile()); }
protected final CsmFunction chooseDeclaration(Collection<CsmDeclaration> decls) { CsmFunction out = null; if (decls.size() == 1) { out = (CsmFunction) decls.iterator().next(); } else { // choose declaration based on file name CsmFile sortFile = null; for (CsmDeclaration decl : decls) { CsmFunction fun = (CsmFunction) decl; CsmFile containingFile = fun.getContainingFile(); if (sortFile == null) { sortFile = containingFile; out = fun; } else if (CharSequences.comparator().compare(sortFile.getAbsolutePath(), containingFile.getAbsolutePath()) > 0) { sortFile = containingFile; out = fun; } } } return out; }
private SourceFileInfo findFunction(CsmProject csmProject, String name, int lineNumber) { CsmFunction function = getFunction(csmProject, name); if (function == null) { return null; } String sourceFile = function.getContainingFile().getAbsolutePath().toString(); int startOffset = function.getStartOffset(); if (lineNumber > 0) { return new SourceFileInfo(sourceFile, lineNumber, 0); } return new SourceFileInfo(sourceFile, startOffset); //) + offset); }
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); } } } }
FileReferencesContext(CsmScope csmScope){ if (CsmKindUtilities.isFile(csmScope)) { csmFile = (CsmFile) csmScope; } else if (CsmKindUtilities.isFunction(csmScope)) { csmFile = ((CsmFunction)csmScope).getContainingFile(); } else if (CsmKindUtilities.isOffsetable(csmScope)) { csmFile = ((CsmOffsetable)csmScope).getContainingFile(); } //lastOffset = 0; CsmListeners.getDefault().addProgressListener(this); }
final HashMap<CsmFunction,CsmReference> set = new HashMap<CsmFunction,CsmReference>(); for(CsmFunction function : functions) { if (CsmKindUtilities.isFunctionDefinition(function) && function.getContainingFile().isValid()) { final List<CsmOffsetable> list = CsmFileInfoQuery.getDefault().getUnusedCodeBlocks((function).getContainingFile(), Interrupter.DUMMY); references.accept((CsmScope)function, null, new CsmFileReferences.Visitor() { @Override
CsmFile containingFile = currentMethod.getContainingFile(); for (CsmParameter par: currentMethod.getParameters()) { CsmType desc = par.getType();
HashMap<CsmMacro,CsmReference> macros = new HashMap<CsmMacro,CsmReference>(); for(CsmFunction function : functions) { if (CsmKindUtilities.isFunction(function) && function.getContainingFile().isValid()) { for(CsmReference r : repository.getReferences(function, project, CsmReferenceKind.ANY_REFERENCE_IN_ACTIVE_CODE, Interrupter.DUMMY)){ if (r == null) {
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); } } } }
CsmFile containingFile = item.getContainingFile(); Document document = CsmUtilities.getDocument(containingFile); if (document == null) {
private boolean isInDeclaration(CsmFunction func, CsmFile csmFile, int offset) { CsmFunctionDefinition def; CsmFunction decl; if (CsmKindUtilities.isFunctionDefinition(func)) { def = (CsmFunctionDefinition) func; decl = def.getDeclaration(); } else { decl = func; def = func.getDefinition(); } if (def != null) { if (csmFile.equals(def.getContainingFile()) && (def.getStartOffset() <= offset && offset <= def.getBody().getStartOffset())) { return true; } } if (decl != null) { // just declaration if (csmFile.equals(decl.getContainingFile()) && (decl.getStartOffset() <= offset && offset <= decl.getEndOffset())) { return true; } } return false; }
String rightText = createRightName(item); String coloredItemText = createDisplayName(item, cls, NbBundle.getMessage(CsmImplementsMethodCompletionItem.class, "extract.txt")); //NOI18N CsmFile containingFile = item.getContainingFile(); CsmCompoundStatement body = ((CsmFunctionDefinition)item).getBody(); if (item.getStartOffset() == body.getStartOffset()) {
private List<CsmType> createFunctionParams(Collection<AST> targetFunParamsAsts, CsmFunction context) { List<CsmType> params = new ArrayList<>(); for (AST paramAst : targetFunParamsAsts) { if (paramAst != null) { AST paramTypeStart = paramAst.getFirstChild(); while (paramTypeStart != null && !AstUtil.isTypeNode(paramTypeStart) && !AstRenderer.isQualifier(paramTypeStart.getType())) { paramTypeStart = paramTypeStart.getNextSibling(); } if (paramTypeStart != null && AstRenderer.isQualifier(paramTypeStart.getType())) { AST typeAst = AstRenderer.getFirstSiblingSkipQualifiers(paramTypeStart); if (!AstUtil.isTypeNode(typeAst)) { paramTypeStart = null; } } if (paramTypeStart != null) { AST ptrOperator = AstUtil.findSiblingOfType(paramTypeStart, CPPTokenTypes.CSM_PTR_OPERATOR); // TODO: AST has wrong offsets here! CsmType type = TypeFactory.createType(paramTypeStart, context.getContainingFile(), ptrOperator, 0, context.getScope()); params.add(type); } } } return params; }
scopeFile = ((CsmFunction) referencedObject).getContainingFile();