当前位置: 首页>>代码示例>>Java>>正文


Java CompletionProposalInvocationContext.getInvocationOffset方法代码示例

本文整理汇总了Java中org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext.getInvocationOffset方法的典型用法代码示例。如果您正苦于以下问题:Java CompletionProposalInvocationContext.getInvocationOffset方法的具体用法?Java CompletionProposalInvocationContext.getInvocationOffset怎么用?Java CompletionProposalInvocationContext.getInvocationOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext的用法示例。


在下文中一共展示了CompletionProposalInvocationContext.getInvocationOffset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeCompletionProposals

import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext; //导入方法依赖的package包/类
/**
 * <p>
 * This does all the magic of figuring out where in the JSON type document
 * the content assist was invoked and then calling the corresponding method
 * to add the correct proposals
 * </p>
 * 
 * <p>
 * <b>NOTE: </b>if overriding be sure to make super call back to this method
 * otherwise you will loose all of the proposals generated by this method
 * </p>
 * 
 * @param matchString
 * @param completionRegion
 * @param treeNode
 * @param xmlnode
 * @param context
 * 
 * @return {@link ContentAssistRequest} that now has all the proposals in it
 */
protected ContentAssistRequest computeCompletionProposals(
		String matchString, ITextRegion completionRegion,
		IJSONNode treeNode, IJSONNode xmlnode,
		CompletionProposalInvocationContext context) {

	int documentPosition = context.getInvocationOffset();

	ContentAssistRequest contentAssistRequest = null;
	String regionType = completionRegion.getType();
	IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);

	// Handle the most common and best supported cases
	if ((xmlnode.getNodeType() == IJSONNode.OBJECT_NODE)) {
		if (regionType == JSONRegionContexts.JSON_OBJECT_OPEN
				|| regionType == JSONRegionContexts.JSON_OBJECT_CLOSE
				|| regionType == JSONRegionContexts.JSON_COMMA) {
			contentAssistRequest = computeObjectKeyProposals(matchString,
					completionRegion, treeNode, xmlnode, context);
		}
	} else if ((xmlnode.getNodeType() == IJSONNode.PAIR_NODE)) {
		if (regionType == JSONRegionContexts.JSON_OBJECT_KEY) {
			contentAssistRequest = computeObjectKeyProposals(matchString,
					completionRegion, treeNode, xmlnode, context);
		}
	}
	return contentAssistRequest;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:48,代码来源:AbstractJSONCompletionProposalComputer.java

示例2: computeObjectKeyProposals

import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext; //导入方法依赖的package包/类
private ContentAssistRequest computeObjectKeyProposals(String matchString,
		ITextRegion completionRegion, IJSONNode nodeAtOffset,
		IJSONNode node, CompletionProposalInvocationContext context) {
	int documentPosition = context.getInvocationOffset();
	ContentAssistRequest contentAssistRequest = null;
	IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);

	int replaceLength = 0;
	int begin = documentPosition;
	if (completionRegion.getType() == JSONRegionContexts.JSON_OBJECT_KEY) {
		replaceLength = completionRegion.getTextLength();
		// if container region, be sure replace length is only the attribute
		// value region not the entire container
		if (completionRegion instanceof ITextRegionContainer) {
			ITextRegion openRegion = ((ITextRegionContainer) completionRegion)
					.getFirstRegion();
			ITextRegion closeRegion = ((ITextRegionContainer) completionRegion)
					.getLastRegion();
			if (openRegion.getType() != closeRegion.getType()) {
				replaceLength = openRegion.getTextLength();
			}
		}
		begin = sdRegion.getStartOffset(completionRegion);
	}

	contentAssistRequest = new ContentAssistRequest(nodeAtOffset,
			node.getParentNode(), sdRegion, completionRegion, begin,
			replaceLength, matchString);
	addObjectKeyProposals(contentAssistRequest, context);
	return contentAssistRequest;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:32,代码来源:AbstractJSONCompletionProposalComputer.java

示例3: processCSSCompletion

import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext; //导入方法依赖的package包/类
/**
 * Process completion for CSS class name or id.
 * 
 * @param contentAssistRequest
 * @param context
 * @param attrValue
 * @param attrValueRegion
 */
