MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / getParent

Method getParent

src/main/java/wycc/util/AbstractHeap.java:104–119  ·  view source on GitHub ↗

Get first parent of a syntactic item matching the given kind. If no item was found, then null is returned. @param child @param kind @return

(Item child, Class<T> kind)

Source from the content-addressed store, hash-verified

102 * @return
103 */
104 @Override
105 public <T extends Item> T getParent(Item child, Class<T> kind) {
106 // FIXME: this could be optimised a *lot*
107 for (int i = 0; i != syntacticItems.size(); ++i) {
108 Item parent = syntacticItems.get(i);
109 if(kind.isInstance(parent)) {
110 for(int j=0;j!=parent.size();++j) {
111 if(parent.get(j) == child) {
112 return (T) parent;
113 }
114 }
115 }
116 }
117 // no match
118 return null;
119 }
120
121 @Override
122 public <T extends Item> List<T> getParents(Item child, Class<T> kind) {

Callers

nothing calls this directly

Calls 3

getMethod · 0.95
sizeMethod · 0.95
sizeMethod · 0.65

Tested by

no test coverage detected