@Override public CsmFile getContainingFile() { return include.getIncludeFile(); }
for (Iterator<CsmInclude> it = includes.iterator(); it.hasNext(); ){ CsmInclude incl = it.next(); files.add(incl.getContainingFile()); String name; if (incl.isSystem()){ name = "<"+incl.getIncludeName()+">"; // NOI18N } else { name = "\""+incl.getIncludeName()+"\""; // NOI18N
public IncludeErrorInfo(CsmInclude incl) { super(incl, Severity.ERROR); if (incl.getIncludeState() == IncludeState.Recursive) { this.message = decorateWithExtraHyperlinkTip(NbBundle.getMessage(IncludeErrorProvider.class, "HighlightProvider_IncludeRecursive")); } else { this.message = decorateWithExtraHyperlinkTip(NbBundle.getMessage(IncludeErrorProvider.class, "HighlightProvider_IncludeMissed", getIncludeText(incl))); } }
private static String getIncludeText(CsmInclude incl){ if (incl.isSystem()){ return "<"+incl.getIncludeName()+">"; // NOI18N } return "\""+incl.getIncludeName()+"\""; // NOI18N }
Offsets(CsmInclude include){ startOffset = include.getStartOffset(); endOffset = include.getEndOffset(); object = include; } Offsets(int offset){
private String getIncludeName(CsmFile file, int offset) { for (CsmInclude inc : file.getIncludes()) { if (inc.getStartOffset() == offset) { if(inc.isSystem()) { StringBuilder sb = new StringBuilder("<"); // NOI18N sb.append(inc.getIncludeName().toString()); sb.append(">"); // NOI18N return sb.toString(); } else { StringBuilder sb = new StringBuilder("\""); // NOI18N sb.append(inc.getIncludeName().toString()); sb.append("\""); // NOI18N return sb.toString(); } } } return null; }
includeStack = CsmFileInfoQuery.getDefault().getIncludeStack(errorDirective); CsmFile includedFile = includeTarget == null ? null : includeTarget.getIncludeFile(); if (includedFile != null) { buf = new StringBuilder(tooltip); String inclString; if (brokenInclude.isSystem()) { inclString = "#include <" + brokenInclude.getIncludeName() + ">"; // NOI18N } else { inclString = "#include \"" + brokenInclude.getIncludeName() + "\""; // NOI18N String key = brokenInclude.getIncludeState() == CsmInclude.IncludeState.Recursive ? "RecursionInFile" : "UnresolvedInFile"; // NOI18N buf.append(i18n(key, CsmDisplayUtilities.htmlize(inclString), brokenInclude.getContainingFile().getAbsolutePath())); tooltip = buf.toString(); out.println("path to file " + csmFile.getAbsolutePath(), new RefLink(csmFile)); // NOI18N for (CsmInclude incl : includeStack) { out.println(incl.getText() + " from file " + incl.getContainingFile().getAbsolutePath(), new RefLink(incl)); // NOI18N
while (iter.hasNext()) { CsmInclude inc = iter.next(); if (inc.getStartOffset() >= stopAtOffset) { break; lastIncludeOffset = inc.getEndOffset(); CsmFile includedFrom = inc.getContainingFile(); int incOffset = inc.getStartOffset(); gatherMaps(includedFrom, incOffset, out); CsmFile incFile = inc.getIncludeFile(); if (incFile != null) { gatherMaps(incFile, Integer.MAX_VALUE, out);
while (iter.hasNext()){ CsmInclude inc = iter.next(); if (inc.getStartOffset() < startOffset) { continue; if (inc.getEndOffset() < endOffset) { if (endOffset != MAX_FILE_OFFSET) { returnPoint = inc.getEndOffset(); localReturnPoint = returnPoint; localEndPoint = localReturnPoint; CsmFile incFile = inc.getIncludeFile(); if( incFile != null && (onlyInProject == null || incFile.getProject() == onlyInProject)) {
CsmFile srcFile = include.getContainingFile(); int endOffset = include.getStartOffset(); Iterator<CsmVariable> it = CsmSelect.getStaticVariables(srcFile, filter); while (it.hasNext()) { CsmFile f = incl.getIncludeFile(); if (f != null) { fillFileLocalIncludeVariables(filter, f, out, antiLoop, false);
} else if (CsmKindUtilities.isInclude(item)) { CsmInclude incl = (CsmInclude)item; CsmFile target = incl.getIncludeFile(); if (target == null) { if (incl.getIncludeState() == CsmInclude.IncludeState.Recursive) { tooltipText = getHtmlizedString("DSC_IncludeRecursiveTooltip", incl.getText()); // NOI18N } else { tooltipText = getHtmlizedString("DSC_IncludeErrorTooltip", incl.getText()); // NOI18N
CsmInclude find = null; for(CsmInclude inc : startFile.getIncludes()){ if (offset == inc.getStartOffset()){ find = inc; break; startFile = find.getIncludeFile(); if (startFile == null) { break;
public boolean goToInclude(Document doc, JTextComponent target, int offset, HyperlinkType type) { if (!preJump(doc, target, offset, "opening-include-element", type)) { //NOI18N return false; } IncludeTarget item = findTargetObject(doc, offset); if (type == HyperlinkType.ALT_HYPERLINK && ((item != null))) { CsmInclude incl = item.getInclude(); CsmFile toShow = incl.getIncludeFile(); if (toShow == null) { toShow = incl.getContainingFile(); } else { CsmInclude brokenInclude = getFirstBrokenIncludeInsideIncludedFiles(toShow, new HashSet<CsmFile>()); if (brokenInclude != null) { toShow = brokenInclude.getContainingFile(); // jump into problem file return postJump(brokenInclude, "goto_source_source_not_found", "cannot-open-include-element");//NOI18N } } CsmIncludeHierarchyResolver.showIncludeHierachyView(toShow); return true; } else { return postJump(item, "goto_source_source_not_found", "cannot-open-include-element");//NOI18N } }
@Override protected void doGetErrors(CsmErrorProvider.Request request, CsmErrorProvider.Response response) { CsmFile file = request.getFile(); Thread currentThread = Thread.currentThread(); currentThread.setName("Provider "+getName()+" prosess "+file.getAbsolutePath()); // NOI18N for(CsmInclude incl : CsmFileInfoQuery.getDefault().getBrokenIncludes(file)) { if (request.isCancelled()) { break; } if (incl.getIncludeState() == IncludeState.Recursive) { response.addError(new IncludeErrorInfo(incl)); } else if(incl.getIncludeFile() == null) { response.addError(new IncludeErrorInfo(incl)); } } for (CsmErrorDirective error : file.getErrors()) { response.addError(new ErrorDirectiveInfo(error)); } Collection<CsmFile> visited = new HashSet<CsmFile>(); for (CsmInclude incl : file.getIncludes()) { CsmFile newFile = incl.getIncludeFile(); if (newFile != null && hasBrokenIncludes(newFile, visited)) { response.addError(new IncludeWarningInfo(incl)); } } }
private void appendInclStack(StringBuilder buf, List<CsmInclude> includeStack) { if (!includeStack.isEmpty()) { buf.append("<i>").append(i18n("PathToCurFile")).append("</i>\n"); // NOI18N for (CsmInclude inc : includeStack) { if (inc != null) { final CsmFile file = inc.getContainingFile(); CharSequence path = null; if (file != null) { path = file.getAbsolutePath(); } if (path == null) { path = "?"; //NOI18N } final CsmOffsetable.Position startPosition = inc.getStartPosition(); int line = -1; if (startPosition != null) { line = startPosition.getLine(); } if (file != null && startPosition != null){ String msg = i18n("PathToHeaderOnLine", path.toString(), line); // NOI18N buf.append(msg).append('\n'); } } } } }
@Override public CharSequence getText() { return include.getIncludeName(); } }
boolean isLastIncludeTypeMatch = false; for (CsmInclude inc : currentFile.getIncludes()) { if (inc.getEndOffset() <= substOffset) { if (inc.isSystem() == isSystem) { lastInclude = inc; isLastIncludeTypeMatch = true;
private static List<KindAndSignature> createFileSignature(CsmFile csmFile) { Collection<FileElement> fileElements = new TreeSet<>(PAIR_COMPARATOR); for (CsmInclude element : csmFile.getIncludes()) { // TODO: what about system vs user, shouldn't it be part of Utils.getCsmIncludeKindKey? CharAndCharSequence cs = new CharAndCharSequence(element.getIncludeName(), Utils.getCsmIncludeKindKey()); FileElement fe = new FileElement(element.getStartOffset(), cs); fileElements.add(fe); } for (CsmMacro element : csmFile.getMacros()) { MacroCharSequence cs = new MacroCharSequence(element.getName(), element.getBody(), Utils.getCsmDeclarationKindkey(CsmDeclaration.Kind.MACRO)); FileElement fe = new FileElement(element.getStartOffset(), cs); fileElements.add(fe); } for (CsmOffsetableDeclaration element : csmFile.getDeclarations()) { addDeclarationAndNested(fileElements, element); } ArrayList<KindAndSignature> out = new ArrayList<>(fileElements.size()); for (FileElement fe : fileElements) { out.add(fe.signature); } out.trimToSize(); return out; }
private void gatherFileMaps() { final HashSet<CsmFile> visitedFiles = new HashSet<>(); // gather all visible by this file's include stack List<CsmInclude> includeStack = CsmFileInfoQuery.getDefault().getIncludeStack(destFile); for (CsmInclude inc : includeStack) { CsmFile includedFrom = inc.getContainingFile(); int incOffset = inc.getStartOffset(); gatherFileMaps(visitedFiles, includedFrom, MIN_FILE_OFFSET, incOffset); } // gather all visible by this file upto destination offset gatherFileMaps(visitedFiles, this.destFile, this.startOffset, this.destOffset); }
out = incl.isSystem() ? XRefResultSet.IncludeLevel.LIBRARY_DIRECT : XRefResultSet.IncludeLevel.PROJECT_DIRECT; } else { out = file.getProject().equals(objPrj) ? XRefResultSet.IncludeLevel.PROJECT_DEEP : XRefResultSet.IncludeLevel.LIBRARY_DEEP;