本文整理汇总了Java中org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion.getText方法的典型用法代码示例。如果您正苦于以下问题:Java IStructuredDocumentRegion.getText方法的具体用法?Java IStructuredDocumentRegion.getText怎么用?Java IStructuredDocumentRegion.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion
的用法示例。
在下文中一共展示了IStructuredDocumentRegion.getText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttrValue
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Extracts contents enclosed with quotes. Quotes may be double or single.
*/
static String getAttrValue(IStructuredDocumentRegion flatNode, ITextRegion region) {
if (region == null)
return null;
if (flatNode == null)
return null;
String value = flatNode.getText(region);
if (value == null)
return null;
int length = value.length();
if (length == 0)
return value;
char firstChar = value.charAt(0);
if (firstChar == '"' || firstChar == '\'') {
if (length == 1)
return ""; //$NON-NLS-1$
if (value.charAt(length - 1) == firstChar)
length--;
return value.substring(1, length);
}
return value;
}
示例2: getEntityRefName
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Extracts the name without heading '&' and tailing ';'.
*/
static String getEntityRefName(IStructuredDocumentRegion flatNode, ITextRegion region) {
if (region == null)
return null;
String ref = flatNode.getText(region);
int length = ref.length();
if (length == 0)
return ref;
int offset = 0;
if (ref.charAt(0) == '&')
offset = 1;
if (ref.charAt(length - 1) == ';')
length--;
if (offset >= length)
return null;
return ref.substring(offset, length);
}
示例3: getAttrByRegion
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Returns the SSE DOM Attribute {@link IDOMAttr} by region from the SSE DOM
* element {@link IDOMElement}.
*
* @param element
* the SSE DOM element {@link IDOMElement}.
* @param region
* the region.
* @return
*/
public static IDOMAttr getAttrByRegion(IDOMNode element, ITextRegion region) {
if (!isAttrRegion(region)) {
return null;
}
IStructuredDocumentRegion structuredDocumentRegionElement = element.getFirstStructuredDocumentRegion();
// 1) Get attribute name region
ITextRegionList elementRegions = structuredDocumentRegionElement.getRegions();
int index = elementRegions.indexOf(region);
if (index < 0) {
return null;
}
ITextRegion attrNameRegion = null;
while (index >= 0) {
attrNameRegion = elementRegions.get(index--);
if (attrNameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
break;
}
}
if (attrNameRegion == null) {
return null;
}
String attrName = structuredDocumentRegionElement.getText(attrNameRegion);
return (IDOMAttr) element.getAttributes().getNamedItem(attrName);
}
示例4: isStyleElement
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Determines whether the given region is a UiBinder style element (opening or
* closing) that can contain a CSS block.
*
* @param styleElementRegion the region to check. If null, method returns
* false.
*/
private boolean isStyleElement(IStructuredDocumentRegion styleElementRegion) {
if (styleElementRegion == null) {
return false;
}
String uiBinderPrefix = null;
ITextRegionList regions = styleElementRegion.getRegions();
for (int i = 0; i < regions.size(); i++) {
ITextRegion styleElementChildTextRegion = regions.get(i);
if (styleElementChildTextRegion.getType().equals(
DOMRegionContext.XML_TAG_NAME)) {
// Ensure the namespace prefix and element name match
if (uiBinderPrefix == null) {
// Lazily fetch the prefix
uiBinderPrefix = UiBinderXmlModelUtilities.resolveUiBinderNamespacePrefix(styleElementRegion.getParentDocument());
}
String tagName = styleElementRegion.getText(styleElementChildTextRegion);
if (tagName.equalsIgnoreCase(uiBinderPrefix + ":"
+ UiBinderConstants.UI_BINDER_STYLE_ELEMENT_NAME)) {
return true;
}
}
}
return false;
}
示例5: changeAttrName
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* changeAttrName method
*
*/
private void changeAttrName(IStructuredDocumentRegion flatNode,
ITextRegion region) {
int offset = flatNode.getStart();
if (offset < 0)
return;
JSONNodeImpl root = (JSONNodeImpl) this.context.getRootNode();
if (root == null)
return;
IJSONNode node = root.getNodeAt(offset);
if (node == null)
return;
if (node.getNodeType() != IJSONNode.PAIR_NODE) {
return;
}
JSONPairImpl pair = (JSONPairImpl) node;
String name = flatNode.getText(region);
pair.setName(name);
/*
* List<IJSONPair> attributes = element.getPairs(); if (attributes ==
* null) return; for (IJSONPair attr : attributes) { if (((JSONPairImpl)
* attr).getNameRegion() != region) continue;
*
* String name = flatNode.getText(region); ((JSONPairImpl)
* attr).setName(name); break; }
*/
}