1 11 package org.eclipse.jdt.internal.debug.ui.actions; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.eclipse.jdt.core.dom.ASTNode; 18 import org.eclipse.jdt.core.dom.ASTVisitor; 19 import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 20 import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration; 21 import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration; 22 import org.eclipse.jdt.core.dom.AnonymousClassDeclaration; 23 import org.eclipse.jdt.core.dom.ArrayAccess; 24 import org.eclipse.jdt.core.dom.ArrayCreation; 25 import org.eclipse.jdt.core.dom.ArrayInitializer; 26 import org.eclipse.jdt.core.dom.ArrayType; 27 import org.eclipse.jdt.core.dom.AssertStatement; 28 import org.eclipse.jdt.core.dom.Assignment; 29 import org.eclipse.jdt.core.dom.Block; 30 import org.eclipse.jdt.core.dom.BlockComment; 31 import org.eclipse.jdt.core.dom.BodyDeclaration; 32 import org.eclipse.jdt.core.dom.BooleanLiteral; 33 import org.eclipse.jdt.core.dom.BreakStatement; 34 import org.eclipse.jdt.core.dom.CastExpression; 35 import org.eclipse.jdt.core.dom.CatchClause; 36 import org.eclipse.jdt.core.dom.CharacterLiteral; 37 import org.eclipse.jdt.core.dom.ClassInstanceCreation; 38 import org.eclipse.jdt.core.dom.CompilationUnit; 39 import org.eclipse.jdt.core.dom.ConditionalExpression; 40 import org.eclipse.jdt.core.dom.ConstructorInvocation; 41 import org.eclipse.jdt.core.dom.ContinueStatement; 42 import org.eclipse.jdt.core.dom.DoStatement; 43 import org.eclipse.jdt.core.dom.EmptyStatement; 44 import org.eclipse.jdt.core.dom.EnhancedForStatement; 45 import org.eclipse.jdt.core.dom.EnumConstantDeclaration; 46 import org.eclipse.jdt.core.dom.EnumDeclaration; 47 import org.eclipse.jdt.core.dom.Expression; 48 import org.eclipse.jdt.core.dom.ExpressionStatement; 49 import org.eclipse.jdt.core.dom.FieldAccess; 50 import org.eclipse.jdt.core.dom.FieldDeclaration; 51 import org.eclipse.jdt.core.dom.ForStatement; 52 import org.eclipse.jdt.core.dom.IBinding; 53 import org.eclipse.jdt.core.dom.IVariableBinding; 54 import org.eclipse.jdt.core.dom.IfStatement; 55 import org.eclipse.jdt.core.dom.ImportDeclaration; 56 import org.eclipse.jdt.core.dom.InfixExpression; 57 import org.eclipse.jdt.core.dom.Initializer; 58 import org.eclipse.jdt.core.dom.InstanceofExpression; 59 import org.eclipse.jdt.core.dom.Javadoc; 60 import org.eclipse.jdt.core.dom.LabeledStatement; 61 import org.eclipse.jdt.core.dom.LineComment; 62 import org.eclipse.jdt.core.dom.MarkerAnnotation; 63 import org.eclipse.jdt.core.dom.MemberRef; 64 import org.eclipse.jdt.core.dom.MemberValuePair; 65 import org.eclipse.jdt.core.dom.MethodDeclaration; 66 import org.eclipse.jdt.core.dom.MethodInvocation; 67 import org.eclipse.jdt.core.dom.MethodRef; 68 import org.eclipse.jdt.core.dom.MethodRefParameter; 69 import org.eclipse.jdt.core.dom.Modifier; 70 import org.eclipse.jdt.core.dom.Name; 71 import org.eclipse.jdt.core.dom.NormalAnnotation; 72 import org.eclipse.jdt.core.dom.NullLiteral; 73 import org.eclipse.jdt.core.dom.NumberLiteral; 74 import org.eclipse.jdt.core.dom.PackageDeclaration; 75 import org.eclipse.jdt.core.dom.ParameterizedType; 76 import org.eclipse.jdt.core.dom.ParenthesizedExpression; 77 import org.eclipse.jdt.core.dom.PostfixExpression; 78 import org.eclipse.jdt.core.dom.PrefixExpression; 79 import org.eclipse.jdt.core.dom.PrimitiveType; 80 import org.eclipse.jdt.core.dom.QualifiedName; 81 import org.eclipse.jdt.core.dom.QualifiedType; 82 import org.eclipse.jdt.core.dom.ReturnStatement; 83 import org.eclipse.jdt.core.dom.SimpleName; 84 import org.eclipse.jdt.core.dom.SimpleType; 85 import org.eclipse.jdt.core.dom.SingleMemberAnnotation; 86 import org.eclipse.jdt.core.dom.SingleVariableDeclaration; 87 import org.eclipse.jdt.core.dom.StringLiteral; 88 import org.eclipse.jdt.core.dom.SuperConstructorInvocation; 89 import org.eclipse.jdt.core.dom.SuperFieldAccess; 90 import org.eclipse.jdt.core.dom.SuperMethodInvocation; 91 import org.eclipse.jdt.core.dom.SwitchCase; 92 import org.eclipse.jdt.core.dom.SwitchStatement; 93 import org.eclipse.jdt.core.dom.SynchronizedStatement; 94 import org.eclipse.jdt.core.dom.TagElement; 95 import org.eclipse.jdt.core.dom.TextElement; 96 import org.eclipse.jdt.core.dom.ThisExpression; 97 import org.eclipse.jdt.core.dom.ThrowStatement; 98 import org.eclipse.jdt.core.dom.TryStatement; 99 import org.eclipse.jdt.core.dom.TypeDeclaration; 100 import org.eclipse.jdt.core.dom.TypeDeclarationStatement; 101 import org.eclipse.jdt.core.dom.TypeLiteral; 102 import org.eclipse.jdt.core.dom.TypeParameter; 103 import org.eclipse.jdt.core.dom.VariableDeclarationExpression; 104 import org.eclipse.jdt.core.dom.VariableDeclarationFragment; 105 import org.eclipse.jdt.core.dom.VariableDeclarationStatement; 106 import org.eclipse.jdt.core.dom.WhileStatement; 107 import org.eclipse.jdt.core.dom.WildcardType; 108 import org.eclipse.jdt.core.dom.PrefixExpression.Operator; 109 110 114 public class ValidBreakpointLocationLocator extends ASTVisitor { 115 116 public static final int LOCATION_NOT_FOUND= 0; 117 public static final int LOCATION_LINE= 1; 118 public static final int LOCATION_METHOD= 2; 119 public static final int LOCATION_FIELD= 3; 120 121 private CompilationUnit fCompilationUnit; 122 private int fLineNumber; 123 private boolean fBindingsResolved; 124 private boolean fNeedBindings = false; 125 private boolean fBestMatch; 126 127 private int fLocationType; 128 private boolean fLocationFound; 129 private String fTypeName; 130 private int fLineLocation; 131 private int fMemberOffset; 132 private List fLabels; 133 134 139 public ValidBreakpointLocationLocator(CompilationUnit compilationUnit, int lineNumber, boolean bindingsResolved, boolean bestMatch) { 140 fCompilationUnit= compilationUnit; 141 fLineNumber= lineNumber; 142 fBindingsResolved= bindingsResolved; 143 fBestMatch= bestMatch; 144 fLocationFound= false; 145 } 146 147 155 public boolean isBindingsRequired() { 156 return fNeedBindings; 157 } 158 159 163 public int getLocationType() { 164 return fLocationType; 165 } 166 167 170 public String getFullyQualifiedTypeName() { 171 return fTypeName; 172 } 173 174 177 public int getLineLocation() { 178 if (fLocationType == LOCATION_LINE) { 179 return fLineLocation; 180 } 181 return -1; 182 } 183 184 188 public int getMemberOffset() { 189 return fMemberOffset; 190 } 191 192 196 static protected String computeTypeName(ASTNode node) { 197 String typeName = null; 198 while (!(node instanceof CompilationUnit)) { 199 if (node instanceof AbstractTypeDeclaration) { 200 String identifier= ((AbstractTypeDeclaration)node).getName().getIdentifier(); 201 if (typeName == null) { 202 typeName= identifier; 203 } else { 204 typeName= identifier + "$" + typeName; } 206 } else { 207 typeName= null; 208 } 209 node= node.getParent(); 210 } 211 PackageDeclaration packageDecl= ((CompilationUnit)node).getPackage(); 212 String packageIdentifier= ""; if (packageDecl != null) { 214 Name packageName= packageDecl.getName(); 215 while (packageName.isQualifiedName()) { 216 QualifiedName qualifiedName= (QualifiedName) packageName; 217 packageIdentifier= qualifiedName.getName().getIdentifier() + "." + packageIdentifier; packageName= qualifiedName.getQualifier(); 219 } 220 packageIdentifier= ((SimpleName)packageName).getIdentifier() + "." + packageIdentifier; } 222 return packageIdentifier + typeName; 223 } 224 225 232 private boolean visit(ASTNode node, boolean isCode) { 233 if (fLocationFound) { 236 return false; 237 } 238 int startPosition= node.getStartPosition(); 239 int endLine= lineNumber(startPosition + node.getLength() - 1); 240 if (endLine < fLineNumber) { 243 return false; 244 } 245 int startLine = lineNumber(startPosition); 249 if (isCode && (fLineNumber <= startLine)) { 250 fLineLocation= startLine; 251 fLocationFound= true; 252 fLocationType= LOCATION_LINE; 253 fTypeName= computeTypeName(node); 254 return false; 255 } 256 return true; 257 } 258 259 private boolean isReplacedByConstantValue(Expression node) { 260 switch (node.getNodeType()) { 261 case ASTNode.BOOLEAN_LITERAL: 263 case ASTNode.CHARACTER_LITERAL: 264 case ASTNode.NUMBER_LITERAL: 265 case ASTNode.STRING_LITERAL: 266 return true; 267 case ASTNode.SIMPLE_NAME: 268 case ASTNode.QUALIFIED_NAME: 269 return isReplacedByConstantValue((Name)node); 270 case ASTNode.FIELD_ACCESS: 271 return isReplacedByConstantValue((FieldAccess)node); 272 case ASTNode.SUPER_FIELD_ACCESS: 273 return isReplacedByConstantValue((SuperFieldAccess)node); 274 case ASTNode.INFIX_EXPRESSION: 275 return isReplacedByConstantValue((InfixExpression)node); 276 case ASTNode.PREFIX_EXPRESSION: 277 return isReplacedByConstantValue((PrefixExpression)node); 278 case ASTNode.CAST_EXPRESSION: 279 return isReplacedByConstantValue(((CastExpression)node).getExpression()); 280 default: 281 return false; 282 } 283 } 284 285 private boolean isReplacedByConstantValue(InfixExpression node) { 286 if (!(isReplacedByConstantValue(node.getLeftOperand()) && isReplacedByConstantValue(node.getRightOperand()))) { 288 return false; 289 } 290 if (node.hasExtendedOperands()) { 291 for (Iterator iter = node.extendedOperands().iterator(); iter.hasNext(); ) { 292 if (!isReplacedByConstantValue((Expression) iter.next())) { 293 return false; 294 } 295 } 296 } 297 return true; 298 } 299 300 private boolean isReplacedByConstantValue(PrefixExpression node) { 301 Operator operator = node.getOperator(); 304 if (operator != PrefixExpression.Operator.INCREMENT && operator != PrefixExpression.Operator.DECREMENT) { 305 return isReplacedByConstantValue(node.getOperand()); 306 } 307 return false; 308 } 309 310 private boolean isReplacedByConstantValue(Name node) { 311 if (!fBindingsResolved) { 312 fNeedBindings = true; 313 return false; 314 } 315 IBinding binding= node.resolveBinding(); 317 if (binding != null && binding.getKind() == IBinding.VARIABLE) { 318 return ((IVariableBinding)binding).getConstantValue() != null; 319 } 320 return false; 321 } 322 323 private boolean isReplacedByConstantValue(FieldAccess node) { 324 if (!fBindingsResolved) { 325 fNeedBindings = true; 326 return false; 327 } 328 Expression expression= node.getExpression(); 330 IVariableBinding binding= node.resolveFieldBinding(); 331 if (binding != null && expression.getNodeType() == ASTNode.THIS_EXPRESSION) { 332 return binding.getConstantValue() != null; 333 } 334 return false; 335 } 336 337 private boolean isReplacedByConstantValue(SuperFieldAccess node) { 338 if (!fBindingsResolved) { 339 fNeedBindings = true; 340 return false; 341 } 342 IVariableBinding binding= node.resolveFieldBinding(); 344 if (binding != null) { 345 return binding.getConstantValue() != null; 346 } 347 return false; 348 } 349 350 353 public boolean visit(AnnotationTypeDeclaration node) { 354 return false; 355 } 356 357 360 public boolean visit(AnnotationTypeMemberDeclaration node) { 361 return false; 362 } 363 364 367 public boolean visit(AnonymousClassDeclaration node) { 368 return visit(node, false); 369 } 370 371 374 public boolean visit(ArrayAccess node) { 375 return visit(node, true); 376 } 377 378 381 public boolean visit(ArrayCreation node) { 382 return visit(node, node.getInitializer() == null); 383 } 384 385 388 public boolean visit(ArrayInitializer node) { 389 return visit(node, true); 390 } 391 392 395 public boolean visit(ArrayType node) { 396 return false; 397 } 398 399 402 public boolean visit(AssertStatement node) { 403 return visit(node, true); 404 } 405 406 409 public boolean visit(Assignment node) { 410 if (visit(node, false)) { 411 Expression leftHandSide= node.getLeftHandSide(); 417 if (leftHandSide instanceof Name) { 418 int startLine = lineNumber(node.getStartPosition()); 419 if (fLineNumber < startLine) { 420 if (fBindingsResolved) { 421 IVariableBinding binding= (IVariableBinding)((Name)leftHandSide).resolveBinding(); 422 if (binding != null && (!binding.isField() || Modifier.isStatic(binding.getModifiers()))) { 423 node.getRightHandSide().accept(this); 424 } 425 } else { 426 fNeedBindings = true; 427 } 428 } 429 } 430 return true; 431 } 432 return false; 433 } 434 435 438 public boolean visit(Block node) { 439 if (visit(node, false)) { 440 if (node.statements().isEmpty() && node.getParent().getNodeType() == ASTNode.METHOD_DECLARATION) { 441 fLineLocation= lineNumber(node.getStartPosition() + node.getLength() - 1); 443 fLocationFound= true; 444 fLocationType= LOCATION_LINE; 445 fTypeName= computeTypeName(node); 446 return false; 447 } 448 return true; 449 } 450 return false; 451 } 452 453 456 public boolean visit(BlockComment node) { 457 return false; 458 } 459 460 463 public boolean visit(BooleanLiteral node) { 464 return visit(node, true); 465 } 466 467 470 public boolean visit(BreakStatement node) { 471 return visit(node, true); 472 } 473 474 477 public boolean visit(CastExpression node) { 478 return visit(node, true); 479 } 480 481 484 public boolean visit(CatchClause node) { 485 return visit(node, false); 486 } 487 488 491 public boolean visit(CharacterLiteral node) { 492 return visit(node, true); 493 } 494 495 498 public boolean visit(ClassInstanceCreation node) { 499 return visit(node, true); 500 } 501 502 505 public boolean visit(CompilationUnit node) { 506 return visit(node, false); 507 } 508 509 512 public boolean visit(ConditionalExpression node) { 513 return visit(node, true); 514 } 515 516 519 public boolean visit(ConstructorInvocation node) { 520 return visit(node, true); 521 } 522 523 526 public boolean visit(ContinueStatement node) { 527 return visit(node, true); 528 } 529 530 533 public boolean visit(DoStatement node) { 534 return visit(node, false); 535 } 536 537 540 public boolean visit(EmptyStatement node) { 541 return false; 542 } 543 544 547 public boolean visit(EnhancedForStatement node) { 548 if (visit(node, false)) { 549 node.getExpression().accept(this); 550 node.getBody().accept(this); 551 } 552 return false; 553 } 554 555 558 public boolean visit(EnumConstantDeclaration node) { 559 if (visit(node, false)) { 560 List arguments= node.arguments(); 561 for (Iterator iter= arguments.iterator(); iter.hasNext();) { 562 ((Expression)iter.next()).accept(this); 563 } 564 AnonymousClassDeclaration decl= node.getAnonymousClassDeclaration(); 565 if (decl != null) { 566 decl.accept(this); 567 } 568 } 569 return false; 570 } 571 572 575 public boolean visit(EnumDeclaration node) { 576 if (visit(node, false)) { 577 List enumConstants= node.enumConstants(); 578 for (Iterator iter = enumConstants.iterator(); iter.hasNext();) { 579 ((EnumConstantDeclaration) iter.next()).accept(this); 580 } 581 List bodyDeclaration= node.bodyDeclarations(); 582 for (Iterator iter= bodyDeclaration.iterator(); iter.hasNext();) { 583 ((BodyDeclaration)iter.next()).accept(this); 584 } 585 } 586 return false; 587 } 588 589 592 public boolean visit(ExpressionStatement node) { 593 return visit(node, false); 594 } 595 596 599 public boolean visit(FieldAccess node) { 600 return visit(node, false); 601 } 602 603 606 public boolean visit(FieldDeclaration node) { 607 if (visit(node, false)) { 608 if (fBestMatch) { 609 List fragments = node.fragments(); 611 if (fragments.size() == 1) { 612 int offset= ((VariableDeclarationFragment)fragments.get(0)).getName().getStartPosition(); 613 if (lineNumber(offset) == fLineNumber) { 615 fMemberOffset= offset; 616 fLocationType= LOCATION_FIELD; 617 fLocationFound= true; 618 return false; 619 } 620 } 621 } 622 List fragments= node.fragments(); 624 for (Iterator iter= fragments.iterator(); iter.hasNext();) { 625 ((VariableDeclarationFragment)iter.next()).accept(this); 626 } 627 } 628 return false; 629 } 630 631 634 public boolean visit(ForStatement node) { 635 return visit(node, node.initializers().isEmpty() && node.getExpression() == null && node.updaters().isEmpty()); 637 } 638 639 642 public boolean visit(IfStatement node) { 643 return visit(node, false); 644 } 645 646 649 public boolean visit(ImportDeclaration node) { 650 return false; 651 } 652 653 656 public boolean visit(InfixExpression node) { 657 if (visit(node, false)) { 664 Expression leftOperand= node.getLeftOperand(); 665 Expression firstConstant= null; 666 if (visit(leftOperand, false)) { 667 leftOperand.accept(this); 668 return false; 669 } 670 if (isReplacedByConstantValue(leftOperand)) { 671 firstConstant= leftOperand; 672 } 673 Expression rightOperand= node.getRightOperand(); 674 if (visit(rightOperand, false)) { 675 if (firstConstant == null || !isReplacedByConstantValue(rightOperand)) { 676 rightOperand.accept(this); 677 return false; 678 } 679 } else { 680 if (isReplacedByConstantValue(rightOperand)) { 681 if (firstConstant == null) { 682 firstConstant= rightOperand; 683 } 684 } else { 685 firstConstant= null; 686 } 687 List extendedOperands= node.extendedOperands(); 688 for (Iterator iter= extendedOperands.iterator(); iter.hasNext();) { 689 Expression operand= (Expression) iter.next(); 690 if (visit(operand, false)) { 691 if (firstConstant == null || !isReplacedByConstantValue(operand)) { 692 operand.accept(this); 693 return false; 694 } 695 break; 696 } 697 if (isReplacedByConstantValue(operand)) { 698 if (firstConstant == null) { 699 firstConstant= operand; 700 } 701 } else { 702 firstConstant= null; 703 } 704 705 } 706 } 707 fLineLocation= lineNumber(firstConstant.getStartPosition()); 708 fLocationFound= true; 709 fLocationType= LOCATION_LINE; 710 fTypeName= computeTypeName(firstConstant); 711 } 712 return false; 713 } 714 715 718 public boolean visit(Initializer node) { 719 return visit(node, false); 720 } 721 722 725 public boolean visit(InstanceofExpression node) { 726 return visit(node, true); 727 } 728 729 732 public boolean visit(Javadoc node) { 733 return false; 734 } 735 736 739 public boolean visit(LabeledStatement node) { 740 nestLabel(node.getLabel().getFullyQualifiedName()); 741 return visit(node, false); 742 } 743 744 747 public void endVisit(LabeledStatement node) { 748 popLabel(); 749 super.endVisit(node); 750 } 751 752 private String getLabel() { 753 if (fLabels == null || fLabels.isEmpty()) { 754 return null; 755 } 756 return (String ) fLabels.get(fLabels.size() - 1); 757 } 758 759 private void nestLabel(String label) { 760 if (fLabels == null) { 761 fLabels = new ArrayList (); 762 } 763 fLabels.add(label); 764 } 765 766 private void popLabel() { 767 if (fLabels == null || fLabels.isEmpty()) { 768 return; 769 } 770 fLabels.remove(fLabels.size() - 1); 771 } 772 773 776 public boolean visit(LineComment node) { 777 return false; 778 } 779 780 783 public boolean visit(MarkerAnnotation node) { 784 return false; 785 } 786 787 790 public boolean visit(MemberRef node) { 791 return false; 792 } 793 794 797 public boolean visit(MemberValuePair node) { 798 return false; 799 } 800 801 804 public boolean visit(MethodDeclaration node) { 805 if (visit(node, false)) { 806 if (fBestMatch) { 807 int nameOffset= node.getName().getStartPosition(); 809 if (lineNumber(nameOffset) == fLineNumber) { 810 fMemberOffset= nameOffset; 811 fLocationType= LOCATION_METHOD; 812 fLocationFound= true; 813 return false; 814 } 815 } 816 Block body = node.getBody(); 818 if (body != null) { body.accept(this); 820 } 821 } 822 return false; 823 } 824 825 828 public boolean visit(MethodInvocation node) { 829 return visit(node, true); 830 } 831 832 835 public boolean visit(MethodRef node) { 836 return false; 837 } 838 839 842 public boolean visit(MethodRefParameter node) { 843 return false; 844 } 845 846 849 public boolean visit(Modifier node) { 850 return false; 851 } 852 853 856 public boolean visit(NormalAnnotation node) { 857 return false; 858 } 859 860 863 public boolean visit(NullLiteral node) { 864 return visit(node, true); 865 } 866 867 870 public boolean visit(NumberLiteral node) { 871 return visit(node, true); 872 } 873 874 877 public boolean visit(PackageDeclaration node) { 878 return false; 879 } 880 881 884 public boolean visit(ParameterizedType node) { 885 return false; 886 } 887 888 891 public boolean visit(ParenthesizedExpression node) { 892 return visit(node, false); 893 } 894 895 898 public boolean visit(PostfixExpression node) { 899 return visit(node, true); 900 } 901 902 905 public boolean visit(PrefixExpression node) { 906 if (visit(node, false)) { 907 if (isReplacedByConstantValue(node)) { 908 fLineLocation= lineNumber(node.getStartPosition()); 909 fLocationFound= true; 910 fLocationType= LOCATION_LINE; 911 fTypeName= computeTypeName(node); 912 return false; 913 } 914 return true; 915 } 916 return false; 917 } 918 919 922 public boolean visit(PrimitiveType node) { 923 return false; 924 } 925 926 929 public boolean visit(QualifiedName node) { 930 visit(node, true); 931 return false; 932 } 933 934 937 public boolean visit(QualifiedType node) { 938 return false; 939 } 940 941 944 public boolean visit(ReturnStatement node) { 945 return visit(node, true); 946 } 947 948 951 public boolean visit(SimpleName node) { 952 return visit(node, !node.getFullyQualifiedName().equals(getLabel())); 954 } 955 956 959 public boolean visit(SimpleType node) { 960 return false; 961 } 962 963 966 public boolean visit(SingleMemberAnnotation node) { 967 return false; 968 } 969 970 973 public boolean visit(SingleVariableDeclaration node) { 974 return visit(node, false); 975 } 976 977 980 public boolean visit(StringLiteral node) { 981 return visit(node, true); 982 } 983 984 987 public boolean visit(SuperConstructorInvocation node) { 988 return visit(node, true); 989 } 990 991 994 public boolean visit(SuperFieldAccess node) { 995 return visit(node, true); 996 } 997 998 1001 public boolean visit(SuperMethodInvocation node) { 1002 return visit(node, true); 1003 } 1004 1005 1008 public boolean visit(SwitchCase node) { 1009 return false; 1010 } 1011 1012 1015 public boolean visit(SwitchStatement node) { 1016 return visit(node, false); 1017 } 1018 1019 1022 public boolean visit(SynchronizedStatement node) { 1023 return visit(node, false); 1024 } 1025 1026 1029 public boolean visit(TagElement node) { 1030 return false; 1031 } 1032 1033 1036 public boolean visit(TextElement node) { 1037 return false; 1038 } 1039 1040 1043 public boolean visit(ThisExpression node) { 1044 return visit(node, true); 1045 } 1046 1047 1050 public boolean visit(ThrowStatement node) { 1051 return visit(node, true); 1052 } 1053 1054 1057 public boolean visit(TryStatement node) { 1058 return visit(node, false); 1059 } 1060 1061 1064 public boolean visit(TypeDeclaration node) { 1065 if (visit(node, false)) { 1066 List bodyDeclaration= node.bodyDeclarations(); 1068 for (Iterator iter= bodyDeclaration.iterator(); iter.hasNext();) { 1069 ((BodyDeclaration)iter.next()).accept(this); 1070 } 1071 } 1072 return false; 1073 } 1074 1075 1078 public boolean visit(TypeDeclarationStatement node) { 1079 return visit(node, false); 1080 } 1081 1082 1085 public boolean visit(TypeParameter node) { 1086 return false; 1087 } 1088 1089 1092 public boolean visit(TypeLiteral node) { 1093 return false; 1094 } 1095 1096 1099 public boolean visit(VariableDeclarationExpression node) { 1100 return visit(node, false); 1101 } 1102 1103 1106 public boolean visit(VariableDeclarationFragment node) { 1107 Expression initializer = node.getInitializer(); 1108 if (visit(node, false) && initializer != null) { 1109 int startLine = lineNumber(node.getName().getStartPosition()); 1110 1111 if (fLineNumber == startLine) { 1112 fLineLocation= startLine; 1113 fLocationFound= true; 1114 fLocationType= LOCATION_LINE; 1115 fTypeName= computeTypeName(node); 1116 return false; 1117 } 1118 initializer.accept(this); 1119 } 1120 return false; 1121 } 1122 1123 private int lineNumber(int offset) { 1124 int lineNumber = fCompilationUnit.getLineNumber(offset); 1125 return lineNumber < 1 ? 1 : lineNumber; 1126 } 1127 1128 1129 1132 public boolean visit(WildcardType node) { 1133 return false; 1134 } 1135 1136 1139 public boolean visit(VariableDeclarationStatement node) { 1140 return visit(node, false); 1141 } 1142 1143 1146 public boolean visit(WhileStatement node) { 1147 return visit(node, false); 1148 } 1149 1150} 1151 | Popular Tags |