private MethodViewItem[] getMethods(CFNodeList nodes) { if (sortItems) { CFCMethodsComparator comparator = new CFCMethodsComparator(); Collections.sort(nodes, comparator); } Iterator i = nodes.iterator(); MethodViewItem[] methods = new MethodViewItem[nodes.size()]; int index = 0; while (i.hasNext()) { try { Object itemThing = i.next(); DocItem thisTag = (DocItem) itemThing; MethodViewItem item; if (itemThing instanceof FunctionInfo) { item = new CFCMethodViewScriptItem((FunctionInfo) itemThing); } else { item = new CFCMethodViewItem((TagItem) thisTag); } boolean addItem = true; if (item.getAccess().toLowerCase().equals("remote") && !this.showRemote) { addItem = false; } if (item.getAccess().toLowerCase().equals("public") && !this.showPublic) { addItem = false; } if (item.getAccess().toLowerCase().equals("package") && !this.showPackage) { addItem = false; } if (item.getAccess().toLowerCase().equals("private") && !this.showPrivate) { addItem = false; } if (addItem) { methods[index] = item; index++; } } catch (Exception e) { e.printStackTrace(); } } MethodViewItem[] finalMethods = new MethodViewItem[index]; for (int x = 0; x < finalMethods.length; x++) { finalMethods[x] = methods[x]; } return finalMethods; }
/* (non-Javadoc) * @see org.cfeclipse.cfml.editors.contentassist.IAssistContributor#getTagProposals(org.cfeclipse.cfml.editors.contentassist.IAssistState) */ public ICompletionProposal[] getTagProposals(IAssistState state) { /* * Only show content assist if the trigger was ( or , * We should probably find a better way than this, but the * content assist is getting in the way right now. */ if (state.getTriggerData() != ',' && state.getTriggerData() != '(') { return null; } if (state.getTriggerData() == ' ' || state.getTriggerData() == '\t') { return null; } if (!checkContext(state)) return null; else { // int length = this.functionName.length(); Set params = ((ISyntaxDictionary) this.sourceDict).getFunctionParams(this.functionName); String helpText = ((ISyntaxDictionary) this.sourceDict).getFunctionHelp(this.functionName); /* * here begins denny's attempt at in-page function argument proposals */ if (params == null) { params = new LinkedHashSet(); CFDocument doc = ((ICFDocument) state.getIDocument()).getCFDocument(); DocItem rootItem = doc.getDocumentRoot(); Matcher matcher; Pattern pattern; String name = "", type = "", required = "", defaultvalue = ""; pattern = Pattern.compile( "(\\w+)[\\s=]+(((\\x22|\\x27)((?!\\4).|\\4{2})*\\4))", Pattern.CASE_INSENSITIVE); // nodes = rootItem.selectNodes("//function[#startpos>=0 and #endpos < 200]"); nodes = rootItem.selectNodes("//cffunction"); Iterator i = nodes.iterator(); while (i.hasNext()) { DocItem currItem = (DocItem) i.next(); if (currItem.getItemData().indexOf(this.functionName) > 0) { // Function newFunk = new Function(this.functionName); // System.out.println(currItem.getItemData()); if (currItem.getFirstChild().getName().equals("cfargument")) { CFNodeList childNodes = currItem.getChildNodes(); int x = 0; DocItem childNode = (DocItem) childNodes.get(x); while (childNode.getName().equals("cfargument")) { matcher = pattern.matcher(childNode.getItemData()); while (matcher.find()) { String value = matcher.group(2).replaceAll("'", "").replaceAll("\"", ""); if (matcher.group(1).toLowerCase().equals("name")) { name = value; } if (matcher.group(1).toLowerCase().equals("type")) { type = value; } if (matcher.group(1).toLowerCase().equals("required")) { required = value; } if (matcher.group(1).toLowerCase().equals("default")) { defaultvalue = value; } } Parameter newParam = new Parameter(name, type, Boolean.valueOf(required), defaultvalue); // Parameter newParam = new Parameter(name,type); params.add(newParam); System.out.println(currItem.getFirstChild().getItemData()); childNode = (DocItem) nodes.get(x); x++; } } } } /* * here endss denny's attempt at in-page function argument proposals */ if (params == null) { return null; } } Parameter[] filteredParams = getFilteredParams(params); int x = 0; String extraInfo = paramIndent + "<b>" + functionName + "</b> (\n"; // CompletionProposal proposal = null; // String usage = ""; Parameter activeParam = null; int paramCount = filteredParams.length; while (x < paramCount) { Parameter p = filteredParams[x]; String delimiter = ""; if (x + 1 < paramCount) { delimiter = " ,"; } extraInfo += paramIndent + paramIndent; if (x == this.paramsSoFar) { activeParam = p; extraInfo += "<b>"; } extraInfo += p.toString() + delimiter; if (x == this.paramsSoFar) { extraInfo += "</b>"; } extraInfo += "\n"; x++; } if (this.paramsSoFar == paramCount) { // System.out.println("End of params"); return null; } extraInfo += paramIndent + ") \n\n"; extraInfo += helpText; return getParamProposals(activeParam, extraInfo, state.getOffset(), paramCount); } }