本文整理汇总了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());
}
示例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);
}
示例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));
}
}
示例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);
}
示例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);
}
示例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());
}
示例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();
}
示例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);
}