Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

introduces CtModel for #584 #589

Merged
merged 2 commits into from
Apr 22, 2016
Merged

introduces CtModel for #584 #589

merged 2 commits into from
Apr 22, 2016

Conversation

monperrus
Copy link
Collaborator

Currently, the notion of "model" in Spoon is implicit, and the factory takes this role. However, it's not the way it should be. It's been a long time we wanted to introduce CtModel, #584 triggered it.

The tentative interface is:

/** represents a Java program, modeled by a set of compile-time (Ct) objects
 * where each objects is a program element (for instance, a CtClass represents a class).
 */
public interface CtModel {

    /** returns the root package */
    CtPackage getRootPackage();

    /** returns all types of the model */
    Collection<CtType<?>> getAllTypes();

    /** returns all packages of the model */
    Collection<CtPackage> getAllPackages();

    /** process this model with the given processor */
    void processWith(Processor<?> processor);

}

The workflow of #584 is tested in FactoryTest.testIncrementalModel.

This has triggered cleaning the factory infrastructure.

One more commit is a utility constructor in AbstractFilter.

Done in AF145.

@monperrus monperrus force-pushed the ctmodel branch 5 times, most recently from 02e2979 to 66c945c Compare April 18, 2016 15:46

@Override
public Collection<CtType<?>> getAllTypes() {
return Collections.unmodifiableCollection(rootPackage.getElements(new TypeFilter<CtType<?>>(CtType.class)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Unify implementation

@GerardPaligot
Copy link
Contributor

@leventov What do you think about this for your issue #584?

@monperrus monperrus force-pushed the ctmodel branch 10 times, most recently from 2152864 to dd8731c Compare April 21, 2016 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants