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; }
public HydrographCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) { Assert.isNotNull(replacementString); Assert.isTrue(replacementOffset >= 0); Assert.isTrue(replacementLength >= 0); Assert.isTrue(cursorPosition >= 0); fReplacementString = replacementString; fReplacementOffset = replacementOffset; fReplacementLength = replacementLength; fCursorPosition = cursorPosition; fImage = image; fDisplayString = displayString; fContextInformation = contextInformation; fAdditionalProposalInfo = additionalProposalInfo; }
private void addProposal(ContentAssistRequest contentAssistRequest, String name, INgBindingType bindingType, String displayString, Image image, String additionalProposalInfo) { String alternateMatch = bindingType.formatAttr(name); StringBuilder replacementString = new StringBuilder(alternateMatch); if (!hasValue) { replacementString.append("=\"\""); } StringBuilder replacementStringCursor = new StringBuilder(alternateMatch); replacementStringCursor.append("=\"\""); int replacementOffset = contentAssistRequest.getReplacementBeginPosition(); int replacementLength = contentAssistRequest.getReplacementLength(); int cursorPosition = getCursorPositionForProposedText(replacementStringCursor.toString()); IContextInformation contextInformation = null; int relevance = XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME; ICompletionProposal proposal = new HTMLAngularCompletionProposal(replacementString.toString(), replacementOffset, replacementLength, cursorPosition, image, displayString, alternateMatch, contextInformation, additionalProposalInfo, relevance); contentAssistRequest.addProposal(proposal); }
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { // Retrieve selected range Point selectedRange = viewer.getSelectedRange(); if (selectedRange.y > 0) { // Text is selected. Create a context information array. ContextInformation[] contextInfos = new ContextInformation[ITLAReserveredWords.ALL_WORDS_ARRAY.length]; // Create one context information item for each style for (int i = 0; i < ITLAReserveredWords.ALL_WORDS_ARRAY.length; i++) contextInfos[i] = new ContextInformation(null, ITLAReserveredWords.ALL_WORDS_ARRAY[i] + " Style"); return contextInfos; } return new ContextInformation[0]; }
/** * Creates a new completion proposal. All fields are initialized based on the provided information. * * @param replacementString the actual string to be inserted into the document * @param replacementOffset the offset of the text to be replaced * @param replacementLength the length of the text to be replaced * @param cursorPosition the position of the cursor following the insert relative to replacementOffset * @param image the image to display for this proposal * @param displayString the string to be displayed for the proposal * @param contextInformation the context information associated with this proposal * @param additionalProposalInfo the additional information associated with this proposal */ public ConfigurableCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, StyledString displayString, IContextInformation contextInformation, String additionalProposalInfo) { Assert.isNotNull(replacementString); Assert.isTrue(replacementOffset >= 0); Assert.isTrue(replacementLength >= 0); Assert.isTrue(cursorPosition >= 0); this.replacementString= replacementString; this.replacementOffset= replacementOffset; this.replacementLength= replacementLength; this.cursorPosition= cursorPosition; this.selectionStart = replacementOffset + cursorPosition; this.image= image; this.displayString= displayString==null ? new StyledString(this.replacementString) : displayString; this.contextInformation= contextInformation; this.additionalProposalInfo= additionalProposalInfo; }
/** * Creates a context frame for the given offset. * * @param information * the context information * @param offset * the offset * @return the created context frame * @since 3.0 */ private ContextFrame createContextFrame(IContextInformation information, int offset) { IContextInformationValidator validator = fContentAssistSubjectControlAdapter.getContextInformationValidator( fContentAssistant, offset); if (validator != null) { int beginOffset = (information instanceof IContextInformationExtension) ? ((IContextInformationExtension) information) .getContextInformationPosition() : offset; if (beginOffset == -1) { beginOffset = offset; } int visibleOffset = fContentAssistSubjectControlAdapter.getWidgetSelectionRange().x - (offset - beginOffset); IContextInformationPresenter presenter = fContentAssistSubjectControlAdapter .getContextInformationPresenter(fContentAssistant, offset); return new ContextFrame(information, beginOffset, offset, visibleOffset, validator, presenter); } return null; }
/** * Returns an array of context information objects computed based on the specified document position. The position * is used to determine the appropriate code assist processor to invoke. * * @param viewer * the viewer for which to compute the context information * @param offset * a document offset * @return an array of context information objects * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int) */ IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { fLastErrorMessage = null; IContextInformation[] result = null; IContentAssistProcessor p = getProcessor(viewer, offset); if (p != null) { result = p.computeContextInformation(viewer, offset); fLastErrorMessage = p.getErrorMessage(); } return result; }
/** * Returns an array of context information objects computed based on the specified document position. The position * is used to determine the appropriate code assist processor to invoke. * * @param contentAssistSubjectControl * the code assist subject control * @param offset * a document offset * @return an array of context information objects * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int) * @since 3.0 */ IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubjectControl, int offset) { fLastErrorMessage = null; IContextInformation[] result = null; IContentAssistProcessor p = getProcessor(contentAssistSubjectControl, offset); if (p instanceof ISubjectControlContentAssistProcessor) { result = ((ISubjectControlContentAssistProcessor) p).computeContextInformation(contentAssistSubjectControl, offset); fLastErrorMessage = p.getErrorMessage(); } return result; }
/** * createProsal * * @param displayName * @param name * @param image * @param description * @param userAgents * @param fileLocation * @param offset * @param length * @return */ protected CommonCompletionProposal createProposal(String displayName, String name, Image image, String description, Image[] userAgents, String fileLocation, int offset, int length) { IContextInformation contextInfo = null; // TEMP: int replaceLength = 0; if (this._replaceRange != null) { offset = this._replaceRange.getStartingOffset(); replaceLength = this._replaceRange.getLength(); } // build proposal CommonCompletionProposal proposal = new CommonCompletionProposal(name, offset, replaceLength, length, image, displayName, contextInfo, description); proposal.setFileLocation(fileLocation); proposal.setUserAgentImages(userAgents); proposal.setTriggerCharacters(getProposalTriggerCharacters()); return proposal; }
/** * createProposal * * @param displayName * @param name * @param image * @param description * @param userAgents * @param fileLocation * @param offset * @return */ protected CommonCompletionProposal createProposal(String displayName, String name, Image image, String description, String[] userAgentIds, String fileLocation, int offset) { int length = name.length(); IContextInformation contextInfo = null; int replaceLength = 0; if (this._replaceRange != null) { offset = this._replaceRange.getStartingOffset(); replaceLength = this._replaceRange.getLength(); } // build proposal Image[] userAgents = UserAgentManager.getInstance().getUserAgentImages(getProject(), userAgentIds); CommonCompletionProposal proposal = new CommonCompletionProposal(name, offset, replaceLength, length, image, displayName, contextInfo, description); proposal.setFileLocation(fileLocation); proposal.setUserAgentImages(userAgents); proposal.setTriggerCharacters(getProposalTriggerCharacters()); return proposal; }
/** * createProposal * * @param displayName * @param name * @param image * @param description * @param userAgents * @param fileLocation * @param offset * @param length * @return */ protected CommonCompletionProposal createProposal(String displayName, String name, Image image, String description, String[] userAgentIds, String fileLocation, int offset, int length) { IContextInformation contextInfo = null; // TEMP: int replaceLength = 0; if (this._replaceRange != null) { offset = this._replaceRange.getStartingOffset(); replaceLength = this._replaceRange.getLength(); } Image[] userAgents = UserAgentManager.getInstance().getUserAgentImages(getProject(), userAgentIds); // build proposal CommonCompletionProposal proposal = new CommonCompletionProposal(name, offset, replaceLength, length, image, displayName, contextInfo, description); proposal.setFileLocation(fileLocation); proposal.setUserAgentImages(userAgents); return proposal; }
private List<IContextInformation> addContextInformations(JavaContentAssistInvocationContext context, int offset) { List<ICompletionProposal> proposals= internalComputeCompletionProposals(offset, context); List<IContextInformation> result= new ArrayList<IContextInformation>(proposals.size()); List<IContextInformation> anonymousResult= new ArrayList<IContextInformation>(proposals.size()); for (Iterator<ICompletionProposal> it= proposals.iterator(); it.hasNext();) { ICompletionProposal proposal= it.next(); IContextInformation contextInformation= proposal.getContextInformation(); if (contextInformation != null) { ContextInformationWrapper wrapper= new ContextInformationWrapper(contextInformation); wrapper.setContextInformationPosition(offset); if (proposal instanceof AnonymousTypeCompletionProposal) anonymousResult.add(wrapper); else result.add(wrapper); } } if (result.size() == 0) return anonymousResult; return result; }
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { clearState(); IProgressMonitor monitor= createProgressMonitor(); monitor.beginTask(JavaTextMessages.ContentAssistProcessor_computing_contexts, fCategories.size() + 1); monitor.subTask(JavaTextMessages.ContentAssistProcessor_collecting_contexts); List<IContextInformation> proposals= collectContextInformation(viewer, offset, monitor); monitor.subTask(JavaTextMessages.ContentAssistProcessor_sorting_contexts); List<IContextInformation> filtered= filterAndSortContextInformation(proposals, monitor); fNumberOfComputedResults= filtered.size(); IContextInformation[] result= filtered.toArray(new IContextInformation[filtered.size()]); monitor.done(); return result; }
/** * Creates a new completion proposal. All fields are initialized based on the provided information. * * @param replacementString the actual string to be inserted into the document * @param replacementOffset the offset of the text to be replaced * @param replacementLength the length of the text to be replaced * @param cursorPosition the position of the cursor following the insert relative to replacementOffset * @param image the image to display for this proposal * @param displayString the string to be displayed for the proposal * @param contextInformation the context information associated with this proposal * @param additionalProposalInfo the additional information associated with this proposal */ public Proposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) { Assert.isNotNull(replacementString); Assert.isTrue(replacementOffset >= 0); Assert.isTrue(replacementLength >= 0); Assert.isTrue(cursorPosition >= 0); fReplacementString= replacementString; fReplacementOffset= replacementOffset; fReplacementLength= replacementLength; fCursorPosition= cursorPosition; fImage= image; fDisplayString= displayString; fContextInformation= contextInformation; fAdditionalProposalInfo= additionalProposalInfo; }
/** * Creates a new proposal. */ public N4JSCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, StyledString displayString, IContextInformation contextInformation, String additionalProposalInfo) { super(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo); }
public IContextInformation[] computeContextInformation( ITextViewer viewer, int documentOffset){ // viewer.getSelectedRange(); // if (selectedRange.y > 0) Text is selected. Create a context information array. // ContextInformation[] contextInfos = new // ContextInformation[STYLELABELS.length]; // // Create one context information item for each style // for (int i = 0; i < STYLELABELS.length; i++) // contextInfos[i] = new ContextInformation("<" + STYLETAGS[i] + ">", // STYLELABELS[i] + " Style"); // return contextInfos; // } return new ContextInformation[0]; }
/** * Creates a new completion proposal. All fields are initialized based on the provided information. * * @param replacementString the actual string to be inserted into the document * @param replacementOffset the offset of the text to be replaced * @param replacementLength the length of the text to be replaced * @param cursorPosition the position of the cursor following the insert relative to replacementOffset * @param displayString the string to be displayed for the proposal * @param contextInformation the context information associated with this proposal */ public SimpleCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, String displayString, IContextInformation contextInformation) { Assert.isNotNull(replacementString); Assert.isTrue(replacementOffset >= 0); Assert.isTrue(replacementLength >= 0); Assert.isTrue(cursorPosition >= 0); fReplacementString= replacementString; fReplacementOffset= replacementOffset; fReplacementLength= replacementLength; fCursorPosition= cursorPosition; fDisplayString= displayString; fContextInformation= contextInformation; }
/** * Returns the style context. * * @return Array of style contexts */ public IContextInformation[] getStyleContext() { ContextInformation[] contextInfos = new ContextInformation[STYLELABELS.length]; // Create one context information item for each style for (int i = 0; i < STYLELABELS.length; i++) { contextInfos[i] = new ContextInformation(null, STYLELABELS[i]+" Style"); } return contextInfos; }
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { // FIXME -- for testing // Retrieve selected range Point selectedRange = viewer.getSelectedRange(); if (selectedRange.y > 0) { if (styleManager == null) { styleManager = TexStyleCompletionManager.getInstance(); } return styleManager.getStyleContext(); } return new ContextInformation[0]; }
public HTMLAngularCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, String alternateMatch, IContextInformation contextInformation, String additionalProposalInfo, int relevance) { super(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, alternateMatch, contextInformation, additionalProposalInfo, relevance, true); }
private IContextInformation[] merge(IContextInformation[] information1, IContextInformation[] information2) { IContextInformation[] information = information1; if (information1 == null) { information = information2; } else if (information2 == null) { information = information1; } else { information = new IContextInformation[information1.length + information2.length]; System.arraycopy(information1, 0, information, 0, information1.length); System.arraycopy(information2, 0, information, information1.length, information2.length); } return information; }
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { IContextInformation[] allInformation = null; for (IContentAssistProcessor delegate : delegates) { IContextInformation[] information = delegate.computeContextInformation(viewer, offset); allInformation = merge(allInformation, information); } return allInformation; }
@Override public IContextInformation getContextInformation() { if (contextInformationComputed) { return contextInformation; } this.contextInformation = createContextInformation(); contextInformationComputed = true; return contextInformation; }
private IContextInformation createContextInformation() { try { String information = null; List<CompletionEntryDetails> entryDetails = super.getEntryDetails(); if (entryDetails == null || entryDetails.size() < 1) { return null; } if (isFunction()) { information = TypeScriptHelper.extractFunctionParameters(entryDetails.get(0).getDisplayParts()); } return information != null ? new ContextInformation("", information) : null; } catch (TypeScriptException e) { } return null; }
public boolean isContextInformationValid(int offset) { if (fContextInformation instanceof ISmartContextInformation) { return ((ISmartContextInformation) fContextInformation).isContextInformationValid(fViewer, offset); } else { IContextInformation[] infos= fProcessor.computeContextInformation(fViewer, offset); if (infos != null && infos.length > 0) { for (int i= 0; i < infos.length; i++) if (fContextInformation.equals(infos[i])) return true; } return false; } }
public IContextInformation[] computeContextInformation(final ITextViewer viewer, final int offset) { if (contextInformationProvider == null) return null; IXtextDocument document = (IXtextDocument) viewer.getDocument(); return document.readOnly(createContextInformationComputer(viewer, offset)); }
public ContextInformationComputer(State state, ITextViewer viewer, int offset) { super(); this.information = new LinkedHashSet<IContextInformation>(); this.state = state; this.offset = offset; this.viewer = viewer; }
public IContextInformation[] exec(XtextResource resource) throws Exception { IContextInformationAcceptor acceptor = state.decorateAcceptor(this); ContentAssistContext[] contexts = state.getContextFactory().create(viewer, offset, resource); for (ContentAssistContext context: contexts) { if (acceptor.canAcceptMoreInformation()) state.getContextInformationProvider().getContextInformation(context, acceptor); } if (information.isEmpty()) return null; return information.toArray(new IContextInformation[information.size()]); }
private CompletionProposal newCompletionProposal(final String proposal, final String displayName, final int documentOffset, final int qlen, final String imageID, final int offset, final String description) { final Image image = JavaUI.getSharedImages().getImage(imageID); final IContextInformation contextInformation = new ContextInformation(proposal, description); return new CompletionProposal(proposal, documentOffset - qlen, qlen, proposal.length() - (-offset), image, displayName, contextInformation, description); }
/** * Context info is done by the PopupManager class, we don't use Eclipse's * built in context stuff. */ /* Override */ public IContextInformation[] computeContextInformation( ITextViewer viewer, int offset ) { return null; }
public JSONKeyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo, int relevance) { super(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, relevance); }
public ContextFrame(IContextInformation information, int beginOffset, int offset, int visibleOffset, IContextInformationValidator validator, IContextInformationPresenter presenter) { fInformation = information; fBeginOffset = beginOffset; fOffset = offset; fVisibleOffset = visibleOffset; fValidator = validator; fPresenter = presenter; }
/** * Displays the given context information for the given offset. * * @param info * the context information * @param offset * the offset * @since 2.0 */ public void showContextInformation(final IContextInformation info, final int offset) { Control control = fContentAssistSubjectControlAdapter.getControl(); BusyIndicator.showWhile(control.getDisplay(), new Runnable() { public void run() { if (info == null) { validateContextInformation(); } else { ContextFrame frame = createContextFrame(info, offset); if (isDuplicate(frame)) { validateContextInformation(); } else { internalShowContextInfo(frame); } hideContextSelector(); } } }); }
/** * Sets the contexts in the context selector to the given set. * * @param contexts * the possible contexts */ private void setContexts(IContextInformation[] contexts) { if (Helper.okToUse(fContextSelectorTable)) { fContextSelectorInput = contexts; fContextSelectorTable.setRedraw(false); fContextSelectorTable.removeAll(); TableItem item; IContextInformation t; for (int i = 0; i < contexts.length; i++) { t = contexts[i]; item = new TableItem(fContextSelectorTable, SWT.NULL); if (t.getImage() != null) { item.setImage(t.getImage()); } item.setText(t.getContextDisplayString()); } fContextSelectorTable.select(0); fContextSelectorTable.setRedraw(true); } }
/** * addProposal - The display name is used as the insertion text * * @param proposals * @param displayName * @param image * @param description * @param userAgents * @param fileLocation * @param offset */ private void addProposal(Set<ICompletionProposal> proposals, String displayName, Image image, String description, String[] userAgentIds, String fileLocation, int offset) { if (isActiveByUserAgent(userAgentIds)) { int length = displayName.length(); // calculate what text will be replaced int replaceLength = 0; replaceLength = replaceStr.length(); offset = offset - replaceLength; IContextInformation contextInfo = null; Image[] userAgents = UserAgentManager.getInstance().getUserAgentImages(getProject(), userAgentIds); CommonCompletionProposal proposal = new CommonCompletionProposal(displayName, offset, replaceLength, length, image, displayName, contextInfo, description); proposal.setFileLocation(fileLocation); proposal.setUserAgentImages(userAgents); proposal.setTriggerCharacters(getProposalTriggerCharacters()); // add the proposal to the list proposals.add(proposal); } }
private void addApicloudRequire(Set<ICompletionProposal> proposals, String displayName, String replaceName, Image image, String description, String[] userAgentIds, String fileLocation, int offset) { if (isActiveByUserAgent(userAgentIds)) { int length = replaceName.length(); // calculate what text will be replaced int replaceLength = 0; // if (replaceRange != null) // { // offset = replaceRange.getStartingOffset(); // $codepro.audit.disable questionableAssignment // replaceLength = replaceRange.getLength(); // } else { replaceLength = replaceStr.length(); offset = offset - replaceLength; // } // build proposal IContextInformation contextInfo = null; Image[] userAgents = UserAgentManager.getInstance().getUserAgentImages(getProject(), userAgentIds); CommonCompletionProposal proposal = new CommonCompletionProposal(replaceName, offset, replaceLength, length - 3, image, displayName, contextInfo, description); proposal.setFileLocation(fileLocation); proposal.setUserAgentImages(userAgents); proposal.setTriggerCharacters(getProposalTriggerCharacters()); // add the proposal to the list proposals.add(proposal); } }
private void addApicloudProposal(Set<ICompletionProposal> proposals, String displayName, String replaceName, Image image, String description, String[] userAgentIds, String fileLocation, int offset) { if (isActiveByUserAgent(userAgentIds)) { int length = replaceName.length(); // calculate what text will be replaced int replaceLength = 0; // if (replaceRange != null) // { // offset = replaceRange.getStartingOffset(); // $codepro.audit.disable questionableAssignment // replaceLength = replaceRange.getLength(); // System.out.println("replaceLength============================" + replaceLength); // } else { replaceLength = replaceStr.length(); offset = offset - replaceLength; // } // build proposal IContextInformation contextInfo = null; Image[] userAgents = UserAgentManager.getInstance().getUserAgentImages(getProject(), userAgentIds); CommonCompletionProposal proposal = new CommonCompletionProposal(replaceName, offset, replaceLength, length, image, displayName, contextInfo, description); proposal.setFileLocation(fileLocation); proposal.setUserAgentImages(userAgents); proposal.setTriggerCharacters(getProposalTriggerCharacters()); proposal.getContextInformation(); // add the proposal to the list proposals.add(proposal); } }
@Override public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { List<IContextInformation> result = new ArrayList<IContextInformation>(2); FunctionElement function = getFunctionElement(viewer, offset); if (function != null) { JSArgumentsNode node = getArgumentsNode(offset); if (node != null) { boolean inObjectLiteral = false; // find argument we're in for (IParseNode arg : node) { if (arg.contains(offset)) { // Not foolproof, but this should cover 99% of the cases we're likely to encounter inObjectLiteral = (arg instanceof JSObjectNode); break; } } // prevent context info popup from appearing and immediately disappearing if (!inObjectLiteral) { IContextInformation ci = new JSContextInformation(function, getProjectURI(), node.getStartingOffset()); result.add(ci); } } } return result.toArray(new IContextInformation[result.size()]); }
public void install(IContextInformation info, ITextViewer viewer, int offset) { this._contextInformation = info; this._viewer = viewer; if (info instanceof IContextInformationExtension) { this._startingOffset = ((IContextInformationExtension) info).getContextInformationPosition(); } else { this._startingOffset = offset; } }