@Test public void testNestedDeclarationMess() { try { final File file = new File("./src/test/java/org/eclipse/steady/java/test/NestedDeclarations.java"); final FileAnalyzer fa = FileAnalyzerFactory.buildFileAnalyzer(file); final Map<ConstructId, Construct> constructs = fa.getConstructs(); final JavaPackageId p = new JavaPackageId("org.eclipse.steady.java.test"); final JavaClassId cl1 = JavaId.parseClassQName("org.eclipse.steady.java.test.NestedDeclarations"); final JavaMethodId cl1_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations.doSomething()"); final JavaClassId cl2 = JavaId.parseClassQName( "org.eclipse.steady.java.test.NestedDeclarations$DoSomethingElse$DoThis"); final JavaMethodId cl2_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations$DoSomethingElse$DoThis.doThis()"); final JavaClassId cl3 = JavaId.parseClassQName( "org.eclipse.steady.java.test.NestedDeclarations$DoSomethingElse$DoThis$1"); final JavaMethodId cl3_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations$DoSomethingElse$DoThis$1.doThat()"); final JavaClassId cl4 = JavaId.parseClassQName("org.eclipse.steady.java.test.NestedDeclarations$1"); final JavaMethodId cl4_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations$1.doSomethingElse()"); final JavaClassId cl5 = JavaId.parseClassQName( "org.eclipse.steady.java.test.NestedDeclarations$DoThis"); final JavaMethodId cl5_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations$DoThis.doThis()"); final JavaClassId cl6 = JavaId.parseClassQName( "org.eclipse.steady.java.test.NestedDeclarations$DoThis$1"); final JavaMethodId cl6_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations$DoThis$1.doThat()"); final JavaClassId cl7 = JavaId.parseClassQName("org.eclipse.steady.java.test.NestedDeclarations$2"); final JavaMethodId cl7_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations$2.doSomething()"); final JavaClassId cl8 = JavaId.parseClassQName( "org.eclipse.steady.java.test.NestedDeclarations$1DoThat"); final JavaMethodId cl8_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations$1DoThat.doThat()"); final JavaClassId cl9 = JavaId.parseClassQName( "org.eclipse.steady.java.test.NestedDeclarations$1DoThat$1"); final JavaMethodId cl9_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations$1DoThat$1.doThis()"); final JavaEnumId e = JavaId.parseEnumQName("org.eclipse.steady.java.test.NestedDeclarations$Foo"); final JavaMethodId e_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations$Foo.bar()"); final JavaClassId cl10 = JavaId.parseClassQName( "org.eclipse.steady.java.test.NestedDeclarations$Foo$1DoThis"); final JavaMethodId cl10_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations$Foo$1DoThis.doThis()"); final JavaClassId cl11 = JavaId.parseClassQName( "org.eclipse.steady.java.test.NestedDeclarations$Foo$1DoThis$1"); final JavaMethodId cl11_m = JavaId.parseMethodQName( "org.eclipse.steady.java.test.NestedDeclarations$Foo$1DoThis$1.doThat()"); assertEquals(25, constructs.size()); assertTrue(constructs.containsKey(p)); assertTrue(constructs.containsKey(cl1)); assertTrue(constructs.containsKey(cl1_m)); assertTrue(constructs.containsKey(cl2)); assertTrue(constructs.containsKey(cl2_m)); assertTrue(constructs.containsKey(cl3)); assertTrue(constructs.containsKey(cl3_m)); assertTrue(constructs.containsKey(cl4)); assertTrue(constructs.containsKey(cl4_m)); assertTrue(constructs.containsKey(cl5)); assertTrue(constructs.containsKey(cl5_m)); assertTrue(constructs.containsKey(cl6)); assertTrue(constructs.containsKey(cl6_m)); assertTrue(constructs.containsKey(cl7)); assertTrue(constructs.containsKey(cl7_m)); assertTrue(constructs.containsKey(cl8)); assertTrue(constructs.containsKey(cl8_m)); assertTrue(constructs.containsKey(cl9)); assertTrue(constructs.containsKey(cl9_m)); assertTrue(constructs.containsKey(e)); assertTrue(constructs.containsKey(e_m)); assertTrue(constructs.containsKey(cl10)); assertTrue(constructs.containsKey(cl10_m)); assertTrue(constructs.containsKey(cl11)); assertTrue(constructs.containsKey(cl11_m)); } catch (FileAnalysisException e) { System.err.println(e.getMessage()); assertTrue(false); } }
@Override public Map<ConstructId, Construct> getConstructs() throws FileAnalysisException { if (this.constructs == null) { try { this.constructs = new TreeMap<ConstructId, Construct>(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (final InputStream is2 = new BufferedInputStream(new FileInputStream(this.file))) { int cc = -1; while ((cc = is2.read()) >= 0) baos.write(cc); } baos.flush(); this.input = new ANTLRInputStream(new ByteArrayInputStream(baos.toByteArray())); JavaLexer lexer = new JavaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); JavaParser parser = new JavaParser(tokens); CompilationUnitContext ctx = parser.compilationUnit(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(this, ctx); } catch (FileNotFoundException e) { throw new FileAnalysisException(e.getMessage(), e); } catch (RecognitionException e) { throw new FileAnalysisException( "ANTLR exception while analysing class file [" + this.file.getName() + "]: " + e.getMessage(), e); } catch (IOException e) { throw new FileAnalysisException( "I/O exception while analysing class file [" + this.file.getName() + "]: " + e.getMessage(), e); } catch (Exception e) { throw new FileAnalysisException( "Exception of type [" + e.getClass().getSimpleName() + "] while analyzing file [" + this.file.toPath().toAbsolutePath() + "]: " + e.getMessage(), e); } } return this.constructs; }
JavaFileAnalyzer2 extends JavaParserBaseListener implements FileAnalyzer { @Override public Map<ConstructId, Construct> getConstructs() throws FileAnalysisException { if (this.constructs == null) { try { this.constructs = new TreeMap<ConstructId, Construct>(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (final InputStream is2 = new BufferedInputStream(new FileInputStream(this.file))) { int cc = -1; while ((cc = is2.read()) >= 0) baos.write(cc); } baos.flush(); this.input = new ANTLRInputStream(new ByteArrayInputStream(baos.toByteArray())); JavaLexer lexer = new JavaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); JavaParser parser = new JavaParser(tokens); CompilationUnitContext ctx = parser.compilationUnit(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(this, ctx); } catch (FileNotFoundException e) { throw new FileAnalysisException(e.getMessage(), e); } catch (RecognitionException e) { throw new FileAnalysisException( "ANTLR exception while analysing class file [" + this.file.getName() + "]: " + e.getMessage(), e); } catch (IOException e) { throw new FileAnalysisException( "I/O exception while analysing class file [" + this.file.getName() + "]: " + e.getMessage(), e); } catch (Exception e) { throw new FileAnalysisException( "Exception of type [" + e.getClass().getSimpleName() + "] while analyzing file [" + this.file.toPath().toAbsolutePath() + "]: " + e.getMessage(), e); } } return this.constructs; } }
JavaFileAnalyzer2 extends JavaParserBaseListener implements FileAnalyzer { @Override public Map<ConstructId, Construct> getConstructs() throws FileAnalysisException { if (this.constructs == null) { try { this.constructs = new TreeMap<ConstructId, Construct>(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (final InputStream is2 = new BufferedInputStream(new FileInputStream(this.file))) { int cc = -1; while ((cc = is2.read()) >= 0) baos.write(cc); } baos.flush(); this.input = new ANTLRInputStream(new ByteArrayInputStream(baos.toByteArray())); JavaLexer lexer = new JavaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); JavaParser parser = new JavaParser(tokens); CompilationUnitContext ctx = parser.compilationUnit(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(this, ctx); } catch (FileNotFoundException e) { throw new FileAnalysisException(e.getMessage(), e); } catch (RecognitionException e) { throw new FileAnalysisException( "ANTLR exception while analysing class file [" + this.file.getName() + "]: " + e.getMessage(), e); } catch (IOException e) { throw new FileAnalysisException( "I/O exception while analysing class file [" + this.file.getName() + "]: " + e.getMessage(), e); } catch (Exception e) { throw new FileAnalysisException( "Exception of type [" + e.getClass().getSimpleName() + "] while analyzing file [" + this.file.toPath().toAbsolutePath() + "]: " + e.getMessage(), e); } } return this.constructs; }  }
JavaFileAnalyzer2 extends JavaParserBaseListener implements FileAnalyzer { @Override public Map<ConstructId, Construct> getConstructs() throws FileAnalysisException { if (this.constructs == null) { try { this.constructs = new TreeMap<ConstructId, Construct>(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (final InputStream is2 = new BufferedInputStream(new FileInputStream(this.file))) { int cc = -1; while ((cc = is2.read()) >= 0) baos.write(cc); } baos.flush(); this.input = new ANTLRInputStream(new ByteArrayInputStream(baos.toByteArray())); JavaLexer lexer = new JavaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); JavaParser parser = new JavaParser(tokens); CompilationUnitContext ctx = parser.compilationUnit(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(this, ctx); } catch (FileNotFoundException e) { throw new FileAnalysisException(e.getMessage(), e); } catch (RecognitionException e) { throw new FileAnalysisException( "ANTLR exception while analysing class file [" + this.file.getName() + "]: " + e.getMessage(), e); } catch (IOException e) { throw new FileAnalysisException( "I/O exception while analysing class file [" + this.file.getName() + "]: " + e.getMessage(), e); } catch (Exception e) { throw new FileAnalysisException( "Exception of type [" + e.getClass().getSimpleName() + "] while analyzing file [" + this.file.toPath().toAbsolutePath() + "]: " + e.getMessage(), e); } } return this.constructs; }  @Override String[] getSupportedFileExtensions(); @Override boolean canAnalyze(File _file); @Override void analyze(final File _file); void setFile(File _file); @Override void enterPackageDeclaration(@NotNull JavaParser.PackageDeclarationContext ctx); @Override void enterEnumDeclaration(@NotNull JavaParser.EnumDeclarationContext ctx); @Override void exitEnumDeclaration(@NotNull JavaParser.EnumDeclarationContext ctx); @Override void enterInterfaceDeclaration(@NotNull JavaParser.InterfaceDeclarationContext ctx); @Override void exitInterfaceDeclaration(@NotNull JavaParser.InterfaceDeclarationContext ctx); @Override void enterClassDeclaration(@NotNull JavaParser.ClassDeclarationContext ctx); @Override void exitClassDeclaration(@NotNull JavaParser.ClassDeclarationContext ctx); @Override void enterClassBody(@NotNull JavaParser.ClassBodyContext ctx); @Override void exitClassBody(@NotNull JavaParser.ClassBodyContext ctx); @Override void enterMethodDeclaration(@NotNull JavaParser.MethodDeclarationContext ctx); @Override void exitMethodDeclaration(
      org.eclipse.steady.java.antlr.JavaParser.MethodDeclarationContext ctx); @Override void enterConstructorDeclaration(@NotNull JavaParser.ConstructorDeclarationContext ctx); @Override void exitConstructorDeclaration(
      org.eclipse.steady.java.antlr.JavaParser.ConstructorDeclarationContext ctx); @Override Map<ConstructId, Construct> getConstructs(); @Override boolean containsConstruct(ConstructId _id); @Override Construct getConstruct(ConstructId _id); @Override boolean hasChilds(); @Override Set<FileAnalyzer> getChilds(boolean _recursive); }
JavaFileAnalyzer2 extends JavaParserBaseListener implements FileAnalyzer { @Override public Map<ConstructId, Construct> getConstructs() throws FileAnalysisException { if (this.constructs == null) { try { this.constructs = new TreeMap<ConstructId, Construct>(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (final InputStream is2 = new BufferedInputStream(new FileInputStream(this.file))) { int cc = -1; while ((cc = is2.read()) >= 0) baos.write(cc); } baos.flush(); this.input = new ANTLRInputStream(new ByteArrayInputStream(baos.toByteArray())); JavaLexer lexer = new JavaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); JavaParser parser = new JavaParser(tokens); CompilationUnitContext ctx = parser.compilationUnit(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(this, ctx); } catch (FileNotFoundException e) { throw new FileAnalysisException(e.getMessage(), e); } catch (RecognitionException e) { throw new FileAnalysisException( "ANTLR exception while analysing class file [" + this.file.getName() + "]: " + e.getMessage(), e); } catch (IOException e) { throw new FileAnalysisException( "I/O exception while analysing class file [" + this.file.getName() + "]: " + e.getMessage(), e); } catch (Exception e) { throw new FileAnalysisException( "Exception of type [" + e.getClass().getSimpleName() + "] while analyzing file [" + this.file.toPath().toAbsolutePath() + "]: " + e.getMessage(), e); } } return this.constructs; }  @Override String[] getSupportedFileExtensions(); @Override boolean canAnalyze(File _file); @Override void analyze(final File _file); void setFile(File _file); @Override void enterPackageDeclaration(@NotNull JavaParser.PackageDeclarationContext ctx); @Override void enterEnumDeclaration(@NotNull JavaParser.EnumDeclarationContext ctx); @Override void exitEnumDeclaration(@NotNull JavaParser.EnumDeclarationContext ctx); @Override void enterInterfaceDeclaration(@NotNull JavaParser.InterfaceDeclarationContext ctx); @Override void exitInterfaceDeclaration(@NotNull JavaParser.InterfaceDeclarationContext ctx); @Override void enterClassDeclaration(@NotNull JavaParser.ClassDeclarationContext ctx); @Override void exitClassDeclaration(@NotNull JavaParser.ClassDeclarationContext ctx); @Override void enterClassBody(@NotNull JavaParser.ClassBodyContext ctx); @Override void exitClassBody(@NotNull JavaParser.ClassBodyContext ctx); @Override void enterMethodDeclaration(@NotNull JavaParser.MethodDeclarationContext ctx); @Override void exitMethodDeclaration(
      org.eclipse.steady.java.antlr.JavaParser.MethodDeclarationContext ctx); @Override void enterConstructorDeclaration(@NotNull JavaParser.ConstructorDeclarationContext ctx); @Override void exitConstructorDeclaration(
      org.eclipse.steady.java.antlr.JavaParser.ConstructorDeclarationContext ctx); @Override Map<ConstructId, Construct> getConstructs(); @Override boolean containsConstruct(ConstructId _id); @Override Construct getConstruct(ConstructId _id); @Override boolean hasChilds(); @Override Set<FileAnalyzer> getChilds(boolean _recursive);  }