private ICompletionProposal[] getDefaultParamProposals( Parameter activeParam, String extraInfo, int offset, int paramCount) { String value = ""; String suffix = ","; ICompletionProposal[] result = new ICompletionProposal[1]; if (activeParam.getType().equalsIgnoreCase("string")) { value = "\"\""; } else if (activeParam.getType().equalsIgnoreCase("regex")) { value = "\"[.]*\""; } if (activeParam.getDefaultValue() != null) { value = activeParam.getDefaultValue(); } if (this.paramsSoFar == paramCount - 1) { suffix = ""; } CompletionProposal proposal = new CompletionProposal( value + suffix, offset, 0, value.length() + suffix.length(), CFPluginImages.get(CFPluginImages.ICON_PARAM), activeParam.toString() + " - " + value, null, extraInfo); result[0] = proposal; return result; }
private ICompletionProposal[] getBooleanParamProposals( Parameter activeParam, String extraInfo, int offset, int paramCount) { String value = ""; String suffix = ","; ICompletionProposal[] result = new ICompletionProposal[2]; value = "true"; if (this.paramsSoFar == paramCount - 1) { suffix = ""; } CompletionProposal proposal = new CompletionProposal( value + suffix, offset, 0, value.length() + suffix.length(), CFPluginImages.get(CFPluginImages.ICON_PARAM), value, null, extraInfo); result[0] = proposal; value = "false"; proposal = new CompletionProposal( value, offset, 0, value.length() + suffix.length(), CFPluginImages.get(CFPluginImages.ICON_PARAM), value, null, extraInfo); result[1] = proposal; return result; }
private ICompletionProposal[] getValueProposals( Parameter activeParam, String extraInfo, int offset, int paramCount) { // String value = ""; String suffix = ","; Set values = activeParam.getValues(); ICompletionProposal[] tmpResult = new ICompletionProposal[values.size()]; if (this.paramsSoFar == paramCount - 1) { suffix = ""; } Iterator i = values.iterator(); Pattern pattern = Pattern.compile("([\"']?)([^\"']*)([\"']?)"); Matcher matcher = pattern.matcher(paramText); String cleanParamText = ""; if (matcher.find()) { cleanParamText = matcher.group(2); if (cleanParamText.equals("\"") || cleanParamText.equals("'")) { cleanParamText = ""; } } int x = 0; while (i.hasNext()) { Object o = i.next(); if (o instanceof Value) { Value val = (Value) o; if (cleanParamText.length() == 0 || val.toString().toLowerCase().startsWith(cleanParamText.toLowerCase())) { String insertion = val.toString().substring(cleanParamText.length(), val.toString().length()); int cursorOffset = insertion.length() + suffix.length(); if (!paramText.endsWith("\"") && paramText.startsWith("\"")) { insertion += "\""; cursorOffset++; } else if (paramText.startsWith("\"")) { cursorOffset++; } if (!paramText.endsWith("'") && paramText.startsWith("'")) { insertion += "'"; ; cursorOffset++; } else if (paramText.startsWith("'")) { cursorOffset++; } CompletionProposal proposal = new CompletionProposal( insertion + suffix, offset, 0, cursorOffset, CFPluginImages.get(CFPluginImages.ICON_PARAM), activeParam.toString() + " - " + val.toString(), null, extraInfo); // System.out.println("Added " + val.toString()); tmpResult[x] = proposal; x++; } } } ICompletionProposal[] result = new ICompletionProposal[x]; // System.out.println("Temp array length: " + x); for (int y = 0; y < x; y++) { result[y] = tmpResult[y]; } return result; }