/** * Method for tracking macro expansions. * * @since 5.0 */ public void expand( String beforeExpansion, MacroExpansionTracker tracker, String filePath, int lineNumber, boolean protectDefinedConstructs) { fImplicitMacroExpansions.clear(); fImageLocationInfos.clear(); fFixedInput = beforeExpansion.toCharArray(); fFixedCurrentFilename = filePath; fFixedLineNumber = lineNumber; Lexer lexer = new Lexer(fFixedInput, fLexOptions, fLog, this); try { tracker.start(lexer); Token identifier = lexer.nextToken(); if (identifier.getType() != IToken.tIDENTIFIER) { tracker.fail(); return; } PreprocessorMacro macro = fDictionary.get(identifier.getCharImage()); if (macro == null) { tracker.fail(); return; } lexer.nextToken(); fStartOffset = identifier.getOffset(); fEndOffset = identifier.getEndOffset(); fCompletionMode = false; IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden = new IdentityHashMap<PreprocessorMacro, PreprocessorMacro>(); // setup input sequence TokenSource input = new TokenSource(lexer); TokenList firstExpansion = new TokenList(); firstExpansion.append(new ExpansionBoundary(macro, true)); expandOne(identifier, macro, forbidden, input, firstExpansion, tracker); firstExpansion.append(new ExpansionBoundary(macro, false)); input.prepend(firstExpansion); TokenList result = expandAll(input, forbidden, protectDefinedConstructs, tracker); tracker.finish(result, fEndOffset); } catch (OffsetLimitReachedException e) { } }