本文整理汇总了Java中org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion.getRegions方法的典型用法代码示例。如果您正苦于以下问题:Java IStructuredDocumentRegion.getRegions方法的具体用法?Java IStructuredDocumentRegion.getRegions怎么用?Java IStructuredDocumentRegion.getRegions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion
的用法示例。
在下文中一共展示了IStructuredDocumentRegion.getRegions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findStructuredDocumentRegion
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Searches for the specified structured document region type, in the
* direction specified.
*
* @param types if one of these is found, the method will return
* @param abortTypes optional, if one of these is found before one of
* <code>types</code> is found, the method will return null
* @param searchStartRegion the region to start the search at, exclusive
* @param searchForward true to search forward, false to search backward
* @return the region, or null
*/
public static IStructuredDocumentRegion findStructuredDocumentRegion(
Set<String> types, Set<String> abortTypes,
IStructuredDocumentRegion searchStartRegion,
boolean searchForward) {
IStructuredDocumentRegion region = searchForward
? searchStartRegion.getNext() : searchStartRegion.getPrevious();
while (region != null) {
ITextRegionList textRegions = region.getRegions();
for (int i = 0; i < textRegions.size(); i++) {
String curType = textRegions.get(i).getType();
if (abortTypes != null && abortTypes.contains(curType)) {
return null;
} else if (types.contains(curType)) {
return region;
}
}
region = searchForward ? region.getNext() : region.getPrevious();
}
return null;
}
示例2: insertValue
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
private void insertValue(IStructuredDocumentRegion flatNode,
String regionType) {
ITextRegionList regions = flatNode.getRegions();
if (regions == null)
return;
ITextRegion nameRegion = StructuredDocumentRegionUtil
.getFirstRegion(flatNode);
JSONStructureImpl structure = (JSONStructureImpl) this.context
.findPreviousStructure();
if (structure != null) {
JSONValueImpl value = (JSONValueImpl) createJSONValue(regionType);
value.setStructuredDocumentRegion(flatNode);
if (structure.getNodeType() == IJSONNode.OBJECT_NODE) {
if (structure.getLastChild() != null
&& structure.getLastChild().getNodeType() == IJSONNode.PAIR_NODE) {
((JSONPairImpl) structure.getLastChild()).setValue(value);
}
} else {
insertNode(structure, value, null);
}
}
}
示例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: consumesElement
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
private List<Position> consumesElement(IStructuredDocumentRegion region) {
List<Position> positions = null;
ITextRegionList regionList = region.getRegions();
for (int i = 0; i < regionList.size(); i++) {
ITextRegion textRegion = regionList.get(i);
if (textRegion.getType().equals(DOMRegionContext.XML_TAG_NAME)) {
Position position = new Position(region.getStartOffset(textRegion), textRegion.getLength());
if (positions == null) {
positions = new ArrayList<Position>();
}
positions.add(position);
}
}
return positions;
}
示例5: 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;
}
示例6: applyStyles
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Color the text in the sample area according to the current preferences
*/
void applyStyles() {
if (fText == null || fText.isDisposed())
return;
IStructuredDocumentRegion documentRegion = fDocument
.getFirstStructuredDocumentRegion();
while (documentRegion != null) {
ITextRegionList regions = documentRegion.getRegions();
for (int i = 0; i < regions.size(); i++) {
ITextRegion currentRegion = regions.get(i);
// lookup the local coloring type and apply it
String namedStyle = (String) fContextToStyleMap
.get(currentRegion.getType());
if (namedStyle == null)
continue;
TextAttribute attribute = getAttributeFor(namedStyle);
if (attribute == null)
continue;
StyleRange style = new StyleRange(
documentRegion.getStartOffset(currentRegion),
currentRegion.getTextLength(),
attribute.getForeground(), attribute.getBackground(),
attribute.getStyle());
style.strikeout = (attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0;
style.underline = (attribute.getStyle() & TextAttribute.UNDERLINE) != 0;
fText.setStyleRange(style);
}
documentRegion = documentRegion.getNext();
}
}
示例7: getRegions
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Method getRegions.
*
* @param headNode
* @return List
*/
protected List getRegions(IStructuredDocumentRegion headNode) {
List allRegions = new ArrayList();
IStructuredDocumentRegion currentNode = headNode;
while (currentNode != null) {
ITextRegionList nodeRegions = currentNode.getRegions();
for (int i = 0; i < nodeRegions.size(); i++) {
allRegions.add(nodeRegions.get(i));
}
currentNode = currentNode.getNext();
}
return allRegions;
}
示例8: getRegionsWithoutWhiteSpaces
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
*
*/
protected CompoundRegion[] getRegionsWithoutWhiteSpaces(
IStructuredDocument model, IRegion reg, IJSONCleanupStrategy stgy) {
int start = reg.getOffset();
int end = reg.getOffset() + reg.getLength() - 1;
ArrayList list = new ArrayList();
IStructuredDocumentRegion flatNode = model
.getRegionAtCharacterOffset(start);
while (flatNode != null && flatNode.getStartOffset() <= end) {
ITextRegionList regionList = flatNode.getRegions();
Iterator it = regionList.iterator();
while (it.hasNext()) {
ITextRegion region = (ITextRegion) it.next();
if (flatNode.getStartOffset(region) < start)
continue;
if (end < flatNode.getStartOffset(region))
break;
if (region.getType() != JSONRegionContexts.WHITE_SPACE
|| (isCleanup() && !stgy.isFormatSource())) // for
// not
// formatting
// case
// on
// cleanup
// action
list.add(new CompoundRegion(flatNode, region));
}
flatNode = flatNode.getNext();
}
if (list.size() > 0) {
CompoundRegion[] regions = new CompoundRegion[list.size()];
list.toArray(regions);
return regions;
}
return new CompoundRegion[0];
}
示例9: updateAttrRegions
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
*/
private void updateAttrRegions(IJSONObject element,
IStructuredDocumentRegion flatNode) {
// update attributes
ITextRegionList regions = flatNode.getRegions();
if (regions == null)
return;
// NamedNodeMap attributes = element.getAttributes();
// if (attributes == null)
// return;
// int index = -1;
// AttrImpl attr = null;
// Iterator e = regions.iterator();
// while (e.hasNext()) {
// ITextRegion region = (ITextRegion) e.next();
// String regionType = region.getType();
// if (regionType == JSONRegionContexts.JSON_TAG_ATTRIBUTE_NAME) {
// attr = (AttrImpl) attributes.item(++index);
// if (attr != null) {
// attr.setNameRegion(region);
// // reset other regions
// attr.setEqualRegion(null);
// attr.setValueRegion(null);
// }
// } else if (regionType == JSONRegionContexts.JSON_TAG_ATTRIBUTE_EQUALS) {
// if (attr != null)
// attr.setEqualRegion(region);
// } else if (regionType == JSONRegionContexts.JSON_TAG_ATTRIBUTE_VALUE) {
// if (attr != null) {
// attr.setValueRegion(region);
// attr = null;
// }
// }
// }
}
示例10: insertArray
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* insertStartTag method
*
*/
private void insertArray(IStructuredDocumentRegion flatNode) {
ITextRegionList regions = flatNode.getRegions();
if (regions == null)
return;
JSONArrayImpl element = (JSONArrayImpl) this.model.getDocument()
.createJSONArray();
element.setStartStructuredDocumentRegion(flatNode);
insertStartArray(element);
}
示例11: insertNumberValue
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
private void insertNumberValue(IStructuredDocumentRegion flatNode) {
ITextRegionList regions = flatNode.getRegions();
if (regions == null)
return;
ITextRegion nameRegion = StructuredDocumentRegionUtil
.getFirstRegion(flatNode);
JSONStructureImpl array = (JSONStructureImpl) this.context
.findPreviousStructure();
if (array != null) {
JSONNumberValueImpl value = (JSONNumberValueImpl) this.model
.getDocument().createNumberValue();
insertNode(array, value, null);
}
}
示例12: insertNullValue
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
private void insertNullValue(IStructuredDocumentRegion flatNode) {
ITextRegionList regions = flatNode.getRegions();
if (regions == null)
return;
ITextRegion nameRegion = StructuredDocumentRegionUtil
.getFirstRegion(flatNode);
JSONStructureImpl array = (JSONStructureImpl) this.context
.findPreviousStructure();
if (array != null) {
JSONNullValueImpl value = (JSONNullValueImpl) this.model
.getDocument().createNullValue();
insertNode(array, value, null);
}
}
示例13: insertStringValue
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
private void insertStringValue(IStructuredDocumentRegion flatNode) {
ITextRegionList regions = flatNode.getRegions();
if (regions == null)
return;
ITextRegion nameRegion = StructuredDocumentRegionUtil
.getFirstRegion(flatNode);
JSONStructureImpl array = (JSONStructureImpl) this.context
.findPreviousStructure();
if (array != null) {
JSONStringValueImpl value = (JSONStringValueImpl) this.model
.getDocument().createStringValue();
insertNode(array, value, null);
}
}
示例14: getFirstRegion
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Returns the first region.
*/
static ITextRegion getFirstRegion(IStructuredDocumentRegion flatNode) {
if(flatNode instanceof StructuredDocumentRegionProxy) {
flatNode = ((StructuredDocumentRegionProxy)flatNode).getStructuredDocumentRegion();
}
if (flatNode == null)
return null;
ITextRegionList regions = flatNode.getRegions();
if (regions == null || regions.size() == 0)
return null;
return regions.get(0);
}
示例15: getFirstRegionType
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Returns the type of the first region.
*/
static String getFirstRegionType(IStructuredDocumentRegion flatNode) {
if(flatNode instanceof StructuredDocumentRegionProxy) {
flatNode = ((StructuredDocumentRegionProxy)flatNode).getStructuredDocumentRegion();
}
if (flatNode == null)
return JSONRegionContexts.UNDEFINED;
ITextRegionList regions = flatNode.getRegions();
if (regions == null || regions.size() == 0)
return JSONRegionContexts.UNDEFINED;
ITextRegion region = regions.get(0);
return region.getType();
}