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


Java IHiddenRegion类代码示例

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


IHiddenRegion类属于org.eclipse.xtext.formatting2.regionaccess包,在下文中一共展示了IHiddenRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: format

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
@Override
public void format(final ITextSegment region, final IHiddenRegionFormatting wrapped, @Extension final IFormattableDocument document) {
  if ((!this.hasWrapped)) {
    IHiddenRegion _switchResult = null;
    boolean _matched = false;
    if (region instanceof IHiddenRegion) {
      _matched=true;
      _switchResult = ((IHiddenRegion)region);
    }
    if (!_matched) {
      if (region instanceof IHiddenRegionPart) {
        _matched=true;
        _switchResult = ((IHiddenRegionPart)region).getHiddenRegion();
      }
    }
    final IHiddenRegion hiddenRegion = _switchResult;
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.indent();
    };
    document.set(hiddenRegion, this.last, _function);
    this.hasWrapped = true;
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:IndentOnceAutowrapFormatter.java

示例2: assertAllWhitespaceIsFormatted

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
protected void assertAllWhitespaceIsFormatted(ITextRegionAccess access, List<ITextReplacement> replacements) {
	List<ITextSegment> expected = Lists.newArrayList();
	IHiddenRegion current = access.regionForRootEObject().getPreviousHiddenRegion();
	while (current != null) {
		expected.addAll(current.getMergedSpaces());
		current = current.getNextHiddenRegion();
	}
	List<ITextSegment> missing = TextRegions.difference(expected, replacements);
	if (!missing.isEmpty()) {
		TextRegionsToString toString = new TextRegionsToString().setTextRegionAccess(access);
		for (ITextSegment region : missing)
			toString.add(region, region.getClass().getSimpleName());
		String msg = "The following regions are not formatted:\n" + toString;
		System.err.println(msg);
		Assert.fail(msg);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:FormatterTester.java

示例3: toString

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
protected String toString(ITextSegment region) {
	String result;
	if (region instanceof IEObjectRegion)
		result = toString((IEObjectRegion) region);
	else if (region instanceof ISemanticRegion)
		result = toString((ISemanticRegion) region);
	else if (region instanceof IHiddenRegion)
		result = toString((IHiddenRegion) region);
	else if (region instanceof IWhitespace)
		result = toString((IWhitespace) region);
	else if (region instanceof IComment)
		result = toString((IComment) region);
	else if (region != null)
		result = region.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(region));
	else
		result = "null";
	if (hightlightOrigin && region == origin)
		return ">>>" + result + "<<<";
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:TextRegionAccessToString.java

示例4: copyAndAppend

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
protected ISequentialRegion copyAndAppend(ISequentialRegion first, ISequentialRegion last) {
	ISequentialRegion current = first;
	ISequentialRegion result = null;
	while (true) {
		if (current instanceof IHiddenRegion) {
			copyAndAppend((IHiddenRegion) current);
		} else if (current instanceof ISemanticRegion) {
			copyAndAppend((ISemanticRegion) current, current.getText());
		}
		if (result == null) {
			result = this.last;
		}
		if (current == last) {
			break;
		}
		current = current.getNextSequentialRegion();
		if (current == null) {
			throw new IllegalStateException("last didn't match");
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:StringBasedTextRegionAccessDiffAppender.java

示例5: merge

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
@Override
public List<IHiddenRegionPart> merge(ITextRegionAccess b, IHiddenRegion first, IHiddenRegion last, boolean del) {
	List<IHiddenRegionPart> parts1 = first.getParts();
	List<IHiddenRegionPart> parts2 = last.getParts();
	boolean firstInFile1 = first.getPreviousSemanticRegion() == null;
	boolean firstInFile2 = last.getPreviousSemanticRegion() == null;
	int index1 = firstInFile1 ? getIndexFirstInFile(parts1) : getIndex(parts1);
	int index2 = firstInFile2 ? getIndexFirstInFile(parts2) : getIndex(parts2);
	List<IHiddenRegionPart> result = Lists.newArrayList();
	if (del && !first.isMultiline()) {
		result.addAll(parts1);
	} else {
		for (int i = 0; i < index1; i++) {
			result.add(parts1.get(i));
		}
	}
	if (del && !last.isMultiline()) {
		result.addAll(parts2);
	} else {
		for (int i = index2; i < parts2.size(); i++) {
			result.add(parts2.get(i));
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:26,代码来源:HiddenRegionPartMerger.java

示例6: mergeHiddenRegionReplacers

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
protected ITextReplacer mergeHiddenRegionReplacers(List<? extends ITextReplacer> conflicting) {
	List<IHiddenRegionFormatting> formattings = Lists.newArrayList();
	IHiddenRegion region = null;
	for (ITextReplacer replacer : conflicting) {
		if (replacer instanceof HiddenRegionReplacer) {
			HiddenRegionReplacer hiddenRegionReplacer = (HiddenRegionReplacer) replacer;
			formattings.add(hiddenRegionReplacer.getFormatting());
			if (region == null)
				region = hiddenRegionReplacer.getRegion();
			else if (region != hiddenRegionReplacer.getRegion())
				return null;
		} else
			return null;
	}
	IHiddenRegionFormatting mergedFormatting = merger.merge(formattings);
	if (mergedFormatting != null)
		return formatter.createHiddenRegionReplacer(region, mergedFormatting);
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:TextReplacerMerger.java

示例7: computeNewLineCount

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
protected int computeNewLineCount(ITextReplacerContext context) {
	Integer newLineDefault = formatting.getNewLineDefault();
	Integer newLineMin = formatting.getNewLineMin();
	Integer newLineMax = formatting.getNewLineMax();
	if (newLineMin != null || newLineDefault != null || newLineMax != null) {
		if (region instanceof IHiddenRegion && ((IHiddenRegion) region).isUndefined()) {
			if (newLineDefault != null)
				return newLineDefault;
			if (newLineMin != null)
				return newLineMin;
			if (newLineMax != null)
				return newLineMax;
		} else {
			int lineCount = region.getLineCount() - 1;
			if (newLineMin != null && newLineMin > lineCount)
				lineCount = newLineMin;
			if (newLineMax != null && newLineMax < lineCount)
				lineCount = newLineMax;
			return lineCount;
		}
	}
	return 0;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:WhitespaceReplacer.java

示例8: isInRequestedRange

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
protected boolean isInRequestedRange(EObject obj) {
	Collection<ITextRegion> regions = request.getRegions();
	if (regions.isEmpty())
		return true;
	ITextRegionAccess access = request.getTextRegionAccess();
	IEObjectRegion objRegion = access.regionForEObject(obj);
	if (objRegion == null)
		return false;
	IHiddenRegion previousHidden = objRegion.getPreviousHiddenRegion();
	IHiddenRegion nextHidden = objRegion.getNextHiddenRegion();
	int objOffset = previousHidden != null ? previousHidden.getOffset() : 0;
	int objEnd = nextHidden != null ? nextHidden.getEndOffset() : access.regionForRootEObject().getEndOffset();
	for (ITextRegion region : regions) {
		int regionOffset = region.getOffset();
		int regionEnd = regionOffset + region.getLength();
		if (regionOffset <= objEnd && regionEnd >= objOffset)
			return true;
	}
	return false;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:AbstractFormatter2.java

示例9: assertToStringDoesNotCrash

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
private void assertToStringDoesNotCrash(final ITextRegionAccess access) {
  IHiddenRegion _previousHiddenRegion = access.regionForRootEObject().getPreviousHiddenRegion();
  ISequentialRegion current = ((ISequentialRegion) _previousHiddenRegion);
  while ((current != null)) {
    {
      Assert.assertNotNull(current.toString());
      boolean _matched = false;
      if (current instanceof IHiddenRegion) {
        _matched=true;
        current = ((IHiddenRegion)current).getNextSemanticRegion();
      }
      if (!_matched) {
        if (current instanceof ISemanticRegion) {
          _matched=true;
          Assert.assertNotNull(((ISemanticRegion)current).getEObjectRegion().toString());
          current = ((ISemanticRegion)current).getNextHiddenRegion();
        }
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:RegionAccessBuilderTest.java

示例10: serialize

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
@Override
public void serialize(ITextRegionDiffBuilder result) {
	ISemanticSequencer semantic = semanticSequencerProvider.get();
	ISyntacticSequencer syntactic = syntacticSequencerProvider.get();
	IHiddenTokenSequencer hidden = hiddenTokenSequencerProvider.get();
	semantic.init((ISemanticSequenceAcceptor) syntactic, errorAcceptor);
	syntactic.init(context, root, (ISyntacticSequenceAcceptor) hidden, errorAcceptor);
	ISequenceAcceptor acceptor;
	if (insertAt instanceof IHiddenRegion) {
		IHiddenRegion h = (IHiddenRegion) insertAt;
		acceptor = result.replaceSequence(h, h, context, root);
	} else {
		IHiddenRegion originalFirst = insertAt.getPreviousHiddenRegion();
		IHiddenRegion originalLast = insertAt.getNextHiddenRegion();
		acceptor = result.replaceSequence(originalFirst, originalLast, context, root);
	}
	hidden.init(context, root, acceptor, errorAcceptor);
	if (acceptor instanceof TokenStreamSequenceAdapter)
		((TokenStreamSequenceAdapter) acceptor).init(context);
	semantic.createSequence(context, root);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:PartialSerializer.java

示例11: findInsertionPoint

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
public IHiddenRegion findInsertionPoint(ISerializationContext ctx, IEObjectRegion obj, AbstractElement ins) {
	ISerState insertionState = findState(ctx, ins);
	Set<AbstractElement> followers = collectAdjacent(insertionState, s -> s.getFollowers());
	Set<AbstractElement> precendents = collectAdjacent(insertionState, s -> s.getPrecedents());
	List<IAstRegion> regions = Lists.newArrayList(obj.getAstRegions());
	if (regions.isEmpty()) {
		return obj.getPreviousHiddenRegion();
	}
	if (followers.contains(regions.get(0).getGrammarElement())) {
		return obj.getPreviousHiddenRegion();
	}
	if (precendents.contains(regions.get(regions.size() - 1).getGrammarElement())) {
		return obj.getNextHiddenRegion();
	}
	for (int i = 0; i < regions.size() - 1; i++) {
		IAstRegion leading = regions.get(i);
		IAstRegion trailing = regions.get(i + 1);
		if (precendents.contains(leading.getGrammarElement()) && followers.contains(trailing.getGrammarElement())) {
			return leading.getNextHiddenRegion();
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:InsertionPointFinder.java

示例12: apply

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
@Override
public SequentialRegionDiff apply(StringBasedTextRegionAccessDiffAppender appender) {
	StringBasedRegionAccess textRegionAccess = sequencer.getRegionAccess();
	IEObjectRegion substituteRoot = textRegionAccess.regionForRootEObject();
	IHiddenRegion substituteFirst = substituteRoot.getPreviousHiddenRegion();
	IHiddenRegion substituteLast = substituteRoot.getNextHiddenRegion();
	SequentialRegionDiff result = appender.copyAndAppend((IHiddenRegion) originalFirst,
			(IHiddenRegion) originalLast, substituteFirst, substituteLast);
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:11,代码来源:StringBasedTextRegionAccessDiffBuilder.java

示例13: addRemoveAction

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
protected void addRemoveAction(IHiddenRegion first, IHiddenRegion last, boolean del) {
	for (RewriteAction rw : rewrites) {
		if (rw.originalFirst == last) {
			rw.originalFirst = first;
			return;
		}
		if (rw.originalLast == first) {
			rw.originalLast = last;
			return;
		}
	}
	rewrites.add(new RemoveRewriteAction(first, last, del));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:14,代码来源:StringBasedTextRegionAccessDiffBuilder.java

示例14: replace

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
@Override
public void replace(IHiddenRegion originalFirst, IHiddenRegion originalLast, IHiddenRegion modifiedFirst,
		IHiddenRegion modifiedLast) {
	checkOriginal(originalFirst);
	checkOriginal(originalLast);
	addInsert(new ReplaceRewriteAction(originalFirst, originalLast, modifiedFirst, modifiedLast));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:StringBasedTextRegionAccessDiffBuilder.java

示例15: replaceSequence

import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion; //导入依赖的package包/类
@Override
public ISequenceAcceptor replaceSequence(IHiddenRegion originalFirst, IHiddenRegion originalLast,
		ISerializationContext ctx, EObject root) {
	checkOriginal(originalFirst);
	checkOriginal(originalLast);
	TextRegionAccessBuildingSequencer sequenceAcceptor = new TextRegionAccessBuildingSequencer();
	addInsert(new SequenceRewriteAction(originalFirst, originalLast, sequenceAcceptor));
	return sequenceAcceptor.withRoot(ctx, root);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:StringBasedTextRegionAccessDiffBuilder.java


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