• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ContentAssistUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ContentAssistUtils类属于org.eclipse.wst.sse.ui.internal.contentassist包,在下文中一共展示了ContentAssistUtils类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: computeHoverHelp

import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; //导入依赖的package包/类
/**
 * Retrieves documentation to display in the hover help popup.
 * 
 * @return String any documentation information to display <code>null</code>
 *         if there is nothing to display.
 * 
 */
protected String computeHoverHelp(ITextViewer textViewer,
		int documentPosition) {
	String result = null;

	IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer,
			documentPosition);
	if (treeNode == null) {
		return null;
	}
	IJSONNode node = (IJSONNode) treeNode;
	IJSONNode parentNode = node.getParentNode();

	IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer
			.getDocument()).getRegionAtCharacterOffset(documentPosition);
	if (flatNode != null) {
		ITextRegion region = flatNode
				.getRegionAtCharacterOffset(documentPosition);
		if (region != null) {
			result = computeRegionHelp(treeNode, parentNode, flatNode,
					region);
		}
	}

	return result;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:33,代码来源:JSONHoverProcessor.java


示例2: getWebResourceRegion

import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; //导入依赖的package包/类
public WebResourceRegion getWebResourceRegion(ITextViewer textViewer,
		int offset) {
	IStructuredDocumentRegion documentRegion = ContentAssistUtils
			.getStructuredDocumentRegion(textViewer, offset);
	WebResourcesTextRegion attrValueRegion = DOMHelper.getTextRegion(
			documentRegion, offset);
	if (attrValueRegion != null) {
		switch (attrValueRegion.getType()) {
		case CSS_CLASS_NAME:
		case CSS_ID:
			return DOMHelper.getCSSRegion(attrValueRegion, documentRegion,
					textViewer.getDocument(), offset);
		case SCRIPT_SRC:
		case LINK_HREF:
		case IMG_SRC:
			return DOMHelper.getAttrValueRegion(attrValueRegion,
					documentRegion, textViewer.getDocument(), offset);
		default:
			break;
		}
	}
	return null;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:24,代码来源:WebResourcesHoverProcessor.java


示例3: detectHyperlinks

import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; //导入依赖的package包/类
@Override
public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
		IRegion region, boolean canShowMultipleHyperlinks) {
	if ((region != null) && (textViewer != null)) {

		IStructuredDocumentRegion documentRegion = ContentAssistUtils
				.getStructuredDocumentRegion(textViewer, region.getOffset());
		WebResourcesTextRegion attrValueRegion = DOMHelper.getTextRegion(
				documentRegion, region.getOffset());
		if (attrValueRegion != null) {
			switch (attrValueRegion.getType()) {
			case CSS_CLASS_NAME:
			case CSS_ID:
				// hyperlink is done for @id or @class
				WebResourceRegion classNameRegion = DOMHelper.getCSSRegion(
						attrValueRegion, documentRegion,
						textViewer.getDocument(), region.getOffset());
				if (classNameRegion != null) {
					// Try to find CSS class name or CSS ID and build
					// Hyperlink
					IDOMNode node = (IDOMNode) ContentAssistUtils
							.getNodeAt(textViewer, region.getOffset());
					CSSHyperlinkTraverser traverser = new CSSHyperlinkTraverser(
							node, classNameRegion);
					IProgressMonitor monitor = null;
					traverser.process(monitor);
					return traverser.getHyperlinks();
				}
			default:
				// Do nothing : WTP already implements hyperlink for
				// script/@src and
				// link/@href
			}
		}
	}
	return null;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:38,代码来源:CSSHyperlinkDetector.java


示例4: getAdditionalInfo

import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; //导入依赖的package包/类
private String getAdditionalInfo(ITextViewer textViewer,
		WebResourceRegion resourceRegion) {
	IDOMNode xmlnode = (IDOMNode) ContentAssistUtils.getNodeAt(textViewer,
			resourceRegion.getOffset());
	IProgressMonitor monitor = null;
	switch (resourceRegion.getType()) {
	case CSS_CLASS_NAME:
	case CSS_ID:
		return getCSSHoverInfo(resourceRegion, xmlnode, monitor);
	case IMG_SRC:
		return getImageHoverInfo(resourceRegion, xmlnode, monitor);
	default:
		return getFileHoverInfo(resourceRegion, xmlnode, monitor);
	}
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:16,代码来源:WebResourcesHoverProcessor.java


示例5: computeHoverHelp

import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; //导入依赖的package包/类
@Override
protected String computeHoverHelp(ITextViewer textViewer,
		int documentPosition) {
	String result = null;
	IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer,
			documentPosition);
	if (treeNode == null) {
		return null;
	}
	Node node = (Node) treeNode;

	while ((node != null) && (node.getNodeType() == Node.TEXT_NODE)
			&& (node.getParentNode() != null)) {
		node = node.getParentNode();
	}
	IDOMNode parentNode = (IDOMNode) node;

	IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer
			.getDocument()).getRegionAtCharacterOffset(documentPosition);
	if (flatNode != null) {
		ITextRegion region = flatNode
				.getRegionAtCharacterOffset(documentPosition);
		if (region != null) {
			result = computeRegionHelp(treeNode, parentNode, flatNode,
					region, documentPosition, textViewer.getDocument());
		}
	}

	return result;
}
 
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:31,代码来源:HTMLAngularTagInfoHoverProcessor.java


