org.drools.eclipse.editors.completion
Class CompletionUtil

java.lang.Object
  extended by org.drools.eclipse.editors.completion.CompletionUtil

public class CompletionUtil
extends Object


Field Summary
protected static Pattern COMPLETED_MVEL_EXPRESSION
           
protected static Pattern INCOMPLETED_MVEL_EXPRESSION
           
protected static Pattern MODIFY_PATTERN
           
protected static Pattern START_OF_METHOD_ARGS
           
protected static Pattern START_OF_NEW_JAVA_STATEMENT
           
 
Method Summary
static String getCompilableText(String backText)
          Attempt to enhance a consequence backtext such that it should compile in MVEL
static String getInnerExpression(String backText)
           
static String getLastExpression(String backText)
           
static String getLastLine(String text)
           
static String getPreviousExpression(String backText)
           
static String getPropertyName(String methodName, char[] signature)
           
static String getPropertyName(String methodName, int parameterCount, String returnType)
          Given a data depicting a method (name, # or params/args, returned type key), tries to return a bean property name derived from that method.
static String getSimpleClassName(Class cls)
          COMPENSATES FOR LACK OF getSimpleName IN java.lang.Class Borrowed and adpated from MVEL's org.mvel.util.ParseTools.getSimpleClassName(Class)
static String getTextWithoutPrefix(String javaText, String prefix)
           
static String getWritablePropertyName(String methodName, char[] signature)
           
static String getWritablePropertyName(String methodName, int parameterCount, String returnType)
          Given a data depicting a method (name, # or params/args, returned type key), tries to return a writable bean property name derived from that method.
static boolean isGetter(String methodName, int argCount, String returnedType)
           
static boolean isIsGetter(String methodName, int argCount, String returnedType)
           
static boolean isSetter(String methodName, int argCount, String returnedType)
           
static boolean isStartOfDialectExpression(String text)
           
static boolean isStartOfMethodArgsExpression(String text)
           
static boolean isStartOfNewStatement(String text, String prefix)
           
static int nestedExpressionIndex(char[] chars, int start, char type)
           
static String stripLastWord(String prefix)
          Looks behind, gets stuff after the white space.
static String stripWhiteSpace(String prefix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INCOMPLETED_MVEL_EXPRESSION

protected static final Pattern INCOMPLETED_MVEL_EXPRESSION

COMPLETED_MVEL_EXPRESSION

protected static final Pattern COMPLETED_MVEL_EXPRESSION

MODIFY_PATTERN

protected static final Pattern MODIFY_PATTERN

START_OF_NEW_JAVA_STATEMENT

protected static final Pattern START_OF_NEW_JAVA_STATEMENT

START_OF_METHOD_ARGS

protected static final Pattern START_OF_METHOD_ARGS
Method Detail

stripLastWord

public static String stripLastWord(String prefix)
Looks behind, gets stuff after the white space. Basically ripping out the last word.


getPreviousExpression

public static String getPreviousExpression(String backText)

getLastExpression

public static String getLastExpression(String backText)

getInnerExpression

public static String getInnerExpression(String backText)

nestedExpressionIndex

public static int nestedExpressionIndex(char[] chars,
                                        int start,
                                        char type)

stripWhiteSpace

public static String stripWhiteSpace(String prefix)

getCompilableText

public static String getCompilableText(String backText)
Attempt to enhance a consequence backtext such that it should compile in MVEL

Parameters:
backText -
Returns:
a substring of the back text, that should be compilable without syntax errors by the mvel compiler TODO: add tests and more use cases

isGetter

public static boolean isGetter(String methodName,
                               int argCount,
                               String returnedType)

isSetter

public static boolean isSetter(String methodName,
                               int argCount,
                               String returnedType)

isIsGetter

public static boolean isIsGetter(String methodName,
                                 int argCount,
                                 String returnedType)

getPropertyName

public static String getPropertyName(String methodName,
                                     int parameterCount,
                                     String returnType)
Given a data depicting a method (name, # or params/args, returned type key), tries to return a bean property name derived from that method. If a bean property name is not found, the initial method name is returned

Parameters:
methodName -
parameterCount -
returnType -
Returns:
a bean property name

getPropertyName

public static String getPropertyName(String methodName,
                                     char[] signature)

getWritablePropertyName

public static String getWritablePropertyName(String methodName,
                                             int parameterCount,
                                             String returnType)
Given a data depicting a method (name, # or params/args, returned type key), tries to return a writable bean property name derived from that method. If a writable (ie setter) bean property name is not found, the initial method name is returned

Parameters:
methodName -
parameterCount -
returnType -
Returns:
a bean property name

getWritablePropertyName

public static String getWritablePropertyName(String methodName,
                                             char[] signature)

isStartOfNewStatement

public static boolean isStartOfNewStatement(String text,
                                            String prefix)

getLastLine

public static String getLastLine(String text)

getSimpleClassName

public static String getSimpleClassName(Class cls)
COMPENSATES FOR LACK OF getSimpleName IN java.lang.Class Borrowed and adpated from MVEL's org.mvel.util.ParseTools.getSimpleClassName(Class)

Parameters:
cls - -- class reference
Returns:
Simple name of class

getTextWithoutPrefix

public static String getTextWithoutPrefix(String javaText,
                                          String prefix)

isStartOfDialectExpression

public static boolean isStartOfDialectExpression(String text)

isStartOfMethodArgsExpression

public static boolean isStartOfMethodArgsExpression(String text)


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.