本文整理汇总了Java中org.eclipse.xtext.serializer.impl.Serializer.serialize方法的典型用法代码示例。如果您正苦于以下问题:Java Serializer.serialize方法的具体用法?Java Serializer.serialize怎么用?Java Serializer.serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.serializer.impl.Serializer
的用法示例。
在下文中一共展示了Serializer.serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.eclipse.xtext.serializer.impl.Serializer; //导入方法依赖的package包/类
public static void main(String[] args) {
// Getting the serializer
GExpressionsStandaloneSetup setup = new GExpressionsStandaloneSetup();
Injector injector = setup.createInjectorAndDoEMFRegistration();
Serializer serializer = injector.getInstance(Serializer.class);
// Creating a model
GexpressionsFactory factory = GexpressionsFactory.eINSTANCE;
GAdditionExpression exp = factory.createGAdditionExpression();
GIntegerExpression un = factory.createGIntegerExpression();
un.setValue(1);
GStringExpression deux = factory.createGStringExpression();
deux.setValue("deux");
exp.setLeftOperand(un);
exp.setRightOperand(deux);
// Serializing
String s = serializer.serialize(exp);
System.out.println(s);
}
示例2: loadGexpressionTestFile
import org.eclipse.xtext.serializer.impl.Serializer; //导入方法依赖的package包/类
public static void loadGexpressionTestFile() {
// Getting the serializer
GExpressionsStandaloneSetup setup = new GExpressionsStandaloneSetup();
Injector injector = setup.createInjectorAndDoEMFRegistration();
GexpressionsPackage.eINSTANCE.eClass();
Serializer serializer = injector.getInstance(Serializer.class);
// Load the model
URI modelURI = URI
.createFileURI("/home/flatombe/thesis/gemoc/git/gemoc-dev/org/eclipse/gemoc/GEL/org.eclipse.gemoc.gel.gexpressions.test/model/test.gexpressions");
XtextResourceSet resSet = injector.getInstance(XtextResourceSet.class);
resSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
Resource resource = resSet.getResource(modelURI, true);
GProgram program = (GProgram) resource.getContents().get(0);
List<GExpression> exps = program.getExpressions();
for (GExpression exp : exps) {
// Serializing
String s = serializer.serialize(exp);
System.out.println(s);
}
}
示例3: testBug370426
import org.eclipse.xtext.serializer.impl.Serializer; //导入方法依赖的package包/类
@Test public void testBug370426() throws Exception {
with(SimpleExpressionsTestLanguageStandaloneSetup.class);
String model = "a/b\n+c";
XtextResource resource = getResourceFromString(model);
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
// turn /b into a comment
resource.update(model.indexOf("/"), 0, "/");
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
Serializer serializer = get(Serializer.class);
String newModel = serializer.serialize(EcoreUtil.copy(resource.getContents().get(0)));
assertEquals("a + c", newModel);
// change comment back into /b
resource.update(model.indexOf("/"), 1, "");
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
assertEquals(model, serialize(resource.getContents().get(0)));
}