protected void doCreateContexts( INode lastCompleteNode, INode currentNode, String prefix, EObject previousModel, Collection<FollowElement> followElements) { Set<AbstractElement> followElementAsAbstractElements = Sets.newLinkedHashSet(); computeFollowElements(followElements, followElementAsAbstractElements); Multimap<EObject, AbstractElement> contextMap = computeCurrentModel(previousModel, lastCompleteNode, followElementAsAbstractElements); currentNode = getContainingDatatypeRuleNode(currentNode); for (Entry<EObject, Collection<AbstractElement>> entry : contextMap.asMap().entrySet()) { ContentAssistContext.Builder contextBuilder = doCreateContext(lastCompleteNode, entry.getKey(), previousModel, currentNode, prefix); for(AbstractElement element: entry.getValue()) { contextBuilder.accept(element); } contextBuilders.add(contextBuilder); } }
public ContentAssistContext.Builder doCreateContext( INode lastCompleteNode, EObject currentModel, EObject previousModel, INode currentNode, String prefix) { ContentAssistContext.Builder context = contentAssistContextProvider.get(); context.setRootNode(rootNode); context.setLastCompleteNode(lastCompleteNode); context.setCurrentNode(currentNode); context.setRootModel(parseResult.getRootASTElement()); context.setCurrentModel(currentModel); context.setPreviousModel(previousModel); context.setOffset(completionOffset); context.setViewer(viewer); context.setPrefix(prefix); int regionLength = prefix.length(); if (selection.getLength() > 0) regionLength = regionLength + selection.getLength(); Region region = new Region(completionOffset - prefix.length(), regionLength); context.setReplaceRegion(region); context.setSelectedText(selection.getText()); context.setMatcher(matcher); context.setResource(resource); return context; }
protected void handleLastCompleteNodeHasNoGrammarElement(List<Builder> contextBuilderToCheck, EObject previousModel) throws BadLocationException { List<ContentAssistContext> newContexts = Lists.transform(contextBuilderToCheck, this); boolean wasValid = isLikelyToBeValidProposal(lastCompleteNode, newContexts); if (wasValid && !(lastCompleteNode instanceof ILeafNode && ((ILeafNode) lastCompleteNode).isHidden())) { createContextsForLastCompleteNode(previousModel, false); } }
@Override public Builder doCreateContext(INode lastCompleteNode, EObject currentModel, EObject previousModel, INode currentNode, String prefix) { if (currentModel == null) { currentModel = parseResult.getRootASTElement(); } Builder result = super.doCreateContext(lastCompleteNode, currentModel, previousModel, currentNode, prefix); return result; }
protected void initializeFromViewerAndResource(final int offset) { Runnable runnable = new Runnable() { @Override public void run() { initializeAndAdjustCompletionOffset(offset); initializeNodeAndModelData(); contextBuilders = Collections.synchronizedList(Lists.<ContentAssistContext.Builder>newArrayList()); } }; if (Display.getCurrent() == null) { Display.getDefault().syncExec(runnable); } else { runnable.run(); } }
public ContentAssistContext apply(Builder from) { return from.toContext(); }