protected final boolean isValid() { CsmFile file = getContainingFile(); return file != null && file.isValid(); } }
private synchronized void resetKeys(){ if (object.isValid()) { Set<CsmFile> set = model.getModel().get(object); if (set != null && set.size() > 0) { List<CsmFile> list = new ArrayList<CsmFile>(set); Collections.sort(list, COMARATOR); setKeys(list); return; } } setKeys(new CsmFile[0]); }
@Override public String getShortDescription() { if (object.isValid()) { return object.getAbsolutePath().toString(); } return super.getShortDescription(); }
public static List<CsmDeclaration> findFunctionLocalVariables(Document doc, int offset, FileReferencesContext fileReferncesContext) { CsmFile file = CsmUtilities.getCsmFile(doc, true, false); if (file == null || !file.isValid()) { return Collections.<CsmDeclaration>emptyList(); } CsmContext context = CsmOffsetResolver.findContext(file, offset, fileReferncesContext); return CsmContextUtilities.findFunctionLocalVariables(context); }
public static List<CsmDeclaration> findFileVariables(Document doc, int offset) { CsmFile file = CsmUtilities.getCsmFile(doc, true, false); if (file == null || !file.isValid()) { return Collections.<CsmDeclaration>emptyList(); } CsmContext context = CsmOffsetResolver.findContext(file, offset, null); return CsmContextUtilities.findFileLocalVariables(context); }
public static CsmClass findClassOnPosition(CsmFile file, Document doc, int offset) { if (file == null) { file = CsmUtilities.getCsmFile(doc, true, false); } if (file == null || !file.isValid()) { return null; } CsmContext context = CsmOffsetResolver.findContext(file, offset, null); CsmClass clazz = CsmContextUtilities.getClass(context, true, false); return clazz; }
@Override public Problem preCheck() { CsmUID uid = refactoring.getRefactoringSource().lookup(CsmUID.class); Problem invalidContext = new Problem(true, NbBundle.getMessage(CsmWhereUsedQueryPlugin.class, "MSG_InvalidObjectNothingToFind")); // NOI18N; if (uid == null) { CsmFile startFile = CsmRefactoringUtils.getCsmFile(startReferenceObject); if (startFile == null || !startFile.isValid()) { return invalidContext; } return super.preCheck(); } CsmObject referencedObject = (CsmObject) uid.getObject(); if (!CsmBaseUtilities.isValid(referencedObject)) { return invalidContext; } return super.preCheck(); }
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); } } } }
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); } } } }
if (cls != null && cls.isValid()) { CsmFile file = cls.getContainingFile(); if (file != null && file.isValid()) { UpdatebleHost host = hosts.get(PersistentKey.createKey(cls)); if (host != null) { if (cls.isValid()) { CsmFile file = cls.getContainingFile(); if (file != null && file.isValid()) { UpdatebleHost host = hosts.get(PersistentKey.createKey(cls)); if (host != null) { if (cls.isValid()) { CsmFile file = cls.getContainingFile(); if (file != null && file.isValid()) { UpdatebleHost host = hosts.get(PersistentKey.createKey(cls)); if (host != null) { CsmNamespaceDefinition cls = (CsmNamespaceDefinition)scope; CsmFile file = cls.getContainingFile(); if (file != null && file.isValid()) { UpdatebleHost host = hosts.get(PersistentKey.createKey(cls.getNamespace())); if (host != null) { if (cls.isValid()) { UpdatebleHost host = hosts.get(PersistentKey.createKey(project.getGlobalNamespace())); if (host != null) {
if (cls.isValid()) { CsmFile file = cls.getContainingFile(); if (file != null && file.isValid()) { return hosts.get(PersistentKey.createKey(cls)); if (cls.isValid()) { CsmFile file = cls.getContainingFile(); if (file != null && file.isValid()) { return hosts.get(PersistentKey.createKey(cls)); if (cls.isValid() && cls.getName().length()==0) { CsmFile file = cls.getContainingFile(); if (file != null && file.isValid()) { return hosts.get(PersistentKey.createKey(def));
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 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; }
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 public Action getPreferredAction() { if (object.isValid()) { Node parent = getParentNode(); if (parent instanceof IncludeNode){ CsmFile find = ((IncludeNode)parent).object; for (final CsmInclude inc : object.getIncludes()){ if (find.equals(inc.getIncludeFile())) { if (CsmKindUtilities.isOffsetable(inc)){ return new GoToFileAction(inc, model.getCloseWindowAction()); } break; } else if (object.equals(inc.getIncludeFile())){ if (CsmKindUtilities.isOffsetable(inc)){ return new GoToFileAction(inc, model.getCloseWindowAction()); } } } } return new GoToFileAction(object, model.getCloseWindowAction()); } return null; }
doc = CsmReferenceRepository.getDocument(csmFile); if (!(doc instanceof BaseDocument) || !csmFile.isValid()) {