本文整理匯總了Java中org.eclipse.xtext.resource.XtextResource.reparse方法的典型用法代碼示例。如果您正苦於以下問題:Java XtextResource.reparse方法的具體用法?Java XtextResource.reparse怎麽用?Java XtextResource.reparse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.xtext.resource.XtextResource
的用法示例。
在下文中一共展示了XtextResource.reparse方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testReparse
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test
public void testReparse() {
try {
final ContentAssistFragmentTestLanguageRoot result = this.parseHelper.parse(" newArrayList(1) ");
Resource _eResource = result.eResource();
final XtextResource res = ((XtextResource) _eResource);
res.reparse(" newArrayList(2) ");
final EObject first = IterableExtensions.<EObject>head(res.getContents());
Assert.assertTrue((first instanceof ContentAssistFragmentTestLanguageRoot));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例2: testNoLeaking
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test
public void testNoLeaking() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{val x = \"foo\"");
_builder.newLine();
_builder.append("print(x)}");
_builder.newLine();
String contents = _builder.toString();
Resource _newResource = this.newResource(contents);
final XtextResource resource = ((XtextResource) _newResource);
EcoreUtil2.resolveAll(resource);
final JvmTypeChangeDispatcher dispatcher = JvmTypeChangeDispatcher.findResourceChangeDispatcher(resource.getResourceSet());
List<Runnable> listeners = this._reflectExtensions.<List<Runnable>>get(dispatcher, "listeners");
Assert.assertEquals(2, listeners.size());
resource.reparse(contents);
EcoreUtil2.resolveAll(resource);
listeners = this._reflectExtensions.<List<Runnable>>get(dispatcher, "listeners");
Assert.assertEquals(2, listeners.size());
final EObject jvmType = resource.getContents().get(1);
this.unloader.unloadRoot(jvmType);
resource.getContents().remove(jvmType);
listeners = this._reflectExtensions.<List<Runnable>>get(dispatcher, "listeners");
Assert.assertEquals(0, listeners.size());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例3: testUtfBytesWithIsoOptions
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test public void testUtfBytesWithIsoOptions() throws Exception {
XtextResource resource = createXtextResource();
try {
resource.load(new ByteArrayInputStream(utfBytes), isoOptions);
assertFalse(resource.getErrors().toString(), resource.getErrors().isEmpty());
} catch (WrappedException e) {
if (e.getCause() instanceof CharConversionException) {
// ok
} else {
throw e;
}
}
resource.reparse(model);
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
}
示例4: testIsoBytesWithUtfOptions
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test public void testIsoBytesWithUtfOptions() throws Exception {
XtextResource resource = createXtextResource();
try {
resource.load(new ByteArrayInputStream(isoBytes), utfOptions);
assertFalse(resource.getErrors().toString(), resource.getErrors().isEmpty());
} catch(WrappedException e) {
if (e.getCause() instanceof CharConversionException) {
// ok
} else {
throw e;
}
}
resource.reparse(model);
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
}
示例5: testIsoEncoding
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test public void testIsoEncoding() throws Exception {
XtextResource resource = createXtextResource();
resource.load(new ByteArrayInputStream(isoBytes), isoOptions);
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
resource.reparse(model);
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
}
示例6: testUtfEncoding
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test public void testUtfEncoding() throws Exception {
XtextResource resource = createXtextResource();
resource.load(new ByteArrayInputStream(utfBytes), utfOptions);
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
resource.reparse(model);
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
}
示例7: testReparse
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test public void testReparse() throws Exception {
String modelText = " type A extends B \n type B extends C";
XtextResource resource = getResourceFromStringAndExpect(modelText, 1);
Main model = (Main) getModel(resource);
assertEquals(2, model.getTypes().size());
assertEquals(4, getContentSize(model));
resource.reparse(modelText);
model = (Main) getModel(resource);
assertEquals(2, model.getTypes().size());
assertEquals(4, getContentSize(model));
}
示例8: quickFixAndRun
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
/**
* Apply quick fix, compile and run the result. Compares the generated stdout-result to the expectation on the right
* hand side.
*
* @param expectation
* - expected output of running script, just stdout no error-stream. Expecting the error-stream to be
* empty.
* @param resource
* - injected resource
* @param offset
* - parsed arg2 - cursor position
* @param selected
* - parsed arg3 - selection from list of expectations
* @param offset2issue
* - injected Map of issues
* @param init
* - injected xpect-initizalizer
* @param fileSetupContext
* - injected xpect meta-info about file under test.
* @throws Exception
* in failure case
*/
@Xpect
@ParameterParser(syntax = "('at' arg2=STRING)? ('apply' arg3=STRING )?")
@ConsumedIssues({ Severity.INFO, Severity.ERROR, Severity.WARNING })
public void quickFixAndRun(
@StringExpectation(caseSensitive = true) IStringExpectation expectation, // arg0
@ThisResource XtextResource resource, // arg1
RegionWithCursor offset, // arg2
String selected, // arg3
@IssuesByLine Multimap<Integer, Issue> offset2issue,
ISetupInitializer<Object> init,
FileSetupContext fileSetupContext) throws Exception {
try {
long timeStart = System.currentTimeMillis();
logger.info("Execution started: " + new Date(timeStart));
// System.out.println(
// "##-Qr-## we got it selected='" + selected + "' at " + offset + " in " + resource.toString() + "");
String executionResult;
ExecutionResult exRes = new ExecutionResult();
ResourceTweaker resourceTweaker = resourceToTweak -> {
try {
quickFix(null, resourceToTweak, offset, selected, "fileValid", "", offset2issue, false);
} catch (Exception e) {
Exceptions.sneakyThrow(e);
}
};
Display.getDefault().syncExec(
() -> exRes.result = compileAndExecute(resource, init, fileSetupContext, resourceTweaker));
executionResult = exRes.result;
long timeEnd = System.currentTimeMillis();
logger.info("Execution finished: " + new Date(timeEnd));
logger.info("Execution took " + (timeEnd - timeStart + 0.0) / 1000.0 + " seconds.");
expectation.assertEquals(executionResult);
// Reset resource after quick fix application and code execution
resource.reparse(getContentForResourceUri(resource.getURI()));
} finally {
logger.info("Closing all editors");
EditorsUtil.forceCloseAllEditors();
}
logger.info("Successful End of Execution");
}