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


Java PartialParsingPointers类代码示例

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


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

示例1: getOldSemanticElement

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
protected EObject getOldSemanticElement(ICompositeNode replaceMe, PartialParsingPointers parsingPointers) {
	EObject oldSemanticElement = null;
	if (replaceMe.hasDirectSemanticElement()) {
		oldSemanticElement = replaceMe.getSemanticElement();
	} else {
		List<ICompositeNode> nodesEnclosingRegion = parsingPointers.getNodesEnclosingRegion();
		for (int i = nodesEnclosingRegion.size() - 1; i >= 0; --i) {
			ICompositeNode enclosingNode = nodesEnclosingRegion.get(i);
			if (enclosingNode == replaceMe) {
				break;
			}
			if (enclosingNode.hasDirectSemanticElement())
				oldSemanticElement = enclosingNode.getSemanticElement();
		}
	}
	return oldSemanticElement;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:TokenSequencePreservingPartialParsingHelper.java

示例2: calculatePartialParsingPointers

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
protected PartialParsingPointers calculatePartialParsingPointers(ICompositeNode oldRoot, ILeafNode left, ILeafNode right) {
	ICompositeNode result = right.getParent();
	while(result.getTotalOffset() > left.getTotalOffset()) {
		result = result.getParent();
	}
	List<ICompositeNode> nodesEnclosingRegion = getAllParents(result);
	Range range = new Range(left.getTotalOffset(), right.getTotalEndOffset());
	List<ICompositeNode> validReplaceRootNodes = internalFindValidReplaceRootNodeForChangeRegion(nodesEnclosingRegion);

	filterInvalidRootNodes(validReplaceRootNodes);

	if (validReplaceRootNodes.isEmpty()) {
		validReplaceRootNodes = Collections.singletonList(oldRoot);
	}
	return new PartialParsingPointers(oldRoot, range.getOffset(), range.getLength(), validReplaceRootNodes, nodesEnclosingRegion);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:TokenSequencePreservingPartialParsingHelper.java

示例3: checkParseRegionPointers

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
protected void checkParseRegionPointers(
		PartialParsingPointers parsingPointers, 
		String expectedRegion,
		String expectedGrammarElementClassName, 
		String expectedEntryRuleName) {

	assertEquals(expectedRegion, getReparseRegion(parsingPointers));
	EObject grammarElement = parsingPointers.getDefaultReplaceRootNode().getGrammarElement();
	String grammarElementName = grammarElement.eClass().getName();
	assertEquals(expectedGrammarElementClassName, grammarElementName);
	EObject ruleOrRuleCall = parsingPointers.findEntryRuleOrRuleCall(parsingPointers.getDefaultReplaceRootNode());
	if (ruleOrRuleCall instanceof RuleCall) {
		ruleOrRuleCall = ((RuleCall) ruleOrRuleCall).getRule();
	}
	assertEquals(expectedEntryRuleName, ((AbstractRule) ruleOrRuleCall).getName());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:AbstractPartialParsingPointerTest.java

示例4: replaceAndReparse

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
protected void replaceAndReparse(String model, int offset, int length, String change, String expectedReparseRegion)
		throws Exception {
	IParseResult parseResult = getParseResult(model);
	PartialParsingPointers parsingPointers = getPartialParser().calculatePartialParsingPointers(parseResult, offset,
			length);
	String reparseRegion = getPartialParser().insertChangeIntoReplaceRegion(parsingPointers
			.getDefaultReplaceRootNode(), new ReplaceRegion(offset, length, change));
	assertEquals(expectedReparseRegion, reparseRegion);
	final Wrapper<Boolean> unloaded = Wrapper.wrap(Boolean.FALSE);
	getPartialParser().setUnloader(new IReferableElementsUnloader() {
		@Override
		public void unloadRoot(EObject root) {
			unloaded.set(Boolean.TRUE);
		}
	});
	IParseResult partiallyReparse = reparse(parseResult, offset, length, change);
	assertTrue("unloaded", unloaded.get());
	assertFalse(partiallyReparse.getRootNode().getText(), partiallyReparse.hasSyntaxErrors());
	String expectedReparseModel = model.substring(0, offset) + change + model.substring(offset + length);
	assertEquals(expectedReparseModel, partiallyReparse.getRootNode().getText());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:AbstractPartialParserReplaceTest.java

示例5: replaceAndReparse

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
protected void replaceAndReparse(String model, int offset, int length, String change, String expectedReparseRegion)
		throws Exception {
	IParseResult parseResult = getParseResultAndExpect(model, UNKNOWN_EXPECTATION);
	PartialParsingPointers parsingPointers = getPartialParser().calculatePartialParsingPointers(parseResult, offset,
			length);
	String reparseRegion = getPartialParser().insertChangeIntoReplaceRegion(parsingPointers
			.getDefaultReplaceRootNode(), new ReplaceRegion(offset, length, change));
	assertEquals(expectedReparseRegion, reparseRegion);
	final Wrapper<Boolean> unloaded = Wrapper.wrap(Boolean.FALSE);
	getPartialParser().setUnloader(new IReferableElementsUnloader() {
		@Override
		public void unloadRoot(EObject root) {
			unloaded.set(Boolean.TRUE);
		}
	});
	IParseResult partiallyReparse = reparse(parseResult, offset, length, change);
	assertTrue("unloaded", unloaded.get());
	String expectedReparseModel = model.substring(0, offset) + change + model.substring(offset + length);
	assertEquals(expectedReparseModel, partiallyReparse.getRootNode().getText());
	
	compareWithFullParse(model, offset, length, change);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:Bug419429Test.java

示例6: calculatePartialParsingPointers

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
public PartialParsingPointers calculatePartialParsingPointers(final IParseResult previousParseResult, final int offset, final int replacedTextLength) {
  int myOffset = offset;
  int myReplacedTextLength = replacedTextLength;
  ICompositeNode oldRootNode = previousParseResult.getRootNode();
  if (myOffset == oldRootNode.getTotalLength() && myOffset != 0) {
    // newText is appended, so look for the last original character instead
    --myOffset;
    myReplacedTextLength = 1;
  }
  // include any existing parse errors
  Range range = new Range(myOffset, myReplacedTextLength + myOffset);
  if (previousParseResult.hasSyntaxErrors()) {
    range.mergeAllSyntaxErrors(oldRootNode);
  }

  myOffset = range.getOffset();
  List<ICompositeNode> nodesEnclosingRegion = collectNodesEnclosingChangeRegion(oldRootNode, range);
  List<ICompositeNode> validReplaceRootNodes = internalFindValidReplaceRootNodeForChangeRegion(nodesEnclosingRegion, range);

  filterInvalidRootNodes(oldRootNode, validReplaceRootNodes);

  if (validReplaceRootNodes.isEmpty()) {
    validReplaceRootNodes = Collections.singletonList(oldRootNode);
  }
  return new PartialParsingPointers(oldRootNode, myOffset, myReplacedTextLength, validReplaceRootNodes, nodesEnclosingRegion);
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:27,代码来源:FixedPartialParsingHelper.java

示例7: getReplacedNode

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
protected ICompositeNode getReplacedNode(PartialParsingPointers parsingPointers) {
	List<ICompositeNode> validReplaceRootNodes = parsingPointers.getValidReplaceRootNodes();
	ICompositeNode replaceMe = null;
	for (int i = validReplaceRootNodes.size() - 1; i >= 0; --i) {
		replaceMe = validReplaceRootNodes.get(i);
		if (!(replaceMe instanceof SyntheticCompositeNode)) {
			break;	
		}
	}
	return replaceMe;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:TokenSequencePreservingPartialParsingHelper.java

示例8: doParseRegion

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
protected IParseResult doParseRegion(IParser parser, PartialParsingPointers parsingPointers,
		ICompositeNode replaceMe, String reparseRegion) {
	EObject entryRuleOrRuleCall = parsingPointers.findEntryRuleOrRuleCall(replaceMe);
	IParseResult newParseResult = null;
	try {
		if (entryRuleOrRuleCall instanceof RuleCall)
			newParseResult = parser.parse((RuleCall)entryRuleOrRuleCall, new StringReader(reparseRegion), replaceMe.getLookAhead());
		else
			newParseResult = parser.parse((ParserRule)entryRuleOrRuleCall, new StringReader(reparseRegion));
	} catch (ParseException exc) {
	}
	return newParseResult;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:14,代码来源:TokenSequencePreservingPartialParsingHelper.java

示例9: testLookahead_0_2

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
@Test public void testLookahead_0_2() throws Exception {
	String model = "bar a foo bar c b d foo bar b c";
	for (int i = 0; i < 3; ++i) {
		PartialParsingPointers parsingPointers = calculatePartialParsingPointers(model, i, 1);
		checkParseRegionPointers(parsingPointers, model, "ParserRule", "Entry");
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:PartialParsingPointerLookaheadTest.java

示例10: testLookahead_3_4

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
@Test public void testLookahead_3_4() throws Exception {
	String model = "bar a foo bar c b d foo bar b c";
	for (int i = 3; i < 5; ++i) {
		PartialParsingPointers parsingPointers = calculatePartialParsingPointers(model, i, 1);
		checkParseRegionPointers(parsingPointers, "bar a", "RuleCall", "LookAhead0");
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:PartialParsingPointerLookaheadTest.java

示例11: testLookahead_6_8

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
@Test public void testLookahead_6_8() throws Exception {
	String model = "bar a foo bar c b d foo bar b c";
	for (int i = 6; i < 9; ++i) {
		PartialParsingPointers parsingPointers = calculatePartialParsingPointers(model, i, 1);
		checkParseRegionPointers(parsingPointers, model, "ParserRule", "Entry");
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:PartialParsingPointerLookaheadTest.java

示例12: testLookahead_9_14

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
@Test public void testLookahead_9_14() throws Exception {
		String model = "bar a foo bar c b d foo bar b c";
		for (int i = 9; i < 15; ++i) {
			PartialParsingPointers parsingPointers = calculatePartialParsingPointers(model, i, 1);
			// actual expecation would lead to yet more complexity in partial parser
//			checkParseRegionPointers(parsingPointers, " foo bar c b d", "RuleCall", "Alts");
			checkParseRegionPointers(parsingPointers, model, "ParserRule", "Entry");
		}
	}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:PartialParsingPointerLookaheadTest.java

示例13: testLookahead_15_18

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
@Test public void testLookahead_15_18() throws Exception {
	String model = "bar a foo bar c b d foo bar b c";
	for (int i = 15; i < 19; ++i) {
		PartialParsingPointers parsingPointers = calculatePartialParsingPointers(model, i, 1);
		checkParseRegionPointers(parsingPointers, " foo bar c b d", "RuleCall", "LookAhead1");
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:PartialParsingPointerLookaheadTest.java

示例14: testLookahead_19_22

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
@Test public void testLookahead_19_22() throws Exception {
	String model = "bar a foo bar c b d foo bar b c";
	for (int i = 19; i < 22; ++i) {
		PartialParsingPointers parsingPointers = calculatePartialParsingPointers(model, i, 1);
		checkParseRegionPointers(parsingPointers, model, "ParserRule", "Entry");
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:PartialParsingPointerLookaheadTest.java

示例15: testLookahead_23_28

import org.eclipse.xtext.parser.impl.PartialParsingPointers; //导入依赖的package包/类
@Test public void testLookahead_23_28() throws Exception {
	String model = "bar a foo bar c b d foo bar b c";
	for (int i = 23; i < 29; ++i) {
		PartialParsingPointers parsingPointers = calculatePartialParsingPointers(model, i, 1);
		checkParseRegionPointers(parsingPointers, model, "ParserRule", "Entry");
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:PartialParsingPointerLookaheadTest.java


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