org.eclipse.xtext.conversion.IValueConverterService Java Examples
The following examples show how to use
org.eclipse.xtext.conversion.IValueConverterService.
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: KeywordAlternativeConverter.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
private IValueConverter<Object> getDelegateConverter() { if (delegateConverter != null) { return delegateConverter; } if (delegateService instanceof IValueConverterService.Introspectable) { return delegateConverter = ((IValueConverterService.Introspectable) delegateService).getConverter(delegateRule.getName()); } else { final String ruleName = delegateRule.getName(); return delegateConverter = new IValueConverter<Object>() { @Override public Object toValue(String string, INode node) throws ValueConverterException { return delegateService.toValue(string, ruleName, node); } @Override public String toString(Object value) throws ValueConverterException { return delegateService.toString(value, ruleName); } }; } }
Example #2
Source File: QualifiedNameValueConverter.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
private IValueConverter<Object> initializeDelegateConverter() { if (valueConverterService instanceof IValueConverterService.Introspectable) { return delegateConverter = ((IValueConverterService.Introspectable) valueConverterService).getConverter(getDelegateRuleName()); } else { final String ruleName = getDelegateRuleName(); return delegateConverter = new IValueConverter<Object>() { @Override public Object toValue(String string, INode node) throws ValueConverterException { return valueConverterService.toValue(string, ruleName, node); } @Override public String toString(Object value) throws ValueConverterException { return valueConverterService.toString(value, ruleName); } }; } }
Example #3
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 #4
Source File: ValueConverterForTerminalFragmentsTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testExceptionWhenRegistered() { IValueConverterService converters = get(ConverterForFragment.class); try { converters.toValue("foo", "STRING", null); } catch(IllegalStateException e) { assertTrue(e.getMessage().contains("ESCAPED_CHAR")); } }
Example #5
Source File: Ecore2XtextValueConverterServiceFragment2.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void generate() { new GuiceModuleAccess.BindingFactory() .addTypeToType(TypeReference.typeRef(IValueConverterService.class), TypeReference.typeRef(Ecore2XtextTerminalConverters.class)) .contributeTo(getLanguage().getRuntimeGenModule()); }
Example #6
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 #7
Source File: AbstractJavaBasedContentProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.1 */ public DefaultProposalCreator(ContentAssistContext contentAssistContext, String ruleName, IQualifiedNameConverter qualifiedNameConverter) { this.contentAssistContext = contentAssistContext; this.ruleName = ruleName; this.qualifiedNameConverter = qualifiedNameConverter; if (this.ruleName != null && getValueConverter() instanceof IValueConverterService.Introspectable) { this.valueConverter = ((IValueConverterService.Introspectable)getValueConverter()).getConverter(ruleName); } else { this.valueConverter = null; } }
Example #8
Source File: ImportsAwareReferenceProposalCreator.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Inject private void setValueConverter(IValueConverterService service, N4JSGrammarAccess grammarAccess) { @SuppressWarnings({ "unchecked", "rawtypes" }) IValueConverter<String> converter = (IValueConverter) ((IValueConverterService.Introspectable) service) .getConverter(grammarAccess .getTypeReferenceNameRule() .getName()); this.valueConverter = converter; }
Example #9
Source File: ExpressionRuntimeModule.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return ExpressionValueConverterService.class; }
Example #10
Source File: AbstractSARLRuntimeModule.java From sarl with Apache License 2.0 | 4 votes |
public Class<? extends IValueConverterService> bindIValueConverterService() { return XtendValueConverterService.class; }
Example #11
Source File: TerminalRulesTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return TerminalRuleTestLanguageConverters.class; }
Example #12
Source File: XtextTerminalsTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return TerminalRuleTestLanguageConverters.class; }
Example #13
Source File: AssignmentsTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return AssignmentsValueConverterService.class; }
Example #14
Source File: DatatypeRulesTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return DatatypeRulesTestLanguageValueConverters.class; }
Example #15
Source File: DeclarativeValueConverterServiceTest.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Test public void testSimpleIdConverter() { IValueConverterService converter = get(SimpleIdConverter.class); expectedIdent = "idConverter"; converter.toValue("Foo", "ID", null); }
Example #16
Source File: ValidRuntimeModule.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return ValidValueConverterService.class; }
Example #17
Source File: AbstractValueConverterServiceTest.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
/** * Returns the {@link IValueConverterService}. * * @return the {@link IValueConverterService}, never {@code null} */ protected IValueConverterService getValueConverterService() { final IValueConverterService valueConverterService = getXtextTestUtil().get(IValueConverterService.class); assertNotNull("The IValueConverterService must be registered in order to test it.", valueConverterService); return valueConverterService; }
Example #18
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"); }
Example #19
Source File: ScopeRuntimeModule.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return ScopeValueConverterService.class; }
Example #20
Source File: ConcreteTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return AbstractTestLanguageValueConverters.class; }
Example #21
Source File: QualifiedNameTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return QualifiedNameTerminalConverters.class; }
Example #22
Source File: Bug250313RuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return Converters.class; }
Example #23
Source File: Bug250313Test.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return MyConverterService.class; }
Example #24
Source File: AssignmentFinderTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return AFValueConverter.class; }
Example #25
Source File: SequencerTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return SequencerTestValueConverter.class; }
Example #26
Source File: AbstractXtextTests.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected IValueConverterService getValueConverterService() { return getInjector().getInstance(IValueConverterService.class); }
Example #27
Source File: FormatRuntimeModule.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return FormatValueConverterService.class; }
Example #28
Source File: Bug362902RuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return Bug362902ValueConverters.class; }
Example #29
Source File: RenameService2.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected IValueConverterService getValueConverterService() { return valueConverterService; }
Example #30
Source File: GH1462TestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Class<? extends IValueConverterService> bindIValueConverterService() { return FallbackValueConverterService.class; }