View Javadoc

1   /*
2    * Copyright (c) 2001-2005,
3    * RedVerst Group, ISP RAS http://www.ispras.ru
4    * All rights reserved.
5    *
6    * Redistribution and use in source and binary forms, with or without
7    * modification, are permitted provided that the following conditions are met:
8    *
9    * 1. Redistributions of source code must retain the above copyright notice, this
10   *    list of conditions and the following disclaimer.
11   *
12   * 2. Redistributions in binary form must reproduce the above copyright notice,
13   *    this list of conditions and the following disclaimer in the documentation
14   *    and/or other materials provided with the distribution.
15   *
16   * 3. The names "ATP", "TreeDL", "RedVerst", "ISP RAS"
17   *    may not be used to endorse or promote products derived from this software
18   *    without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
24   * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27   * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30   */
31  
32  package com.unitesk.atp.treedl;
33  
34  import java.util.Iterator;
35  
36  import com.unitesk.atp.treedl.TDL.*;
37  import com.unitesk.atp.tool.PluginClass;
38  
39  /***
40   * @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
41   * @version $Id: JavaEmptyVisitorGenerator.java,v 1.20 2005/11/20 20:20:13 all-x Exp $
42   */
43  public class JavaEmptyVisitorGenerator
44      extends JavaTextGenerator
45      implements TDL_Visitor
46  {
47      /***
48       * {@inheritDoc}
49       */
50      public String getVersion()
51      {
52          return PluginClass.getRevision( "$Revision: 1.20 $" ) + "-stable";
53      }
54  
55      public void visitModule( Module node )
56      {
57          generateHeader();
58  
59          int indexOfLastDot = getOutClassName().lastIndexOf( '.' );
60          if( indexOfLastDot != -1 )
61          {
62              txt( "package " + getOutClassName().substring( 0, indexOfLastDot ) + ";" ); nl();
63              nl();
64          }
65          String outShortClassName = getOutClassName().substring( indexOfLastDot + 1 );
66  
67          txt( "public class " + outShortClassName + " implements ${name}.${visitorName}" ); nl();
68          block_nl();
69          txt( "protected void visit( ${.Node} node ) {}" ); nl();
70          TDL_ModuleMap moduleMap = node.getModuleMap();
71          Iterator it = moduleMap.getModuleNames().iterator();
72          while( it.hasNext() )
73          {
74              TDL_Module tdlModule = moduleMap.getModule( (QID)it.next() );
75              Module t = tdlModule.getRoot();
76              pushNode( t );
77              list
78              ( "i"
79              , 0
80              , t.sizeOptMemberList()
81              , "${optMemberList[i]}"
82              , null
83              ); nl();
84              popNode();
85          }
86          unblock_nl();
87      }
88  
89      public void visitNodeTypeDecl( NodeTypeDecl node )
90      {
91          if( node.isAbstract() ) return;
92          
93          nl();
94          txt( "public void visit${name}( ${parent.name}.${name} node )" ); nl();
95          block_nl();
96          txt( "visit( node );" ); nl();
97          unblock_nl();
98      }
99  
100     public void visitConstTypeDecl( ConstTypeDecl node )
101     {
102     }
103 
104     public void visitOperationDecl( OperationDecl node )
105     {
106     }
107 
108     public void visitBaseModule( BaseModule node )
109     {
110         throw new UnsupportedOperationException();
111     }
112 
113     public void visitConstructorCodeMember( ConstructorCodeMember node )
114     {
115         throw new UnsupportedOperationException();
116     }
117     
118     public void visitBodyCodeMember( BodyCodeMember node )
119     {
120         throw new UnsupportedOperationException();
121     }
122 
123     public void visitField( Field node ) 
124     {
125         throw new UnsupportedOperationException();
126     }
127 
128     public void visitNonVirtualParameterDecl( NonVirtualParameterDecl node ) 
129     {
130         throw new UnsupportedOperationException();
131     }
132 
133     public void visitVirtualParameterDecl( VirtualParameterDecl node )
134     {
135         throw new UnsupportedOperationException();
136     }
137 
138     public void visitCase( Case node ) 
139     {
140         throw new UnsupportedOperationException();
141     }
142 
143     public void visitCaseSignature( CaseSignature node ) 
144     {
145         throw new UnsupportedOperationException();
146     }
147 
148     public void visitParameter( Parameter node ) 
149     {
150         throw new UnsupportedOperationException();
151     }
152 }