private void createLineTagProposal(String prefix, N4JSDocletParser docletParser, ArrayList<ICompletionProposal> proposals) { int replacementOffset = offset - prefix.length(); // create line tag proposals for (ITagDefinition td : docletParser.getLineTagDictionary().getTagDefinitions()) { String tagString = '@' + td.getTitle() + ' '; if (tagString.startsWith(prefix)) { int replacementLength = prefix.length(); int cursorPosition = tagString.length(); ICompletionProposal proposal = new CompletionProposal(tagString, replacementOffset, replacementLength, cursorPosition); proposals.add(proposal); } } }
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { List<ICompletionProposal> propList = new ArrayList<ICompletionProposal>(); List<ICompletionProposal> newpropList = new ArrayList<ICompletionProposal>(); List<IContextInformation> propList2 = new ArrayList<IContextInformation>(); ICompletionProposal first; DataManager datamanger = new DataManager(context,monitor); Activator.applyoperationlist.add(new ApplyOperation(ConsoleOperationListener2.ope.getStart(), ConsoleOperationListener2.ope.getAuthor(), ConsoleOperationListener2.ope.getFilePath(), propList)); List<String> list = new ArrayList(); CompletionProposal proposal; propList = datamanger.JavaDefaultProposal(); propList2 = datamanger.ContextInformation(); ApplyOperation ao = new ApplyOperation(ConsoleOperationListener2.ope.getStart(), ConsoleOperationListener2.ope.getAuthor(), ConsoleOperationListener2.ope.getFilePath(), propList); System.out.println(ao.toString()); return newpropList; }
/** * Constuit les propositions d'aucomplétion. * * @param suggestions Suggestionsà proposer. * @param currentWordSelection Mot courant à remplacer dans le document. * @return Propositions d'autocomplétion. */ private ICompletionProposal[] buildProposals(List<CompletionCandidate> suggestions, ITextSelection currentWordSelection) { /* Calcul l'offset et la longueur du mot à remplacer dans le document. */ int replacementLength = currentWordSelection.getLength(); int replacementOffset = currentWordSelection.getOffset(); /* Construit les propositions en parcourant les suggestions. */ List<ICompletionProposal> proposals = new ArrayList<>(); for (CompletionCandidate suggestion : suggestions) { /* String qui remplacera le mot courant. */ String replacementString = suggestion.getDisplayString(); /* String affiché comme libellé de la proposition. */ String displayString = replacementString; /* String affiché comme description de la proposition (dans la boîte jaune). */ String additionalProposalInfo = suggestion.getAdditionalProposalInfo(); CompletionProposal proposal = new CompletionProposal(replacementString, replacementOffset, replacementLength, replacementString.length(), null, displayString, null, additionalProposalInfo); proposals.add(proposal); } return proposals.toArray(new ICompletionProposal[0]); }
private void addProposals(List<ICompletionProposal> proposals, String prefix, int replacementOffset, String type) { Collection<IFile> files = null; if (MetaModelPartitionScanner.META_MODEL_LOADMODEL.equals(type)) { files = allEcoreFiles.values(); } else if (MetaModelPartitionScanner.META_MODEL_LOADINSTANCE.equals(type)) { files = allFiles.values(); } if (files == null) return; for (IFile iFile : files) { String path = iFile.getFullPath().toString(); if (path.toLowerCase().startsWith(prefix.toLowerCase()) || iFile.getName().toLowerCase().startsWith(prefix.toLowerCase())) { proposals.add(new CompletionProposal(path, replacementOffset, prefix.length(), path.length(), null, iFile.getName() + " - " + path, null, null)); } } }
public static CompletionProposal[] createCompletionProposals(int completionOffset, String variableType, String pattern, String currentText) { String patchedText = currentText; int variablePosition = completionOffset; debug("** create completion proposals **"); debug("pattern: " + pattern); debug(String.format("completion offset %d, variable type %s calculated variable position %d", completionOffset, variableType, variablePosition)); debug("query for parsing: " + patchedText); CompletionProposal[] proposals = FtcCompletionProcessor.getModelElementProposals(patchedText, variablePosition, 0); debug(String.format("%d proposals", proposals.length)); return proposals; }
/** * Computes the abbreviation completions available based on the prefix. * * @param offset Cursor offset in the document * @param replacementLength Length of the text to be replaced * @param prefix The start of the abbreviation or "" * @return An array containing all possible completions */ private ICompletionProposal[] computeAbbrevCompletions(int offset, int replacementLength, String prefix) { ReferenceEntry[] abbrevs = abbrManager.getCompletions(prefix); if (abbrevs == null) return null; ICompletionProposal[] result = new ICompletionProposal[abbrevs.length]; for (int i = 0; i < abbrevs.length; i++) { result[i] = new CompletionProposal(abbrevs[i].key, offset - replacementLength, replacementLength, abbrevs[i].key.length(), null, abbrevs[i].key, null, abbrevs[i].info); } return result; }
@SuppressWarnings("unchecked") @Override public ICompletionProposal[] getProposals(IQuickAssistInvocationContext context) { List<Word> sugg = fError.getSuggestions(); int length = fError.getInvalidWord().length(); ICompletionProposal[] props = new ICompletionProposal[sugg.size() + 2]; for (int i=0; i < sugg.size(); i++) { String suggestion = sugg.get(i).toString(); String s = MessageFormat.format(CHANGE_TO, new Object[] { suggestion }); props[i] = new CompletionProposal(suggestion, fOffset, length, suggestion.length(), fCorrectionImage, s, null, null); } props[props.length - 2] = new IgnoreProposal(ignore, fError.getInvalidWord(), context.getSourceViewer()); props[props.length - 1] = new AddToDictProposal(fError, fLang, context.getSourceViewer()); return props; }
/** * Computes and returns reference-proposals (labels). * * @param offset * Current cursor offset * @param replacementLength * The length of the string to be replaced * @param prefix * The already typed prefix of the entry to assist with * @return An array of completion proposals to use directly or null */ private ICompletionProposal[] computeRefCompletions(int offset, int replacementLength, String prefix) { List<ReferenceEntry> refEntries = refManager.getCompletionsRef(prefix); if (refEntries == null) return null; ICompletionProposal[] result = new ICompletionProposal[refEntries .size()]; for (int i = 0; i < refEntries.size(); i++) { String infoText = null; ReferenceEntry ref = refEntries.get(i); if (ref.info != null) { infoText = (ref.info.length() > assistLineLength) ? wrapString( ref.info, assistLineLength) : ref.info; } result[i] = new CompletionProposal(ref.key, offset - replacementLength, replacementLength, ref.key.length(), null, ref.key, null, infoText); } return result; }
private Collection<? extends ICompletionProposal> addHeaderAttributes(String oldWord, int offset) { int bracketPos = StringUtils.lastIndexOf(oldWord, "["); int wordLength = oldWord.length(); int replacementPos = wordLength - bracketPos; String word = StringUtils.substringAfterLast(oldWord, "["); List<String> keywords = Formatter.IMPEX_KEYWORDS_ATTRIBUTES; Collection<ICompletionProposal> result = Lists.newArrayList(); for (String keyword : keywords) { if (keyword.toUpperCase(Locale.ENGLISH).startsWith(word.toUpperCase(Locale.ENGLISH)) && word.length() < keyword.length()) { result.add(new CompletionProposal(keyword + "=", (offset - replacementPos) + 1, word.length(), keyword.length() + 1)); } } return result; }
private ICompletionProposal[] attributeProposals(int cursorPosition, List<String> autoSuggests, String currentPart) { int counter = 0; ICompletionProposal[] proposals = new ICompletionProposal[autoSuggests.size()]; for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) { String autoSuggest = (String)iter.next(); if (currentPart.endsWith(";") || currentPart.endsWith("(")) { proposals[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length()); } else { int bracketStart = currentPart.indexOf("("); if (bracketStart > 0) { int a = (cursorPosition + 1) - (currentPart.length() - bracketStart); int b = currentPart.length() - (bracketStart + 1); int c = autoSuggest.length(); proposals[counter] = new CompletionProposal(autoSuggest, a, b, c); } else { proposals[counter] = new CompletionProposal(autoSuggest, cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length()); } } counter++; } return proposals; }
private ICompletionProposal[] attributeProposals(int cursorPosition, List<String> autoSuggests, String thisAttrib, String currentPart, boolean endingSemiColon) { int counter = 0; ICompletionProposal[] suggestions = new ICompletionProposal[autoSuggests.size()]; for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) { String autoSuggest = (String)iter.next(); //Each proposal contains the text to propose, as well as information about where to insert the text into the document. if (thisAttrib.endsWith(";") || thisAttrib.endsWith("(") || !endingSemiColon) { suggestions[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length()); } else { suggestions[counter] = new CompletionProposal(autoSuggest, cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length()); } counter++; } return suggestions; }
/** * Returns proposals from all variables with given prefix. */ private ICompletionProposal[] getVariableProposals(String aPrefix, int anOffset) { ICompletionProposal[] result = null; List variables = fEditor.getVariables(fEditor.getLine(anOffset)); if (!variables.isEmpty()) { List proposals = new ArrayList(); Iterator iter = variables.iterator(); while (iter.hasNext()) { String variable = (String) iter.next(); if (variable.substring(1).startsWith(aPrefix)) { proposals.add(new CompletionProposal(variable.substring(1), anOffset, aPrefix.length(), variable.length() - 1, null, variable, null, null)); } } Collections.sort(proposals, proposalComparator); result = (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]); } return result; }
@Override public ICompletionProposal[] computeCompletionProposals( ITextViewer viewer, int offset) { List<ICompletionProposal> proposals = new ArrayList<>(); for (String[] texts : PROPOSAL_TEXTS) { String replacement = texts[0]; String text = texts[1]; CompletionProposal proposal = new CompletionProposal(replacement, offset, replacement.length(), replacement.length(), null, text, new ContextInformation(replacement, text), null); proposals.add(proposal); } return proposals.toArray(new ICompletionProposal[proposals.size()]); }
/** * Create a completion proposal with normal properties. * * @param replacementString The string to replace * @param replacetmentOffset Where to replace from * @param replacementLength How long is the replacement * @param cursorPosition The cursor position after completion * @param image The icon to display with the proposal * @param displayString The string to display in the proposal * @param additionalProposalInfo Detailed info to be displayed in a popup. * @param type The type of this proposal */ public ZCompletionProposal( String replacementString, int replacetmentOffset, int replacementLength, int cursorPosition, Image image, String displayString, String additionalProposalInfo, Type type ) { this.wrapped = new CompletionProposal( replacementString, replacetmentOffset, replacementLength, cursorPosition, image, displayString, null, additionalProposalInfo ); this.type = type; }
/** * addCompletionProposalsForCategory * * @param viewer * @param offset * @param index * @param completionProposals * @param category */ protected void addCompletionProposalsForCategory(ITextViewer viewer, int offset, Index index, List<ICompletionProposal> completionProposals, String category) { List<QueryResult> queryResults = index.query(new String[] { category }, "", SearchPattern.PREFIX_MATCH); //$NON-NLS-1$ if (queryResults != null) { for (QueryResult queryResult : queryResults) { String text = queryResult.getWord(); int length = text.length(); String info = category + " : " + text; //$NON-NLS-1$ completionProposals.add(new CompletionProposal(text, offset, 0, length, null, text, null, info)); } } }
static List<ICompletionProposal> calculateProposalsForEmptyString(final StringLiteral stringLiteral, final int documentOffset) throws IOException { List<ICompletionProposal> sss = new ArrayList<ICompletionProposal>(); File[] listRoots = File.listRoots(); for (File file2 : listRoots) { long startInLoop = System.currentTimeMillis(); String string = file2.getAbsolutePath(); string = string.replace("\\", "/"); sss.add(new CompletionProposal(string, stringLiteral.getStartPosition() + 1, stringLiteral.getLiteralValue().length(), string.length())); startInLoop = System.currentTimeMillis() - startInLoop; startInLoop = startInLoop / 1000; if (startInLoop > 2) { LOG.info("listing take too much time " + startInLoop + " " + file2.getAbsolutePath()); } } LOG.info("returning roots " + sss); return sss; }
private void proposeStatementId(ContentAssistRequest contentAssistRequest, IJavaProject project, String matchString, int start, int length, IDOMNode node) throws JavaModelException, XPathExpressionException { final List<ICompletionProposal> results = new ArrayList<ICompletionProposal>(); final MethodNameStore methodStore = new MethodNameStore(); String qualifiedName = MybatipseXmlUtil.getNamespace(node.getOwnerDocument()); JavaMapperUtil.findMapperMethod(methodStore, project, qualifiedName, new RejectStatementAnnotation(matchString, false)); for (String methodName : methodStore.getMethodNames()) { results.add(new CompletionProposal(methodName, start, length, methodName.length(), Activator.getIcon(), methodName, null, null)); } addProposals(contentAssistRequest, results); }
/** * @param columns * @return */ private ICompletionProposal[] convertColumnsToCompletionProposals( ArrayList columns, int offset ) { if ( columns.size( ) > 0 ) { ICompletionProposal[] proposals = new ICompletionProposal[columns.size( )]; Iterator iter = columns.iterator( ); int n = 0; while ( iter.hasNext( ) ) { Column column = (Column) iter.next( ); proposals[n++] = new CompletionProposal( addQuotes( column.getName( ) ), offset, 0, column.getName( ).length( ) ); } return proposals; } return null; }
/** * @param tables * @return */ private ICompletionProposal[] convertTablesToCompletionProposals( ArrayList tables, int offset ) { if ( tables.size( ) > 0 ) { ICompletionProposal[] proposals = new ICompletionProposal[tables.size( )]; Iterator iter = tables.iterator( ); int n = 0; while ( iter.hasNext( ) ) { Table table = (Table) iter.next( ); proposals[n++] = new CompletionProposal( addQuotes( table.getName( ) ), offset, 0, table.getName( ).length( ) ); } return proposals; } return null; }
protected CompletionProposal[] getCompletionProposals( JSObjectMetaData[] metas, int offset ) { List<CompletionProposal> proposals = new ArrayList<CompletionProposal>( ); int wordLength = currentWord == null ? 0 : currentWord.length( ); for ( int i = 0; i < metas.length; i++ ) { if ( currentWord == null || currentWord.equals( "" ) //$NON-NLS-1$ || metas[i].getName( ) .toLowerCase( ) .startsWith( currentWord.toLowerCase( ) ) ) { proposals.add( new CompletionProposal( metas[i].getName( ), offset - wordLength, wordLength, metas[i].getName( ).length( ), null, metas[i].getName( ), null, metas[i].getDescription( ) ) ); } } return proposals.toArray( new CompletionProposal[proposals.size( )] ); }
public void testCompareWithUnder() throws Exception { List<ICompletionProposal> props = new ArrayList<ICompletionProposal>(); props.add(new CompletionProposal("_foo1(a, b)", 0, 0, 0)); props.add(new CompletionProposal("__foo1__", 0, 0, 0)); props.add(new CompletionProposal("__foo1__()", 0, 0, 0)); props.add(new CompletionProposal("__foo1()", 0, 0, 0)); props.add(new CompletionProposal("__foo1 - __something__", 0, 0, 0)); String qualifier = "_"; boolean onlyForCalltips = false; ICompletionProposal[] proposals = PyCodeCompletionUtils.onlyValid(props, qualifier, onlyForCalltips, false, null); PyCodeCompletionUtils.sort(proposals, qualifier, null); compare(new String[] { "_foo1(a, b)", "__foo1 - __something__", "__foo1()", "__foo1__", "__foo1__()", }, proposals); }
private ICompletionProposal createProposal(PySelection ps, ImageCache imageCache, PyEdit edit, final String startIndent, IRegion region, int iComp, String comp, TemplateContext context) { Template t = new Template("Surround with", SURROUND_WITH_COMPLETIONS[iComp + 1], "", comp, false); if (context != null) { TemplateProposal proposal = new TemplateProposal(t, context, region, imageCache.get(UIConstants.COMPLETION_TEMPLATE), 5) { @Override public String getAdditionalProposalInfo() { return startIndent + super.getAdditionalProposalInfo(); } }; return proposal; } else { //In tests return new CompletionProposal(comp, region.getOffset(), region.getLength(), 0); } }
static List<ICompletionProposal> createProposals(String[] choices, int offset, String prefix, String postfix, int cursorOffset, int replacementLen, ProposalIcon icon) { List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(); for (String choice : choices) { int len = choice.length(); String display = choice; if (postfix != null) { choice = choice + postfix; } if (prefix != null) { choice = prefix + choice; } CompletionProposal proposal = createProposal(display, choice, offset - replacementLen, len + cursorOffset, len, replacementLen, icon); proposals.add(proposal); } return proposals; }
@Override public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { try { String lastWord = getLastWord(viewer, offset).toUpperCase(); List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(); if(TEMPLATE_RULE_TEXT.startsWith(lastWord) && !TEMPLATE_RULE_TEXT.equals(lastWord)) { proposals.add(createRuleTemplate(viewer.getDocument(), offset - lastWord.length())); } for(String keyword: PROPOSAL_RULE_KEYWORDS){ if(keyword.startsWith(lastWord) && !keyword.equals(lastWord)){ proposals.add(new CompletionProposal( keyword, offset - lastWord.length(), lastWord.length(), keyword.length())); } } return proposals.toArray(new ICompletionProposal[proposals.size()]); } catch(Exception e){ BytemanEditorPlugin.logException(e); } return null; }
public static CompletionProposal build(PropertyKeySuggestion suggestion, int offset, int currentWordLength) { String completion = suggestion.getSuggestion() + "=" + suggestion.getDefaultValue(); String displayName = completion; String imgCode = ModulesUICoreImages.AUTOCOMLETE_ATTRIBUTE; Image image = ModulesUICoreImages.getImage(imgCode); int completionLength = StringUtils.length(completion); return new CompletionProposal( completion, offset - currentWordLength, currentWordLength, completionLength, image, displayName, null, suggestion.getDescription()); }
public static CompletionProposal build(GroovyCompletionSuggestion suggestion, int offset, int currentWordLength) { String completion = buildCompletion(suggestion); String displayName = buildDisplayName(suggestion); Image image = buildImage(suggestion); int completionLength = StringUtils.length(completion); return new CompletionProposal( completion, offset - currentWordLength, currentWordLength, completionLength, image, displayName, null, suggestion.getSuggestionDescription()); }
@Override public void apply(IDocument document) { initIfNeeded(); CompletionProposal proposal = new CompletionProposal(getReplacementString(), getReplacementOffset(), getReplacementLength(), getCursorPosition(), getImage(), getDisplayString(), getContextInformation(), getAdditionalProposalInfo()); proposal.apply(document); }
public static ComparableCompletionProposal toCompletionProposal(IDocument document, int offset, int replacement, String variable, int priority) { String replacementString = "<<" + variable + ",>>"; return new ComparableCompletionProposal( new CompletionProposal(replacementString, offset - replacement, replacement, replacementString.length() - 2, Activator.getDefault().getImage("/icons/completion-gotoanchor.png"), replacementString + " - Add link to anchor", null, null), priority); }
/** * Adding http 1.1 headers proposals */ public static void doHttpHeadersProposals( int offset, String qualifier, List proposalsList){ List httpHeaders = LazyObjects.getHttpHeaders(); int qlen = qualifier.length(); for (Iterator iter = httpHeaders.iterator(); iter.hasNext();) { String text = (String) iter.next(); if (text.toLowerCase().startsWith(qualifier.toLowerCase())) { int cursor = text.length(); CompletionProposal cp = new CompletionProposal(text + AssistConstants.BRACKETS_COMPLETION, offset - qlen, qlen, cursor + 4, ResourceUtils.getImage(CoreConstants.PLUGIN_CORE, CoreImages.ASSIST_HEADER), text, null, LazyObjects.getInfoMap("Headers").getInfo(text)); proposalsList.add(cp); } } }
private static void buildWordTrackProposals( List suggestions, String replacedWord, int offset, List proposalsList){ int index = 0; for (Iterator i = suggestions.iterator(); i.hasNext();) { String currSuggestion = (String) i.next(); proposalsList.add( new CompletionProposal(currSuggestion, offset, replacedWord.length(), currSuggestion.length(), ResourceUtils.getImage(CoreConstants.PLUGIN_CORE, CoreImages.ASSIST_HEADER_CACHED), currSuggestion, null, LazyObjects.getInfoMap("Headers").getInfo(currSuggestion))); index++; } }
private ICompletionProposal[] buildProposals( List suggestions, String replacedWord, int offset){ ICompletionProposal[] proposals = new ICompletionProposal[suggestions.size()]; int index = 0; for (Iterator i = suggestions.iterator(); i.hasNext();) { String currSuggestion = (String) i.next(); proposals[index] = new CompletionProposal(currSuggestion, offset, replacedWord.length(), currSuggestion.length()); index++; } return proposals; }
private static CompletionProposal[] getModelElementProposals(List<ModelElementCompletion> modelElements, int replacementOffset, int replacementLength) { CompletionProposal[] result = new CompletionProposal[modelElements.size()]; int i = 0; for (ModelElementCompletion e : modelElements) { result[i] = new CompletionProposal(e.getPatch(), replacementOffset, replacementLength, e.getPatch().length()); i++; } return result; }
@Override public ICompletionProposal[] getChoices() { CompletionProposal[] choices = createCompletionProposals(offset, variable.getType(), context.getCurrentTemplate().getPattern(), context.getDocument().get()); ICompletionProposal[] result = createPositionBasedProposals(offset, variable, choices); return result; }
public static CompletionProposal[] createCompletionProposals(int completionOffset, String variableType, String pattern, String currentText) { debug("* variable resolver *"); int replacementLength = 0; // TODO length of selected text actually CompletionProposal[] proposals; String patchedText = StringUtil.insert(currentText, completionOffset, prepareForParsing(pattern)); // + 2 : in prepareForParsing e.g. "${t}" gets changed to " t " // so the index must be at "t" rather than "$" int variablePosition = completionOffset + (pattern.indexOf(String.format("${%s}", variableType))) + 2; if (variableType.startsWith(LEADING_CHAR_COLUMNVAR)) { String patch = DUMMY_COLNAME; CompletionProposal dummyProposal = new CompletionProposal(patch, variablePosition, replacementLength, patch.length()); // 2 dummy proposals needed to trigger the use of a TweakedProposalPosition in TweakedTemplateProposal // no handling of this kind for tables, though, to cover the case where there's one table only too proposals = new CompletionProposal[] { dummyProposal, dummyProposal }; } else { debug(String.format("table at %d ", variablePosition)); debug("pattern: " + pattern); debug(String.format("completion offset %d, variable type %s calculated variable position %d", completionOffset, variableType, variablePosition)); debug("patched query for parsing: " + patchedText); proposals = FtcCompletionProcessor.getModelElementProposals(patchedText, variablePosition, replacementLength); debug(String.format("%d proposals", proposals.length)); } return proposals; }
private void proposeHeaderOperands(int offset, IDocument document, List<ICompletionProposal> proposals) { String line = getCurrentLine(document, offset); if (!containsHeader(line)) { for (String keyword : Formatter.HEADER_MODE_PROPOSALS) { proposals.add(new CompletionProposal(keyword + " ", offset, 0, keyword.length() + 1)); } } }
private ICompletionProposal[] typeProposals(int cursorPosition, List<String> autoSuggests, String currentPart) { int counter = 0; ICompletionProposal[] proposals = new ICompletionProposal[autoSuggests.size()]; for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) { String autoSuggest = (String)iter.next(); //Each proposal contains the text to propose, as well as information about where to insert the text into the document. proposals[counter] = new CompletionProposal(autoSuggest + ";", cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length() + 1); counter++; } return proposals; }
private ICompletionProposal[] keywordProposals(int cursorPosition, List<String> autoSuggests, String currentPart, boolean includeEquals, boolean includesComma) { int counter = 0; ICompletionProposal[] proposals = new ICompletionProposal[autoSuggests.size()]; for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) { String autoSuggest = (String)iter.next(); if (currentPart.endsWith("[")) { proposals[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition, 0, autoSuggest.length() + 1); } else { if (includeEquals) { if (includesComma) { proposals[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition, 0, autoSuggest.length() + 1); } else { proposals[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length() + 1); } } else if (includesComma) { if (currentPart.endsWith("=")) { proposals[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length()); } else { proposals[counter] = new CompletionProposal(autoSuggest, cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length() + 1); } } else { proposals[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length()); } } counter++; } return proposals; }
private ICompletionProposal[] typeProposals(int cursorPosition, List<String> autoSuggests, String thisAttrib, String currentPart) { int counter = 0; ICompletionProposal[] suggestions = new ICompletionProposal[autoSuggests.size()]; for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) { String autoSuggest = (String)iter.next(); //Each proposal contains the text to propose, as well as information about where to insert the text into the document. suggestions[counter] = new CompletionProposal(autoSuggest + ";", cursorPosition - thisAttrib.length(), thisAttrib.length(), autoSuggest.length() + 1); counter++; } return suggestions; }
private ICompletionProposal[] keywordProposals(int cursorPosition, List<String> autoSuggests, String thisAttrib, String currentPart, boolean includeEquals, boolean includesComma) { int counter = 0; ICompletionProposal[] suggestions = new ICompletionProposal[autoSuggests.size()]; for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) { String autoSuggest = (String)iter.next(); //Each proposal contains the text to propose, as well as information about where to insert the text into the document. if (thisAttrib.endsWith("[")) { suggestions[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition, 0, autoSuggest.length() + 1); } else { if (includeEquals) { if (includesComma) { suggestions[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition, 0, autoSuggest.length() + 1); } else { suggestions[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length() + 1); } } else if (includesComma) { if (thisAttrib.endsWith("=")) { suggestions[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length()); } else { suggestions[counter] = new CompletionProposal(autoSuggest, cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length() + 1); } } else { suggestions[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length()); } } counter++; } return suggestions; }