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

Method replace

src/main/java/wyil/lang/WyilFile.java:340–362  ·  view source on GitHub ↗
(T from, T to)

Source from the content-addressed store, hash-verified

338 }
339
340 @Override
341 public <T extends Syntactic.Item> void replace(T from, T to) {
342 BitSet matches = findReachable(from, new BitSet());
343 Decl.Module module = getModule();
344 // Carefully remove all markers for items within that being replaced.
345 Tuple<Syntactic.Marker> markers = module.getAttributes();
346 ArrayList<Syntactic.Item> items = new ArrayList<>();
347 //
348 for(int i=0;i!=markers.size();++i) {
349 Syntactic.Item marker = markers.get(i);
350 for(int j=0;j!=marker.size();++j) {
351 if(matches.get(marker.get(j).getIndex())) {
352 // Found a match
353 items.add(marker);
354 break;
355 }
356 }
357 }
358 // Remove all existing markers
359 module.setAttributes(markers.removeAll(items));
360 // Done
361 super.replace(from, to);
362 }
363
364 /**
365 * A qualified name represents a <i>fully-qualified</i> name within a

Callers

nothing calls this directly

Calls 10

getModuleMethod · 0.95
findReachableMethod · 0.80
getAttributesMethod · 0.80
setAttributesMethod · 0.80
sizeMethod · 0.65
getMethod · 0.65
getIndexMethod · 0.65
addMethod · 0.65
replaceMethod · 0.65
removeAllMethod · 0.45

Tested by

no test coverage detected