Home | History | Annotate | Download | only in visitor
      1 /*
      2  * Copyright (C) 2007-2010 Jlio Vilmar Gesser.
      3  * Copyright (C) 2011, 2013-2016 The JavaParser Team.
      4  *
      5  * This file is part of JavaParser.
      6  *
      7  * JavaParser can be used either under the terms of
      8  * a) the GNU Lesser General Public License as published by
      9  *     the Free Software Foundation, either version 3 of the License, or
     10  *     (at your option) any later version.
     11  * b) the terms of the Apache License
     12  *
     13  * You should have received a copy of both licenses in LICENCE.LGPL and
     14  * LICENCE.APACHE. Please refer to those files for details.
     15  *
     16  * JavaParser is distributed in the hope that it will be useful,
     17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19  * GNU Lesser General Public License for more details.
     20  */
     21 
     22 package com.github.javaparser.ast.visitor;
     23 
     24 import com.github.javaparser.ast.*;
     25 import com.github.javaparser.ast.body.*;
     26 import com.github.javaparser.ast.comments.BlockComment;
     27 import com.github.javaparser.ast.comments.Comment;
     28 import com.github.javaparser.ast.comments.JavadocComment;
     29 import com.github.javaparser.ast.comments.LineComment;
     30 import com.github.javaparser.ast.expr.*;
     31 import com.github.javaparser.ast.stmt.*;
     32 import com.github.javaparser.ast.type.*;
     33 
     34 import java.util.List;
     35 
     36 /**
     37  * @author Julio Vilmar Gesser
     38  */
     39 public abstract class GenericVisitorAdapter<R, A> implements GenericVisitor<R, A> {
     40 
     41 	@Override
     42 	public R visit(final AnnotationDeclaration n, final A arg) {
     43 		visitComment(n, arg);
     44 		if (n.getAnnotations() != null) {
     45 			for (final AnnotationExpr a : n.getAnnotations()) {
     46 				{
     47 					R result = a.accept(this, arg);
     48 					if (result != null) {
     49 						return result;
     50 					}
     51 				}
     52 			}
     53 		}
     54 		if (n.getMembers() != null) {
     55             for (final BodyDeclaration<?> member : n.getMembers()) {
     56 				{
     57 					R result = member.accept(this, arg);
     58 					if (result != null) {
     59 						return result;
     60 					}
     61 				}
     62 			}
     63 		}
     64 		return null;
     65 	}
     66 
     67 	@Override
     68 	public R visit(final AnnotationMemberDeclaration n, final A arg) {
     69 		visitComment(n, arg);
     70 		if (n.getAnnotations() != null) {
     71 			for (final AnnotationExpr a : n.getAnnotations()) {
     72 				{
     73 					R result = a.accept(this, arg);
     74 					if (result != null) {
     75 						return result;
     76 					}
     77 				}
     78 			}
     79 		}
     80 		{
     81 			R result = n.getType().accept(this, arg);
     82 			if (result != null) {
     83 				return result;
     84 			}
     85 		}
     86 		if (n.getDefaultValue() != null) {
     87 			{
     88 				R result = n.getDefaultValue().accept(this, arg);
     89 				if (result != null) {
     90 					return result;
     91 				}
     92 			}
     93 		}
     94 		return null;
     95 	}
     96 
     97 	@Override
     98 	public R visit(final ArrayAccessExpr n, final A arg) {
     99 		visitComment(n, arg);
    100 		{
    101 			R result = n.getName().accept(this, arg);
    102 			if (result != null) {
    103 				return result;
    104 			}
    105 		}
    106 		{
    107 			R result = n.getIndex().accept(this, arg);
    108 			if (result != null) {
    109 				return result;
    110 			}
    111 		}
    112 		return null;
    113 	}
    114 
    115 	@Override
    116 	public R visit(final ArrayCreationExpr n, final A arg) {
    117 		visitComment(n, arg);
    118 		{
    119 			R result = n.getType().accept(this, arg);
    120 			if (result != null) {
    121 				return result;
    122 			}
    123 		}
    124 		for(ArrayCreationLevel level: n.getLevels()){
    125 			R result = level.accept(this, arg);
    126 			if (result != null) {
    127 				return result;
    128 			}
    129 		}
    130 		if (n.getInitializer() != null) {
    131 			R result = n.getInitializer().accept(this, arg);
    132 			if (result != null) {
    133 				return result;
    134 			}
    135 		}
    136 		return null;
    137 	}
    138 
    139 	@Override
    140 	public R visit(final ArrayInitializerExpr n, final A arg) {
    141 		visitComment(n, arg);
    142 		if (n.getValues() != null) {
    143 			for (final Expression expr : n.getValues()) {
    144 				{
    145 					R result = expr.accept(this, arg);
    146 					if (result != null) {
    147 						return result;
    148 					}
    149 				}
    150 			}
    151 		}
    152 		return null;
    153 	}
    154 
    155 	@Override
    156 	public R visit(final AssertStmt n, final A arg) {
    157 		visitComment(n, arg);
    158 		{
    159 			R result = n.getCheck().accept(this, arg);
    160 			if (result != null) {
    161 				return result;
    162 			}
    163 		}
    164 		if (n.getMessage() != null) {
    165 			{
    166 				R result = n.getMessage().accept(this, arg);
    167 				if (result != null) {
    168 					return result;
    169 				}
    170 			}
    171 		}
    172 		return null;
    173 	}
    174 
    175 	@Override
    176 	public R visit(final AssignExpr n, final A arg) {
    177 		visitComment(n, arg);
    178 		{
    179 			R result = n.getTarget().accept(this, arg);
    180 			if (result != null) {
    181 				return result;
    182 			}
    183 		}
    184 		{
    185 			R result = n.getValue().accept(this, arg);
    186 			if (result != null) {
    187 				return result;
    188 			}
    189 		}
    190 		return null;
    191 	}
    192 
    193 	@Override
    194 	public R visit(final BinaryExpr n, final A arg) {
    195 		visitComment(n, arg);
    196 		{
    197 			R result = n.getLeft().accept(this, arg);
    198 			if (result != null) {
    199 				return result;
    200 			}
    201 		}
    202 		{
    203 			R result = n.getRight().accept(this, arg);
    204 			if (result != null) {
    205 				return result;
    206 			}
    207 		}
    208 		return null;
    209 	}
    210 
    211 	@Override
    212 	public R visit(final BlockStmt n, final A arg) {
    213 		visitComment(n, arg);
    214 		if (n.getStmts() != null) {
    215 			for (final Statement s : n.getStmts()) {
    216 				{
    217 					R result = s.accept(this, arg);
    218 					if (result != null) {
    219 						return result;
    220 					}
    221 				}
    222 			}
    223 		}
    224 		return null;
    225 
    226 	}
    227 
    228 	@Override
    229 	public R visit(final BooleanLiteralExpr n, final A arg) {
    230 		visitComment(n, arg);
    231 		return null;
    232 	}
    233 
    234 	@Override
    235 	public R visit(final BreakStmt n, final A arg) {
    236 		visitComment(n, arg);
    237 		return null;
    238 	}
    239 
    240 	@Override
    241 	public R visit(final CastExpr n, final A arg) {
    242 		visitComment(n, arg);
    243 		{
    244 			R result = n.getType().accept(this, arg);
    245 			if (result != null) {
    246 				return result;
    247 			}
    248 		}
    249 		{
    250 			R result = n.getExpr().accept(this, arg);
    251 			if (result != null) {
    252 				return result;
    253 			}
    254 		}
    255 		return null;
    256 	}
    257 
    258 	@Override
    259 	public R visit(final CatchClause n, final A arg) {
    260 		visitComment(n, arg);
    261 		{
    262 			R result = n.getParam().accept(this, arg);
    263 			if (result != null) {
    264 				return result;
    265 			}
    266 		}
    267 		{
    268 			R result = n.getBody().accept(this, arg);
    269 			if (result != null) {
    270 				return result;
    271 			}
    272 		}
    273 		return null;
    274 
    275 	}
    276 
    277 	@Override
    278 	public R visit(final CharLiteralExpr n, final A arg) {
    279 		visitComment(n, arg);
    280 		return null;
    281 	}
    282 
    283 	@Override
    284 	public R visit(final ClassExpr n, final A arg) {
    285 		visitComment(n, arg);
    286 		{
    287 			R result = n.getType().accept(this, arg);
    288 			if (result != null) {
    289 				return result;
    290 			}
    291 		}
    292 		return null;
    293 	}
    294 
    295 	@Override
    296 	public R visit(final ClassOrInterfaceDeclaration n, final A arg) {
    297 		visitComment(n, arg);
    298 		if (n.getAnnotations() != null) {
    299 			for (final AnnotationExpr a : n.getAnnotations()) {
    300 				{
    301 					R result = a.accept(this, arg);
    302 					if (result != null) {
    303 						return result;
    304 					}
    305 				}
    306 			}
    307 		}
    308 		if (n.getTypeParameters() != null) {
    309 			for (final TypeParameter t : n.getTypeParameters()) {
    310 				{
    311 					R result = t.accept(this, arg);
    312 					if (result != null) {
    313 						return result;
    314 					}
    315 				}
    316 			}
    317 		}
    318 		if (n.getExtends() != null) {
    319 			for (final ClassOrInterfaceType c : n.getExtends()) {
    320 				{
    321 					R result = c.accept(this, arg);
    322 					if (result != null) {
    323 						return result;
    324 					}
    325 				}
    326 			}
    327 		}
    328 
    329 		if (n.getImplements() != null) {
    330 			for (final ClassOrInterfaceType c : n.getImplements()) {
    331 				{
    332 					R result = c.accept(this, arg);
    333 					if (result != null) {
    334 						return result;
    335 					}
    336 				}
    337 			}
    338 		}
    339 		if (n.getMembers() != null) {
    340             for (final BodyDeclaration<?> member : n.getMembers()) {
    341 				{
    342 					R result = member.accept(this, arg);
    343 					if (result != null) {
    344 						return result;
    345 					}
    346 				}
    347 			}
    348 		}
    349 		return null;
    350 	}
    351 
    352 	@Override
    353 	public R visit(final ClassOrInterfaceType n, final A arg) {
    354 		visitComment(n, arg);
    355 		for (final AnnotationExpr a : n.getAnnotations()) {
    356 			R result = a.accept(this, arg);
    357 			if (result != null) {
    358 				return result;
    359 			}
    360 		}
    361 		if (n.getScope() != null) {
    362 			{
    363 				R result = n.getScope().accept(this, arg);
    364 				if (result != null) {
    365 					return result;
    366 				}
    367 			}
    368 		}
    369 		if (n.getTypeArguments() != null) {
    370 			for (Type<?> type : n.getTypeArguments()) {
    371 				R result = type.accept(this, arg);
    372 				if (result != null) {
    373 					return result;
    374 				}
    375 			}
    376 		}
    377 		return null;
    378 	}
    379 
    380 	@Override
    381 	public R visit(final CompilationUnit n, final A arg) {
    382 		visitComment(n, arg);
    383 		if (n.getPackage() != null) {
    384 			{
    385 				R result = n.getPackage().accept(this, arg);
    386 				if (result != null) {
    387 					return result;
    388 				}
    389 			}
    390 		}
    391 		if (n.getImports() != null) {
    392 			for (final ImportDeclaration i : n.getImports()) {
    393 				{
    394 					R result = i.accept(this, arg);
    395 					if (result != null) {
    396 						return result;
    397 					}
    398 				}
    399 			}
    400 		}
    401 		if (n.getTypes() != null) {
    402             for (final TypeDeclaration<?> typeDeclaration : n.getTypes()) {
    403 				{
    404 					R result = typeDeclaration.accept(this, arg);
    405 					if (result != null) {
    406 						return result;
    407 					}
    408 				}
    409 			}
    410 		}
    411 		return null;
    412 	}
    413 
    414 	@Override
    415 	public R visit(final ConditionalExpr n, final A arg) {
    416 		visitComment(n, arg);
    417 		{
    418 			R result = n.getCondition().accept(this, arg);
    419 			if (result != null) {
    420 				return result;
    421 			}
    422 		}
    423 		{
    424 			R result = n.getThenExpr().accept(this, arg);
    425 			if (result != null) {
    426 				return result;
    427 			}
    428 		}
    429 		{
    430 			R result = n.getElseExpr().accept(this, arg);
    431 			if (result != null) {
    432 				return result;
    433 			}
    434 		}
    435 		return null;
    436 	}
    437 
    438 	@Override
    439 	public R visit(final ConstructorDeclaration n, final A arg) {
    440 		visitComment(n, arg);
    441 		if (n.getAnnotations() != null) {
    442 			for (final AnnotationExpr a : n.getAnnotations()) {
    443 				{
    444 					R result = a.accept(this, arg);
    445 					if (result != null) {
    446 						return result;
    447 					}
    448 				}
    449 			}
    450 		}
    451 		if (n.getTypeParameters() != null) {
    452 			for (final TypeParameter t : n.getTypeParameters()) {
    453 				{
    454 					R result = t.accept(this, arg);
    455 					if (result != null) {
    456 						return result;
    457 					}
    458 				}
    459 			}
    460 		}
    461 		if (n.getParameters() != null) {
    462 			for (final Parameter p : n.getParameters()) {
    463 				{
    464 					R result = p.accept(this, arg);
    465 					if (result != null) {
    466 						return result;
    467 					}
    468 				}
    469 			}
    470 		}
    471 		if (n.getThrows() != null) {
    472 			for (final ReferenceType name : n.getThrows()) {
    473 				{
    474 					R result = name.accept(this, arg);
    475 					if (result != null) {
    476 						return result;
    477 					}
    478 				}
    479 			}
    480 		}
    481 		{
    482 			R result = n.getBody().accept(this, arg);
    483 			if (result != null) {
    484 				return result;
    485 			}
    486 		}
    487 		return null;
    488 	}
    489 
    490 	@Override
    491 	public R visit(final ContinueStmt n, final A arg) {
    492 		visitComment(n, arg);
    493 		return null;
    494 	}
    495 
    496 	@Override
    497 	public R visit(final DoStmt n, final A arg) {
    498 		visitComment(n, arg);
    499 		{
    500 			R result = n.getBody().accept(this, arg);
    501 			if (result != null) {
    502 				return result;
    503 			}
    504 		}
    505 		{
    506 			R result = n.getCondition().accept(this, arg);
    507 			if (result != null) {
    508 				return result;
    509 			}
    510 		}
    511 		return null;
    512 	}
    513 
    514 	@Override
    515 	public R visit(final DoubleLiteralExpr n, final A arg) {
    516 		visitComment(n, arg);
    517 		return null;
    518 	}
    519 
    520 	@Override
    521 	public R visit(final EmptyMemberDeclaration n, final A arg) {
    522 		visitComment(n, arg);
    523 		return null;
    524 	}
    525 
    526 	@Override
    527 	public R visit(final EmptyStmt n, final A arg) {
    528 		visitComment(n, arg);
    529 		return null;
    530 	}
    531 
    532 	@Override
    533 	public R visit(final EmptyTypeDeclaration n, final A arg) {
    534 		visitComment(n, arg);
    535 		return null;
    536 	}
    537 
    538 	@Override
    539 	public R visit(final EnclosedExpr n, final A arg) {
    540 		visitComment(n, arg);
    541 		{
    542 			R result = n.getInner().accept(this, arg);
    543 			if (result != null) {
    544 				return result;
    545 			}
    546 		}
    547 		return null;
    548 	}
    549 
    550 	@Override
    551 	public R visit(final EnumConstantDeclaration n, final A arg) {
    552 		visitComment(n, arg);
    553 		if (n.getAnnotations() != null) {
    554 			for (final AnnotationExpr a : n.getAnnotations()) {
    555 				{
    556 					R result = a.accept(this, arg);
    557 					if (result != null) {
    558 						return result;
    559 					}
    560 				}
    561 			}
    562 		}
    563 		if (n.getArgs() != null) {
    564 			for (final Expression e : n.getArgs()) {
    565 				{
    566 					R result = e.accept(this, arg);
    567 					if (result != null) {
    568 						return result;
    569 					}
    570 				}
    571 			}
    572 		}
    573 		if (n.getClassBody() != null) {
    574             for (final BodyDeclaration<?> member : n.getClassBody()) {
    575 				{
    576 					R result = member.accept(this, arg);
    577 					if (result != null) {
    578 						return result;
    579 					}
    580 				}
    581 			}
    582 		}
    583 		return null;
    584 	}
    585 
    586 	@Override
    587 	public R visit(final EnumDeclaration n, final A arg) {
    588 		visitComment(n, arg);
    589 		if (n.getAnnotations() != null) {
    590 			for (final AnnotationExpr a : n.getAnnotations()) {
    591 				{
    592 					R result = a.accept(this, arg);
    593 					if (result != null) {
    594 						return result;
    595 					}
    596 				}
    597 			}
    598 		}
    599 		if (n.getImplements() != null) {
    600 			for (final ClassOrInterfaceType c : n.getImplements()) {
    601 				{
    602 					R result = c.accept(this, arg);
    603 					if (result != null) {
    604 						return result;
    605 					}
    606 				}
    607 			}
    608 		}
    609 		if (n.getEntries() != null) {
    610 			for (final EnumConstantDeclaration e : n.getEntries()) {
    611 				{
    612 					R result = e.accept(this, arg);
    613 					if (result != null) {
    614 						return result;
    615 					}
    616 				}
    617 			}
    618 		}
    619 		if (n.getMembers() != null) {
    620             for (final BodyDeclaration<?> member : n.getMembers()) {
    621 				{
    622 					R result = member.accept(this, arg);
    623 					if (result != null) {
    624 						return result;
    625 					}
    626 				}
    627 			}
    628 		}
    629 		return null;
    630 	}
    631 
    632 	@Override
    633 	public R visit(final ExplicitConstructorInvocationStmt n, final A arg) {
    634 		visitComment(n, arg);
    635 		if (!n.isThis() && n.getExpr() != null) {
    636 			{
    637 				R result = n.getExpr().accept(this, arg);
    638 				if (result != null) {
    639 					return result;
    640 				}
    641 			}
    642 		}
    643 		if (n.getTypeArguments() != null) {
    644 			for (Type<?> type : n.getTypeArguments()) {
    645 				R result = type.accept(this, arg);
    646 				if (result != null) {
    647 					return result;
    648 				}
    649 			}
    650 		}
    651 		if (n.getArgs() != null) {
    652 			for (final Expression e : n.getArgs()) {
    653 				{
    654 					R result = e.accept(this, arg);
    655 					if (result != null) {
    656 						return result;
    657 					}
    658 				}
    659 			}
    660 		}
    661 		return null;
    662 	}
    663 
    664 	@Override
    665 	public R visit(final ExpressionStmt n, final A arg) {
    666 		visitComment(n, arg);
    667 		{
    668 			R result = n.getExpression().accept(this, arg);
    669 			if (result != null) {
    670 				return result;
    671 			}
    672 		}
    673 		return null;
    674 	}
    675 
    676 	@Override
    677 	public R visit(final FieldAccessExpr n, final A arg) {
    678 		visitComment(n, arg);
    679 		{
    680 			R result = n.getScope().accept(this, arg);
    681 			if (result != null) {
    682 				return result;
    683 			}
    684 		}
    685         {
    686             if (n.getTypeArguments() != null) {
    687                 for (Type<?> type : n.getTypeArguments()) {
    688                     R result = type.accept(this, arg);
    689                     if (result != null) {
    690                         return result;
    691                     }
    692                 }
    693             }
    694         }
    695 		return null;
    696 	}
    697 
    698 	@Override
    699 	public R visit(final FieldDeclaration n, final A arg) {
    700 		visitComment(n, arg);
    701 		if (n.getAnnotations() != null) {
    702 			for (final AnnotationExpr a : n.getAnnotations()) {
    703 				{
    704 					R result = a.accept(this, arg);
    705 					if (result != null) {
    706 						return result;
    707 					}
    708 				}
    709 			}
    710 		}
    711 		{
    712 			R result = n.getElementType().accept(this, arg);
    713 			if (result != null) {
    714 				return result;
    715 			}
    716 		}
    717 		for (final VariableDeclarator var : n.getVariables()) {
    718 			{
    719 				R result = var.accept(this, arg);
    720 				if (result != null) {
    721 					return result;
    722 				}
    723 			}
    724 		}
    725 		return null;
    726 	}
    727 
    728 	@Override
    729 	public R visit(final ForeachStmt n, final A arg) {
    730 		visitComment(n, arg);
    731 		{
    732 			R result = n.getVariable().accept(this, arg);
    733 			if (result != null) {
    734 				return result;
    735 			}
    736 		}
    737 		{
    738 			R result = n.getIterable().accept(this, arg);
    739 			if (result != null) {
    740 				return result;
    741 			}
    742 		}
    743 		{
    744 			R result = n.getBody().accept(this, arg);
    745 			if (result != null) {
    746 				return result;
    747 			}
    748 		}
    749 		return null;
    750 	}
    751 
    752 	@Override
    753 	public R visit(final ForStmt n, final A arg) {
    754 		visitComment(n, arg);
    755 		if (n.getInit() != null) {
    756 			for (final Expression e : n.getInit()) {
    757 				{
    758 					R result = e.accept(this, arg);
    759 					if (result != null) {
    760 						return result;
    761 					}
    762 				}
    763 			}
    764 		}
    765 		if (n.getCompare() != null) {
    766 			{
    767 				R result = n.getCompare().accept(this, arg);
    768 				if (result != null) {
    769 					return result;
    770 				}
    771 			}
    772 		}
    773 		if (n.getUpdate() != null) {
    774 			for (final Expression e : n.getUpdate()) {
    775 				{
    776 					R result = e.accept(this, arg);
    777 					if (result != null) {
    778 						return result;
    779 					}
    780 				}
    781 			}
    782 		}
    783 		{
    784 			R result = n.getBody().accept(this, arg);
    785 			if (result != null) {
    786 				return result;
    787 			}
    788 		}
    789 		return null;
    790 	}
    791 
    792 	@Override
    793 	public R visit(final IfStmt n, final A arg) {
    794 		visitComment(n, arg);
    795 		{
    796 			R result = n.getCondition().accept(this, arg);
    797 			if (result != null) {
    798 				return result;
    799 			}
    800 		}
    801 		{
    802 			R result = n.getThenStmt().accept(this, arg);
    803 			if (result != null) {
    804 				return result;
    805 			}
    806 		}
    807 		if (n.getElseStmt() != null) {
    808 			{
    809 				R result = n.getElseStmt().accept(this, arg);
    810 				if (result != null) {
    811 					return result;
    812 				}
    813 			}
    814 		}
    815 		return null;
    816 	}
    817 
    818 	@Override
    819 	public R visit(final ImportDeclaration n, final A arg) {
    820 		visitComment(n, arg);
    821 		{
    822 			R result = n.getName().accept(this, arg);
    823 			if (result != null) {
    824 				return result;
    825 			}
    826 		}
    827 		return null;
    828 	}
    829 
    830 	@Override
    831 	public R visit(final InitializerDeclaration n, final A arg) {
    832 		visitComment(n, arg);
    833 		{
    834 			R result = n.getBlock().accept(this, arg);
    835 			if (result != null) {
    836 				return result;
    837 			}
    838 		}
    839 		return null;
    840 	}
    841 
    842 	@Override
    843 	public R visit(final InstanceOfExpr n, final A arg) {
    844 		visitComment(n, arg);
    845 		{
    846 			R result = n.getExpr().accept(this, arg);
    847 			if (result != null) {
    848 				return result;
    849 			}
    850 		}
    851 		{
    852 			R result = n.getType().accept(this, arg);
    853 			if (result != null) {
    854 				return result;
    855 			}
    856 		}
    857 		return null;
    858 	}
    859 
    860 	@Override
    861 	public R visit(final IntegerLiteralExpr n, final A arg) {
    862 		visitComment(n, arg);
    863 		return null;
    864 	}
    865 
    866 	@Override
    867 	public R visit(final IntegerLiteralMinValueExpr n, final A arg) {
    868 		visitComment(n, arg);
    869 		return null;
    870 	}
    871 
    872 	@Override
    873 	public R visit(final JavadocComment n, final A arg) {
    874 		return null;
    875 	}
    876 
    877 	@Override
    878 	public R visit(final LabeledStmt n, final A arg) {
    879 		visitComment(n, arg);
    880 		{
    881 			R result = n.getStmt().accept(this, arg);
    882 			if (result != null) {
    883 				return result;
    884 			}
    885 		}
    886 		return null;
    887 	}
    888 
    889 	@Override
    890 	public R visit(final LongLiteralExpr n, final A arg) {
    891 		visitComment(n, arg);
    892 		return null;
    893 	}
    894 
    895 	@Override
    896 	public R visit(final LongLiteralMinValueExpr n, final A arg) {
    897 		visitComment(n, arg);
    898 		return null;
    899 	}
    900 
    901 	@Override
    902 	public R visit(final MarkerAnnotationExpr n, final A arg) {
    903 		visitComment(n, arg);
    904 		{
    905 			R result = n.getName().accept(this, arg);
    906 			if (result != null) {
    907 				return result;
    908 			}
    909 		}
    910 		return null;
    911 	}
    912 
    913 	@Override
    914 	public R visit(final MemberValuePair n, final A arg) {
    915 		visitComment(n, arg);
    916 		{
    917 			R result = n.getValue().accept(this, arg);
    918 			if (result != null) {
    919 				return result;
    920 			}
    921 		}
    922 		return null;
    923 	}
    924 
    925 	@Override
    926 	public R visit(final MethodCallExpr n, final A arg) {
    927 		visitComment(n, arg);
    928 		if (n.getScope() != null) {
    929 			{
    930 				R result = n.getScope().accept(this, arg);
    931 				if (result != null) {
    932 					return result;
    933 				}
    934 			}
    935 		}
    936 		if (n.getTypeArguments() != null) {
    937 			for (Type<?> type : n.getTypeArguments()) {
    938 				R result = type.accept(this, arg);
    939 				if (result != null) {
    940 					return result;
    941 				}
    942 			}
    943 		}
    944 		if (n.getArgs() != null) {
    945 			for (final Expression e : n.getArgs()) {
    946 				{
    947 					R result = e.accept(this, arg);
    948 					if (result != null) {
    949 						return result;
    950 					}
    951 				}
    952 			}
    953 		}
    954 		return null;
    955 	}
    956 
    957 	@Override
    958 	public R visit(final MethodDeclaration n, final A arg) {
    959 		visitComment(n, arg);
    960 		if (n.getAnnotations() != null) {
    961 			for (final AnnotationExpr a : n.getAnnotations()) {
    962 				{
    963 					R result = a.accept(this, arg);
    964 					if (result != null) {
    965 						return result;
    966 					}
    967 				}
    968 			}
    969 		}
    970 		if (n.getTypeParameters() != null) {
    971 			for (final TypeParameter t : n.getTypeParameters()) {
    972 				{
    973 					R result = t.accept(this, arg);
    974 					if (result != null) {
    975 						return result;
    976 					}
    977 				}
    978 			}
    979 		}
    980 		{
    981 			R result = n.getElementType().accept(this, arg);
    982 			if (result != null) {
    983 				return result;
    984 			}
    985 		}
    986 		if (n.getParameters() != null) {
    987 			for (final Parameter p : n.getParameters()) {
    988 				{
    989 					R result = p.accept(this, arg);
    990 					if (result != null) {
    991 						return result;
    992 					}
    993 				}
    994 			}
    995 		}
    996 		if (n.getThrows() != null) {
    997 			for (final ReferenceType name : n.getThrows()) {
    998 				{
    999 					R result = name.accept(this, arg);
   1000 					if (result != null) {
   1001 						return result;
   1002 					}
   1003 				}
   1004 			}
   1005 		}
   1006 		if (n.getBody() != null) {
   1007 			{
   1008 				R result = n.getBody().accept(this, arg);
   1009 				if (result != null) {
   1010 					return result;
   1011 				}
   1012 			}
   1013 		}
   1014 		return null;
   1015 	}
   1016 
   1017 	@Override
   1018 	public R visit(final NameExpr n, final A arg) {
   1019 		visitComment(n, arg);
   1020 		return null;
   1021 	}
   1022 
   1023 	@Override
   1024 	public R visit(final NormalAnnotationExpr n, final A arg) {
   1025 		visitComment(n, arg);
   1026 		{
   1027 			R result = n.getName().accept(this, arg);
   1028 			if (result != null) {
   1029 				return result;
   1030 			}
   1031 		}
   1032 		if (n.getPairs() != null) {
   1033 			for (final MemberValuePair m : n.getPairs()) {
   1034 				{
   1035 					R result = m.accept(this, arg);
   1036 					if (result != null) {
   1037 						return result;
   1038 					}
   1039 				}
   1040 			}
   1041 		}
   1042 		return null;
   1043 	}
   1044 
   1045 	@Override
   1046 	public R visit(final NullLiteralExpr n, final A arg) {
   1047 		visitComment(n, arg);
   1048 		return null;
   1049 	}
   1050 
   1051 	@Override
   1052 	public R visit(final ObjectCreationExpr n, final A arg) {
   1053 		visitComment(n, arg);
   1054 		if (n.getScope() != null) {
   1055 			{
   1056 				R result = n.getScope().accept(this, arg);
   1057 				if (result != null) {
   1058 					return result;
   1059 				}
   1060 			}
   1061 		}
   1062 		if (n.getTypeArguments() != null) {
   1063 			for (Type<?> type : n.getTypeArguments()) {
   1064 				R result = type.accept(this, arg);
   1065 				if (result != null) {
   1066 					return result;
   1067 				}
   1068 			}
   1069 		}
   1070 		{
   1071 			R result = n.getType().accept(this, arg);
   1072 			if (result != null) {
   1073 				return result;
   1074 			}
   1075 		}
   1076 		if (n.getArgs() != null) {
   1077 			for (final Expression e : n.getArgs()) {
   1078 				{
   1079 					R result = e.accept(this, arg);
   1080 					if (result != null) {
   1081 						return result;
   1082 					}
   1083 				}
   1084 			}
   1085 		}
   1086 		if (n.getAnonymousClassBody() != null) {
   1087             for (final BodyDeclaration<?> member : n.getAnonymousClassBody()) {
   1088 				{
   1089 					R result = member.accept(this, arg);
   1090 					if (result != null) {
   1091 						return result;
   1092 					}
   1093 				}
   1094 			}
   1095 		}
   1096 		return null;
   1097 	}
   1098 
   1099 	@Override
   1100 	public R visit(final PackageDeclaration n, final A arg) {
   1101 		visitComment(n, arg);
   1102 		if (n.getAnnotations() != null) {
   1103 			for (final AnnotationExpr a : n.getAnnotations()) {
   1104 				{
   1105 					R result = a.accept(this, arg);
   1106 					if (result != null) {
   1107 						return result;
   1108 					}
   1109 				}
   1110 			}
   1111 		}
   1112 		{
   1113 			R result = n.getName().accept(this, arg);
   1114 			if (result != null) {
   1115 				return result;
   1116 			}
   1117 		}
   1118 		return null;
   1119 	}
   1120 
   1121 	@Override
   1122 	public R visit(final Parameter n, final A arg) {
   1123 		visitComment(n, arg);
   1124 		if (n.getAnnotations() != null) {
   1125 			for (final AnnotationExpr a : n.getAnnotations()) {
   1126 				{
   1127 					R result = a.accept(this, arg);
   1128 					if (result != null) {
   1129 						return result;
   1130 					}
   1131 				}
   1132 			}
   1133 		}
   1134 		{
   1135 			R result = n.getElementType().accept(this, arg);
   1136 			if (result != null) {
   1137 				return result;
   1138 			}
   1139 		}
   1140 		{
   1141 			R result = n.getId().accept(this, arg);
   1142 			if (result != null) {
   1143 				return result;
   1144 			}
   1145 		}
   1146 		return null;
   1147 	}
   1148 
   1149 	@Override
   1150 	public R visit(final PrimitiveType n, final A arg) {
   1151 		visitComment(n, arg);
   1152 		for (final AnnotationExpr a : n.getAnnotations()) {
   1153 			R result = a.accept(this, arg);
   1154 			if (result != null) {
   1155 				return result;
   1156 			}
   1157 		}
   1158 		return null;
   1159 	}
   1160 
   1161 	@Override
   1162 	public R visit(final QualifiedNameExpr n, final A arg) {
   1163 		visitComment(n, arg);
   1164 		{
   1165 			R result = n.getQualifier().accept(this, arg);
   1166 			if (result != null) {
   1167 				return result;
   1168 			}
   1169 		}
   1170 		return null;
   1171 	}
   1172 
   1173 	@Override
   1174 	public R visit(ArrayType n, A arg) {
   1175 		visitComment(n, arg);
   1176 		for (final AnnotationExpr a : n.getAnnotations()) {
   1177 			R result = a.accept(this, arg);
   1178 			if (result != null) {
   1179 				return result;
   1180 			}
   1181 		}
   1182 		{
   1183 			R result = n.getComponentType().accept(this, arg);
   1184 			if (result != null) {
   1185 				return result;
   1186 			}
   1187 		}
   1188 		return null;
   1189 	}
   1190 
   1191 	@Override
   1192 	public R visit(ArrayCreationLevel n, A arg) {
   1193 		visitComment(n, arg);
   1194 		for (final AnnotationExpr a : n.getAnnotations()) {
   1195 			R result = a.accept(this, arg);
   1196 			if (result != null) {
   1197 				return result;
   1198 			}
   1199 		}
   1200 		{
   1201 			if(n.getDimension()!=null) {
   1202 				R result = n.getDimension().accept(this, arg);
   1203 				if (result != null) {
   1204 					return result;
   1205 				}
   1206 			}
   1207 		}
   1208 		return null;
   1209 	}
   1210 
   1211 	@Override
   1212     public R visit(final IntersectionType n, final A arg) {
   1213 		visitComment(n, arg);
   1214 		for (final AnnotationExpr a : n.getAnnotations()) {
   1215 			R result = a.accept(this, arg);
   1216 			if (result != null) {
   1217 				return result;
   1218 			}
   1219 		}
   1220         {
   1221             for (ReferenceType element : n.getElements()) {
   1222                 R result = element.accept(this, arg);
   1223                 if (result != null) {
   1224                     return result;
   1225                 }
   1226             }
   1227         }
   1228         return null;
   1229     }
   1230 
   1231     @Override
   1232     public R visit(final UnionType n, final A arg) {
   1233 		visitComment(n, arg);
   1234 		for (final AnnotationExpr a : n.getAnnotations()) {
   1235 			R result = a.accept(this, arg);
   1236 			if (result != null) {
   1237 				return result;
   1238 			}
   1239 		}
   1240         {
   1241             for (ReferenceType element : n.getElements()) {
   1242                 R result = element.accept(this, arg);
   1243                 if (result != null) {
   1244                     return result;
   1245                 }
   1246             }
   1247         }
   1248         return null;
   1249     }
   1250 
   1251 	@Override
   1252 	public R visit(final ReturnStmt n, final A arg) {
   1253 		visitComment(n, arg);
   1254 		if (n.getExpr() != null) {
   1255 			{
   1256 				R result = n.getExpr().accept(this, arg);
   1257 				if (result != null) {
   1258 					return result;
   1259 				}
   1260 			}
   1261 		}
   1262 		return null;
   1263 	}
   1264 
   1265 	@Override
   1266 	public R visit(final SingleMemberAnnotationExpr n, final A arg) {
   1267 		visitComment(n, arg);
   1268 		{
   1269 			R result = n.getName().accept(this, arg);
   1270 			if (result != null) {
   1271 				return result;
   1272 			}
   1273 		}
   1274 		{
   1275 			R result = n.getMemberValue().accept(this, arg);
   1276 			if (result != null) {
   1277 				return result;
   1278 			}
   1279 		}
   1280 		return null;
   1281 	}
   1282 
   1283 	@Override
   1284 	public R visit(final StringLiteralExpr n, final A arg) {
   1285 		visitComment(n, arg);
   1286 		return null;
   1287 	}
   1288 
   1289 	@Override
   1290 	public R visit(final SuperExpr n, final A arg) {
   1291 		visitComment(n, arg);
   1292 		if (n.getClassExpr() != null) {
   1293 			{
   1294 				R result = n.getClassExpr().accept(this, arg);
   1295 				if (result != null) {
   1296 					return result;
   1297 				}
   1298 			}
   1299 		}
   1300 		return null;
   1301 	}
   1302 
   1303 	@Override
   1304 	public R visit(final SwitchEntryStmt n, final A arg) {
   1305 		visitComment(n, arg);
   1306 		if (n.getLabel() != null) {
   1307 			{
   1308 				R result = n.getLabel().accept(this, arg);
   1309 				if (result != null) {
   1310 					return result;
   1311 				}
   1312 			}
   1313 		}
   1314 		if (n.getStmts() != null) {
   1315 			for (final Statement s : n.getStmts()) {
   1316 				{
   1317 					R result = s.accept(this, arg);
   1318 					if (result != null) {
   1319 						return result;
   1320 					}
   1321 				}
   1322 			}
   1323 		}
   1324 		return null;
   1325 	}
   1326 
   1327 	@Override
   1328 	public R visit(final SwitchStmt n, final A arg) {
   1329 		visitComment(n, arg);
   1330 		{
   1331 			R result = n.getSelector().accept(this, arg);
   1332 			if (result != null) {
   1333 				return result;
   1334 			}
   1335 		}
   1336 		if (n.getEntries() != null) {
   1337 			for (final SwitchEntryStmt e : n.getEntries()) {
   1338 				{
   1339 					R result = e.accept(this, arg);
   1340 					if (result != null) {
   1341 						return result;
   1342 					}
   1343 				}
   1344 			}
   1345 		}
   1346 		return null;
   1347 
   1348 	}
   1349 
   1350 	@Override
   1351 	public R visit(final SynchronizedStmt n, final A arg) {
   1352 		visitComment(n, arg);
   1353 		{
   1354 			if (n.getExpr() != null) {
   1355 			    R result = n.getExpr().accept(this, arg);
   1356 			    if (result != null) {
   1357 				    return result;
   1358 			    }
   1359 			}
   1360 		}
   1361 		{
   1362 			R result = n.getBody().accept(this, arg);
   1363 			if (result != null) {
   1364 				return result;
   1365 			}
   1366 		}
   1367 		return null;
   1368 	}
   1369 
   1370 	@Override
   1371 	public R visit(final ThisExpr n, final A arg) {
   1372 		visitComment(n, arg);
   1373 		if (n.getClassExpr() != null) {
   1374 			{
   1375 				R result = n.getClassExpr().accept(this, arg);
   1376 				if (result != null) {
   1377 					return result;
   1378 				}
   1379 			}
   1380 		}
   1381 		return null;
   1382 	}
   1383 
   1384 	@Override
   1385 	public R visit(final ThrowStmt n, final A arg) {
   1386 		visitComment(n, arg);
   1387 		{
   1388 			R result = n.getExpr().accept(this, arg);
   1389 			if (result != null) {
   1390 				return result;
   1391 			}
   1392 		}
   1393 		return null;
   1394 	}
   1395 
   1396 	@Override
   1397 	public R visit(final TryStmt n, final A arg) {
   1398 		visitComment(n, arg);
   1399 		if (n.getResources() != null) {
   1400 			for (final VariableDeclarationExpr v : n.getResources()) {
   1401 				{
   1402 					R result = v.accept(this, arg);
   1403 					if (result != null) {
   1404 						return result;
   1405 					}
   1406 				}
   1407 			}
   1408 		}
   1409 		{
   1410 			R result = n.getTryBlock().accept(this, arg);
   1411 			if (result != null) {
   1412 				return result;
   1413 			}
   1414 		}
   1415 		if (n.getCatchs() != null) {
   1416 			for (final CatchClause c : n.getCatchs()) {
   1417 				{
   1418 					R result = c.accept(this, arg);
   1419 					if (result != null) {
   1420 						return result;
   1421 					}
   1422 				}
   1423 			}
   1424 		}
   1425 		if (n.getFinallyBlock() != null) {
   1426 			{
   1427 				R result = n.getFinallyBlock().accept(this, arg);
   1428 				if (result != null) {
   1429 					return result;
   1430 				}
   1431 			}
   1432 		}
   1433 		return null;
   1434 	}
   1435 
   1436 	@Override
   1437 	public R visit(final TypeDeclarationStmt n, final A arg) {
   1438 		visitComment(n, arg);
   1439 		{
   1440 			R result = n.getTypeDeclaration().accept(this, arg);
   1441 			if (result != null) {
   1442 				return result;
   1443 			}
   1444 		}
   1445 		return null;
   1446 	}
   1447 
   1448 	@Override
   1449 	public R visit(final TypeParameter n, final A arg) {
   1450 		visitComment(n, arg);
   1451 		if (n.getTypeBound() != null) {
   1452 			for (final ClassOrInterfaceType c : n.getTypeBound()) {
   1453 				{
   1454 					R result = c.accept(this, arg);
   1455 					if (result != null) {
   1456 						return result;
   1457 					}
   1458 				}
   1459 			}
   1460 		}
   1461 		return null;
   1462 	}
   1463 
   1464 	@Override
   1465 	public R visit(final UnaryExpr n, final A arg) {
   1466 		visitComment(n, arg);
   1467 		{
   1468 			R result = n.getExpr().accept(this, arg);
   1469 			if (result != null) {
   1470 				return result;
   1471 			}
   1472 		}
   1473 		return null;
   1474 	}
   1475 
   1476 	@Override
   1477 	public R visit(final UnknownType n, final A arg) {
   1478 		visitComment(n, arg);
   1479 		return null;
   1480 	}
   1481 
   1482 	@Override
   1483 	public R visit(final VariableDeclarationExpr n, final A arg) {
   1484 		visitComment(n, arg);
   1485 		for (final AnnotationExpr a : n.getAnnotations()) {
   1486 			R result = a.accept(this, arg);
   1487 			if (result != null) {
   1488 				return result;
   1489 			}
   1490 		}
   1491 		{
   1492 			R result = n.getElementType().accept(this, arg);
   1493 			if (result != null) {
   1494 				return result;
   1495 			}
   1496 		}
   1497 		for (final VariableDeclarator v : n.getVariables()) {
   1498 			{
   1499 				R result = v.accept(this, arg);
   1500 				if (result != null) {
   1501 					return result;
   1502 				}
   1503 			}
   1504 		}
   1505 		return null;
   1506 	}
   1507 
   1508 	@Override
   1509 	public R visit(final VariableDeclarator n, final A arg) {
   1510 		visitComment(n, arg);
   1511 		{
   1512 			R result = n.getId().accept(this, arg);
   1513 			if (result != null) {
   1514 				return result;
   1515 			}
   1516 		}
   1517 		if (n.getInit() != null) {
   1518 			{
   1519 				R result = n.getInit().accept(this, arg);
   1520 				if (result != null) {
   1521 					return result;
   1522 				}
   1523 			}
   1524 		}
   1525 		return null;
   1526 	}
   1527 
   1528 	@Override
   1529 	public R visit(final VariableDeclaratorId n, final A arg) {
   1530 		visitComment(n, arg);
   1531 		return null;
   1532 	}
   1533 
   1534 	@Override
   1535 	public R visit(final VoidType n, final A arg) {
   1536 		visitComment(n, arg);
   1537 		for (final AnnotationExpr a : n.getAnnotations()) {
   1538 			R result = a.accept(this, arg);
   1539 			if (result != null) {
   1540 				return result;
   1541 			}
   1542 		}
   1543 		return null;
   1544 	}
   1545 
   1546 	@Override
   1547 	public R visit(final WhileStmt n, final A arg) {
   1548 		visitComment(n, arg);
   1549 		{
   1550 			R result = n.getCondition().accept(this, arg);
   1551 			if (result != null) {
   1552 				return result;
   1553 			}
   1554 		}
   1555 		{
   1556 			R result = n.getBody().accept(this, arg);
   1557 			if (result != null) {
   1558 				return result;
   1559 			}
   1560 		}
   1561 		return null;
   1562 	}
   1563 
   1564 	@Override
   1565 	public R visit(final WildcardType n, final A arg) {
   1566 		visitComment(n, arg);
   1567 		for (final AnnotationExpr a : n.getAnnotations()) {
   1568 			R result = a.accept(this, arg);
   1569 			if (result != null) {
   1570 				return result;
   1571 			}
   1572 		}
   1573 		if (n.getExtends() != null) {
   1574 			{
   1575 				R result = n.getExtends().accept(this, arg);
   1576 				if (result != null) {
   1577 					return result;
   1578 				}
   1579 			}
   1580 		}
   1581 		if (n.getSuper() != null) {
   1582 			{
   1583 				R result = n.getSuper().accept(this, arg);
   1584 				if (result != null) {
   1585 					return result;
   1586 				}
   1587 			}
   1588 		}
   1589 		return null;
   1590 	}
   1591 
   1592     @Override
   1593     public R visit(LambdaExpr n, A arg) {
   1594 		visitComment(n, arg);
   1595 		if (n.getParameters() != null) {
   1596 			for (final Parameter a : n.getParameters()) {
   1597 				R result = a.accept(this, arg);
   1598 				if (result != null) {
   1599 					return result;
   1600 				}
   1601 			}
   1602 		}
   1603 		if (n.getBody() != null) {
   1604 			R result = n.getBody().accept(this, arg);
   1605 			if (result != null) {
   1606 				return result;
   1607 			}
   1608 		}
   1609 		return null;
   1610     }
   1611 
   1612     @Override
   1613     public R visit(MethodReferenceExpr n, A arg) {
   1614         visitComment(n, arg);
   1615         {
   1616             if (n.getTypeArguments() != null) {
   1617                 for (Type<?> type : n.getTypeArguments()) {
   1618                     R result = type.accept(this, arg);
   1619                     if (result != null) {
   1620                         return result;
   1621                     }
   1622                 }
   1623             }
   1624         }
   1625         if (n.getScope() != null) {
   1626 			R result = n.getScope().accept(this, arg);
   1627 			if (result != null) {
   1628 				return result;
   1629 			}
   1630 		}
   1631 		return null;
   1632     }
   1633 
   1634     @Override
   1635     public R visit(TypeExpr n, A arg){
   1636 		visitComment(n, arg);
   1637 		if (n.getType() != null) {
   1638 			R result = n.getType().accept(this, arg);
   1639 			if (result != null) {
   1640 				return result;
   1641 			}
   1642 		}
   1643 		return null;
   1644     }
   1645 
   1646 	@Override
   1647 	public R visit(ArrayBracketPair n, A arg) {
   1648 		for (final AnnotationExpr a : n.getAnnotations()) {
   1649 			{
   1650 				R result = a.accept(this, arg);
   1651 				if (result != null) {
   1652 					return result;
   1653 				}
   1654 			}
   1655 		}
   1656 		return null;
   1657 	}
   1658 
   1659 	@Override
   1660 	public R visit(final BlockComment n, final A arg) {
   1661 		return null;
   1662 	}
   1663 
   1664 	@Override
   1665 	public R visit(final LineComment n, final A arg) {
   1666 		return null;
   1667 	}
   1668 
   1669 	private void visitComment(Node n, A arg) {
   1670 		if(n.getComment()!=null){
   1671 			Comment result = (Comment) n.getComment().accept(this, arg);
   1672 			if(result!=null){
   1673 				n.setComment(result);
   1674 			}
   1675 		}
   1676 	}
   1677 }
   1678