org.eclipse.emf.mwe.core.issues.Issues Java Examples
The following examples show how to use
org.eclipse.emf.mwe.core.issues.Issues.
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: LanguageConfig.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public void checkConfiguration(Issues issues) { super.checkConfiguration(issues); if (isCheckFileExtension()) { for (String extension : fileExtensions) { char[] charArray = extension.toCharArray(); if (!Character.isJavaIdentifierPart(charArray[0])) { issues.addError("file extension '"+extension+"' starts with a non identifier letter : '"+charArray[0]+"'", this); } for (int i = 1; i < charArray.length; i++) { char c = charArray[i]; if (!Character.isJavaIdentifierPart(c)) { issues.addError("file extension '"+extension+"' contains non identifier letter : '"+c+"'", this); } } } } if (getGrammar() == null) { issues.addError("property 'uri' is mandatory for element 'language'.", this); } }
Example #2
Source File: Validator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public String toString(Issues issues) { if (!issues.hasErrors() && !issues.hasWarnings()) return "No issues."; StringBuilder result = new StringBuilder(); if (issues.hasErrors()) { MWEDiagnostic[] errors = issues.getErrors(); if (errors.length == 1) { result.append("1 error:\n"); } else { result.append(errors.length).append(" errors:\n"); } appendMessages(result, errors); } if (issues.hasWarnings()) { MWEDiagnostic[] warnings = issues.getWarnings(); if (issues.hasErrors()) result.append('\n'); if (warnings.length == 1) { result.append("1 warning:\n"); } else { result.append(warnings.length).append(" warnings:\n"); } appendMessages(result, warnings); } return result.toString(); }
Example #3
Source File: Reader.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { ResourceSet resourceSet = getResourceSet(); Multimap<String, URI> uris = getPathTraverser().resolvePathes(pathes, new Predicate<URI>() { @Override public boolean apply(URI input) { boolean result = true; if (getUriFilter() != null) result = getUriFilter().matches(input); if (result) result = getRegistry().getResourceServiceProvider(input) != null; return result; } }); IAllContainersState containersState = containersStateFactory.getContainersState(pathes, uris); installAsAdapter(resourceSet, containersState); populateResourceSet(resourceSet, uris); getValidator().validate(resourceSet, getRegistry(), issues); addModelElementsToContext(ctx, resourceSet); }
Example #4
Source File: Reader.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected void checkConfigurationInternal(Issues issues) { super.checkConfigurationInternal(issues); if (pathes.isEmpty()) { issues.addWarning("No path set, using java class path entries (useJavaClassPath='true')."); setUseJavaClassPath(true); } if (log.isDebugEnabled()) { log.debug("Resource Pathes : " + pathes); } for (String path : pathes) { if (!new File(path).exists()) issues.addWarning("Skipping the path '" + path + "', because it does not exist."); } }
Example #5
Source File: BasicUiGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void checkConfiguration(Issues issues) { issues.addWarning("Fragment org.eclipse.xtext.ui.generator.BasicUiGeneratorFragment is deprecated and not needed anymore. Just remove it from the mwe configuration."); if (fileExtensions!=null) issues.addError("the fileExtensions property has been moved to the main language configuration. \n\tPlease change your *.mwe file to something like \n\n\t" + "<language uri='${grammarURI}' fileExtensions='" + fileExtensions + "'> \n\t\t <-- fragments go here ... --> \n\t</languageConfig>\n\n",this); }
Example #6
Source File: Ecore2XtextGenerator.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected void invokeInternal(final WorkflowContext ctx, ProgressMonitor monitor, final Issues issues) { createXtextProjectInfo(issues); CharSequence grammar = xtextProjectInfo.getRuntimeProject().grammar(); try { Files.asCharSink(new File(genPath, xtextProjectInfo.getRuntimeProject().getGrammarFilePath()), Charsets.ISO_8859_1).write(grammar); } catch (IOException e) { String message = "Can't create grammar file"; log.error(message, e); issues.addError(Ecore2XtextGenerator.this, message, this, e, null); } }
Example #7
Source File: XcoreReader.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { ResourceSet resourceSet = getResourceSet(); // due to some Xcore peculiarity we have to access the IAllContainerState here // to trigger some lazy init logic IAllContainersState allContainerState = (IAllContainersState) EcoreUtil.getAdapter(resourceSet.eAdapters(), IAllContainersState.class); allContainerState.isEmpty(""); Multimap<String, URI> uris = getPathTraverser().resolvePathes(pathes, new Predicate<URI>() { @Override public boolean apply(URI input) { return input.fileExtension().equals(XCORE_FILE_EXT); } }); List<Resource> resources = new ArrayList<>(); for (URI uri : uris.values()) { LOGGER.info(uri); try { resources.add(parse(uri, resourceSet)); } catch (Exception e) { LOGGER.error("Problem during loading of resource @ " + uri, e); } } installIndex(resourceSet); for (Resource r : resources) { EcoreUtil.resolveAll(r); for (Diagnostic x : r.getErrors()) { issues.addError(x.getMessage(), x); } } ctx.set(slot, resources); }
Example #8
Source File: Validator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public void validate(ResourceSet resourceSet, IResourceServiceProvider.Registry registry, Issues issues) { List<Resource> resources = Lists.newArrayList(resourceSet.getResources()); for (Resource resource : resources) { try { resource.load(null); IResourceServiceProvider provider = registry.getResourceServiceProvider(resource.getURI()); if (provider != null) { List<Issue> result = provider.getResourceValidator().validate(resource, CheckMode.ALL, null); for (Issue issue : result) { switch (issue.getSeverity()) { case ERROR: issues.addError(issue.getMessage(), issue); break; case WARNING: issues.addWarning(issue.getMessage(), issue); break; case INFO: issues.addInfo(issue.getMessage(), issue); break; case IGNORE: break; } } } } catch (IOException e) { throw new WorkflowInterruptedException("Couldn't load resource (" + resource.getURI() + ")", e); } } if (isStopOnError() && issues.hasErrors()) { String errorMessage = toString(issues); throw new WorkflowInterruptedException("Validation problems: \n" + errorMessage); } }
Example #9
Source File: UriBasedReader.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected void checkConfigurationInternal(Issues issues) { super.checkConfigurationInternal(issues); if (uris.isEmpty()) issues.addError(this, "No resource uri configured (property 'uri')"); for (String uri : uris) { try { uris2.add(URI.createURI(uri)); } catch (Exception e) { issues.addError(this, "Invalid URI '" + uri + "' (" + e.getMessage() + ")"); } } }
Example #10
Source File: UriBasedReader.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { ResourceSet resourceSet = getResourceSet(); for (URI uri : uris2) { Resource resource = resourceSet.getResource(uri, true); int numberResources; do { numberResources = resourceSet.getResources().size(); EcoreUtil.resolveAll(resource); } while (numberResources!=resourceSet.getResources().size()); } getValidator().validate(resourceSet, getRegistry(), issues); addModelElementsToContext(ctx, resourceSet); }
Example #11
Source File: AbstractReader.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected void checkConfigurationInternal(Issues issues) { super.checkConfigurationInternal(issues); if (injectors.isEmpty()) issues.addError(this,"No setup has been registered (example: register=foo.bar.MyLanguageStandaloneSetup{})"); if (slotEntries.isEmpty()) { issues.addError(this,"No slot entries configured (example: load={slot='mySlot' type='Type'})."); } }
Example #12
Source File: Ecore2XtextGenerator.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected void checkConfigurationInternal(Issues issues) { if (genPath == null) { issues.addError("genPath not set"); } if (rootElementClassName == null) { issues.addError("rootElement not set"); } if (!issues.hasErrors()) { createXtextProjectInfo(issues); } }
Example #13
Source File: XtextGenerator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected void checkConfigurationInternal(final Issues issues) { this.initialize(); final MweIssues generatorIssues = new MweIssues(this, issues); this.configuration.checkConfiguration(generatorIssues); final HashMap<String, Grammar> uris = new HashMap<String, Grammar>(); for (final XtextGeneratorLanguage language : this.languageConfigs) { { language.checkConfiguration(generatorIssues); Iterable<GeneratedMetamodel> _filter = Iterables.<GeneratedMetamodel>filter(language.getGrammar().getMetamodelDeclarations(), GeneratedMetamodel.class); for (final GeneratedMetamodel generatedMetamodel : _filter) { { final String nsURI = generatedMetamodel.getEPackage().getNsURI(); boolean _containsKey = uris.containsKey(nsURI); if (_containsKey) { String _name = uris.get(nsURI).getName(); String _plus = ((("Duplicate generated grammar with nsURI \'" + nsURI) + "\' in ") + _name); String _plus_1 = (_plus + " and "); String _name_1 = language.getGrammar().getName(); String _plus_2 = (_plus_1 + _name_1); generatorIssues.addError(_plus_2); } else { uris.put(nsURI, language.getGrammar()); } } } } } }
Example #14
Source File: XtextGenerator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private void handleException(final Exception ex, final Issues issues) { if ((ex instanceof CompositeGeneratorException)) { final Consumer<Exception> _function = (Exception it) -> { this.handleException(it, issues); }; ((CompositeGeneratorException)ex).getExceptions().forEach(_function); } else { issues.addError(this, "GeneratorException: ", null, ex, null); } }
Example #15
Source File: ValidatorTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * https://bugs.eclipse.org/bugs/show_bug.cgi?id=322645 */ @Test public void testBugFix322645() throws Exception { Issues issues = issues(); Issue a = new Issue.IssueImpl(); Issue b = new Issue.IssueImpl(); issues.addError("foo", a); issues.addWarning(null, a); issues.addError(null, b); MWEDiagnostic[] errors = issues.getErrors(); assertEquals(2, errors.length); final Validator validator = new Validator(); final String string = validator.toString(issues); assert(string.contains("foo")); }
Example #16
Source File: ReaderTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testLoadTwo() throws Exception { Reader reader = getReader(); reader.addPath(pathTo("emptyFolder")); reader.addPath(pathTo("nonemptyFolder")); reader.addRegister(new IndexTestLanguageStandaloneSetup()); SlotEntry entry = createSlotEntry(); entry.setSlot("person"); entry.setName("foo.bar.Person"); entry.setNamespaceDelimiter("."); entry.setFirstOnly(true); SlotEntry entry2 = createSlotEntry(); entry2.setSlot("string"); entry2.setName("foo.bar.sub.String"); entry2.setNamespaceDelimiter("."); entry2.setFirstOnly(true); reader.addLoad(entry); reader.addLoad(entry2); WorkflowContext ctx = ctx(); Issues issues = issues(); try { reader.invoke(ctx, monitor(), issues); } catch (Exception e) { System.out.println(issues); throw e; } assertEquals("Person", ((Entity) ctx.get("person")).getName()); assertEquals("String", ((Datatype) ctx.get("string")).getName()); }
Example #17
Source File: LazyStandaloneSetup.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { for (String generatedEPackage : allgeneratedEPackages) { addRegisterGeneratedEPackage(generatedEPackage); } for (String genModelFile : allGenModelFiles) { addRegisterGenModelFile(genModelFile); } for (String ecoreFile : allEcoreFiles) { addRegisterEcoreFile(ecoreFile); } }
Example #18
Source File: LazyStandaloneSetup.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { for (String generatedEPackage : allgeneratedEPackages) { addRegisterGeneratedEPackage(generatedEPackage); } for (String genModelFile : allGenModelFiles) { addRegisterGenModelFile(genModelFile); } for (String ecoreFile : allEcoreFiles) { addRegisterEcoreFile(ecoreFile); } }
Example #19
Source File: Generator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
private void generate(LanguageConfig config, XpandExecutionContext ctx, Issues issues) { try { config.generate(config, ctx); } catch(CompositeGeneratorException e) { if (!handleWarnings(issues, e)) { throw e; } } }
Example #20
Source File: GeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void checkConfiguration(Issues issues) { super.checkConfiguration(issues); if(generateJavaMain && generateXtendMain) { issues.addWarning("Options 'generateJavaMain' and 'generateXtendMain' are mutually exclusive. Generating Xtend only."); generateJavaMain = false; } }
Example #21
Source File: AbstractAntlrGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void checkConfiguration(Issues issues) { super.checkConfiguration(issues); if (!antlrTool.isWorkable()) { issues.addError("\n\n*ATTENTION*\nIt is highly recommended to use ANTLR's parser generator (get it from 'http://xtext.itemis.com/'). \nAs an alternative to ANTLR you could also use the alternative implementation shipped with Xtext.\nTo do so use the generator fragment '" + PackratParserFragment.class.getName() + "' in your mwe2 file instead."); } }
Example #22
Source File: XtextAntlrGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void checkConfiguration(Issues issues) { super.checkConfiguration(issues); if (getOptions().isBacktrackLexer()) { issues.addError("This fragment does not support the option 'backtracking' for the lexer. Use 'org.eclipse.xtext.generator.parser.antlr.ex.rt.AntlrGeneratorFragment' instead"); } if (getOptions().isIgnoreCase()) { issues.addError("This fragment does not support the option 'ignorecase'. Use 'org.eclipse.xtext.generator.parser.antlr.ex.rt.AntlrGeneratorFragment' instead"); } }
Example #23
Source File: XtextAntlrUiGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void checkConfiguration(Issues issues) { super.checkConfiguration(issues); if (getOptions().isBacktrackLexer()) { issues.addError("This fragment does not support the option 'backtracking' for the lexer. Use 'org.eclipse.xtext.generator.parser.antlr.ex.ca.ContentAssistParserGeneratorFragment' instead"); } if (getOptions().isIgnoreCase()) { issues.addError("This fragment does not support the option 'ignoreCase'. Use 'org.eclipse.xtext.generator.parser.antlr.ex.ca.ContentAssistParserGeneratorFragment' instead"); } }
Example #24
Source File: Junit4Fragment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void checkConfiguration(Issues issues) { super.checkConfiguration(issues); if (getNaming().getPathTestProject()==null) { issues.addWarning("Missing test project path configuration 'Generator#pathTestProject' required for fragment '"+getClass().getName()+"'."); } }
Example #25
Source File: DelegatingGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void checkConfiguration(Issues issues) { if (delegate == null && message != null) { issues.addWarning("---- ATTENTION----\n\t" + "\n\n\t" + message); } if (fallback instanceof NamingAware) ((NamingAware) fallback).registerNaming(getNaming()); if (delegate instanceof NamingAware) ((NamingAware) delegate).registerNaming(getNaming()); if (delegate != null) delegate.checkConfiguration(issues); else fallback.checkConfiguration(issues); }
Example #26
Source File: AntlrDelegatingFragment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void checkConfiguration(Issues issues) { super.checkConfiguration(issues); if (getInstance() == null) { issues.addError(getMessage()); } else { getInstance().checkConfiguration(issues); } }
Example #27
Source File: Generator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
private boolean handleWarnings(Issues issues, CompositeGeneratorException e) { for (Exception ex : e.getExceptions()) { if (ex instanceof CompositeGeneratorException) { if (!handleWarnings(issues, (CompositeGeneratorException) ex)) { return false; } } else if (ex instanceof GeneratorWarning) { issues.addWarning(this, "Warning: " + ex.getMessage(), null, null, null); } else { return false; } } return true; }
Example #28
Source File: Generator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
private void handleCompositeException(Issues issues, CompositeGeneratorException e) { for (Exception ex : e.getExceptions()) { if (ex instanceof CompositeGeneratorException) { handleCompositeException(issues, (CompositeGeneratorException) ex); } else if (!(ex instanceof GeneratorWarning)) { issues.addError(this, "GeneratorException: ", null, ex, null); } } }
Example #29
Source File: Generator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override protected void checkConfigurationInternal(Issues issues) { naming.setProjectNameRt(getProjectNameRt()); naming.setProjectNameIde(getProjectNameIde()); naming.setIdeBasePackage(!isIde() && isUi() ? getProjectNameUi() : getProjectNameIde()); naming.setProjectNameUi(getProjectNameUi()); naming.setUiBasePackage(getProjectNameUi()); naming.setActivatorName(getActivator()); naming.setPathTestProject(getPathTestProject()); naming.setFileHeader(getFileHeader()); naming.setClassAnnotations(getClassAnnotationsAsString()); naming.setAnnotationImports(getAnnotationImportsAsString()); naming.setHasUI(isUi()); naming.setHasIde(isIde()); Map<String, Grammar> uris = new HashMap<String, Grammar>(); for (LanguageConfig config : languageConfigs) { config.registerNaming(naming); config.checkConfiguration(issues); Grammar grammar = config.getGrammar(); List<GeneratedMetamodel> select = EcoreUtil2.typeSelect(grammar.getMetamodelDeclarations(), GeneratedMetamodel.class); for (GeneratedMetamodel generatedMetamodel : select) { String nsURI = generatedMetamodel.getEPackage().getNsURI(); if (uris.containsKey(nsURI)) { issues.addError("Duplicate generated grammar with nsURI '" + nsURI + "' in " + uris.get(nsURI).getName() + " and " + grammar.getName()); } else { uris.put(nsURI, grammar); } } } if (getProjectNameRt() == null) issues.addError("The property 'projectNameRt' is mandatory"); if (isUiMergedIntoRt() && getPathIdeProject() != null && ! isIdeMergedIntoRt()) { issues.addError("Cannot have a dedicated ide project when ui project is merged into runtime project"); } }
Example #30
Source File: DebugAntlrGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public void checkConfiguration(Issues issues) { super.checkConfiguration(issues); issues.addInfo("Generate debugging grammar file"); }