private IOpenMethod getMethodFromDispatcher(OpenMethodDispatcher method, TableSyntaxNode syntaxNode) { List<IOpenMethod> candidates = method.getCandidates(); for (IOpenMethod candidate : candidates) { IOpenMethod resolvedMethod = resolveMethod(candidate, syntaxNode); if (resolvedMethod != null) { return resolvedMethod; } } return null; }
@Override public List<IOpenMethod> getCandidates() { if (candidatesSorted == null) { candidatesSorted = prioritySorter.sort(super.getCandidates()); } return candidatesSorted; }
private static void extractMethods(Collection<IOpenMethod> methods, List<IOpenMethod> result) { for (IOpenMethod method : methods) { if (method instanceof OpenMethodDispatcher) { extractMethods(((OpenMethodDispatcher) method).getCandidates(), result); } else { result.add(method); } } }
private IOpenMethod getMethodFromDispatcher(OpenMethodDispatcher method, TableSyntaxNode syntaxNode) { List<IOpenMethod> candidates = method.getCandidates(); for (IOpenMethod candidate : candidates) { IOpenMethod resolvedMethod = resolveMethod(candidate, syntaxNode); if (resolvedMethod != null) { return resolvedMethod; } } return null; }
private IOpenMethod resolveMethodDispatcher(OpenMethodDispatcher method, TableSyntaxNode syntaxNode) { List<IOpenMethod> candidates = method.getCandidates(); for (IOpenMethod candidate : candidates) { IOpenMethod resolvedMethod = resolveMethod(candidate, syntaxNode); if (resolvedMethod != null) { return method; } } return null; }
private IOpenMethod resolveMethodDispatcher(OpenMethodDispatcher method, TableSyntaxNode syntaxNode) { List<IOpenMethod> candidates = method.getCandidates(); for (IOpenMethod candidate : candidates) { IOpenMethod resolvedMethod = resolveMethod(candidate, syntaxNode); if (resolvedMethod != null) { return resolvedMethod; } } return null; }
private IOpenMethod resolveMethodDispatcher(OpenMethodDispatcher method, TableSyntaxNode syntaxNode) { List<IOpenMethod> candidates = method.getCandidates(); for (IOpenMethod candidate : candidates) { IOpenMethod resolvedMethod = resolveMethod(candidate, syntaxNode); if (resolvedMethod != null) { return resolvedMethod; } } return null; }
/** * Dispatcher method should be added by adding all candidates of the * specified dispatcher to current XlsModuleOpenClass(it will cause adding * methods to dispatcher of current module or creating new dispatcher in * current module). * * Previously there was problems because dispatcher from dependency was * either added to dispatcher of current module(dispatcher as a candidate in * another dispatcher) or added to current module and was modified during * the current module processing. FIXME * * @param dispatcher Dispatcher methods to add. */ public void addDispatcherMethod(OpenMethodDispatcher dispatcher) { for (IOpenMethod candidate : dispatcher.getCandidates()) { addMethod(candidate); } }
public List<IOpenMethod> getTargetMethods(String testOrRunUri) { List<IOpenMethod> targetMethods = new ArrayList<IOpenMethod>(); IOpenMethod testMethod = getMethod(testOrRunUri); if (testMethod instanceof TestSuiteMethod) { IOpenMethod targetMethod = ((TestSuiteMethod) testMethod).getTestedMethod(); // Overloaded methods if (targetMethod instanceof OpenMethodDispatcher) { List<IOpenMethod> overloadedMethods = ((OpenMethodDispatcher) targetMethod).getCandidates(); targetMethods.addAll(overloadedMethods); } else { targetMethods.add(targetMethod); } } return targetMethods; }
public List<IOpenMethod> getTargetMethods(String testOrRunUri) { List<IOpenMethod> targetMethods = new ArrayList<IOpenMethod>(); IOpenMethod testMethod = getMethod(testOrRunUri); if (testMethod instanceof TestSuiteMethod) { IOpenMethod targetMethod = ((TestSuiteMethod) testMethod).getTestedMethod(); // Overloaded methods if (targetMethod instanceof OpenMethodDispatcher) { List<IOpenMethod> overloadedMethods = ((OpenMethodDispatcher) targetMethod).getCandidates(); targetMethods.addAll(overloadedMethods); } else { targetMethods.add(targetMethod); } } return targetMethods; }
public List<IOpenMethod> getTargetMethods(String testOrRunUri) { List<IOpenMethod> targetMethods = new ArrayList<IOpenMethod>(); IOpenMethod testMethod = getMethod(testOrRunUri); if (testMethod instanceof TestSuiteMethod) { IOpenMethod targetMethod = ((TestSuiteMethod) testMethod).getTestedMethod(); // Overloaded methods if (targetMethod instanceof OpenMethodDispatcher) { List<IOpenMethod> overloadedMethods = ((OpenMethodDispatcher) targetMethod).getCandidates(); targetMethods.addAll(overloadedMethods); } else { targetMethods.add(targetMethod); } } return targetMethods; }
@Override public void addMethodDependency(IOpenMethod method, IBoundNode node) { getMethodsMap().put(method, node); // check if method is instance of Openl executable rules method. if (method instanceof ExecutableMethod) { getRulesMethodsMap().put((ExecutableMethod)method, node); } else if (method instanceof OpenMethodDispatcher) { List<IOpenMethod> overlappedMethods =((OpenMethodDispatcher)method).getCandidates(); for (IOpenMethod overlappedMethod : overlappedMethods) { addMethodDependency(overlappedMethod, node); } } }
static ATableTracerNode create(OpenMethodDispatcher dispatcher, Object[] params, IRuntimeContext context) { ExecutableRulesMethod method = (ExecutableRulesMethod) dispatcher.getDispatcherTable().getMember(); return new OverloadedMethodChoiceTraceObject(method, params, context, dispatcher.getCandidates()); } }
static ATableTracerNode create(OpenMethodDispatcher dispatcher, Object[] params, IRuntimeContext context) { ExecutableRulesMethod method = (ExecutableRulesMethod) dispatcher.getDispatcherTable().getMember(); return new OverloadedMethodChoiceTraceObject(method, params, context, dispatcher.getCandidates()); } }
public static ITracerObject getTracedObject(Object source, String id, Object[] args) { ITracerObject trObj; if ("index".equals(id) || "condition".equals(id)) { trObj = DTRuleTraceObject.create(args); } else if ("match".equals(id)) { trObj = MatchTraceObject.create(args); } else if ("result".equals(id)) { trObj = ResultTraceObject.create(args); } else if (source instanceof SpreadsheetCell) { SpreadsheetTracerLeaf tr = new SpreadsheetTracerLeaf((SpreadsheetCell) source); tr.setResult(args[0]); trObj = tr; } else if (source instanceof OpenMethodDispatcher) { trObj = new DTRuleTracerLeaf(new int[]{((OpenMethodDispatcher) source).getCandidates().indexOf(args[0])}); } else { trObj = null; } return trObj; }
public static ITracerObject getTracedObject(Object source, String id, Object[] args) { ITracerObject trObj; if ("index".equals(id) || "condition".equals(id)) { trObj = DTRuleTraceObject.create(args); } else if ("match".equals(id)) { trObj = MatchTraceObject.create(args); } else if ("result".equals(id)) { trObj = ResultTraceObject.create(args); } else if (source instanceof SpreadsheetCell) { SpreadsheetTracerLeaf tr = new SpreadsheetTracerLeaf((SpreadsheetCell) source); tr.setResult(args[0]); trObj = tr; } else if (source instanceof OpenMethodDispatcher) { trObj = new DTRuleTracerLeaf(new int[]{((OpenMethodDispatcher) source).getCandidates().indexOf(args[0])}); } else { trObj = null; } return trObj; }
if (method instanceof OpenMethodDispatcher) { OpenMethodDispatcher openMethodDispatcher = (OpenMethodDispatcher) method; IOpenMethod[] methods = openMethodDispatcher.getCandidates().toArray(new IOpenMethod[] {}); for (int i = 0; i < methods.length - 1; i++) { ITableProperties propsA = PropertiesHelper.getTableProperties(methods[i]);
public static ITableProperties getTableProperties(IOpenMethod method) { if (method instanceof OpenMethodDispatcher){ List<IOpenMethod> methods = ((OpenMethodDispatcher) method).getCandidates(); if (methods.size() == 1) { return getTableProperties(methods.get(0)); } else { throw new IllegalArgumentException( "Dispatcher method with more than one candidate doesn't have properties!"); } } if (method instanceof ITablePropertiesMethod) { return ((ITablePropertiesMethod) method).getMethodProperties(); } else if (method.getInfo() != null) { TableProperties properties = new TableProperties(); Map<String, Object> definedInTable = method.getInfo().getProperties(); if (definedInTable != null) { for (Entry<String, Object> property : definedInTable.entrySet()) { properties.setFieldValue(property.getKey(), property.getValue()); } } return properties; } if (method instanceof MethodDelegator) { return getTableProperties(((MethodDelegator) method).getMethod()); } return new TableProperties(); }
/** * If tester is an instance of {@link TestSuiteMethod} and tested method * object in tester is equal to tested we consider tester is test for tested * method. */ public static boolean isTestForMethod(IOpenMethod tester, IOpenMethod tested) { if (!(tester instanceof TestSuiteMethod)) { return false; } IOpenMethod toTest = ((TestSuiteMethod) tester).getTestedMethod(); if (toTest == tested) { return true; } if (toTest instanceof OpenMethodDispatcher) { if (((OpenMethodDispatcher) toTest).getCandidates().contains(tested)) { return true; } } if (tested instanceof MethodDelegator) { return isTestForMethod(tester, tested.getMethod()); } if (tested instanceof OpenMethodDispatcher) { return isTestForMethod(tester, ((OpenMethodDispatcher) tested).getTargetMethod()); } return false; }
OpenMethodDispatcher openMethodDispatcher = (OpenMethodDispatcher) singleParameterMethodCaller.getMethod(); boolean f = true; for (IOpenMethod method : openMethodDispatcher.getCandidates()) { if (method instanceof ITablePropertiesMethod) { ITablePropertiesMethod tablePropertiesMethod = (ITablePropertiesMethod) method;