Java 类org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext.Builder 实例源码

项目:bts    文件:ParserBasedContentAssistContextFactory.java   
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);
    }
}
项目:bts    文件:ParserBasedContentAssistContextFactory.java   
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;
}
项目:bts    文件:ParserBasedContentAssistContextFactory.java   
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);
    }
}
项目:statecharts    文件:STextStatefulFactory.java   
@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;
}
项目:statecharts    文件:STextStatefulFactory.java   
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();
    }
}
项目:bts    文件:ParserBasedContentAssistContextFactory.java   
public ContentAssistContext apply(Builder from) {
    return from.toContext();
}