private String getSearchElementName(CsmObject csmObj) { assert csmObj != null; String objName; if (csmObj instanceof CsmReference) { objName = ((CsmReference)csmObj).getText().toString(); } else if (CsmKindUtilities.isNamedElement(csmObj)) { objName = ((CsmNamedElement)csmObj).getName().toString(); } else if (CsmKindUtilities.isInclude(csmObj)) { objName = ((CsmInclude)csmObj).getIncludeName().toString(); } else if (csmObj != null) { objName = "<UNNAMED ELEMENT>"; // NOI18N } else { objName = "<UNRESOLVED ELEMENT>"; // NOI18N } return objName; } }
public static CsmObject convertToCsmObjectIfNeeded(CsmObject referencedObject) { if (CsmKindUtilities.isInclude(referencedObject)) { referencedObject = ((CsmInclude) referencedObject).getIncludeFile(); } else if (CsmKindUtilities.isFunctionDefinition(referencedObject)) { CsmFunction decl = CsmBaseUtilities.getFunctionDeclaration((CsmFunction) referencedObject); if (decl != null) { referencedObject = decl; } } return referencedObject; }
@Override public String getReplaceText(CsmReference ref, String newText, AbstractRefactoring refactoring) { String out = null; final CsmObject referencedObject = ref.getReferencedObject(); if (CsmKindUtilities.isFile(referencedObject)) { final CsmObject owner = ref.getOwner(); assert CsmKindUtilities.isInclude(owner) : "include directive is expected " + owner; FileObject file = CsmUtilities.getFileObject((CsmFile) referencedObject); if (file != null) { String oldText = ref.getText().toString(); // check if include directive really contains file name and not macro expression String fileNameExt = file.getNameExt(); final int lastIndexOf = oldText.lastIndexOf(fileNameExt); if (lastIndexOf > 0) { String fileName = file.getName(); out = oldText.substring(0, lastIndexOf) + newText + oldText.substring(lastIndexOf + fileName.length()); } } } return out; }
public static boolean isSupportedReference(CsmReference ref) { if (ref != null) { if (ref.getClosestTopLevelObject() != null) { return !CsmKindUtilities.isMacro(ref.getClosestTopLevelObject()) && !CsmKindUtilities.isInclude(ref.getClosestTopLevelObject()); } } return false; }
final StringBuilder buf = new StringBuilder(); String found = item; boolean handleIncludeError = CsmKindUtilities.isInclude(error); if (handleIncludeError) { if (searchBase == null) {
public static CsmFile findFile(Node[] activatedNodes) { if (activatedNodes != null && activatedNodes.length > 0) { if (ContextUtils.USE_REFERENCE_RESOLVER) { CsmReference ref = ContextUtils.findReference(activatedNodes[0]); if (ref != null){ if (ref.getClosestTopLevelObject() != null) { if (CsmKindUtilities.isInclude(ref.getClosestTopLevelObject())) { CsmInclude incl = (CsmInclude) ref.getClosestTopLevelObject(); CsmFile file = incl.getIncludeFile(); if (file != null) { return file; } } } } } return ContextUtils.findFile(activatedNodes[0]); } return null; }
if (CsmKindUtilities.isType(anOwner) || CsmKindUtilities.isInheritance(anOwner)) { // owner is needed outKind = ReferencesSupport.getReferenceUsageKind(this); } else if (CsmKindUtilities.isInclude(anOwner)) { // owner not needed outKind = CsmReferenceKind.DIRECT_USAGE; } else {
} else if (CsmKindUtilities.isErrorDirective(o)) { return ERROR; } else if (CsmKindUtilities.isInclude(o)) { if (((CsmInclude) o).isSystem()) { return INCLUDE_SYSTEM;
} else if (CsmKindUtilities.isInclude(item)) { CsmInclude incl = (CsmInclude)item; CsmFile target = incl.getIncludeFile();