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

feat(filter): adds LineFilter that matches lines of code #678

Merged
merged 1 commit into from
May 31, 2016

Conversation

tdurieux
Copy link
Collaborator

No description provided.

@monperrus
Copy link
Collaborator

monperrus commented May 27, 2016

Cool.

Here is a proposal for the javadoc. Could you also update the filter documentation page?

/**
 * This filter matches all elements that can be considered as line of code (e.g. directly contained in a block, or a then statement). This discards CtStatement that are not used as statement (such as a method call used as RHS).
 * <pre>
* // lines of a method
 * List<CtStatement> lines = method.getElement(new LineFilter());
 * </pre>
 */

@tdurieux tdurieux force-pushed the feat_line_filter branch 2 times, most recently from 244b099 to c425361 Compare May 27, 2016 09:24
@tdurieux
Copy link
Collaborator Author

Done
I'm not sure that getElement(new LineFilter()) is more useful than getParent(...).
Personally, I nerver used getElements(new LineFilter()) but I almost use getParent(new LineFilter()) in all my projects.

@monperrus
Copy link
Collaborator

getParent(new LineFilter())
for what purpose?

--Martin

@monperrus
Copy link
Collaborator

Could you also update the filter documentation page http://spoon.gforge.inria.fr/filter.html?

@tdurieux tdurieux force-pushed the feat_line_filter branch from c425361 to 3e84796 Compare May 27, 2016 09:32
@tdurieux
Copy link
Collaborator Author

tdurieux commented May 27, 2016

Could you also update the filter documentation page http://spoon.gforge.inria.fr/filter.html?

Done

for what purpose?

In order to

  • insert element before/after the current line
  • analyse the repetition of a element in the statement
  • know the type of the parent line
  • instrument the line that contains my current element
  • ...

This filter can be useful if you have to count the number of line of a project (but not efficient).

// count the number of line of a project
ctRootPackage.getElements(new LineFilter()).size();

@@ -33,6 +33,7 @@ Filter class | Description
`CompositeFilter` ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/visitor/filter/CompositeFilter.html)) | defines a composite filter, which can compose several filters together by using `FilteringOperator` ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/visitor/filter/FilteringOperator.html)).
`OverridingMethodFilter` ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/visitor/filter/OverridingMethodFilter.html)) | get all overriding methods from the method given.
`OverriddenMethodFilter` ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/visitor/filter/OverriddenMethodFilter.html)) | get all overridden methods from the method given.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@GerardPaligot Why OverriddenMethodFilter is duplicated?

Copy link
Contributor

Choose a reason for hiding this comment

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

Re-read.

Copy link
Collaborator Author

@tdurieux tdurieux May 27, 2016

Choose a reason for hiding this comment

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

Oups

@tdurieux tdurieux force-pushed the feat_line_filter branch from 3e84796 to a6fcd1d Compare May 31, 2016 11:38
@tdurieux
Copy link
Collaborator Author

Done

@monperrus monperrus merged commit 73ff189 into INRIA:master May 31, 2016
@tdurieux tdurieux deleted the feat_line_filter branch June 1, 2016 08:22
@tdurieux tdurieux mentioned this pull request Jun 24, 2016
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.

3 participants