Java Code Examples for org.eclipse.xtext.GrammarUtil#getSimpleName()

The following examples show how to use org.eclipse.xtext.GrammarUtil#getSimpleName() . 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: ValidValidatorFragment.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets the valid model.
 *
 * @param grammar
 *          the grammar
 * @return the valid model
 */
private ValidModel getValidModel(final Grammar grammar) {
  if (model != null) {
    return model;
  }

  Resource resource = null;
  final String name = GrammarUtil.getSimpleName(grammar) + '.' + XTEXT_EXTENSION;
  URI uri;
  for (final Resource res : grammar.eResource().getResourceSet().getResources()) {
    if (res.getURI() != null && name.equals(EmfResourceUtil.getFileName(res.getURI()))) {
      resource = res;
      break;
    }
  }
  if (getValidURI() == null) {
    Assert.isNotNull(resource, NLS.bind(Messages.RESOURCE_NOT_FOUND, name));
    uri = resource.getURI().trimFileExtension().appendFileExtension(VALID_EXTENSION);
  } else {
    uri = URI.createURI(getValidURI());
  }

  resource = resource.getResourceSet().getResource(uri, true);

  final List<Issue> issues = VALIDATOR.validate(resource, LOGGER);
  for (final Issue issue : issues) {
    if (issue.isSyntaxError() || issue.getSeverity() == Severity.ERROR) {
      throw new WorkflowInterruptedException(NLS.bind(Messages.ERROR_FOUND, uri.toString()));
    }
  }
  model = (ValidModel) resource.getContents().get(0);
  return model;
}
 
Example 2
Source File: RuleNames.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private String getInheritedUniqueName(AbstractRule rule, Set<String> usedNames) {
	String grammarName = GrammarUtil.getSimpleName(GrammarUtil.getGrammar(rule));
	String candidate = grammarName + rule.getName();
	int i = 1;
	while(usedNames.contains(candidate)) {
		candidate = grammarName + i + rule.getName();
		i++;
	}
	return candidate;
}
 
Example 3
Source File: ValidatorFragment2.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.14
 */
protected TypeReference getValidatorConfigurationBlockClass() {
  String _runtimeBasePackage = this._xtextGeneratorNaming.getRuntimeBasePackage(this.getGrammar());
  String _plus = (_runtimeBasePackage + ".validation.");
  String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
  String _plus_1 = (_plus + _simpleName);
  String _plus_2 = (_plus_1 + "ValidatorConfigurationBlock");
  return new TypeReference(_plus_2);
}
 
Example 4
Source File: ImportNamespacesScopingFragment2.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected TypeReference getAbstractScopeProviderClass(final Grammar grammar) {
  String _runtimeBasePackage = this._xtextGeneratorNaming.getRuntimeBasePackage(grammar);
  String _plus = (_runtimeBasePackage + ".scoping.");
  String _plus_1 = (_plus + "Abstract");
  String _simpleName = GrammarUtil.getSimpleName(grammar);
  String _plus_2 = (_plus_1 + _simpleName);
  String _plus_3 = (_plus_2 + "ScopeProvider");
  return new TypeReference(_plus_3);
}
 
Example 5
Source File: ContentAssistFragment.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public String getProposalProviderName(final Grammar grammar) {
  String _basePackageUi = this._naming.basePackageUi(grammar);
  String _plus = (_basePackageUi + ".contentassist.");
  String _simpleName = GrammarUtil.getSimpleName(grammar);
  String _plus_1 = (_plus + _simpleName);
  return (_plus_1 + "ProposalProvider");
}
 
Example 6
Source File: ResourceDescriptionStrategyFragment.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected TypeReference getAbstractResourceDescriptionStrategyClass() {
  String _runtimeBasePackage = this._xtextGeneratorNaming.getRuntimeBasePackage(this.getGrammar());
  String _plus = (_runtimeBasePackage + ".resource.");
  String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
  String _plus_1 = (_plus + _simpleName);
  String _plus_2 = (_plus_1 + "AbstractResourceDescriptionStrategy");
  return new TypeReference(_plus_2);
}
 
Example 7
Source File: GrammarAccessUtil.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public static String getGrammarAccessFQName(Grammar grammar, Naming naming) {
	return naming.basePackageRuntime(grammar) + ".services." +GrammarUtil.getSimpleName(grammar) + "GrammarAccess";
}
 
