[jboss-svn-commits] JBL Code SVN: r6061 - labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 31 19:41:48 EDT 2006
Author: KrisVerlaenen
Date: 2006-08-31 19:41:47 -0400 (Thu, 31 Aug 2006)
New Revision: 6061
Modified:
labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/DRLRuleEditor.java
Log:
JBRULES-470: Add support for function imports
- both types of static functions are included when suggesting functions in code completion
Modified: labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/DRLRuleEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/DRLRuleEditor.java 2006-08-31 23:05:33 UTC (rev 6060)
+++ labs/jbossrules/trunk/drools-ide/src/main/java/org/drools/ide/editors/DRLRuleEditor.java 2006-08-31 23:41:47 UTC (rev 6061)
@@ -162,11 +162,25 @@
}
// functions
List functionDescrs = descr.getFunctions();
+ List functionImports = descr.getFunctionImports();
functions = new ArrayList(functionDescrs.size());
iterator = functionDescrs.iterator();
while (iterator.hasNext()) {
functions.add(((FunctionDescr) iterator.next()).getName());
}
+ iterator = functionImports.iterator();
+ while (iterator.hasNext()) {
+ String functionImport = (String) iterator.next();
+ if (functionImport.endsWith(".*")) {
+ String className = functionImport.substring(0, functionImport.length() - 2);
+ functions.addAll(getAllStaticMethodsInClass(className));
+ } else {
+ int index = functionImport.lastIndexOf('.');
+ if (index != -1) {
+ functions.add(functionImport.substring(index + 1));
+ }
+ }
+ }
// templates
List templateDescrs = descr.getFactTemplates();
templates = new HashMap(templateDescrs.size());
@@ -245,7 +259,34 @@
return list;
}
-
+ private List getAllStaticMethodsInClass(String className) {
+ final List list = new ArrayList();
+ if (className != null) {
+ IEditorInput input = getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput) input).getFile().getProject();
+ IJavaProject javaProject = JavaCore.create(project);
+
+ CompletionRequestor requestor = new CompletionRequestor() {
+ public void accept(org.eclipse.jdt.core.CompletionProposal proposal) {
+ String functionName = new String(proposal.getCompletion());
+ if (proposal.getKind() == org.eclipse.jdt.core.CompletionProposal.METHOD_REF) {
+ list.add(functionName.substring(0, functionName.length() - 2)); // remove the ()
+ }
+ // ignore all other proposals
+ }
+ };
+
+ try {
+ javaProject.newEvaluationContext().codeComplete(className + ".", className.length() + 1, requestor);
+ } catch (Throwable t) {
+ DroolsIDEPlugin.log(t);
+ }
+ }
+ }
+ return list;
+ }
+
public Object getAdapter(Class adapter) {
if (adapter.equals(IContentOutlinePage.class)) {
return getContentOutline();
More information about the jboss-svn-commits
mailing list