Java Code Examples for org.eclipse.xtext.conversion.IValueConverterService#toString()
The following examples show how to use
org.eclipse.xtext.conversion.IValueConverterService#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImportDescriptor.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** Emit N4JS source code for this import. */ public String toCode(String spacing, IValueConverterService valueConverter, N4JSGrammarAccess grammarAccess) { StringBuilder sb = new StringBuilder(128); sb.append("import "); if (isNamed) { if (isDefault) { sb.append(alias); } else { sb.append('{'); sb.append(spacing); sb.append(elementName); if (alias != null) { sb.append(" as "); sb.append(alias); } sb.append(spacing); sb.append('}'); } sb.append(' '); } else if (isNamespace) { sb.append("* as "); sb.append(alias); sb.append(' '); } if (!isBare()) { sb.append("from "); } if (valueConverter != null && grammarAccess != null) { String syntacticModuleSpecifier = valueConverter.toString(moduleSpecifier, grammarAccess.getModuleSpecifierRule().getName()); sb.append(syntacticModuleSpecifier); } else { sb.append('"'); sb.append(moduleSpecifier); sb.append('"'); } sb.append(';'); return sb.toString(); }
Example 2
Source File: DeclarativeValueConverterServiceTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testDuplicateConverters() { IValueConverterService converter = get(DuplicateConverters.class); try { converter.toString("Foo", "unknown"); fail("Expected IllegalStateException"); } catch(IllegalStateException e) { assertTrue(e.getMessage().endsWith("'STRING'")); } }
Example 3
Source File: DeclarativeValueConverterServiceTest.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Test public void testOverriddenIdConverter() { IValueConverterService converter = get(OverriddenIdConverter.class); expectedIdent = "overriddenIdConverter"; converter.toString("Foo", "ID"); }