@Override public int getIncludeDirectiveOffset() { return include.getStartOffset(); }
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; }
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); }
CsmInclude find = null; for(CsmInclude inc : startFile.getIncludes()){ if (offset == inc.getStartOffset()){ find = inc; break;
for (CsmInclude include : includeStack) { CsmFile srcFile = include.getContainingFile(); int endOffset = include.getStartOffset(); Iterator<CsmVariable> it = CsmSelect.getStaticVariables(srcFile, filter); while (it.hasNext()) {
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; }
while (iter.hasNext()) { CsmInclude inc = iter.next(); if (inc.getStartOffset() >= stopAtOffset) { break;
while (iter.hasNext()) { CsmInclude inc = iter.next(); if (inc.getStartOffset() >= stopAtOffset) { break; for (CsmInclude inc : includeStack) { CsmFile includedFrom = inc.getContainingFile(); int incOffset = inc.getStartOffset(); gatherMaps(includedFrom, incOffset, out);
for (CsmInclude include : fileContent.getIncludes()) { if (include instanceof IncludeImpl) { if (include.getStartOffset() > inclContainer.getStartOffset() && include.getEndOffset() < inclContainer.getEndOffset()) { if (curFile.equals(offs.getContainingFile())) { if (include.getStartOffset() > offs.getStartOffset() && include.getEndOffset() < offs.getEndOffset()) {
while (iter.hasNext()){ CsmInclude inc = iter.next(); if (inc.getStartOffset() < startOffset) { continue;
private TokenStream getTokenStreamOfIncludedFile(final CsmInclude include) { FileImpl file = (FileImpl) include.getIncludeFile(); if (file != null && file.isValid()) { // create ppHandler till #include directive PreprocessorStatePair includeContextPair = this.getContextPreprocStatePair(include.getStartOffset(), include.getEndOffset()); if (includeContextPair == null) { return file.getTokenStream(0, Integer.MAX_VALUE, 0, true); } APTPreprocHandler.State thisFileStartState = includeContextPair.state; LinkedList<APTIncludeHandler.IncludeInfo> reverseInclStack = APTHandlersSupport.extractIncludeStack(thisFileStartState); reverseInclStack.addLast(new IncludeInfoImpl(include, file.getAbsolutePath())); ProjectBase projectImpl = getProjectImpl(true); if (projectImpl == null) { return file.getTokenStream(0, Integer.MAX_VALUE, 0, true); } APTPreprocHandler preprocHandler = projectImpl.createEmptyPreprocHandler(getAbsolutePath()); APTPreprocHandler restorePreprocHandlerFromIncludeStack = projectImpl.restorePreprocHandlerFromIncludeStack(reverseInclStack, getAbsolutePath(), preprocHandler, thisFileStartState, Interrupter.DUMMY); // using restored preprocessor handler, ask included file for parsing token stream filtered by language TokenStream includedFileTS = file.createParsingTokenStreamForHandler(restorePreprocHandlerFromIncludeStack, true, null, null); if(includedFileTS != null) { APTLanguageFilter languageFilter = file.getLanguageFilter(thisFileStartState); return languageFilter.getFilteredStream(includedFileTS); } } return null; }
doc.insertString(lastInclude2.getEndOffset(), "\n\n" + include, null); // NOI18N } else { doc.insertString(lastInclude2.getStartOffset(), include + "\n\n", null); // NOI18N