MCPcopy Create free account
hub / github.com/PCGen/pcgen / evaluate

Method evaluate

code/src/java/plugin/function/GroupFunction.java:120–149  ·  view source on GitHub ↗
(EvaluateVisitor visitor, Node[] args,
		EvaluationManager manager)

Source from the content-addressed store, hash-verified

118 }
119
120 @Override
121 public Object evaluate(EvaluateVisitor visitor, Node[] args,
122 EvaluationManager manager)
123 {
124 String scopeName = (String) args[0].jjtAccept(visitor,
125 manager.getWith(EvaluationManager.ASSERTED,
126 Optional.of(FormatUtilities.STRING_MANAGER)));
127 LoadContext context = manager.get(ManagerKey.CONTEXT);
128 PCGenScope scope = context.getVariableContext().getScope(scopeName);
129 //Was checked in allowArgs
130 @SuppressWarnings("unchecked")
131 ReferenceManufacturer<? extends PCGenScoped> refMfg =
132 (ReferenceManufacturer<? extends PCGenScoped>) scope
133 .getFormatManager(context).get();
134
135 String groupingName = (String) args[1].jjtAccept(visitor,
136 manager.getWith(EvaluationManager.ASSERTED,
137 Optional.of(FormatUtilities.STRING_MANAGER)));
138
139 Collection<? extends PCGenScoped> all = refMfg.getAllObjects();
140 LoadContext subContext = context.dropIntoContext(scopeName);
141 //Was checked in allowArgs
142 @SuppressWarnings("unchecked")
143 GroupingCollection<PCGenScoped> group =
144 (GroupingCollection<PCGenScoped>) subContext.getGrouping(scope,
145 "GROUP=" + groupingName);
146 List<PCGenScoped> available = new ArrayList<>();
147 all.forEach(object -> group.process(object, available::add));
148 return available.toArray(new PCGenScoped[0]);
149 }
150
151 @Override
152 public Optional<FormatManager<?>> getDependencies(DependencyVisitor visitor,

Callers

nothing calls this directly

Calls 13

getVariableContextMethod · 0.95
getFormatManagerMethod · 0.95
dropIntoContextMethod · 0.95
getGroupingMethod · 0.95
ofMethod · 0.80
forEachMethod · 0.80
getMethod · 0.65
getAllObjectsMethod · 0.65
processMethod · 0.65
jjtAcceptMethod · 0.45
getWithMethod · 0.45
getScopeMethod · 0.45

Tested by

no test coverage detected