0
Good morning ,
I am using AST , so I was able to access the methods, attributes and get if it is public or private, among other things.
How do I display the line number of a particular attribute or method? Example:
int privado = Modifier.ModifierKeyword.PRIVATE_KEYWORD.toFlagValue();
public Teste (ICompilationUnit unit) throws JavaModelException, MalformedTreeException, BadLocationException {
Document documento = new Document(unit.getSource());
ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(unit);
CompilationUnit compUnit = (CompilationUnit) parser.createAST(null);
compUnit.recordModifications();
AST ast = compUnit.getAST();
Visitor visitor = new Visitor();
compUnit.accept(visitor);
for (FieldDeclaration f : type.getFields()) {
int tipo = f.getModifiers();
if ((tipo & publico) == publico) {
mensagem.add(" \n O ATRIBUTO "+f.fragments().toString()+" é public \n");
}
}
}
I wanted to inform in : The test attribute is public in Line x.