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


Java ContentAssistRequest.getReplacementBeginPosition方法代码示例

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


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

示例1: addProposal

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
private void addProposal(ContentAssistRequest contentAssistRequest, String name, INgBindingType bindingType,
		String displayString, Image image, String additionalProposalInfo) {
	String alternateMatch = bindingType.formatAttr(name);
	StringBuilder replacementString = new StringBuilder(alternateMatch);
	if (!hasValue) {
		replacementString.append("=\"\"");
	}
	StringBuilder replacementStringCursor = new StringBuilder(alternateMatch);
	replacementStringCursor.append("=\"\"");

	int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
	int replacementLength = contentAssistRequest.getReplacementLength();
	int cursorPosition = getCursorPositionForProposedText(replacementStringCursor.toString());

	IContextInformation contextInformation = null;

	int relevance = XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME;

	ICompletionProposal proposal = new HTMLAngularCompletionProposal(replacementString.toString(),
			replacementOffset, replacementLength, cursorPosition, image, displayString, alternateMatch,
			contextInformation, additionalProposalInfo, relevance);
	contentAssistRequest.addProposal(proposal);
}
 
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:24,代码来源:HTMLAngularCompletionCollector.java

示例2: 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

示例3: createStaticTextProposalComputerForUiAttribute

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
private static IProposalComputer createStaticTextProposalComputerForUiAttribute(
    String unprefixedAttrName, Node node,
    ContentAssistRequest contentAssistRequest) {

  Node uiBinderElement = XmlUtilities.getRootElement(node);
  String fullAttrName = XmlUtilities.getName(uiBinderElement.getPrefix(),
      unprefixedAttrName);
  String proposalText = fullAttrName + "=\"\"";

  // The cursor position will be inside the quotes
  int replacementBeginPosition = contentAssistRequest.getReplacementBeginPosition();
  int cursorPosition = replacementBeginPosition + proposalText.length() - 1;
  return new StaticTextProposalComputer(new String[]{proposalText},
      contentAssistRequest.getMatchString(), replacementBeginPosition,
      contentAssistRequest.getReplacementLength(), cursorPosition,
      XmlContentAssistUtilities.getImageForAttribute());
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:18,代码来源:ProposalComputerFactory.java

示例4: getReplacementOffset

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
/**
 * Returns the replacement offset.
 * 
 * @param contentAssistRequest
 * @param angularType
 * @param isAttr
 * @return
 */
private int getReplacementOffset(ContentAssistRequest contentAssistRequest,
		AngularType angularType, boolean isAttr) {
	int replacementOffset = contentAssistRequest
			.getReplacementBeginPosition();
	if (isAttr) {
		// the completion is done in an attribute.
		if (!isModuleOrController(angularType)) {
			// getReplacementBeginPosition returns the position of the
			// starts of the attribute value (or quote).
			// in the case of attribute different from "module",
			// "controller", the replacement offset must
			// be the position where completion starts (ex : ng-model="todo.
			// => the position should be after todo. and before.
			replacementOffset += contentAssistRequest.getMatchString()
					.length();
		}
	}
	return replacementOffset;
}
 
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:28,代码来源:HTMLAngularTagsCompletionProposalComputer.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: addProposal

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
private void addProposal(final ContentAssistRequest contentAssistRequest,
		String name, DirectiveValue directiveValue, Directive directive,
		String displayString, Image image, String additionalProposalInfo,
		IDOMNode element, IIDETernProject ternProject) {
	StringBuilder replacementString = new StringBuilder(name);
	if (directiveValue != DirectiveValue.none)
		replacementString.append("=\"\"");

	if (directive != null) {
		Collection<DirectiveParameter> parameters = directive
				.getParameters();
		for (DirectiveParameter parameter : parameters) {
			if (!parameter.isOptionnal()
					&& !hasParameterAttribute(parameter, element)) {
				replacementString.append(" ").append(parameter.getName())
						.append("=\"\"");
			}
		}
	}

	int replacementOffset = contentAssistRequest
			.getReplacementBeginPosition();
	int replacementLength = contentAssistRequest.getReplacementLength();
	int cursorPosition = getCursorPositionForProposedText(replacementString
			.toString());

	IContextInformation contextInformation = null;

	int relevance = XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME;

	ICompletionProposal proposal = new HTMLAngularCompletionProposal(
			replacementString.toString(), replacementOffset,
			replacementLength, cursorPosition, image, displayString,
			contextInformation, additionalProposalInfo, relevance,
			ternProject);
	contentAssistRequest.addProposal(proposal);
}
 
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:38,代码来源:HTMLAngularTagsCompletionProposalComputer.java

示例7: 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

示例8: getAttributeValueOffset

import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
/**
 * Returns the offset to the attribute value fetched via
 * {@link #getAttributeValueUsingMatchString(ContentAssistRequest)} (this will
 * only work if that method returns a valid value).
 * 
 * @param contentAssistRequest the content assist request, in the context of
 *          an attribute completion
 * @return the offset to the attribute value, relative to the replacement
 *         begin position
 */
public static int getAttributeValueOffset(
    ContentAssistRequest contentAssistRequest) {
  // Add one for the leading ' or " that is included in the match string
  return contentAssistRequest.getReplacementBeginPosition() + 1;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:16,代码来源:XmlContentAssistUtilities.java


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