Skip to content

Commit 4d82160

Browse files
committed
Parse inactive code in sticky lines provider
1 parent 869651b commit 4d82160

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceStickyLinesProvider.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public List<IStickyLine> getStickyLines(ISourceViewer sourceViewer, int lineNumb
110110
// fetch AST on first request or if document modified
111111
if (documentModified || (null == fAst)) {
112112
try {
113-
fAst = tu.getAST(null, ITranslationUnit.AST_SKIP_ALL_HEADERS);
113+
fAst = tu.getAST(null,
114+
ITranslationUnit.AST_PARSE_INACTIVE_CODE | ITranslationUnit.AST_SKIP_ALL_HEADERS);
114115
if (DEBUG) {
115116
System.out.println("> Fetching AST: " + tu.toString()); //$NON-NLS-1$
116117
}
@@ -171,11 +172,21 @@ private List<IStickyLine> findPreprocessorStickyLines(int fileLineNumber, ISourc
171172
}
172173
if (nodeInstanceOfPreprocessorIfClass(statement) || statement instanceof IASTPreprocessorElifStatement
173174
|| statement instanceof IASTPreprocessorElseStatement) {
175+
if (DEBUG) {
176+
System.out.printf("> Pushing AST preprocessor node: %s (lines %d-%d)\n", //$NON-NLS-1$
177+
statement.getClass().getSimpleName(), statement.getFileLocation().getStartingLineNumber(),
178+
statement.getFileLocation().getEndingLineNumber());
179+
}
174180
stack.push(statement);
175181
} else if (statement instanceof IASTPreprocessorEndifStatement) {
176182
IASTPreprocessorStatement previous = statement;
177183
while (!stack.isEmpty() && !nodeInstanceOfPreprocessorIfClass(previous)) {
178184
previous = stack.pop();
185+
if (DEBUG) {
186+
System.out.printf("> Popping AST preprocessor node: %s (lines %d-%d)\n", //$NON-NLS-1$
187+
previous.getClass().getSimpleName(), previous.getFileLocation().getStartingLineNumber(),
188+
previous.getFileLocation().getEndingLineNumber());
189+
}
179190
}
180191
}
181192
}

0 commit comments

Comments
 (0)