MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / getCompletionsFor

Method getCompletionsFor

src/main/java/fieldbox/boxes/Box.java:624–660  ·  view source on GitHub ↗
(String prefix)

Source from the content-addressed store, hash-verified

622 throw new Error();
623 }
624
625
626 @Override
627 @HiddenInAutocomplete
628 public List<Completion> getCompletionsFor(String prefix) {
629
630 Log.log("completion.debug", () -> "inside getCompletionsFor (box) " + prefix);
631
632 Stream<Dict.Prop> propStream = this.breadthFirst(this.upwards())
633 .map(x -> x.properties.getMap()
634 .keySet()).flatMap(Collection::stream);
635
636 List<Completion> l1 = assembleCompletions(prefix, propStream);
637 l1.forEach(x -> x.rank++);
638
639 List<Completion> l1b = assembleCompletions(prefix, Dict.canonicalProperties());
640 l1.addAll(l1b.stream()
641 .filter(x -> {
642 for (Completion c : l1)
643 if (c.replacewith.equals(x.replacewith)) return false;
644 return true;
645 })
646 .collect(Collectors.toList()));
647
648 List<Completion> l2 = JavaSupport.javaSupport.getOptionCompletionsFor(this, prefix);
649
650 l1.addAll(l2.stream()
651 .filter(x -> {
652 for (Completion c : l1)
653 if (c.replacewith.equals(x.replacewith)) return false;
654 return true;
655 })
656 .collect(Collectors.toList()));
657
658
659 Log.log("completion.debug", () -> "returning " + l1 + " as completions");
660
661 return l1;
662 }
663

Callers

nothing calls this directly

Calls 13

logMethod · 0.95
breadthFirstMethod · 0.95
upwardsMethod · 0.95
assembleCompletionsMethod · 0.95
canonicalPropertiesMethod · 0.95
getMapMethod · 0.80
collectMethod · 0.80
mapMethod · 0.45
forEachMethod · 0.45
addAllMethod · 0.45
streamMethod · 0.45

Tested by

no test coverage detected