示例6: computeCompletionProposals

import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; //导入依赖的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


示例7: getHoverInfo

import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("deprecation")
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {

	String hoverinfo = null;

	try {
		int cursorposition = hoverRegion.getOffset();
		Node node = (Node)ContentAssistUtils.getNodeAt(textViewer, cursorposition);

		// Figure out what the cursor is hovering over
		String surroundingtext = getSurroundingWord(textViewer.getDocument(), hoverRegion.getOffset());
		int separatorindex = surroundingtext.indexOf(':');

		// Retrieve processor documentation on attribute or element nodes
		if (node instanceof IDOMElement && separatorindex != -1) {
			String dialectprefix = surroundingtext.substring(0, separatorindex);
			String processorname = surroundingtext.substring(separatorindex + 1);

			Processor processor = ProcessorCache.getProcessor(dialectprefix, processorname);
			if (processor != null && processor.isSetDocumentation()) {
				return processor.getDocumentation().getValue();
			}
		}
	}
	catch (BadLocationException ex) {
		ex.printStackTrace();
	}

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


示例8: computeCompletionProposals

import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; //导入依赖的package包/类
@Override
public List computeCompletionProposals(
		CompletionProposalInvocationContext context,
		IProgressMonitor monitor) {

	ITextViewer textViewer = context.getViewer();
	int documentPosition = context.getInvocationOffset();

	setErrorMessage(null);

	fTextViewer = textViewer;

	IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer,
			documentPosition);

	IJSONNode node = (IJSONNode) treeNode;
	while ((node != null) && (node.getNodeType() == Node.TEXT_NODE)
			&& (node.getParentNode() != null)) {
		node = node.getParentNode();
	}

	ContentAssistRequest contentAssistRequest = null;

	IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
	ITextRegion completionRegion = getCompletionRegion(documentPosition,
			node);

	String matchString = getMatchString(sdRegion, completionRegion,
			documentPosition);

	// compute normal proposals
	contentAssistRequest = computeCompletionProposals(matchString,
			completionRegion, (IJSONNode) treeNode, node, context);
	if (contentAssistRequest == null) {
		contentAssistRequest = new ContentAssistRequest(
				(IJSONNode) treeNode, node.getParentNode(), sdRegion,
				completionRegion, documentPosition, 0, ""); //$NON-NLS-1$
		setErrorMessage(JSONUIMessages.Content_Assist_not_availab_UI_);
	}

	/*
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=123892 Only set this
	 * error message if nothing else was already set
	 */
	if (contentAssistRequest.getProposals().size() == 0
			&& getErrorMessage() == null) {
		setErrorMessage(JSONUIMessages.Content_Assist_not_availab_UI_);
	}

	ICompletionProposal[] props = contentAssistRequest
			.getCompletionProposals();
	return (props != null) ? Arrays.asList(props) : new ArrayList(0);
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:54,代码来源:AbstractJSONCompletionProposalComputer.java


示例9: getStructuredDocumentRegion

import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; //导入依赖的package包/类
/**
 * StructuredTextViewer must be set before using this.
 */
private IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
	return ContentAssistUtils.getStructuredDocumentRegion(fTextViewer, pos);
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:7,代码来源:AbstractJSONCompletionProposalComputer.java


示例10: computeCompletionProposals

import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
    fTextViewer=viewer;
    IDocument document=viewer.getDocument();
    int documentPosition = offset;
    String projectSSVersion=CorePreferencesSupport.getInstance().getProjectSpecificPreferencesValue(SilverStripePreferences.SILVERSTRIPE_VERSION, SilverStripeVersion.getDefaultVersion(), this.getProject(document));
    
    IndexedRegion treeNode = ContentAssistUtils.getNodeAt(viewer, documentPosition);

    Node node = (Node) treeNode;
    while ((node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getParentNode() != null)) {
        node = node.getParentNode();
    }
    IDOMNode xmlnode = (IDOMNode) node;
    
    IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
    ITextRegion completionRegion = getCompletionRegion(documentPosition, node);
    
    ITextSelection selection = (ITextSelection) viewer.getSelectionProvider().getSelection();

    // adjust offset to end of normalized selection
    if (selection.getOffset() == offset)
        offset = selection.getOffset() + selection.getLength();

    String prefix = getMatchString(sdRegion, completionRegion, documentPosition);
    Region region = new Region(offset - prefix.length(), prefix.length());
    TemplateContext context = createContext(viewer, region, offset - prefix.length());
    if (context == null)
        return new ICompletionProposal[0];
    // name of the selection variables {line, word}_selection
    context.setVariable("selection", prefix); //$NON-NLS-1$
    
    // TODO Filter based on the completion region context ie if SS open only show ss_open stuff
    Template[] templates = getTemplates(fContextTypeId);

    List matches = new ArrayList();
    for (int i = 0; i < templates.length; i++) {
        Template template = templates[i];
        try {
            context.getContextType().validate(template.getPattern());
        }
        catch (TemplateException e) {
            continue;
        }
        
        if(template instanceof SilverStripeTemplate) {
            SilverStripeTemplate ssTemplate=(SilverStripeTemplate) template;
            
            if ((template.matches(prefix, fContextTypeId)) && (ssTemplate.ssVersions().length==0 || Arrays.asList(ssTemplate.ssVersions()).contains(projectSSVersion))) {
                matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix)));
            }
        }else if (template.matches(prefix, fContextTypeId)) {
            matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix)));
        }
    }

    Collections.sort(matches, fgProposalComparator);

    return (ICompletionProposal[]) matches.toArray(new ICompletionProposal[matches.size()]);
}
 
开发者ID:UndefinedOffset,项目名称:eclipse-silverstripedt,代码行数:61,代码来源:SSTemplateCompletionProcessor.java


示例11: getStructuredDocumentRegion

import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; //导入依赖的package包/类
/**
 * StructuredTextViewer must be set before using this.
 */
private IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
    return ContentAssistUtils.getStructuredDocumentRegion(fTextViewer, pos);
}
 
开发者ID:UndefinedOffset,项目名称:eclipse-silverstripedt,代码行数:7,代码来源:SSTemplateCompletionProcessor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GetApplicationAttemptReportResponseProto类代码示例发布时间:2022-05-23
下一篇:
Java LtExpr类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap