コード例 #1
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.InstanceofExpression)
  */
 public boolean visit(InstanceofExpression node) {
   PTInstanceof inof = InstantiationFactory.eINSTANCE.createPTInstanceof();
   inof.setOperand(perform(node.getLeftOperand()));
   inof.setType(resolver.resolveType(node.getRightOperand()));
   expression = inof;
   return false;
 }
コード例 #2
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ClassInstanceCreation)
  */
 public boolean visit(ClassInstanceCreation node) {
   if (node.getAnonymousClassDeclaration() != null) {
     PTAnonymousClassDeclaration adecl =
         InstantiationFactory.eINSTANCE.createPTAnonymousClassDeclaration();
     adecl.setDeclaration(node.toString());
     expression = adecl;
   } else {
     PTClassInstanceCreation cic = InstantiationFactory.eINSTANCE.createPTClassInstanceCreation();
     // If ast level = 2, then you must use getName, but the name needs to be turned into a type
     // so that it can be resolved. If ast level > 2, then it will return a type to be resolved.
     // Note: can't just use resolve name on the name because if a field and a class were spelled
     // the same then the codegen resolver would return an instance ref to the field instead.
     String type =
         node.getAST().apiLevel() == AST.JLS2
             ? resolver.resolveType(node.getName())
             : resolver.resolveType(node.getType());
     if (type == null) {
       type =
           node.getAST().apiLevel() == AST.JLS2
               ? node.getName().getFullyQualifiedName()
               : node.getType().toString();
     }
     cic.setType(type);
     List args = cic.getArguments();
     List nargs = node.arguments();
     int nsize = nargs.size();
     for (int i = 0; i < nsize; i++) {
       args.add(perform((Expression) nargs.get(i)));
     }
     expression = cic;
   }
   return false;
 }
コード例 #3
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CastExpression)
  */
 public boolean visit(CastExpression node) {
   PTCastExpression ct = InstantiationFactory.eINSTANCE.createPTCastExpression();
   ct.setType(resolver.resolveType(node.getType()));
   ct.setExpression(perform(node.getExpression()));
   expression = ct;
   return false;
 }
コード例 #4
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ArrayCreation)
  */
 public boolean visit(ArrayCreation node) {
   PTArrayCreation ac = InstantiationFactory.eINSTANCE.createPTArrayCreation();
   ac.setType(resolver.resolveType(node.getType()));
   List acDims = ac.getDimensions();
   List nDims = node.dimensions();
   int nsize = nDims.size();
   for (int i = 0; i < nsize; i++) {
     acDims.add(perform((Expression) nDims.get(i)));
   }
   ac.setInitializer((PTArrayInitializer) perform(node.getInitializer()));
   expression = ac;
   return false;
 }
コード例 #5
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.TypeLiteral)
  */
 public boolean visit(TypeLiteral node) {
   PTTypeLiteral ptl = InstantiationFactory.eINSTANCE.createPTTypeLiteral();
   ptl.setType(resolver.resolveType(node.getType()));
   expression = ptl;
   return false;
 }
コード例 #6
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ThisExpression)
  */
 public boolean visit(ThisExpression node) {
   expression = resolver.resolveThis();
   return false;
 }
コード例 #7
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SuperMethodInvocation)
  */
 public boolean visit(SuperMethodInvocation node) {
   expression =
       createMethodInvocation(
           node.getName().getIdentifier(), resolver.resolveThis(), node.arguments());
   return false;
 }
コード例 #8
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SuperFieldAccess)
  */
 public boolean visit(SuperFieldAccess node) {
   expression = createFieldAccess(node.getName().getIdentifier(), resolver.resolveThis());
   return false;
 }
コード例 #9
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SimpleName)
  */
 public boolean visit(SimpleName node) {
   expression = resolver.resolveName(node);
   return false;
 }
コード例 #10
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.QualifiedName)
  */
 public boolean visit(QualifiedName node) {
   expression = resolver.resolveName(node);
   return false;
 }