本文整理汇总了Java中org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest.getMatchString方法的典型用法代码示例。如果您正苦于以下问题:Java ContentAssistRequest.getMatchString方法的具体用法?Java ContentAssistRequest.getMatchString怎么用?Java ContentAssistRequest.getMatchString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest
的用法示例。
在下文中一共展示了ContentAssistRequest.getMatchString方法的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());
}
示例2: 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());
}
示例3: getExpression
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
/**
* Returns the expression to use for tern completion.
*
* @param contentAssistRequest
* @param startIndex
* @return
*/
private String getExpression(ContentAssistRequest contentAssistRequest,
Integer startIndex) {
String expression = contentAssistRequest.getMatchString();
if (startIndex != null) {
// start index is not null , this case comes from when completion is
// done in attribute :
// 1) when completion is done inside an attribute <span
// ng-app="MyModu
// in this case the expression to use is 'MyModu' and not
// '"MyModu'
// 2) when completion is done inside an
// attribute which define {{
// ex : <span class="done-{{to
// in this case, the expression to use is 'to' and not
// '"done-{{to'
expression = expression.substring(startIndex, expression.length());
}
return expression;
}
示例4: 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));
}
}
示例5: 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());
}
示例6: enumProposals
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
private void enumProposals(final ContentAssistRequest request, CompletionProposalInvocationContext context,
ProposalCallback proposalCallback)
{
TapestryProject tapestryProject = getTapestryProject(context);
if (tapestryProject == null)
{
// No tapestry project available for the context
return;
}
Map<String, String> xmlnsMappings = findXmlnsMappingsRelativeTo(request.getNode());
for (TapestryModule tapestryModule : tapestryProject.modules())
{
for (TapestryContext tapestryContext : tapestryModule.getComponents())
{
// If tapestry-library: prefix defined, try to use it first for completion proposals
String tagName = getComponentTagName(tapestryModule, tapestryContext, xmlnsMappings, true);
String displayString = tagName;
String userInput = request.getMatchString();
if (!isComponentNameProposalMatches(tagName, userInput, xmlnsMappings))
{
// ... and fall back to full component name if library prefixed name doesn't match user input:
// maybe the user is entering full component name
String fullTagName = getComponentTagName(tapestryModule, tapestryContext, xmlnsMappings, false);
if (!isComponentNameProposalMatches(fullTagName, userInput, xmlnsMappings))
{
continue;
}
// User tries to input full component name, but prefix is available for this library.
// Force using prefixed tag name for completion proposal, otherwise why would user defined xmlns for it?
displayString = fullTagName;
}
proposalCallback.newProposal(tapestryContext, tagName, displayString);
}
}
}
示例7: 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);
}
示例8: getAttributeValueUsingMatchString
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; //导入方法依赖的package包/类
/**
* Returns the attribute value of the content assist request from an attribute
* completion.
* <p>
* This uses the match string to get the value, so it will work even if the
* attribute is not well-formed and a DOM element does not exist.
*
* @param contentAssistRequest the content assist request, in the context of
* an attribute completion
* @return the attribute value (empty string if the value is empty)
*/
public static String getAttributeValueUsingMatchString(
ContentAssistRequest contentAssistRequest) {
String currentAttrValue = contentAssistRequest.getMatchString();
if (currentAttrValue == null || currentAttrValue.length() < 1) {
return "";
}
// Take off the leading ' or "
return currentAttrValue.substring(1);
}