use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class DocumentLockerTest method testModifySetsOutdatedFalse.
@Test
public void testModifySetsOutdatedFalse() {
DocumentTokenSource _createTokenSource = this.createTokenSource();
ITextEditComposer _createTextEditComposer = this.createTextEditComposer();
final XtextDocument document = new XtextDocument(_createTokenSource, _createTextEditComposer, this.outdatedStateManager, this.operationCanceledManager);
XtextResource _xtextResource = new XtextResource();
final Procedure1<XtextResource> _function = (XtextResource it) -> {
EList<Resource> _resources = new XtextResourceSet().getResources();
_resources.add(it);
};
final XtextResource resource = ObjectExtensions.<XtextResource>operator_doubleArrow(_xtextResource, _function);
document.setInput(resource);
final IUnitOfWork<Object, XtextResource> _function_1 = (XtextResource it) -> {
Object _xblockexpression = null;
{
Assert.assertFalse(document.getCancelIndicator().isCanceled());
_xblockexpression = null;
}
return _xblockexpression;
};
document.<Object>internalModify(_function_1);
final CancelIndicator indicator = document.getCancelIndicator();
Assert.assertFalse(indicator.isCanceled());
document.set("fupp");
Assert.assertTrue(indicator.isCanceled());
final IUnitOfWork<Object, XtextResource> _function_2 = (XtextResource it) -> {
Object _xblockexpression = null;
{
Assert.assertFalse(document.getCancelIndicator().isCanceled());
_xblockexpression = null;
}
return _xblockexpression;
};
document.<Object>internalModify(_function_2);
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class DocumentLockerTest method testNoUpdateContentProcessOnReentrant.
@Test
public void testNoUpdateContentProcessOnReentrant() {
final ArrayList<String> s = CollectionLiterals.<String>newArrayList();
DocumentTokenSource _createTokenSource = this.createTokenSource();
ITextEditComposer _createTextEditComposer = this.createTextEditComposer();
final XtextDocument document = new XtextDocument(_createTokenSource, _createTextEditComposer, this.outdatedStateManager, this.operationCanceledManager) {
@Override
protected boolean updateContentBeforeRead() {
return s.add("x");
}
};
XtextResource _xtextResource = new XtextResource();
final Procedure1<XtextResource> _function = (XtextResource it) -> {
EList<Resource> _resources = new XtextResourceSet().getResources();
_resources.add(it);
};
XtextResource _doubleArrow = ObjectExtensions.<XtextResource>operator_doubleArrow(_xtextResource, _function);
document.setInput(_doubleArrow);
Assert.assertEquals(0, s.size());
final IUnitOfWork<Object, XtextResource> _function_1 = (XtextResource it) -> {
Assert.assertEquals(1, s.size());
final IUnitOfWork<Object, XtextResource> _function_2 = (XtextResource it_1) -> {
Assert.assertEquals(1, s.size());
final IUnitOfWork<Object, XtextResource> _function_3 = (XtextResource it_2) -> {
Assert.assertEquals(1, s.size());
return null;
};
document.<Object>readOnly(_function_3);
return null;
};
document.<Object>readOnly(_function_2);
return null;
};
document.<Object>readOnly(_function_1);
Assert.assertEquals(1, s.size());
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class AbstractHyperlinkingTest method getResourceSet.
public XtextResourceSet getResourceSet() {
final XtextResourceSet rs = this.<XtextResourceSet>get(XtextResourceSet.class);
this.initializeTypeProvider(rs);
return rs;
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class GrammarGeneratorTest method checkGeneratedGrammarIsValid.
private void checkGeneratedGrammarIsValid(List<String> ePackageURIs) throws IOException {
for (String nsURI : ePackageURIs) {
System.out.print(nsURI);
EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(nsURI);
XtextProjectInfo xtextProjectInfo = new XtextProjectInfo();
Set<EPackage> ePackages = new HashSet<EPackage>();
if (!addImportedEPackages(ePackage, ePackages)) {
System.out.println("...skipping");
} else {
List<EPackageInfo> ePackageInfos = Lists.newArrayList(Iterables.transform(ePackages, new Function<EPackage, EPackageInfo>() {
@Override
public EPackageInfo apply(EPackage from) {
return new EPackageInfo(from, URI.createURI(from.getNsURI()), null, null, null);
}
}));
xtextProjectInfo.getEcore2Xtext().getEPackageInfos().addAll(ePackageInfos);
String languageName = "org.eclipse.xtext.xtext.ui.tests." + ePackage.getName();
xtextProjectInfo.getLanguage().setName(languageName);
String grammarFileName = languageName.replaceAll("\\.", "/") + ".xtext";
String xtextGrammar = createGrammar(xtextProjectInfo).toString();
ResourceSet resourceSet = new XtextResourceSet();
Resource xtextResource = resourceSet.createResource(URI.createFileURI(grammarFileName));
xtextResource.load(new StringInputStream(xtextGrammar), null);
checkErrors(ePackage, xtextResource, xtextGrammar);
if (!WARNING_PACKAGE_NS_URIS.contains(ePackage.getNsURI())) {
assertTrue("Warnings in grammar for " + ePackage.getNsURI(), xtextResource.getWarnings().isEmpty());
}
System.out.println(" ...OK");
}
}
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class XtextResourceSetBasedProjectProviderTest method setUp.
@Before
public void setUp() throws Exception {
resourceSet = new XtextResourceSet();
mockProjectProvider = new MockJavaProjectProvider();
resourceSet.setClasspathURIContext(mockProjectProvider.getJavaProject(null));
projectProvider = new XtextResourceSetBasedProjectProvider();
}
Aggregations