Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Nicholas Smith
    @SmiddyPence
    New version of the book is available with code and grammar corrections submitted. You have not been notified by email... thanks to GDPR . Thanks for your input
    Danny van Bruggen
    @matozoid
    If you tweet it we'll retweet it to get the message out
    Nicholas Smith
    @SmiddyPence
    it's only error corrections. not the biggest deal.
    apparently they'll turn them back on June
    Danny van Bruggen
    @matozoid
    Not the facade stuff yet?
    Nicholas Smith
    @SmiddyPence
    I thought I got that...
    let me check the push when I get back
    Nicholas Smith
    @SmiddyPence
    which page?
    Danny van Bruggen
    @matozoid
    Which page what?
    Nicholas Smith
    @SmiddyPence
    The facade stuff?
    Danny van Bruggen
    @matozoid
    The symbol solving chapter
    Nicholas Smith
    @SmiddyPence
    it is all like this now:
        public static void main(String[] args) throws FileNotFoundException {
            TypeSolver typeSolver = new CombinedTypeSolver();
    
            JavaSymbolSolver symbolSolver = new JavaSymbolSolver(typeSolver);
            JavaParser.getStaticConfiguration().setSymbolResolver(symbolSolver);
    
            CompilationUnit cu = JavaParser.parse(new File(FILE_PATH));
    
            cu.findAll(AssignExpr.class).forEach(ae -> {
                ResolvedType resolvedType = ae.calculateResolvedType();
                System.out.println(ae.toString() + " is a: " + resolvedType);
            });
        }
    Danny van Bruggen
    @matozoid
    Cool!
    Federico Tomassetti
    @ftomassetti
    Looking nice and simpler compared to the JavaParserFacade stuff we used to have
    Danny van Bruggen
    @matozoid
    Just to double check: using the facade is still a valid option?
    Federico Tomassetti
    @ftomassetti
    technically yes, it is just that now it should be much more comfortable to just use the API integrated in nodes
    Danny van Bruggen
    @matozoid
    It's with the discussion in my mind that we could deprecate the facade - or not
    Federico Tomassetti
    @ftomassetti
    I think it is still used internally, it should just not be used directly by users
    acaeronte
    @acaeronte1_twitter
    Hello
    Good afternoon for Spain
    Danny van Bruggen
    @matozoid
    Hola
    Geert Vancompernolle
    @GeVanCo
    Remark in book: page 11 (real page 16) -> package name incomplete. Mentioned: org.javaparser.examples.VoidV, should be (I guess) org.javaparser.examples.VoidVisitorstarter
    Nicholas Smith
    @SmiddyPence
    thank you! all help appreciated.
    Geert Vancompernolle
    @GeVanCo

    JavaParser Visited: compilation of remarks/suggestions/improvements for the book.

    Page 12 (real page 17):

    • ...but not operate on... => ...but will not operate on...
    • Text "Appendix B": suggest to put a link to Appendix B itself. This way, it's much more comfortable to jump between two locations in a PDF document

    Page 14 (real page 19):

    • ...create another visitor class... => ...create another inner visitor class...

    Page 15 (real page 20)

    • ...we've named ours ModifyingVisitorExample => ...we've named ours ModifyingVisitorStarter (should be same as file name)

    Page 16 (real page 21)

    • ...The first two visitors...: Mention that we're creating a new file 'ModifyingVisitorComplete.java' with a 'main' method. It's otherwise a bit confusing since just above you're still talking about 'ModifyingVisitorStarter'

    Page 19 (real page 24)

    • ...Within our class create... => Mention that you've created a new class with 'main' in it: 'CommentReporterComplete.java'

    Page 23 (real page 28)

    • ...aside from visitors in the getAllContainedComments... => ...aside from visitors is the getAllContainedComments...: change 'in' to 'is'
    • ...comments are themselves are... => ...comments themselves are...
    • ...comment parsing there a couple of... => ...comment parsing there are a couple of...

    Page 24 (real page 29)

    • ...with single source files is worth remembering... => ...with single source files but is worth remembering...: 'but' is missing
    • ...remembering if you looking to... => ...remembering if you are looking to... or ...remembering if you look to...
    • In this instance, providing comment attribution is enabelled the comment // Blah will be attributed to the method f. => In this instance the comment // Blah will be attributed to the method f providing comment attribution is enabled.

    Didn't go any further in the book yet, since my initial interest is parsing Java files, not immediately generating Java code...

    Nicholas Smith
    @SmiddyPence
    thank you for taking the time to do this!
    Arosha Mudalige
    @aroshamudalige
    Can I know what are the constraints when parsing a java code? I know that java code need not to be always semantically correct in order to parse it?
    Danny van Bruggen
    @matozoid
    Not from the book :-)
    Arosha Mudalige
    @aroshamudalige
    Couldn't find anything about my issue from the book. :)
    Danny van Bruggen
    @matozoid
    There are two things: the grammar is somewhat loose, so it will parse some invalid constructions. There is a little support for parse error recovery too, where a parse error does not always mean that you don't get an AST - but little effort has gone into it until now.
    (The AST will be validated after parsing, which may give more error messages. That can be turned off by setting the language level to raw.)
    Arosha Mudalige
    @aroshamudalige
    Thanks!
    Danny van Bruggen
    @matozoid
    Obvious cases: most places where modifiers are accepted, all modifiers are excepted. Later they go through validation where you get the errors.
    Classes and interfaces can extend and implement what they want. Validation catches these errors.
    ... and validation is far from perfect. Many error can only be detected after the parsing phase, so we don't.
    Arosha Mudalige
    @aroshamudalige
    Thank! I am using Javaparser to create a plugin to catch secure coding violations on the fly. Thats why I need to know when will Javaparser trigger.
    Danny van Bruggen
    @matozoid
    (We're in the wrong gitter group, btw)
    What kind of cases do you worry about?
    Arosha Mudalige
    @aroshamudalige
    Actually I want to parse slightly syntactically incorrect codes as well because my plugin parses what user types in the editor. Due to IntelliJ Idea's intellisense most of the time the code in the editor is syntactically correct. So its not a big problem. I'll post later if I want more help. Thanks!
    flint9ban
    @flint9ban
    when I create a class which would be implemented by another class. how to get ClassOrInterfaceType from ClassOrInterfaceDeclaration of this class
    Danny van Bruggen
    @matozoid
    Just using the parser and ast? 'new' it.
    flint9ban
    @flint9ban
    CompilationUnit daoCompilationUnit = new CompilationUnit();
            ClassOrInterfaceDeclaration daoInterface = daoCompilationUnit.addClass("StudentDao");
            daoInterface.setInterface(true);
            CompilationUnit daoImplCompilationUnit = new CompilationUnit();
            ClassOrInterfaceDeclaration daoImplClass = daoImplCompilationUnit.addClass("StudentDaoImpl");
            // how to set Implemented dao interface
            daoImplClass.setImplementedType(0,daoInterface);
    Danny van Bruggen
    @matozoid
    I get it now. This is the wrong group by the way - try javaparser/javaparser :-)
    Reply is over there.
    flint9ban
    @flint9ban
    thank you!
    peakkj
    @peakkj
    hi, I want to know , does javaparser-symbol-solver support jdk 1.7 ? which version? thank you
    Nicholas Smith
    @SmiddyPence
    Yes it does. Symbol solving is a very complex area though, so it may not always meet expectation, either by design or a bug.
    For general questions, you should use the #javaparser channel
    Danny van Bruggen
    @matozoid
    (it needs a jdk 8+ to run though)
    peakkj
    @peakkj
    thank you all the same , I found the answer at github , download the earliest release
    Nicholas Smith
    @SmiddyPence
    Yes good point!