Skip to content

Commit

Permalink
fix: clarify Environment#checksAreSkipped and associated setters (#2011)
Browse files Browse the repository at this point in the history
  • Loading branch information
monperrus authored and pvojtechovsky committed May 28, 2018
1 parent 11f3808 commit 9030246
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
23 changes: 18 additions & 5 deletions src/main/java/spoon/compiler/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,32 @@ void report(Processor<?> processor, Level level,
void setShouldCompile(boolean shouldCompile);

/**
* Checks if {@link spoon.reflect.visitor.AstParentConsistencyChecker},
* hashcode violation declared in CtElement#equals(CtElement) and
* method violation declared in {@link spoon.reflect.declaration.CtType#addMethod(CtMethod)}
* Tells whether Spoon does no checks at all.
* - parents are consistent (see {@link spoon.reflect.visitor.AstParentConsistencyChecker})
* - hashcode violation (see {@link spoon.support.reflect.declaration.CtElementImpl#equals(Object)})
* - method violation (see {@link spoon.reflect.declaration.CtType#addMethod(CtMethod)})
* are active or not.
*
* By default all checks are enabled and {@link #checksAreSkipped()} return false.
*/
boolean checksAreSkipped();

/**
* Enable or not checks on the AST. See {@link #checksAreSkipped()} to know all checks enabled.
* true means that no self checks are made.
* Enable or not consistency checks on the AST. See {@link #checksAreSkipped()} for a list of all checks.
* @param skip false means that all checks are made (default), true means that no checks are made.
*
* Use {@link #disableConsistencyChecks()} instead.
*/
@Deprecated // method name is super confusing "skip" is missing
void setSelfChecks(boolean skip);

/**
* Disable all consistency checks on the AST. Dangerous! The only valid usage of this is to keep
* full backward-compatibility.
*/
void disableConsistencyChecks();


/** Return the directory where binary .class files are created */
void setBinaryOutputDirectory(String directory);

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/spoon/support/StandardEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class StandardEnvironment implements Serializable, Environment {

private boolean shouldCompile = false;

private boolean skipSelfChecks;
private boolean skipSelfChecks = false;

private FineModelChangeListener modelChangeListener = new EmptyModelChangeListener();

Expand Down Expand Up @@ -161,6 +161,11 @@ public void setSelfChecks(boolean skip) {
skipSelfChecks = skip;
}

@Override
public void disableConsistencyChecks() {
skipSelfChecks = true;
}

private Level toLevel(String level) {
if (level == null || level.isEmpty()) {
throw new SpoonException("Wrong level given at Spoon.");
Expand Down

0 comments on commit 9030246

Please sign in to comment.