Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(scanner): add missing scan properties based on a new powerful specification #966

Merged
merged 1 commit into from
Nov 14, 2016

Conversation

monperrus
Copy link
Collaborator

@monperrus monperrus commented Nov 12, 2016

The idea is no annotate the metamodel methods with Spoon-specific annotations:

  • @DerivedProperty for getters that are derived from other properties
  • @UnsettableProperty for setters that are not usable in certains cases

Then, the core contract is that CtScanner must visit all settable, non-derived properties.

By doing this, I found a couple of bugs in CScanner (property not visited)

// and then we can have smaller clean tested pull requests to see the impact of the change
// cp ./target/generated/spoon/reflect/visitor/CtBiScannerDefault.java ./src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java
//assertThat(build(new File("./src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java")).Class().get(CtBiScannerDefault.class))
// .isEqualTo(build(new File("./target/generated/spoon/reflect/visitor/CtBiScannerDefault.java")).Class().get(CtBiScannerDefault.class));
Copy link
Collaborator

@tdurieux tdurieux Nov 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is useless without assert.

we don't necessarily want to hard-wired the relation bewteen CtScanner and CtBiScannerDefault.java

Yes we went because CtBiScanner is used for the equality of two elements. Without this assertion we may have bug in equals

@@ -122,6 +137,7 @@ public void testGenerateCloneVisitor() throws Exception {
launcher.run();

// cp ./target/generated/spoon/support/visitor/clone/CloneBuilder.java ./src/main/java/spoon/support/visitor/clone/CloneBuilder.java
// cp ./target/generated/spoon/support/visitor/clone/CloneVisitor.java ./src/main/java/spoon/support/visitor/clone/CloneVisitor.java
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you copy the line?

t2.add(computeSimpleSignature((CtMethod<?>) invoc.getExecutable().getExecutableDeclaration()));
}
assertEquals("CtScanner contract violated for "+t.getSimpleName(), t1, t2);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

final ActualCounterScanner actual = new ActualCounterScanner();
actual.biScan(pack, pack.clone());
assertEquals(expected.expectedCounter, actual.counter);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removes ActualCounterScanner.counter if not used

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants