1.1 --- a/ruby/src/org/netbeans/modules/ruby/AstUtilities.java Sun Nov 24 15:46:13 2013 -0600
1.2 +++ b/ruby/src/org/netbeans/modules/ruby/AstUtilities.java Sun Dec 08 11:39:16 2013 -0600
1.3 @@ -1707,19 +1707,33 @@
1.4 }
1.5 }
1.6
1.7 + public static List<Node> getOutermostToInnerMostBlocks(Node leaf) {
1.8 + Node scope = leaf.getInnermostIter();
1.9 +
1.10 + if (scope == null) return Collections.emptyList();
1.11 +
1.12 + List<Node> result = new ArrayList<Node>();
1.13 + while (scope != null) {
1.14 + result.add(scope);
1.15 +
1.16 + scope = scope.getInnermostIter();
1.17 + }
1.18 +
1.19 + Collections.reverse(result);
1.20 +
1.21 + return result;
1.22 + }
1.23 +
1.24 /** Return all the blocknodes that apply to the given node. The outermost block
1.25 * is returned first.
1.26 */
1.27 public static List<Node> getApplicableBlocks(AstPath path, boolean includeNested) {
1.28 Node block = AstUtilities.findBlock(path);
1.29
1.30 - if (block == null) {
1.31 - // Use parent
1.32 + if (block == null) { // Use parent
1.33 block = path.leafParent();
1.34
1.35 - if (block == null) {
1.36 - return Collections.emptyList();
1.37 - }
1.38 + if (block == null) return Collections.emptyList();
1.39 }
1.40
1.41 List<Node> result = new ArrayList<Node>();
1.42 @@ -1727,37 +1741,34 @@
1.43
1.44 // Skip the leaf node, we're going to add it unconditionally afterwards
1.45 if (includeNested) {
1.46 - if (it.hasNext()) {
1.47 - it.next();
1.48 - }
1.49 + if (it.hasNext()) it.next();
1.50 }
1.51
1.52 Node leaf = path.root();
1.53
1.54 - while_loop:
1.55 + while_loop:
1.56 while (it.hasNext()) {
1.57 Node n = it.next();
1.58 switch (n.getNodeType()) {
1.59 - //case BLOCKNODE:
1.60 - case ITERNODE:
1.61 - leaf = n;
1.62 - result.add(n);
1.63 - break;
1.64 - case DEFNNODE:
1.65 - case DEFSNODE:
1.66 - case CLASSNODE:
1.67 - case SCLASSNODE:
1.68 - case MODULENODE:
1.69 - leaf = n;
1.70 - break while_loop;
1.71 + case ITERNODE:
1.72 + leaf = n;
1.73 + result.add(n);
1.74 + break;
1.75 + case DEFNNODE:
1.76 + case DEFSNODE:
1.77 + case CLASSNODE:
1.78 + case SCLASSNODE:
1.79 + case MODULENODE:
1.80 + leaf = n;
1.81 + break while_loop;
1.82 }
1.83 }
1.84
1.85 if (includeNested) {
1.86 - addNodesByType(leaf, new NodeType[] { /*NodeType.BLOCKNODE,*/ NodeType.ITERNODE }, result);
1.87 + addNodesByType(leaf, new NodeType[] { NodeType.ITERNODE }, result);
1.88 }
1.89
1.90 - return result;
1.91 + return result;
1.92 }
1.93
1.94 public static String guessName(Parser.Result result, OffsetRange lexRange, OffsetRange astRange) {