Source Code Cross Referenced for SummaryCollector.java in  » Scripting » groovy-1.0 » org » codehaus » groovy » antlr » treewalker » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » groovy 1.0 » org.codehaus.groovy.antlr.treewalker 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         $Id: SummaryCollector.java 3626 2006-02-20 15:16:17Z jez $
003:
004:         Copyright 2005 (C) Jeremy Rayner. All Rights Reserved.
005:
006:         Redistribution and use of this software and associated documentation
007:         ("Software"), with or without modification, are permitted provided
008:         that the following conditions are met:
009:
010:         1. Redistributions of source code must retain copyright
011:            statements and notices.  Redistributions must also contain a
012:            copy of this document.
013:
014:         2. Redistributions in binary form must reproduce the
015:            above copyright notice, this list of conditions and the
016:            following disclaimer in the documentation and/or other
017:            materials provided with the distribution.
018:
019:         3. The name "groovy" must not be used to endorse or promote
020:            products derived from this Software without prior written
021:            permission of The Codehaus.  For written permission,
022:            please contact info@codehaus.org.
023:
024:         4. Products derived from this Software may not be called "groovy"
025:            nor may "groovy" appear in their names without prior written
026:            permission of The Codehaus. "groovy" is a registered
027:            trademark of The Codehaus.
028:
029:         5. Due credit should be given to The Codehaus -
030:            http://groovy.codehaus.org/
031:
032:         THIS SOFTWARE IS PROVIDED BY THE CODEHAUS AND CONTRIBUTORS
033:         ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
034:         NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
035:         FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
036:         THE CODEHAUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
037:         INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
038:         (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
039:         SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
040:         HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
041:         STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
042:         ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
043:         OF THE POSSIBILITY OF SUCH DAMAGE.
044:
045:         */
046:        package org.codehaus.groovy.antlr.treewalker;
047:
048:        import org.codehaus.groovy.antlr.GroovySourceAST;
049:        import org.codehaus.groovy.antlr.AntlrSourceSummary;
050:        import org.codehaus.groovy.antlr.syntax.AntlrClassSource;
051:        import org.codehaus.groovy.antlr.parser.GroovyTokenTypes;
052:        import org.codehaus.groovy.syntax.ClassSource;
053:        import org.codehaus.groovy.syntax.SourceSummary;
054:
055:        import java.util.Stack;
056:
057:        /**
058:         * A visitor for the antlr ast that creates a summary of the parsed source unit
059:         *
060:         * @author Jeremy Rayner
061:         */
062:        public class SummaryCollector extends VisitorAdapter {
063:            private SourceSummary sourceSummary;
064:            private Stack stack;
065:
066:            public SourceSummary getSourceSummary() {
067:                return sourceSummary;
068:            }
069:
070:            public SummaryCollector() {
071:                sourceSummary = new AntlrSourceSummary();
072:                stack = new Stack();
073:            }
074:
075:            public void setUp() {
076:            }
077:
078:            public void visitClassDef(GroovySourceAST t, int visit) {
079:                if (visit == OPENING_VISIT) {
080:                    ClassSource classSource = new AntlrClassSource(t
081:                            .childOfType(GroovyTokenTypes.IDENT).getText(), t);
082:                    // Here we assume that the optional restrictions (JLS$7.6)
083:                    // on compilation units in file-based implementations apply
084:                    // http://java.sun.com/docs/books/jls/second_edition/html/packages.doc.html#26783
085:                    GroovySourceAST modifiers = t
086:                            .childOfType(GroovyTokenTypes.MODIFIERS);
087:
088:                    if (isPublic(modifiers)) {
089:                        sourceSummary.addPublic(classSource);
090:                    }
091:                }
092:            }
093:
094:            /* figue out if this modifier node represents a public entity */
095:            private boolean isPublic(GroovySourceAST modifiers) {
096:                boolean isPublic = true;
097:                if (modifiers != null) {
098:                    GroovySourceAST modprot = modifiers
099:                            .childOfType(GroovyTokenTypes.LITERAL_protected);
100:                    GroovySourceAST modpriv = modifiers
101:                            .childOfType(GroovyTokenTypes.LITERAL_private);
102:                    if (modpriv != null || modprot != null) {
103:                        isPublic = false;
104:                    }
105:                }
106:                return isPublic;
107:            }
108:
109:            public void tearDown() {
110:            }
111:
112:            public void push(GroovySourceAST t) {
113:                stack.push(t);
114:            }
115:
116:            public GroovySourceAST pop() {
117:                if (!stack.empty()) {
118:                    return (GroovySourceAST) stack.pop();
119:                }
120:                return null;
121:            }
122:
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.