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


Java ContentAssistRequest.getNode方法代码示例

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


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

示例1: newSetterAttributeProposalComputer

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
/**
 * Creates a proposal computer for widget attributes based on existing type
 * setter methods.
 */
public static IProposalComputer newSetterAttributeProposalComputer(
    ContentAssistRequest contentAssistRequest, IJavaProject javaProject) {

  IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
  if (node.getNodeType() != IDOMNode.ELEMENT_NODE) {
    return null;
  }

  String widgetTypeName = UiBinderXmlModelUtilities.computeQualifiedWidgetTypeName(node);
  if (widgetTypeName == null) {
    return null;
  }

  String matchString = contentAssistRequest.getMatchString();

  return new SetterAttributeProposalComputer(node, widgetTypeName,
      javaProject, matchString,
      contentAssistRequest.getReplacementBeginPosition(),
      matchString.length());
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:25,代码来源:ProposalComputerFactory.java

示例2: newUiPhAttributeProposalComputer

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
public static IProposalComputer newUiPhAttributeProposalComputer(
    ContentAssistRequest contentAssistRequest) {

  IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
  if (node.getNodeType() != IDOMNode.ELEMENT_NODE) {
    return null;
  }

  if (XmlUtilities.getAttribute(node,
      UiBinderConstants.UI_BINDER_PH_ATTRIBUTE_NAME, true,
      UiBinderConstants.UI_BINDER_XML_NAMESPACE) != null) {
    // This element already has a ui:field attribute
    return null;
  }

  // Only show this on HTML elements, which should be without a namespace
  if (node.getNamespaceURI() != null) {
    return null;
  }

  return createStaticTextProposalComputerForUiAttribute(
      UiBinderConstants.UI_BINDER_PH_ATTRIBUTE_NAME, node,
      contentAssistRequest);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:25,代码来源:ProposalComputerFactory.java

示例3: addAttributeNameProposals

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
@Override
protected void addAttributeNameProposals(final ContentAssistRequest contentAssistRequest,
		CompletionProposalInvocationContext context) {
	// Check if project has angular nature
	final IDOMElement element = (IDOMElement) contentAssistRequest.getNode();
	IFile file = DOMUtils.getFile(element);
	if (AngularProject.isAngularProject(file.getProject())) {
		String attrName = contentAssistRequest.getMatchString();
		IDOMAttr attr = DOMUtils.getAttrByRegion(element, contentAssistRequest.getRegion());
		AngularCorePlugin.getBindingManager().collect(element, attrName, file,
				new HTMLAngularCompletionCollector(element, attr, contentAssistRequest, this));
	}
}
 
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:14,代码来源:HTMLAngularTagsCompletionProposalComputer.java

示例4: newUiFieldAttributeProposalComputer

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
/**
 * Creates a proposal computer for the ui:field attribute.
 */
public static IProposalComputer newUiFieldAttributeProposalComputer(
    ContentAssistRequest contentAssistRequest) {

  IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
  if (node.getNodeType() != IDOMNode.ELEMENT_NODE) {
    return null;
  }

  if (XmlUtilities.getAttribute(node,
      UiBinderConstants.UI_BINDER_FIELD_ATTRIBUTE_NAME, true,
      UiBinderConstants.UI_BINDER_XML_NAMESPACE) != null) {
    // This element already has a ui:field attribute
    return null;
  }

  /*
   * Show the ui:field attribute on widget elements and HTML elements (without
   * a namespace)
   */
  boolean isWidget = UiBinderXmlModelUtilities.computeQualifiedWidgetTypeName(node) != null;
  boolean isLikelyHtmlElement = node.getNamespaceURI() == null;
  if (!(isWidget || isLikelyHtmlElement)) {
    return null;
  }

  return createStaticTextProposalComputerForUiAttribute(
      UiBinderConstants.UI_BINDER_FIELD_ATTRIBUTE_NAME, node,
      contentAssistRequest);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:33,代码来源:ProposalComputerFactory.java

示例5: addTagInsertionProposals

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
@Override
protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest,
	int childPosition, CompletionProposalInvocationContext context)
{
	int offset = contentAssistRequest.getReplacementBeginPosition();
	int length = contentAssistRequest.getReplacementLength();
	Node node = contentAssistRequest.getNode();
	// Current node can be 'parent' when the cursor is just before the end tag of the parent.
	Node parentNode = node.getNodeType() == Node.ELEMENT_NODE ? node : node.getParentNode();
	if (parentNode.getNodeType() != Node.ELEMENT_NODE)
		return;

	String tagName = parentNode.getNodeName();
	NamedNodeMap tagAttrs = parentNode.getAttributes();
	// Result mapping proposals.
	if ("resultMap".equals(tagName))
		generateResults(contentAssistRequest, offset, length, parentNode,
			tagAttrs.getNamedItem("type"));
	else if ("collection".equals(tagName))
		generateResults(contentAssistRequest, offset, length, parentNode,
			tagAttrs.getNamedItem("ofType"));
	else if ("association".equals(tagName))
		generateResults(contentAssistRequest, offset, length, parentNode,
			tagAttrs.getNamedItem("javaType"));

	proposeStatementText(contentAssistRequest, parentNode);
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:28,代码来源:XmlCompletionProposalComputer.java

示例6: newUiBinderRootElementProposalComputer

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
/**
 * Creates a proposal computer for autocompleting the root UiBinder element in
 * a UiBinder XML file.
 */
public static IProposalComputer newUiBinderRootElementProposalComputer(
    ContentAssistRequest contentAssistRequest) {

  Node node = contentAssistRequest.getNode();
  if (node == null) {
    // No javadoc on getNode(), so play safe
    return null;
  }

  if (node.getNodeType() == Node.ELEMENT_NODE) {
    if (!XmlUtilities.getRootElement(node).equals(node)) {
      // We are not the root element
      return null;
    }
  } else if (node.getNodeType() == Node.TEXT_NODE) {
    // A completion at "<_" produces a text node
    if (node.getOwnerDocument().getDocumentElement() != null) {
      // We are not the root element
      return null;
    }
  } else {
    // Some other node type
    return null;
  }

  String newLine = ((DocumentImpl) node.getOwnerDocument()).getModel().getStructuredDocument().getLineDelimiter();

  // Come up with <ui:UiBinder xmlns:ui="...">\n_\n</ui:UiBinder> text
  String beforeCursorText = MessageFormat.format(
      "ui:{0} xmlns:ui=\"{1}\">{2}",
      UiBinderConstants.UI_BINDER_ELEMENT_NAME,
      UiBinderConstants.UI_BINDER_XML_NAMESPACE, newLine);
  String afterCursorText = MessageFormat.format("{0}</ui:{1}>", newLine,
      UiBinderConstants.UI_BINDER_ELEMENT_NAME);
  String fullText = beforeCursorText + afterCursorText;

  String matchString = contentAssistRequest.getMatchString();
  if (!fullText.startsWith(matchString)) {
    return null;
  }

  int replaceOffset = contentAssistRequest.getReplacementBeginPosition();
  return new StaticTextProposalComputer(new String[] {fullText}, matchString,
      replaceOffset, matchString.length(), replaceOffset
          + beforeCursorText.length(),
      XmlContentAssistUtilities.getImageForElement());
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:52,代码来源:ProposalComputerFactory.java

示例7: CSSContentAssistTraverser

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
public CSSContentAssistTraverser(ContentAssistRequest contentAssistRequest,
		int documentPosition, String attrValue, WebResourcesFinderType type) {
	super((IDOMNode) contentAssistRequest.getNode(), type);
	this.contentAssistRequest = contentAssistRequest;
	this.existingClassNames = type == WebResourcesFinderType.CSS_CLASS_NAME ? new ArrayList<String>()
			: null;
	// ex : <input class="todo-done myClass" />
	// completion done after my (todo-done my // Here Ctrl+Space)

	// matching string = "todo-done my"
	String matchingString = DOMHelper.getAttrValue(contentAssistRequest
			.getMatchString());

	// matching class name = "my"
	matchingClassNameOrId = matchingString;
	if (type == WebResourcesFinderType.CSS_CLASS_NAME) {
		int index = matchingClassNameOrId.lastIndexOf(" ");
		if (index != -1) {
			matchingClassNameOrId = matchingClassNameOrId.substring(
					index + 1, matchingClassNameOrId.length());
		}

		// after matching class name = "Class"
		String afterMatchingClassName = attrValue.substring(
				matchingString.length(), attrValue.length());
		index = afterMatchingClassName.indexOf(" ");
		if (index != -1) {
			afterMatchingClassName = afterMatchingClassName.substring(0,
					index);
		}
		this.replacementLength = matchingClassNameOrId.length()
				+ afterMatchingClassName.length();

		// compute existing class names
		String[] names = attrValue.split(" ");
		for (int i = 0; i < names.length; i++) {
			existingClassNames.add(names[i].trim());
		}
	} else {
		this.replacementLength = attrValue.length();
	}
	this.replacementOffset = documentPosition
			- matchingClassNameOrId.length();

}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:46,代码来源:CSSContentAssistTraverser.java

示例8: addAttributeValueProposals

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
@Override
protected void addAttributeValueProposals(
		final ContentAssistRequest contentAssistRequest,
		CompletionProposalInvocationContext context) {
	// Check if project has angular nature
	IDOMNode element = (IDOMNode) contentAssistRequest.getNode();
	if (AngularDOMUtils.hasAngularNature(element)) {
		// check if it's class attribute
		IDOMAttr attr = DOMUtils.getAttrByRegion(element,
				contentAssistRequest.getRegion());
		// is angular directive attribute?
		Directive directive = AngularDOMUtils.getAngularDirectiveByRegion(
				element, contentAssistRequest.getRegion());
		AngularType angularType = directive != null ? directive.getDirectiveType()
				: null;
		if (angularType != null) {
			if (angularType.equals(AngularType.unknown)
					|| angularType.equals(AngularType.repeat_expression))
				angularType = AngularType.model;
			int startIndex = (contentAssistRequest.getMatchString()
					.startsWith("\"") || contentAssistRequest
					.getMatchString().startsWith("'")) ? 1 : 0;
			populateAngularProposals(contentAssistRequest, element,
					context.getDocument(), angularType, startIndex);
		} else {
			// is angular expression inside attribute?
			String matchingString = contentAssistRequest.getMatchString();
			String startSymbol = AngularProject.DEFAULT_START_SYMBOL;
			try {
				AngularProject angularProject = AngularProject
						.getAngularProject(DOMUtils.getFile(element)
								.getProject());
				startSymbol = angularProject.getStartSymbol();
			} catch (CoreException e) {
			}
			int index = matchingString.lastIndexOf(startSymbol);
			if (index != -1) {
				populateAngularProposals(contentAssistRequest, element,
						context.getDocument(), AngularType.model, index);
			} else {
				if (CLASS_ATTR.equals(attr.getName())) {
					addClassAttributeValueProposals(contentAssistRequest,
							context, attr);
				}
			}
		}
	}
	super.addAttributeValueProposals(contentAssistRequest, context);
}
 
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:50,代码来源:HTMLAngularTagsCompletionProposalComputer.java


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