1 19 package org.netbeans.modules.ruby; 20 21 import java.io.IOException ; 22 import java.util.ArrayList ; 23 import java.util.Collections ; 24 import java.util.HashSet ; 25 import java.util.Iterator ; 26 import java.util.LinkedList ; 27 import java.util.List ; 28 import java.util.Set ; 29 import javax.swing.text.BadLocationException ; 30 import javax.swing.text.Document ; 31 import org.jruby.ast.AliasNode; 32 import org.jruby.ast.ArgsNode; 33 import org.jruby.ast.ArgumentNode; 34 import org.jruby.ast.AssignableNode; 35 import org.jruby.ast.BlockNode; 36 import org.jruby.ast.CallNode; 37 import org.jruby.ast.ClassNode; 38 import org.jruby.ast.Colon2Node; 39 import org.jruby.ast.ConstNode; 40 import org.jruby.ast.ConstNode; 41 import org.jruby.ast.DefnNode; 42 import org.jruby.ast.DefsNode; 43 import org.jruby.ast.FCallNode; 44 import org.jruby.ast.IScopingNode; 45 import org.jruby.ast.IScopingNode; 46 import org.jruby.ast.IterNode; 47 import org.jruby.ast.ListNode; 48 import org.jruby.ast.LocalAsgnNode; 49 import org.jruby.ast.ModuleNode; 50 import org.jruby.ast.NewlineNode; 51 import org.jruby.ast.NewlineNode; 52 import org.jruby.ast.Node; 53 import org.jruby.ast.StrNode; 54 import org.jruby.ast.SymbolNode; 55 import org.jruby.ast.VCallNode; 56 import org.jruby.ast.types.INameNode; 57 import org.jruby.lexer.yacc.ISourcePosition; 58 import org.jruby.util.ByteList; 59 import org.netbeans.api.gsf.CompilationInfo; 60 import org.netbeans.api.gsf.Modifier; 61 import org.netbeans.api.gsf.OffsetRange; 62 import org.netbeans.api.gsf.ParserFile; 63 import org.netbeans.api.gsf.ParserResult; 64 import org.netbeans.api.gsf.SourceFileReader; 65 import org.netbeans.editor.BaseDocument; 66 import org.netbeans.editor.Utilities; 67 import org.netbeans.modules.ruby.elements.IndexedElement; 68 import org.netbeans.spi.gsf.DefaultParseListener; 69 import org.openide.cookies.EditorCookie; 70 import org.openide.filesystems.FileObject; 71 import org.openide.loaders.DataObject; 72 import org.openide.util.Exceptions; 73 74 75 82 public class AstUtilities { 83 87 private static final boolean INCLUDE_DEFS_PREFIX = false; 88 89 90 private AstUtilities() { 91 } 92 93 94 public static BaseDocument getBaseDocument(FileObject fileObject, boolean forceOpen) { 95 DataObject dobj; 96 97 try { 98 dobj = DataObject.find(fileObject); 99 100 EditorCookie ec = dobj.getCookie(EditorCookie.class); 101 102 if (ec == null) { 103 throw new IOException ("Can't open " + fileObject.getNameExt()); 104 } 105 106 Document document; 107 108 if (forceOpen) { 109 document = ec.openDocument(); 110 } else { 111 document = ec.getDocument(); 112 } 113 114 if (document instanceof BaseDocument) { 115 return ((BaseDocument)document); 116 } 117 } catch (IOException ioe) { 118 Exceptions.printStackTrace(ioe); 119 } 120 121 return null; 122 } 123 124 128 public static List <String > gatherDocumentation(BaseDocument baseDoc, Node node) { 129 LinkedList <String > comments = new LinkedList <String >(); 130 int elementBegin = node.getPosition().getStartOffset(); 131 132 try { 133 int offset = Utilities.getRowStart(baseDoc, elementBegin); 136 offset--; 137 138 while (offset >= 0) { 140 offset = Utilities.getRowStart(baseDoc, offset); 142 143 if (!Utilities.isRowEmpty(baseDoc, offset) && 144 !Utilities.isRowWhite(baseDoc, offset)) { 145 break; 146 } 147 148 offset--; 149 } 150 151 if (offset < 0) { 152 return null; 153 } 154 155 while (offset >= 0) { 156 offset = Utilities.getRowStart(baseDoc, offset); 158 159 if (Utilities.isRowEmpty(baseDoc, offset) || Utilities.isRowWhite(baseDoc, offset)) { 160 break; 162 } 163 164 int lineBegin = Utilities.getRowFirstNonWhite(baseDoc, offset); 166 int lineEnd = Utilities.getRowEnd(baseDoc, offset); 167 String line = baseDoc.getText(lineBegin, lineEnd - lineBegin); 168 169 if (line.startsWith("#")) { 170 comments.addFirst(line); 171 } else { 172 break; 174 } 175 176 offset--; 178 } 179 } catch (BadLocationException ble) { 180 Exceptions.printStackTrace(ble); 181 } 182 183 return comments; 184 } 185 186 public static Node getForeignNode(final IndexedElement o) { 187 ParserFile file = o.getFile(); 188 189 if (file == null) { 190 return null; 191 } 192 193 List <ParserFile> files = Collections.singletonList(file); 194 SourceFileReader reader = 195 new SourceFileReader() { 196 public CharSequence read(ParserFile file) 197 throws IOException { 198 Document doc = o.getDocument(); 199 200 try { 201 return doc.getText(0, doc.getLength()); 202 } catch (BadLocationException ble) { 203 IOException ioe = new IOException (); 204 ioe.initCause(ble); 205 throw ioe; 206 } 207 } 208 209 public int getCaretOffset(ParserFile fileObject) { 210 return -1; 211 } 212 }; 213 214 DefaultParseListener listener = new DefaultParseListener(); 215 new RubyParser().parseFiles(files, listener, reader); 216 217 ParserResult result = listener.getParserResult(); 218 219 if (result == null) { 220 return null; 221 } 222 223 Node root = AstUtilities.getRoot(result); 224 225 if (root == null) { 226 return null; 227 } 228 229 String signature = o.getSignature(); 230 231 if (signature == null) { 232 return null; 233 } 234 235 Node node = AstUtilities.findBySignature(root, signature); 236 237 if (node == null && "new".equals(o.getName())) { 239 signature = signature.replaceFirst("new", "initialize"); 240 node = AstUtilities.findBySignature(root, signature); 241 } 242 243 return node; 244 } 245 246 250 public static Set <String > getRequires(Node root) { 251 Set <String > requires = new HashSet <String >(); 252 addRequires(root, requires); 253 254 return requires; 255 } 256 257 private static void addRequires(Node node, Set <String > requires) { 258 if (node instanceof FCallNode) { 259 String name = ((INameNode)node).getName(); 261 262 if (name.equals("require")) { 264 Node argsNode = ((FCallNode)node).getArgsNode(); 265 266 if (argsNode instanceof ListNode) { 267 ListNode args = (ListNode)argsNode; 268 269 if (args.size() > 0) { 270 Node n = args.get(0); 271 272 if (n instanceof StrNode) { 273 ByteList require = ((StrNode)n).getValue(); 274 275 if ((require != null) && (require.length() > 0)) { 276 requires.add(require.toString()); 277 } 278 } 279 } 280 } 281 } 282 } else if (node instanceof ModuleNode || node instanceof ClassNode || 283 node instanceof DefnNode || node instanceof DefsNode) { 284 return; 286 } 287 288 @SuppressWarnings ("unchecked") 289 List <Node> list = node.childNodes(); 290 291 for (Node child : list) { 292 addRequires(child, requires); 293 } 294 } 295 296 public static Node findLocalScope(Node node, AstPath path) { 297 Node method = findMethod(path); 298 299 if (method == null) { 300 if (path.root() != null) { 301 return path.root(); 302 } 303 304 method = findBlock(path); 305 } 306 307 if (method == null) { 308 method = path.leafParent(); 309 310 if (method instanceof NewlineNode) { 311 method = path.leafGrandParent(); 312 } 313 314 if (method == null) { 315 method = node; 316 } 317 } 318 319 return method; 320 } 321 322 public static Node findDynamicScope(Node node, AstPath path) { 323 Node block = findBlock(path); 324 325 if (block == null) { 326 block = path.leafParent(); 328 329 if (block == null) { 330 block = node; 331 } 332 } 333 334 return block; 335 } 336 337 public static Node findBlock(AstPath path) { 338 for (Node curr : path) { 340 if (curr instanceof BlockNode || curr instanceof IterNode) { 341 return curr; 342 } 343 } 344 345 return null; 346 } 347 348 public static Node findMethod(AstPath path) { 349 for (Node curr : path) { 351 if (curr instanceof DefnNode || curr instanceof DefsNode) { 352 return curr; 353 } 354 } 355 356 return null; 357 } 358 359 public static ClassNode findClass(Node node, AstPath path) { 362 for (Node curr : path) { 364 if (curr instanceof ClassNode) { 365 return (ClassNode)curr; 366 } 367 } 368 369 return null; 370 } 371 372 public static String getCallName(Node node) { 373 assert node instanceof FCallNode || node instanceof VCallNode || node instanceof CallNode; 374 375 if (node instanceof INameNode) { 376 return ((INameNode)node).getName(); 377 } 378 assert false : node; 379 380 return null; 381 } 382 383 public static String getDefName(Node node) { 384 if (node instanceof DefnNode) { 385 return ((DefnNode)node).getName(); 386 } else if (node instanceof DefsNode) { 387 return ((DefsNode)node).getName(); 388 } 389 assert false : node; 390 391 return null; 392 } 393 394 395 @SuppressWarnings ("unchecked") 396 public static List <String > getDefArgs(Node node) { 397 assert node instanceof DefnNode || node instanceof DefsNode; 399 400 List <Node> nodes = (List <Node>)node.childNodes(); 401 402 for (Node c : nodes) { 403 if (c instanceof ArgsNode) { 404 ArgsNode an = (ArgsNode)c; 405 406 List <Node> args = (List <Node>)an.childNodes(); 407 List <String > parameters = new ArrayList <String >(); 408 409 for (Node arg : args) { 410 if (arg instanceof ListNode) { 411 List <Node> args2 = (List <Node>)arg.childNodes(); 412 413 for (Node arg2 : args2) { 414 if (arg2 instanceof ArgumentNode) { 415 String name = ((ArgumentNode)arg2).getName(); 416 parameters.add(name); 417 } else if (arg2 instanceof LocalAsgnNode) { 418 String name = ((LocalAsgnNode)arg2).getName(); 419 parameters.add(name); 420 } 421 } 422 } 423 } 424 425 return parameters; 426 } 427 } 428 429 return null; 430 } 431 432 public static String getDefSignature(Node node) { 434 assert node instanceof DefnNode || node instanceof DefsNode : node; 435 436 StringBuilder sb = new StringBuilder (); 437 sb.append(getDefName(node)); 438 439 List <String > args = getDefArgs(node); 440 441 if ((args != null) && (args.size() > 0)) { 442 sb.append('('); 443 444 Iterator <String > it = args.iterator(); 445 sb.append(it.next()); 446 447 while (it.hasNext()) { 448 sb.append(','); 449 sb.append(it.next()); 450 } 451 452 sb.append(')'); 453 } 454 455 return sb.toString(); 456 } 457 458 461 public static boolean isCallFor(Node call, Arity callArity, Node method) { 462 assert call instanceof CallNode || call instanceof VCallNode || call instanceof FCallNode; 463 assert method instanceof DefsNode || method instanceof DefnNode; 464 465 return getDefName(method).equals(getCallName(call)) && 467 Arity.matches(callArity, Arity.getDefArity(method)); 468 } 469 470 472 public static Node findBySignature(Node root, String signature) { 473 String name = getNextSigComponent(signature); 476 signature = signature.substring(name.length()); 477 478 return findBySignature(root, signature, name); 479 } 480 481 private static String getNextSigComponent(String signature) { 485 StringBuilder sb = new StringBuilder (); 486 int i = 0; 487 int n = signature.length(); 488 489 for (; i < n; i++) { 491 char c = signature.charAt(i); 492 493 if ((c == '#') || (c == ':') || (c == '(')) { 494 continue; 495 } 496 497 break; 498 } 499 500 for (; i < n; i++) { 502 char c = signature.charAt(i); 503 504 if ((c == '#') || (c == ':') || (c == '(')) { 505 break; 506 } 507 508 sb.append(c); 509 } 510 511 return sb.toString(); 512 } 513 514 private static Node findBySignature(Node node, String signature, String name) { 515 boolean lookingForMethod = (Character.isLowerCase(name.charAt(0))); 516 517 if (lookingForMethod) { 518 if ((node instanceof DefnNode || node instanceof DefsNode) && 519 name.equals(AstUtilities.getDefName(node))) { 520 List <String > parameters = getDefArgs(node); 523 524 if ((signature.length() == 0) && 525 ((parameters == null) || (parameters.size() == 0))) { 526 return node; 528 } else if (signature.length() != 0) { 529 assert signature.charAt(0) == '('; 530 531 String argList = signature.substring(1, signature.length() - 1); 532 String [] args = argList.split(","); 533 534 if (args.length == parameters.size()) { 535 boolean equal = true; 537 538 for (int i = 0; i < args.length; i++) { 539 if (!args[i].equals(parameters.get(i))) { 540 equal = false; 541 542 break; 543 } 544 } 545 546 if (equal) { 547 return node; 548 } 549 } 550 } 551 } 552 } else if ((node instanceof ModuleNode || node instanceof ClassNode) && 553 name.equals(AstUtilities.getClassOrModuleName(((IScopingNode)node)))) { 554 name = getNextSigComponent(signature); 555 556 if (name.length() == 0) { 557 return node; 559 } 560 561 int index = signature.indexOf(name); 562 assert index != -1; 563 signature = signature.substring(index + name.length()); 564 } 565 566 @SuppressWarnings ("unchecked") 567 List <Node> list = node.childNodes(); 568 569 for (Node child : list) { 570 Node match = findBySignature(child, signature, name); 571 572 if (match != null) { 573 return match; 574 } 575 } 576 577 return null; 578 } 579 580 583 public static OffsetRange getRange(Node node) { 584 ISourcePosition pos = node.getPosition(); 585 OffsetRange range = new OffsetRange(pos.getStartOffset(), pos.getEndOffset()); 586 587 return range; 588 } 589 590 593 public static OffsetRange getLValueRange(AssignableNode node) { 594 assert node instanceof INameNode; 595 assert node instanceof AssignableNode; 596 597 ISourcePosition pos = node.getPosition(); 598 OffsetRange range = 599 new OffsetRange(pos.getStartOffset(), 600 pos.getStartOffset() + ((INameNode)node).getName().length()); 601 602 return range; 603 } 604 605 608 public static OffsetRange getCallRange(Node node) { 609 ISourcePosition pos = node.getPosition(); 610 int start = pos.getStartOffset(); 611 int end = pos.getEndOffset(); 612 assert node instanceof VCallNode || node instanceof CallNode || node instanceof FCallNode; 613 assert node instanceof INameNode; 614 615 if (node instanceof CallNode) { 616 Node receiver = ((CallNode)node).getReceiverNode(); 619 620 if (receiver != null) { 621 start = receiver.getPosition().getEndOffset() + 1; } 623 } 624 625 if (node instanceof INameNode) { 626 end = start + ((INameNode)node).getName().length(); 627 } 628 629 return new OffsetRange(start, end); 630 } 631 632 @SuppressWarnings ("unchecked") 633 public static OffsetRange getFunctionNameRange(Node node) { 634 for (Node child : (List <Node>)node.childNodes()) { 635 if (child instanceof ArgumentNode) { 636 OffsetRange range = AstUtilities.getRange(child); 637 638 return range; 639 } 640 } 641 642 if (node instanceof DefsNode || node instanceof DefnNode) { 643 for (Node child : (List <Node>)node.childNodes()) { 644 if (child instanceof ConstNode) { 645 ISourcePosition pos = child.getPosition(); 646 int end = pos.getEndOffset(); 647 int start; 648 649 if (INCLUDE_DEFS_PREFIX) { 650 start = pos.getStartOffset(); 651 } else { 652 start = end + 1; 653 } 654 655 end = end + 1 + AstUtilities.getDefName(node).length(); 659 OffsetRange range = new OffsetRange(start, end); 660 661 return range; 662 } 663 } 664 } 665 666 return OffsetRange.NONE; 667 } 668 669 672 public static OffsetRange getAliasNewRange(AliasNode node) { 673 ISourcePosition pos = node.getPosition(); 681 682 int newStart = pos.getStartOffset() + 1; 685 686 return new OffsetRange(newStart, newStart + node.getNewName().length()); 687 } 688 689 692 public static OffsetRange getAliasOldRange(AliasNode node) { 693 ISourcePosition pos = node.getPosition(); 701 702 int oldStart = pos.getStartOffset() + 1 + node.getNewName().length() + 1; 706 return new OffsetRange(oldStart, oldStart + node.getOldName().length()); 707 } 708 709 public static String getClassOrModuleName(IScopingNode node) { 710 return ((INameNode)node.getCPath()).getName(); 711 } 712 713 public static List <ClassNode> getClasses(Node root) { 714 List <ClassNode> classes = new ArrayList <ClassNode>(); 734 addClasses(root, classes); 735 736 return classes; 737 } 738 739 private static void addClasses(Node node, List <ClassNode> classes) { 740 if (node instanceof ClassNode) { 741 classes.add((ClassNode)node); 742 } 743 744 @SuppressWarnings ("unchecked") 745 List <Node> list = node.childNodes(); 746 747 for (Node child : list) { 748 addClasses(child, classes); 749 } 750 } 751 752 private static void addAncestorParents(Node node, StringBuilder sb) { 753 if (node instanceof Colon2Node) { 754 Colon2Node c2n = (Colon2Node)node; 755 addAncestorParents(c2n.getLeftNode(), sb); 756 757 if ((sb.length() > 0) && (sb.charAt(sb.length() - 1) != ':')) { 758 sb.append("::"); 759 } 760 761 sb.append(c2n.getName()); 762 } else if (node instanceof INameNode) { 763 if ((sb.length() > 0) && (sb.charAt(sb.length() - 1) != ':')) { 764 sb.append("::"); 765 } 766 767 sb.append(((INameNode)node).getName()); 768 } 769 } 770 771 public static String getFqn(Colon2Node c2n) { 772 StringBuilder sb = new StringBuilder (); 773 774 addAncestorParents(c2n, sb); 775 776 return sb.toString(); 777 } 778 779 public static String getSuperclass(ClassNode clz) { 780 StringBuilder sb = new StringBuilder (); 781 782 if (clz.getSuperNode() != null) { 783 addAncestorParents(clz.getSuperNode(), sb); 784 785 return sb.toString(); 786 } 787 788 return null; 789 } 790 791 792 public static String getFqnName(AstPath path) { 793 StringBuilder sb = new StringBuilder (); 794 795 Iterator <Node> it = path.rootToLeaf(); 796 797 while (it.hasNext()) { 798 Node node = it.next(); 799 800 if (node instanceof ModuleNode || node instanceof ClassNode) { 801 Node cpath = ((IScopingNode)node).getCPath(); 802 803 if ((cpath != null) && cpath instanceof INameNode) { 804 if (sb.length() > 0) { 805 sb.append("::"); } 807 808 sb.append(((INameNode)cpath).getName()); 809 } 810 } 811 } 812 813 return sb.toString(); 814 } 815 816 public static boolean isAttr(Node node) { 817 if (!(node instanceof FCallNode)) { 818 return false; 819 } 820 821 String name = ((INameNode)node).getName(); 822 823 if (name.startsWith("attr")) { 825 if ("attr".equals(name) || "attr_reader".equals(name) || "attr_accessor".equals(name) || "attr_writer".equals(name)) { 828 return true; 829 } 830 } 831 832 return false; 833 } 834 835 @SuppressWarnings ("unchecked") 836 public static SymbolNode[] getAttrSymbols(Node node) { 837 assert isAttr(node); 838 839 List <Node> list = node.childNodes(); 840 841 for (Node child : list) { 842 if (child instanceof ListNode) { 843 List <Node> symbols = (List <Node>)child.childNodes(); 844 List <SymbolNode> symbolList = new ArrayList <SymbolNode>(symbols.size()); 845 846 for (Node symbol : symbols) { 847 if (symbol instanceof SymbolNode) { 848 symbolList.add((SymbolNode)symbol); 849 } 850 } 851 852 return symbolList.toArray(new SymbolNode[symbolList.size()]); 853 } 854 } 855 856 return new SymbolNode[0]; 857 } 858 859 public static Node getRoot(CompilationInfo info) { 861 ParserResult result = info.getParserResult(); 862 863 if (result == null) { 864 return null; 865 } 866 867 return getRoot(result); 868 } 869 870 public static Node getRoot(ParserResult r) { 871 assert r instanceof RubyParseResult; 872 873 RubyParseResult result = (RubyParseResult)r; 874 875 ParserResult.AstTreeNode ast = result.getAst(); 878 879 if (ast == null) { 880 return null; 881 } 882 883 Node root = (Node)ast.getAstNode(); 884 885 return root; 886 } 887 888 891 public static void findPrivateMethods(Node clz, Set <Node> protectedMethods, 892 Set <Node> privateMethods) { 893 Set <String > publicMethodSymbols = new HashSet <String >(); 894 Set <String > protectedMethodSymbols = new HashSet <String >(); 895 Set <String > privateMethodSymbols = new HashSet <String >(); 896 Set <Node> publicMethods = new HashSet <Node>(); 897 898 @SuppressWarnings ("unchecked") 899 List <Node> list = clz.childNodes(); 900 901 Modifier access = Modifier.PUBLIC; 902 903 for (Node child : list) { 904 access = getMethodAccess(child, access, publicMethodSymbols, protectedMethodSymbols, 905 privateMethodSymbols, publicMethods, protectedMethods, privateMethods); 906 } 907 908 privateMethodSymbols.removeAll(publicMethodSymbols); 913 protectedMethodSymbols.removeAll(publicMethodSymbols); 914 915 921 for (String name : privateMethodSymbols) { 923 for (Node n : publicMethods) { 924 if (name.equals(AstUtilities.getDefName(n))) { 925 privateMethods.add(n); 926 } 927 } 928 } 929 930 for (String name : protectedMethodSymbols) { 931 for (Node n : publicMethods) { 932 if (name.equals(AstUtilities.getDefName(n))) { 933 protectedMethods.add(n); 934 } 935 } 936 } 937 } 938 939 946 @SuppressWarnings ("unchecked") 947 private static Modifier getMethodAccess(Node node, Modifier access, 948 Set <String > publicMethodSymbols, Set <String > protectedMethodSymbols, 949 Set <String > privateMethodSymbols, Set <Node> publicMethods, Set <Node> protectedMethods, 950 Set <Node> privateMethods) { 951 if (node instanceof DefsNode || node instanceof DefnNode) { 952 if (access == Modifier.PRIVATE) { 953 privateMethods.add(node); 954 } else if (access == Modifier.PUBLIC) { 955 publicMethods.add(node); 956 } else if (access == Modifier.PROTECTED) { 957 protectedMethods.add(node); 958 } 959 960 return access; 962 } else if (node instanceof VCallNode || node instanceof FCallNode) { 963 String name = ((INameNode)node).getName(); 964 965 if ("private".equals(name)) { 966 if (Arity.callHasArguments(node)) { 970 List <Node> params = (List <Node>)node.childNodes(); 971 972 for (Node param : params) { 973 if (param instanceof ListNode) { 974 List <Node> params2 = (List <Node>)param.childNodes(); 975 976 for (Node param2 : params2) { 977 if (param2 instanceof SymbolNode) { 978 String symbol = ((SymbolNode)param2).getName(); 979 privateMethodSymbols.add(symbol); 980 } 981 } 982 } 983 } 984 } else { 985 access = Modifier.PRIVATE; 986 } 987 988 return access; 989 } else if ("protected".equals(name)) { 990 if (Arity.callHasArguments(node)) { 994 List <Node> params = (List <Node>)node.childNodes(); 995 996 for (Node param : params) { 997 if (param instanceof ListNode) { 998 List <Node> params2 = (List <Node>)param.childNodes(); 999 1000 for (Node param2 : params2) { 1001 if (param2 instanceof SymbolNode) { 1002 String symbol = ((SymbolNode)param2).getName(); 1003 protectedMethodSymbols.add(symbol); 1004 } 1005 } 1006 } 1007 } 1008 } else { 1009 access = Modifier.PROTECTED; 1010 } 1011 1012 return access; 1013 } else if ("public".equals(name)) { 1014 if (!Arity.callHasArguments(node)) { 1015 access = Modifier.PUBLIC; 1016 1017 return access; 1018 } else { 1019 List <Node> params = (List <Node>)node.childNodes(); 1020 1021 for (Node param : params) { 1022 if (param instanceof ListNode) { 1023 List <Node> params2 = (List <Node>)param.childNodes(); 1024 1025 for (Node param2 : params2) { 1026 if (param2 instanceof SymbolNode) { 1027 String symbol = ((SymbolNode)param2).getName(); 1028 publicMethodSymbols.add(symbol); 1029 } 1030 } 1031 } 1032 } 1033 } 1034 } 1035 1036 return access; 1037 } else if (node instanceof ClassNode || node instanceof ModuleNode) { 1038 return access; 1039 } 1040 1041 @SuppressWarnings ("unchecked") 1042 List <Node> list = node.childNodes(); 1043 1044 for (Node child : list) { 1045 access = getMethodAccess(child, access, publicMethodSymbols, protectedMethodSymbols, 1046 privateMethodSymbols, publicMethods, protectedMethods, privateMethods); 1047 } 1048 1049 return access; 1050 } 1051} 1052 | Popular Tags |