本文整理汇总了Java中org.eclipse.wst.sse.core.internal.provisional.IndexedRegion类的典型用法代码示例。如果您正苦于以下问题:Java IndexedRegion类的具体用法?Java IndexedRegion怎么用?Java IndexedRegion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndexedRegion类属于org.eclipse.wst.sse.core.internal.provisional包,在下文中一共展示了IndexedRegion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getNodeByOffset
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
* Returns the SSE DOM Node {@link IDOMNode} by offset from the
* {@link IStructuredModel} SSE mode and null if not found.
*
* @param model
* the SSE model.
* @param offset
* the offset.
* @return
*/
public static final IDOMNode getNodeByOffset(IStructuredModel model, int offset) {
IndexedRegion node = null;
if (model != null) {
node = model.getIndexedRegion(offset);
if (node instanceof IDOMNode) {
return (IDOMNode) node;
}
if (model != null) {
int lastOffset = offset;
node = model.getIndexedRegion(offset);
while (node == null && lastOffset >= 0) {
lastOffset--;
node = model.getIndexedRegion(lastOffset);
}
}
}
return (IDOMNode) node;
}
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:30,代码来源:DOMUtils.java
示例2: consumes
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
@Override
public Position[] consumes(IStructuredDocumentRegion documentRegion,
IndexedRegion indexedRegion) {
if (indexedRegion != null && indexedRegion instanceof IDOMNode) {
IDOMNode node = (IDOMNode) indexedRegion;
IFile file = DOMUtils.getFile(node);
if (canConsume(file)) {
// project has angular nature, compute positions.
List<Position> positions = consumes(node, file, documentRegion);
if (positions != null) {
return positions.toArray(EMPTY_POSITION);
}
}
}
return null;
}
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:17,代码来源:AbstractAngularSemanticHighlighting.java
示例3: containsEmptyMaskedMediaRule
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
private boolean containsEmptyMaskedMediaRule(CSSMediaRule mediaRule,
IndexedRegion mediaRuleRegion) {
for (String rule : EMPTY_MASKED_MEDIA_RULES) {
try {
if (structuredDocument.getLength() < rule.length()) {
continue;
}
if (!rule.equalsIgnoreCase(structuredDocument.get(
mediaRuleRegion.getStartOffset(), rule.length()))) {
continue;
}
if (mediaRule.getMedia().getLength() > 0) {
continue;
}
return true;
} catch (BadLocationException e1) {
// Shouldn't happen, continue on
}
}
return false;
}
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:26,代码来源:CssResourceAwareModelRepairer.java
示例4: fixPotentialEmptyMaskedMediaRule
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
private void fixPotentialEmptyMaskedMediaRule(ICSSNode node) {
CSSMediaRule mediaRule = (CSSMediaRule) node;
IndexedRegion mediaRuleRegion = (IndexedRegion) mediaRule;
if (!containsEmptyMaskedMediaRule(mediaRule, mediaRuleRegion)) {
return;
}
// Set the range to a valid value (it won't be proper since we don't have
// any additional words that can be categorized as CSS_MEDIUM.)
MediaList mediaList = mediaRule.getMedia();
IStructuredDocumentRegion[] structuredDocumentRegions = structuredDocument.getStructuredDocumentRegions(
mediaRuleRegion.getStartOffset(), mediaRuleRegion.getLength());
// The value we set is a 0-length region starting where the next word would
// have been
ITextRegion textRegion = new ContextRegion(CSSRegionContexts.CSS_MEDIUM,
structuredDocumentRegions[0].getEndOffset()
- structuredDocumentRegions[0].getStartOffset(), 0, 0);
try {
callSetRangeRegion(mediaList, structuredDocumentRegions, textRegion);
} catch (Throwable e) {
GWTPluginLog.logError(e, "Could not clean up the @else in the CSS model.");
}
}
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:27,代码来源:CssResourceAwareModelRepairer.java
示例5: computeHoverHelp
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
* Retrieves documentation to display in the hover help popup.
*
* @return String any documentation information to display <code>null</code>
* if there is nothing to display.
*
*/
protected String computeHoverHelp(ITextViewer textViewer,
int documentPosition) {
String result = null;
IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer,
documentPosition);
if (treeNode == null) {
return null;
}
IJSONNode node = (IJSONNode) treeNode;
IJSONNode parentNode = node.getParentNode();
IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer
.getDocument()).getRegionAtCharacterOffset(documentPosition);
if (flatNode != null) {
ITextRegion region = flatNode
.getRegionAtCharacterOffset(documentPosition);
if (region != null) {
result = computeRegionHelp(treeNode, parentNode, flatNode,
region);
}
}
return result;
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:33,代码来源:JSONHoverProcessor.java
示例6: computeRegionHelp
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
* Computes the hoverhelp based on region
*
* @return String hoverhelp
*/
protected String computeRegionHelp(IndexedRegion treeNode,
IJSONNode parentNode, IStructuredDocumentRegion flatNode,
ITextRegion region) {
if (region == null) {
return null;
}
String regionType = region.getType();
if (regionType == JSONRegionContexts.JSON_OBJECT_KEY) {
return computeObjectKeyHelp((IJSONPair) treeNode, parentNode,
flatNode, region);
}
if (JSONUtil.isJSONSimpleValue(regionType)) {
return computeValueHelp((IJSONValue) treeNode, parentNode,
flatNode, region);
}
return null;
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:23,代码来源:JSONHoverProcessor.java
示例7: formatPre
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
*
*/
protected void formatPre(IJSONNode node, StringBuilder source) {
IJSONCleanupStrategy stgy = getCleanupStrategy(node);
int start = ((IndexedRegion) node).getStartOffset();
int end = ((IndexedRegion) node).getEndOffset();
if (end > 0) { // format source
IStructuredDocument structuredDocument = node.getOwnerDocument()
.getModel().getStructuredDocument();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(
structuredDocument, new FormatRegion(start, end - start),
stgy);
for (int i = 0; i < regions.length; i++) {
if (i != 0)
appendSpaceBefore(node, regions[i], source);
source.append(decoratedPropValueRegion(regions[i], stgy));
}
}
// else { // generate source
// JSONUnknownRule rule = (JSONUnknownRule) node;
// source.append(rule.getCssText());
// }
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:26,代码来源:UnknownRuleFormatter.java
示例8: getLengthToReformatAfter
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
*
* @return int
* @param node
* org.eclipse.wst.css.core.model.interfaces.IJSONNode
* @param insertPos
* int
*/
public int getLengthToReformatAfter(IJSONNode node, int insertPos) {
if (node == null)
return 0;
IndexedRegion nnode = (IndexedRegion) node;
if (insertPos < 0 || !nnode.contains(insertPos)) {
if (node.getParentNode() != null && nnode.getEndOffset() <= 0) {
IJSONSourceGenerator pntFormatter = getParentFormatter(node);
if (pntFormatter != null)
return pntFormatter.getLengthToReformatAfter(
node.getParentNode(), insertPos);
}
return 0;
}
return super.getLengthToReformatAfter(node, insertPos);
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:24,代码来源:JSONPairFormatter.java
示例9: getLengthToReformatBefore
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
*
* @return int
* @param node
* org.eclipse.wst.css.core.model.interfaces.IJSONNode
* @param insertPos
* int
*/
public int getLengthToReformatBefore(IJSONNode node, int insertPos) {
if (node == null)
return 0;
IndexedRegion nnode = (IndexedRegion) node;
if (insertPos <= 0 || !nnode.contains(insertPos - 1)) {
if (node.getParentNode() != null && nnode.getEndOffset() <= 0) {
IJSONSourceGenerator pntFormatter = getParentFormatter(node);
if (pntFormatter != null)
return pntFormatter.getLengthToReformatBefore(
node.getParentNode(), insertPos);
}
return 0;
}
return super.getLengthToReformatBefore(node, insertPos);
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:24,代码来源:JSONPairFormatter.java
示例10: formatBefore
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
*
*/
protected void formatBefore(IJSONNode node, IJSONNode child,
IRegion region, String toAppend, StringBuilder source) {
IJSONCleanupStrategy stgy = getCleanupStrategy(node);
IStructuredDocument structuredDocument = node.getOwnerDocument()
.getModel().getStructuredDocument();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(
structuredDocument, region, stgy);
CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
for (int i = 0; i < regions.length; i++) {
if (i != 0 || needS(outside[0]))
appendDelimBefore(node, regions[i], source);
source.append(decoratedRegion(regions[i], 0, stgy)); // must be
// comments
}
if (needS(outside[1])) {
if (((IndexedRegion) child).getStartOffset() == region.getOffset()
+ region.getLength())
appendDelimBefore(node, null, source);
}
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:25,代码来源:JSONDocumentFormatter.java
示例11: getChildInsertPos
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
*
*/
public int getChildInsertPos(IJSONNode node) {
int n = ((IndexedRegion) node).getEndOffset();
if (n > 0) {
IStructuredDocument structuredDocument = node.getOwnerDocument()
.getModel().getStructuredDocument();
IStructuredDocumentRegion flatNode = structuredDocument
.getRegionAtCharacterOffset(n - 1);
ITextRegion region = flatNode.getRegionAtCharacterOffset(n - 1);
RegionIterator it = new RegionIterator(flatNode, region);
while (it.hasPrev()) {
ITextRegion reg = it.prev();
// if (reg.getType() == JSONRegionContexts.JSON_CDC)
// return it.getStructuredDocumentRegion().getStartOffset(reg);
}
return n;
}
return -1;
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:22,代码来源:JSONDocumentFormatter.java
示例12: formatPost
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
*
*/
protected void formatPost(IJSONNode node, StringBuilder source) {
IJSONCleanupStrategy stgy = getCleanupStrategy(node);
int end = ((IndexedRegion) node).getEndOffset();
int start = (node.getLastChild() != null && ((IndexedRegion) node
.getLastChild()).getEndOffset() > 0) ? ((IndexedRegion) node
.getLastChild()).getEndOffset() : getChildInsertPos(node);
if (end > 0 && start < end) { // format source
IStructuredDocument structuredDocument = node.getOwnerDocument()
.getModel().getStructuredDocument();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(
structuredDocument, new FormatRegion(start, end - start),
stgy);
for (int i = 0; i < regions.length; i++) {
appendDelimBefore(node, regions[i], source);
source.append(decoratedRegion(regions[i], 0, stgy));
}
} else { // generate source
String delim = getLineDelimiter(node);
source.append(delim);
source.append(getIndent(node));
source.append("}");//$NON-NLS-1$
}
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:28,代码来源:JSONStructureFormatter.java
示例13: cleanupModel
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
public void cleanupModel(IStructuredModel structuredModel, int start,
int length) {
JSONFormatUtil formatUtil = JSONFormatUtil.getInstance();
if (structuredModel instanceof IJSONModel) {
IJSONDocument doc = ((IJSONModel) structuredModel).getDocument();
IJSONSourceFormatter formatter = JSONSourceFormatterFactory
.getInstance().getSourceFormatter((INodeNotifier) doc);
StringBuilder buf = formatter.cleanup(doc);
if (buf != null) {
int startOffset = ((IndexedRegion) doc).getStartOffset();
int endOffset = ((IndexedRegion) doc).getEndOffset();
formatUtil.replaceSource(doc.getModel(), startOffset, endOffset
- startOffset, buf.toString());
}
}
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:17,代码来源:CleanupProcessorJSON.java
示例14: getNodeByOffset
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
* Returns the SSE DOM Node {@link IDOMNode} by offset from the
* {@link IStructuredModel} SSE mode and null if not found.
*
* @param model
* the SSE model.
* @param offset
* the offset.
* @return
*/
public static final IDOMNode getNodeByOffset(IStructuredModel model,
int offset) {
IndexedRegion node = null;
if (model != null) {
node = model.getIndexedRegion(offset);
if (node instanceof IDOMNode) {
return (IDOMNode) node;
}
int lastOffset = offset;
node = model.getIndexedRegion(offset);
while (node == null && lastOffset >= 0) {
lastOffset--;
node = model.getIndexedRegion(lastOffset);
}
}
return (IDOMNode) node;
}
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:29,代码来源:DOMHelper.java
示例15: computeRegionHelp
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
protected String computeRegionHelp(IndexedRegion treeNode,
IDOMNode parentNode, IStructuredDocumentRegion flatNode,
ITextRegion region, int documentPosition, IDocument document) {
String result = null;
if (region == null) {
return null;
}
if (AngularDOMUtils.hasAngularNature(parentNode)) {
String regionType = region.getType();
if (regionType == DOMRegionContext.XML_CONTENT) {
return computeAngularExpressionHelp((IDOMNode) treeNode,
parentNode, flatNode, region, document,
documentPosition);
} else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
return computeTagAttValueHelp((IDOMNode) treeNode, parentNode,
flatNode, region, document, documentPosition);
}
}
return super.computeRegionHelp(treeNode, parentNode, flatNode, region);
}
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:21,代码来源:HTMLAngularTagInfoHoverProcessor.java
示例16: getAttrByOffset
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
* Returns the SSE DOM Attribute {@link IDOMAttr} by offset from the SSE DOM
* node {@link IDOMNode}.
*
* @param E
* the SSE DOM element {@link IDOMElement}.
* @param region
* the region.
* @return
*/
public static final IDOMAttr getAttrByOffset(Node node, int offset) {
if ((node instanceof IndexedRegion) && ((IndexedRegion) node).contains(offset) && node.hasAttributes()) {
NamedNodeMap attrs = node.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
IndexedRegion attRegion = (IndexedRegion) attrs.item(i);
if (attRegion.contains(offset))
return (IDOMAttr) attrs.item(i);
}
}
return null;
}
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:23,代码来源:DOMUtils.java
示例17: calcNewFoldPosition
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
* @see org.eclipse.wst.sse.ui.internal.projection.AbstractFoldingStrategy#calcNewFoldPosition(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)
*/
protected Position calcNewFoldPosition(IndexedRegion indexedRegion) {
Position retPos = null;
// only want to fold regions of the valid type and with a valid range
if (indexedRegion.getStartOffset() >= 0
&& indexedRegion.getLength() >= 0) {
IJSONNode node = (IJSONNode) indexedRegion;
IStructuredDocumentRegion startRegion = node
.getStartStructuredDocumentRegion();
IStructuredDocumentRegion endRegion = node
.getEndStructuredDocumentRegion();
// if the node has an endRegion (end tag) then folding region is
// between the start and end tag
// else if the region is a comment
// else if the region is only an open tag or an open/close tag then
// don't fold it
if (startRegion != null && endRegion != null) {
if (endRegion.getEndOffset() >= startRegion.getStartOffset())
retPos = new JSONObjectFoldingPosition(startRegion,
endRegion);
}
// else if(startRegion != null && indexedRegion instanceof
// CommentImpl) {
// retPos = new JSONCommentFoldingPosition(startRegion);
// }
}
return retPos;
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:34,代码来源:JSONFoldingStrategy.java
示例18: formatPre
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
*
*/
protected void formatPre(IJSONNode node, StringBuilder source) {
IJSONCleanupStrategy stgy = getCleanupStrategy(node);
int start = ((IndexedRegion) node).getStartOffset();
int end = (node.getFirstChild() != null && ((IndexedRegion) node
.getFirstChild()).getEndOffset() > 0) ? ((IndexedRegion) node
.getFirstChild()).getStartOffset() : getChildInsertPos(node);
if (end > 0) { // format source
IStructuredDocument structuredDocument = node.getOwnerDocument()
.getModel().getStructuredDocument();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(
structuredDocument, new FormatRegion(start, end - start),
stgy);
for (int i = 0; i < regions.length; i++) {
if (i != 0)
appendSpaceBetween(node, regions[i - 1], regions[i], source);
source.append(decoratedSelectorRegion(regions[i],
(i != 0) ? regions[i - 1] : null, stgy));
}
} else { // generate source
String str = "";//((IJSONStyleRule) node).getSelectorText();
// appendSpaceBefore(node,str,source);
source.append(str);
appendSpaceBefore(node, "{", source);//$NON-NLS-1$
source.append("{");//$NON-NLS-1$
}
appendDelimBefore(node, null, source);
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:32,代码来源:JSONObjectFormatter.java
示例19: formatBefore
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
*
*/
protected void formatBefore(IJSONNode node, IJSONNode child,
IRegion region, String toAppend, StringBuilder source) {
IJSONCleanupStrategy stgy = getCleanupStrategy(node);
IJSONModel cssModel = node.getOwnerDocument().getModel();
// BUG202615 - it is possible to have a style declaration
// with no model associated with it
if (cssModel != null) {
IStructuredDocument structuredDocument = cssModel
.getStructuredDocument();
if (structuredDocument != null) {
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(
structuredDocument, region, stgy);
CompoundRegion[] outside = getOutsideRegions(
structuredDocument, region);
for (int i = 0; i < regions.length; i++) {
if (i != 0 || needS(outside[0]))
appendSpaceBefore(node, regions[i], source);
source.append(decoratedRegion(regions[i], 0, stgy)); // must
// be
// comments
}
Preferences preferences = JSONCorePlugin.getDefault()
.getPluginPreferences();
if (needS(outside[1])) {
if (((IndexedRegion) child).getStartOffset() == region
.getOffset() + region.getLength()
&& preferences
.getBoolean(JSONCorePreferenceNames.WRAPPING_ONE_PER_LINE)
&& (node.getOwnerDocument() != node || !preferences
.getBoolean(JSONCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR))) {
appendDelimBefore(node, null, source);
} else
appendSpaceBefore(node, toAppend, source);
}
}
}
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:43,代码来源:JSONPairFormatter.java
示例20: getLengthToReformatAfter
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入依赖的package包/类
/**
*
* @return int
* @param node
* org.eclipse.wst.css.core.model.interfaces.IJSONNode
* @param insertPos
* int
*/
public int getLengthToReformatAfter(IJSONNode node, int insertPos) {
if (node == null)
return 0;
IndexedRegion nnode = (IndexedRegion) node;
if (insertPos < 0 || !nnode.contains(insertPos))
return 0;
IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel()
.getStructuredDocument().getRegionAtCharacterOffset(insertPos);
if (flatNode == null)
return 0;
ITextRegion region = flatNode.getRegionAtCharacterOffset(insertPos);
if (region == null)
return 0;
RegionIterator it = new RegionIterator(flatNode, region);
boolean found = false;
while (it.hasNext()) {
region = it.next();
// if (region.getType() != JSONRegionContexts.WHITE_SPACE &&
// region.getType() != JSONRegionContexts.JSON_DELIMITER &&
// region.getType() !=
// JSONRegionContexts.JSON_DECLARATION_DELIMITER) {
if (region.getType() != JSONRegionContexts.WHITE_SPACE) {
found = true;
break;
}
}
int pos = (found ? it.getStructuredDocumentRegion().getStartOffset(
region) : it.getStructuredDocumentRegion().getTextEndOffset(
region))
- insertPos;
return (pos >= 0) ? pos : 0;
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:42,代码来源:AbstractJSONSourceFormatter.java
注:本文中的org.eclipse.wst.sse.core.internal.provisional.IndexedRegion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论