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

Query improvements - CtQuery and CtBaseQuery #1076

Closed
wants to merge 11 commits into from

Conversation

pvojtechovsky
Copy link
Collaborator

This PR is a proposed solution for the #1070.

It actually does not 100% fits to solution suggested by Martin. I suggest to have a look at this to make further discussion less abstract. So we can now discuss exact code lines and avoid other misunderstandings.

- Extraction of code to CtBaseQuery to make code cleaner and to allow
reuse of queries
- CtFunction can return Iterator now too
@pvojtechovsky
Copy link
Collaborator Author

pvojtechovsky commented Jan 1, 2017

But it's really important that we're along the same page, so that we could maintain your code, and so that we can write together high-quality documentation

@monperrus , I suggest this way to understand each other and to discuss future steps

  1. to understand conceptual model and to agree on names of the concepts.
    It should minimize misunderstandings.
  2. to understand how these concepts are mapped to this PR
  3. to discuss problems of this PR and Martin's suggestions how to do it different.

Conceptual model

Concept model

Concept Description
MappingFunction maps one input element to zero one or more output elements
BaseQuery is kind of MappingFunction, because same like MappingFunction it maps one input element to zero or more output elements. The difference is that this mapping is done by calling of other MappingFunctions, which are organized in a chain of mapping steps. The input of query is sent as input of first MappingFunction and all the outputs of that MappingFunction are sent as input of next MappingFunction ... recursively. Note that BaseQuery extends MappingFunction so we can use one BaseQuery as a step of another BaseQuery.
BoundQuery is a wrapper around BaseQuery, which allows to bind the query to one input element and later evaluate this query. It is a syntactic API sugar, which makes possible to create queries from the spoon model elements. Note that it makes no sense to use BoundQuery as a step of another query, because such query is bound to constant input element.

Mapping of Concepts to java classes

I suggest to postpone the discussion of the content of this table after we have agreed the Conceptual model and we converge on the names for these concepts. The table below is there just to make definition of concepts more exact in case of some ambiguity... you can have a look into java code of this PR.

Concept Interface Implementations
MappingFunction CtConsumableFunction CtFunction, OverridenMethodQuery, CtFieldReferenceQuery, ...
BaseQuery CtBaseQuery CtBaseQueryImpl
BoundQuery CtQuery CtQueryImpl

@pvojtechovsky
Copy link
Collaborator Author

IntercessionTest.testSettersAreAllGood:215 Your setter setInput in CtQuery don't have a generic type for its return type.

public interface CtQuery extends CtQueryable.Step<CtQuery> {
	CtQuery setInput(Object... input);

How to fix it?

@pvojtechovsky pvojtechovsky changed the title Query improvements Query improvements - CtQuery and CtBaseQuery Jan 5, 2017
@pvojtechovsky
Copy link
Collaborator Author

Was decided to continue with #1090. Closing this one

@pvojtechovsky pvojtechovsky deleted the lazyQueries branch January 12, 2017 19:50
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.

None yet

1 participant