Example 8
Source File: XtextGeneratorNaming.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public TypeReference getWebSetup(Grammar grammar) {
	return new TypeReference(getWebBasePackage(grammar), GrammarUtil.getSimpleName(grammar) + "WebSetup");
}
 
Example 9
Source File: CodetemplatesGeneratorFragment.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public static String getContentAssistParser(Grammar grammar, Naming naming) {
	return naming.basePackageIde(grammar) + ".contentassist.antlr." + GrammarUtil.getSimpleName(grammar) + "Parser";
}
 
Example 10
Source File: XtextAntlrUiGeneratorFragment.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public static String getParserClassName(Grammar g, Naming naming) {
	return naming.basePackageIde(g) + ".contentassist.antlr." + GrammarUtil.getSimpleName(g) + "Parser";
}
 
Example 11
Source File: XtextGeneratorNaming.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public TypeReference getWebModule(Grammar grammar) {
	return new TypeReference(getWebBasePackage(grammar), GrammarUtil.getSimpleName(grammar) + "WebModule");
}
 
Example 12
Source File: SerializerFragment2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected TypeReference getSemanticSequencerClass(final Grammar grammar) {
  String _serializerBasePackage = this.getSerializerBasePackage(grammar);
  String _simpleName = GrammarUtil.getSimpleName(grammar);
  String _plus = (_simpleName + "SemanticSequencer");
  return new TypeReference(_serializerBasePackage, _plus);
}
 
Example 13
Source File: XtextGeneratorNaming.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public TypeReference getWebGenModule(Grammar grammar) {
	return new TypeReference(getWebBasePackage(grammar),
			"Abstract" + GrammarUtil.getSimpleName(grammar) + "WebModule");
}
 
Example 14
Source File: XtextGeneratorNaming.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public TypeReference getEclipsePluginExecutableExtensionFactory(Grammar grammar) {
	return new TypeReference(getEclipsePluginBasePackage(grammar),
			GrammarUtil.getSimpleName(grammar) + "ExecutableExtensionFactory");
}
 
Example 15
Source File: XtextGeneratorNaming.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public TypeReference getEclipsePluginEditor(Grammar grammar) {
	return new TypeReference(getEclipsePluginBasePackage(grammar) + ".editor",
			GrammarUtil.getSimpleName(grammar) + "Editor");
}
 
Example 16
Source File: AntlrFragmentHelper.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public String getParserGrammarFileName(Grammar g) {
	return naming.basePackageRuntime(g) + ".parser.antlr.internal.Internal" + GrammarUtil.getSimpleName(g) + "Parser";
}
 
Example 17
Source File: XtextAntlrUiGeneratorFragment.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public static String getInternalLexerClassName(Grammar g, Naming naming) {
	return naming.basePackageIde(g) + ".contentassist.antlr.internal.Internal" + GrammarUtil.getSimpleName(g)
			+ "Lexer";
}
 
Example 18
Source File: AntlrFragmentHelper.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public String getContentAssistLexerGrammarFileName(Grammar g) {
	return naming.basePackageIde(g) + ".contentassist.antlr.lexer.Internal" + GrammarUtil.getSimpleName(g) + "Lexer";
}
 
Example 19
Source File: ValidValidatorFragment.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Gets the java validator name.
 *
 * @param grammar
 *          the grammar
 * @param naming
 *          generator naming variables and properties
 * @return the java validator name
 */
public static String getPreferencePageName(final Grammar grammar, final Naming naming) {
  return getPreferencePackage(grammar, naming) + "." + GrammarUtil.getSimpleName(grammar) + "ValidPreferencePage"; //$NON-NLS-1$ //$NON-NLS-2$
}
 
Example 20
Source File: ValidValidatorFragment.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Gets the check validator name.
 *
 * @param grammar
 *          the grammar
 * @param naming
 *          generator naming variables and properties
 * @return the check validator name
 */
public static String getCheckValidatorName(final Grammar grammar, final Naming naming) {
  return naming.basePackageRuntime(grammar) + ".validation." + GrammarUtil.getSimpleName(grammar) + "CheckValidator"; //$NON-NLS-1$//$NON-NLS-2$
}