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


Java IStructuredDocumentRegion.getEndOffset方法代码示例

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


在下文中一共展示了IStructuredDocumentRegion.getEndOffset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calcNewFoldPosition

import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的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

示例2: create

import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
 * Make sure to call {@link #release()} after you are done!
 * 
 * @return a {@link DtdRemover} or null
 */
private static DtdRemover create(ITextViewer textViewer,
    int documentPosition) {

  IDocumentPartitionerFactory docPartitionerFactory = new IDocumentPartitionerFactory() {
    public IDocumentPartitioner createDocumentPartitioner() {
      return new StructuredTextPartitionerForUiBinderXml();
    }
  };

  StructuredDocumentCloner structuredDocumentCloner = new StructuredDocumentCloner(
      IXMLPartitions.XML_DEFAULT, docPartitionerFactory);
  IStructuredDocument clonedDoc = structuredDocumentCloner.clone(textViewer.getDocument());
  if (clonedDoc == null) {
    return null;
  }

  IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(
      clonedDoc);
  try {
    IDOMNode docType = (IDOMNode) model.getDocument().getDoctype();
    if (docType == null) {
      return null;
    }

    IStructuredDocumentRegion firstRegion = docType.getFirstStructuredDocumentRegion();
    IStructuredDocumentRegion lastRegion = docType.getLastStructuredDocumentRegion();
    int firstPos = firstRegion.getStartOffset();
    int lastPos = lastRegion.getEndOffset();
    int docTypeLen = lastPos - firstPos;

    if (docTypeLen == 0 || documentPosition >= firstPos
        && documentPosition <= lastPos) {
      return null;
    }

    try {
      clonedDoc.replace(firstPos, docTypeLen,
          StringUtilities.repeatCharacter(' ', docTypeLen));
    } catch (BadLocationException e) {
      GWTPluginLog.logError(e,
          "Unexpected bad location while removing doctype");
      return null;
    }

  } finally {
    if (model != null) {
      model.releaseFromRead();
    }
  }

  return new DtdRemover(new DocumentChangingTextViewer(textViewer,
      clonedDoc), documentPosition, structuredDocumentCloner, clonedDoc);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:59,代码来源:UiBinderXmlCompletionProcessor.java

示例3: checkForCrossStructuredDocumentRegionSyntax

import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
 * 
 */
// public StructuredDocumentEvent
// checkForCrossStructuredDocumentRegionBoundryCases2() {
// StructuredDocumentEvent result = specialPositionUpdate(fStart, fStart +
// fLengthToReplace - 1);
// if (result == null) {
// result = checkInsideBrace();
// }
// return result;
// }
@Override
protected StructuredDocumentEvent checkForCrossStructuredDocumentRegionSyntax() {
	int checkStart = fStart;
	int checkEnd = fStart + fLengthToReplace - 1;
	IStructuredDocumentRegion endRegion = fStructuredDocument
			.getRegionAtCharacterOffset(checkEnd);
	if (endRegion != null) {
		checkEnd = endRegion.getEndOffset();
	}

	ReparseRange range = new ReparseRange(checkStart, checkEnd);

	range.expand(getUpdateRangeForDelimiter(range.getStart(),
			range.getEnd()));
	range.expand(getUpdateRangeForUnknownRegion(range.getStart(),
			range.getEnd()));

	// range.expand(getUpdateRangeForQuotes(range.getStart(),
	// range.getEnd()));
	// range.expand(getUpdateRangeForComments(range.getStart(),
	// range.getEnd()));
	range.expand(getUpdateRangeForBraces(range.getStart(), range.getEnd()));

	StructuredDocumentEvent result;

	result = checkInsideBrace(range.getStart(), range.getEnd());

	if (result == null) {
		result = reparse(range.getStart(), range.getEnd());
	}

	return result;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:46,代码来源:JSONStructuredDocumentReParser.java

示例4: getRegions

import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
	 * 
	 */
	protected CompoundRegion[] getRegions(IStructuredDocument model,
			IRegion reg, IRegion exceptFor, String pickupType) {
		int start = reg.getOffset();
		int end = reg.getOffset() + reg.getLength();
		int startE = (exceptFor != null) ? exceptFor.getOffset() : -1;
		int endE = (exceptFor != null) ? exceptFor.getOffset()
				+ exceptFor.getLength() : 0;

		ArrayList list = new ArrayList();
		IStructuredDocumentRegion flatNode = model
				.getRegionAtCharacterOffset(start);
		boolean pickuped = false;
		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 (startE >= 0 && startE <= flatNode.getStartOffset(region)
						&& flatNode.getEndOffset(region) <= endE)
					continue;
//				if (region.getType() == JSONRegionContexts.JSON_COMMENT
//						|| region.getType() == JSONRegionContexts.JSON_CDC
//						|| region.getType() == JSONRegionContexts.JSON_CDO)
//					list.add(new CompoundRegion(flatNode, region));
//				else 
				if (!pickuped && region.getType() == pickupType) {
					list.add(new CompoundRegion(flatNode, region));
					pickuped = true;
				}
			}
			flatNode = flatNode.getNext();
		}
		if (list.size() > 0) {
			CompoundRegion[] regions = new CompoundRegion[list.size()];
			list.toArray(regions);
			return regions;
		}
		return new CompoundRegion[0];
	}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:47,代码来源:AbstractJSONSourceFormatter.java

示例5: JSONObjectFoldingPosition

import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
 * <p>
 * Used to represent a folding position that covers a single
 * {@link IStructuredDocumentRegion}.
 * </p>
 * 
 * @param region
 *            the region that covers the entire position of the folding
 *            region
 */
public JSONObjectFoldingPosition(IStructuredDocumentRegion region) {
	super(region.getStartOffset(), region.getEndOffset()
			- region.getStartOffset());
	this.fStartRegion = region;
	this.fEndRegion = null;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:17,代码来源:JSONObjectFoldingPosition.java


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