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

Boutahar Naoual #29

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

naoualBoutahar
Copy link

No description provided.

@Override
public void apply(CompilationUnitWrapper compilationUnit) {
final List<TypeDeclaration<?>> types = compilationUnit.getTypes();
types.stream()
Copy link
Owner

Choose a reason for hiding this comment

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

use visitor pattern to avoid going through the structure

types.stream()
.forEach(type -> {
type.getFields().stream()
.filter(field -> field.isStatic() && field.isFinal() && !field.getVariables().get(0).getNameAsString().matches("^[A-Z_]+$"))
Copy link
Owner

Choose a reason for hiding this comment

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

get(0) has to be generalized,
a declaration may have more than one field :

private String foo, bar;

for (TypeDeclaration<?> type : types) {
List<MethodDeclaration> methods = type.getMethods();
for (MethodDeclaration method : methods) {
int lineCount = method.getEnd().get().line - method.getBegin().get().line;
Copy link
Owner

Choose a reason for hiding this comment

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

Optinal::get is to be called conditionally

final List<TypeDeclaration<?>> types = compilationUnit.getTypes();

types.stream()
.filter(type -> !Character.isUpperCase(type.getNameAsString().charAt(0)) || type.getNameAsString().contains("_"))
Copy link
Owner

Choose a reason for hiding this comment

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

!Character.isUpperCase ==> Character.isLowerCase

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

Successfully merging this pull request may close these issues.

2 participants