Skip to content

Commit 745799b

Browse files
Pass FORCE_PROBLEM_DETECTION from reconcile to CompilationUnitResolver (eclipse-jdt#4634)
Through ASTParser. The ASTParser implementation may trigger extra analysis on demand. The FORCE_PROBLEM_DETECTION flag must be somehow passed to underlying ICompilationUnitResolver implementation to allow that. Fixes eclipse-jdt#4631
1 parent 2a92751 commit 745799b

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,21 @@ public void setResolveBindings(boolean enabled) {
486486
}
487487
}
488488

489+
/**
490+
* Requests for the compiler to force problem detection (such as extra analysis
491+
* or linting configured in project).
492+
* @param enabled <code>true</code> if problems are wanted, and <code>false</code>
493+
* if problems are not of interest.
494+
* @since 3.44
495+
*/
496+
public void setForceProblemDetection(boolean enabled) {
497+
if (enabled) {
498+
this.bits |= CompilationUnitResolver.FORCE_PROBLEM_DETECTION;
499+
} else {
500+
this.bits &= ~CompilationUnitResolver.FORCE_PROBLEM_DETECTION;
501+
}
502+
}
503+
489504
/**
490505
* Requests an abridged abstract syntax tree.
491506
* By default, complete ASTs are returned.

org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public static synchronized ICompilationUnitResolver getInstance() {
126126
public static final int IGNORE_METHOD_BODIES = 0x8;
127127
public static final int BINDING_RECOVERY = 0x10;
128128
public static final int INCLUDE_RUNNING_VM_BOOTCLASSPATH = 0x20;
129+
public static final int FORCE_PROBLEM_DETECTION = 0x40;
129130

130131
/* A list of int */
131132
static class IntArrayList {

org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,9 @@ public org.eclipse.jdt.core.dom.CompilationUnit makeConsistent(CompilationUnit w
202202
if (CompilationUnit.DOM_BASED_OPERATIONS) {
203203
try {
204204
ASTParser parser = ASTParser.newParser(this.astLevel > 0 ? this.astLevel : AST.getJLSLatest());
205-
parser.setResolveBindings(this.resolveBindings || (this.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0);
205+
parser.setResolveBindings(this.resolveBindings);
206206
parser.setCompilerOptions(options);
207+
parser.setForceProblemDetection((this.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0);
207208
parser.setSource(source);
208209
org.eclipse.jdt.core.dom.CompilationUnit newAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.progressMonitor);
209210
if ((this.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0 && newAST != null) {

0 commit comments

Comments
 (0)