private void processCSSCompletion(
		ContentAssistRequest contentAssistRequest,
		CompletionProposalInvocationContext context, String attrValue,
		WebResourcesTextRegion attrValueRegion, IProgressMonitor monitor) {
	CSSContentAssistTraverser traverser = new CSSContentAssistTraverser(
			contentAssistRequest, context.getInvocationOffset(), attrValue,
			attrValueRegion.getType());
	traverser.process(monitor);
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:18,代码来源:WebResourcesCompletionProposalComputer.java

示例4: computeCompletionProposals

import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext; //导入方法依赖的package包/类
@Override
protected ContentAssistRequest computeCompletionProposals(
		String matchString, ITextRegion completionRegion,
		IDOMNode treeNode, IDOMNode xmlnode,
		CompletionProposalInvocationContext context) {
	String regionType = completionRegion.getType();
	boolean isXMLContent = (regionType == DOMRegionContext.XML_CONTENT);
	if (isXMLContent && AngularDOMUtils.hasAngularNature(xmlnode)) {

		// completion for Angular expression {{}} inside text node.
		int documentPosition = context.getInvocationOffset();
		IStructuredDocumentRegion documentRegion = DOMUIUtils
				.getStructuredDocumentRegion(context.getViewer(),
						documentPosition);

		String match = null;
		AngularELRegion angularRegion = AngularRegionUtils
				.getAngularELRegion(documentRegion, documentPosition,
						DOMUtils.getFile(treeNode).getProject());
		if (angularRegion != null) {
			match = angularRegion.getExpression().substring(0,
					angularRegion.getExpressionOffset());
		}
		if (match != null) {
			ContentAssistRequest contentAssistRequest = new ContentAssistRequest(
					treeNode, treeNode.getParentNode(), documentRegion,
					completionRegion, documentPosition, 0, match);

			populateAngularProposals(contentAssistRequest, treeNode,
					context.getDocument(), AngularType.model, null);

			return contentAssistRequest;
		}
	}

	return super.computeCompletionProposals(matchString, completionRegion,
			treeNode, xmlnode, context);
}
 
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:39,代码来源:HTMLAngularTagsCompletionProposalComputer.java

示例5: computeCompletionProposals

import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext; //导入方法依赖的package包/类
/**
 * @return A list of ICompletionProposal
 */
@Override
public List<? extends Object> computeCompletionProposals(CompletionProposalInvocationContext context, IProgressMonitor monitor) {
	String document;
	if (context != null && rootElementParser.isConcordionSpec((document = context.getDocument().get()))) {
		int offset = context.getInvocationOffset();
		AssistContext assistContext = contextParser.findContext(document, offset, rootElementParser.getNamespacePrefix());
		IFile specFile = EclipseUtils.fileForModel(
			EclipseUtils.domModelForDocument(context.getDocument()));
		Assist assist = new Assist(specFile);
		return assist.provideProposal(assistContext, rootElementParser.getNamespacePrefix(), offset);
	}
	
	return Collections.emptyList();
}
 
开发者ID:sunix,项目名称:org.concordion.ide.eclipse,代码行数:18,代码来源:ConcordionContentAssistant.java

示例6: computeCompletionProposals

import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("rawtypes")
public List computeCompletionProposals(CompletionProposalInvocationContext context, IProgressMonitor monitor) {

	ArrayList<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();

	try {
		IDocument document = context.getDocument();
		int cursorposition = context.getInvocationOffset();
		Node node = (Node)ContentAssistUtils.getNodeAt(context.getViewer(), cursorposition);

		// Get all the known namespaces for this point in the document
		ArrayList<QName> namespaces = getNodeNamespaces(node);

		// Get the text entered before the cursor of this auto-completion invocation
		String pattern = getPattern(document, cursorposition);

		// Collect attribute processors if we're in an HTML element
		if (node instanceof IDOMElement) {
			
			// Make sure there's some whitespace before new attribute suggestions
			if (!pattern.isEmpty() || (pattern.isEmpty() && (cursorposition == 0 ||
					Character.isWhitespace(document.getChar(cursorposition - 1))))) {
				
				List<AttributeProcessor> processors = ProcessorCache.getAttributeProcessors(namespaces, pattern);
				for (AttributeProcessor processor: processors) {
					proposals.add(new AttributeProcessorCompletionProposal(processor,
							pattern.length(), cursorposition));
				}
			}

		}
	}
	catch (BadLocationException ex) {
		ex.printStackTrace();
	}

	return proposals;
}
 
开发者ID:tduchateau,项目名称:thymeleaf-eclipse-plugin,代码行数:43,代码来源:ProcessorCompletionProposalComputer.java


注:本文中的org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext.getInvocationOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。