drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/editors/completion/CompletionContext.java
public Map<String, String[]> getRuleParameters() {
        Map<String, String[]> result = new HashMap<String, String[]>();
        int i = 0;
        int lastLocation = -1;
        for (Object o: parserList) {
            if (o instanceof DroolsToken) {
                DroolsToken token = (DroolsToken) o;
                if (DroolsEditorType.IDENTIFIER_VARIABLE.equals(token.getEditorType()) || DroolsEditorType.IDENTIFIER_PATTERN.equals(token.getEditorType())) {
                    String variableName = token.getText();
                    if (lastLocation == Location.LOCATION_LHS_BEGIN_OF_CONDITION) {
                        int j = i + 2;
                        String className = "";
                        while (j < parserList.size()) {
                            Object obj = parserList.get(j++);
                            if (obj instanceof DroolsToken) {
                                String s = ((DroolsToken) obj).getText();
                                if ("(".equals(s)) {
                                    result.put(variableName, new String[] { className, null });
                                    break;
                                } else {
                                    className += s;
                                }

                            }
                        }
                    } else if (lastLocation == Location.LOCATION_LHS_INSIDE_CONDITION_START) {
                        int index = findTokenBack(Location.LOCATION_LHS_BEGIN_OF_CONDITION, i);
                        int j = index + 3;
                        String className = "";
                        while (j < i) {
                            Object obj = parserList.get(j++);
                            if (obj instanceof DroolsToken) {
                                String s = ((DroolsToken) obj).getText();
                                if ("(".equals(s)) {
                                    break;
                                } else {
                                    className += s;
                                }

                            }
                        }
                        j = i + 2;
                        String propertyName = "";
                        while (j < parserList.size()) {
                            Object obj = parserList.get(j++);
                            if (obj instanceof DroolsToken) {
                                String s = ((DroolsToken) obj).getText();
                                if (",".equals(s) || ")".equals(s)) {
                                    result.put(variableName, new String[] { className, propertyName });
                                    break;
                                } else {
                                    propertyName += s;
                                }
                            } else {
                                result.put(variableName, new String[] { className, propertyName });
                            }
                        }
                    }
                }
            } else if (o instanceof Integer) {
                lastLocation = (Integer) o;
            }
            i++;
        }
        return result;
    }
public Map<String, String[]> getRuleParameters() {
        Map<String, String[]> result = new HashMap<String, String[]>();
        int i = 0;
        int lastLocation = -1;
        for (Object o: parserList) {
            if (o instanceof DroolsToken) {
                DroolsToken token = (DroolsToken) o;
                if (DroolsEditorType.IDENTIFIER_VARIABLE.equals(token.getEditorType()) || DroolsEditorType.IDENTIFIER_PATTERN.equals(token.getEditorType())) {
                    String variableName = token.getText();
                    if (lastLocation == Location.LOCATION_LHS_BEGIN_OF_CONDITION) {
                        int j = i + 2;
                        String className = "";
                        while (j < parserList.size()) {
                            Object obj = parserList.get(j++);
                            if (obj instanceof DroolsToken) {
                                String s = ((DroolsToken) obj).getText();
                                if ("(".equals(s)) {
                                    result.put(variableName, new String[] { className, null });
                                    break;
                                } else {
                                    className += s;
                                }

                            }
                        }
                    } else if (lastLocation == Location.LOCATION_LHS_INSIDE_CONDITION_START) {
                        int index = findTokenBack(Location.LOCATION_LHS_BEGIN_OF_CONDITION, i);
                        int j = index + 3;
                        String className = "";
                        while (j < i) {
                            Object obj = parserList.get(j++);
                            if (obj instanceof DroolsToken) {
                                String s = ((DroolsToken) obj).getText();
                                if ("(".equals(s)) {
                                    break;
                                } else {
                                    className += s;
                                }

                            }
                        }
                        j = i + 2;
                        String propertyName = "";
                        while (j < parserList.size()) {
                            Object obj = parserList.get(j++);
                            if (obj instanceof DroolsToken) {
                                String s = ((DroolsToken) obj).getText();
                                if (",".equals(s) || ")".equals(s)) {
                                    result.put(variableName, new String[] { className, propertyName });
                                    break;
                                } else {
                                    propertyName += s;
                                }
                            } else {
                                result.put(variableName, new String[] { className, propertyName });
                            }
                        }
                    }
                }
            } else if (o instanceof Integer) {
                lastLocation = (Integer) o;
            }
            i++;
        }
        return result;
    }
public Map < String , String [ ] > getRuleParameters ( ) { Map < String , String [ ] > result = new HashMap < String , String [ ] > ( ) ; int i = 0 ; int lastLocation = - 1 ; for ( Object o : parserList ) { if ( o instanceof DroolsToken ) { DroolsToken token = ( DroolsToken ) o ; if ( DroolsEditorType . IDENTIFIER_VARIABLE . equals ( token . getEditorType ( ) ) || DroolsEditorType . IDENTIFIER_PATTERN . equals ( token . getEditorType ( ) ) ) { String variableName = token . getText ( ) ; if ( lastLocation == Location . LOCATION_LHS_BEGIN_OF_CONDITION ) { int j = i + 2 ; String className = "" ; while ( j < parserList . size ( ) ) { Object obj = parserList . get ( j ++ ) ; if ( obj instanceof DroolsToken ) { String s = ( ( DroolsToken ) obj ) . getText ( ) ; if ( "(" . equals ( s ) ) { result . put ( variableName , new String [ ] { className , null } ) ; break ; } else { className += s ; } } } } else if ( lastLocation == Location . LOCATION_LHS_INSIDE_CONDITION_START ) { int index = findTokenBack ( Location . LOCATION_LHS_BEGIN_OF_CONDITION , i ) ; int j = index + 3 ; String className = "" ; while ( j < i ) { Object obj = parserList . get ( j ++ ) ; if ( obj instanceof DroolsToken ) { String s = ( ( DroolsToken ) obj ) . getText ( ) ; if ( "(" . equals ( s ) ) { break ; } else { className += s ; } } } j = i + 2 ; String propertyName = "" ; while ( j < parserList . size ( ) ) { Object obj = parserList . get ( j ++ ) ; if ( obj instanceof DroolsToken ) { String s = ( ( DroolsToken ) obj ) . getText ( ) ; if ( "," . equals ( s ) || ")" . equals ( s ) ) { result . put ( variableName , new String [ ] { className , propertyName } ) ; break ; } else { propertyName += s ; } } else { result . put ( variableName , new String [ ] { className , propertyName } ) ; } } } } } else if ( o instanceof Integer ) { lastLocation = ( Integer ) o ; } i ++ ; } return result ; }
Returns the variables defined in the given rule (fragment).
The key is the name of the variable.
The value is a list of 2 String:
- the first one is the class name of the variable
- the second one is the property of the given class that defines the type of this variable,
note that this property could be nested,
if this property is null then the given class is the type of the variable
Returns the variables defined in the given rule ( fragment ) . The key is the name of the variable . The value is a list of 2 String : - the first one is the class name of the variable - the second one is the property of the given class that defines the type of this variable note that this property could be nested if this property is null then the given class is the type of the variable