当前位置: 首页>>代码示例>>Java>>正文


Java IndexedRegion类代码示例

本文整理汇总了Java中org.eclipse.wst.sse.core.internal.provisional.IndexedRegion的典型用法代码示例。如果您正苦于以下问题:Java IndexedRegion类的具体用法?Java IndexedRegion怎么用?Java IndexedRegion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IndexedRegion类属于org.eclipse.wst.sse.core.internal.provisional包,在下文中一共展示了IndexedRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.eclipse.wst.sse.core.internal.provisional.IndexedRegion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。