Java Code Examples for org.eclipse.xtext.xbase.lib.StringExtensions#isNullOrEmpty()
The following examples show how to use
org.eclipse.xtext.xbase.lib.StringExtensions#isNullOrEmpty() .
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: FormatterTester.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected ArrayList<TextReplacement> createMissingEditReplacements(XtextResource res, Collection<TextReplacement> edits, int offset, int length) { Set<Integer> offsets = IterableExtensions .toSet(Iterables.transform(edits, (TextReplacement it) -> Integer.valueOf(it.getOffset()))); ArrayList<TextReplacement> result = new ArrayList<>(); int lastOffset = 0; IParseResult parseResult = res.getParseResult(); if (parseResult != null) { ICompositeNode rootNode = parseResult.getRootNode(); if (rootNode != null) { for (ILeafNode leaf : rootNode.getLeafNodes()) { if (!leaf.isHidden() || !StringExtensions.isNullOrEmpty(leaf.getText().trim())) { ITextRegion leafRegion = leaf.getTextRegion(); if (lastOffset >= offset && leafRegion.getOffset() <= offset + length && !offsets.contains(Integer.valueOf(lastOffset))) { result.add(new TextReplacement(lastOffset, leafRegion.getOffset() - lastOffset, "!!")); } lastOffset = leafRegion.getOffset() + leafRegion.getLength(); } } } } return result; }
Example 2
Source File: CategoryImplCustom.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public String getName() { if (!StringExtensions.isNullOrEmpty(getId())) { return getId(); } else { return CheckUtil.toIdentifier(getLabel()); } }
Example 3
Source File: EMFGeneratorFragment2.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected String getJavaModelDirectory() { if ((this.javaModelDirectory != null)) { return this.javaModelDirectory; } final String srcGenPath = this.getProjectConfig().getRuntime().getSrcGen().getPath(); final String rootPath = this.getProjectConfig().getRuntime().getRoot().getPath(); if (((!StringExtensions.isNullOrEmpty(rootPath)) && srcGenPath.startsWith(rootPath))) { String _modelPluginID = this.getModelPluginID(); String _plus = ("/" + _modelPluginID); String _substring = srcGenPath.substring(rootPath.length()); return (_plus + _substring); } throw new RuntimeException( "Could not derive the Java model directory from the project configuration. Please set the property \'javaModelDirectory\' explicitly."); }
Example 4
Source File: XtextGenerator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected void mergeManifest(final ManifestAccess manifest, final IXtextGeneratorFileSystemAccess metaInf) throws IOException { InputStream in = null; try { in = metaInf.readBinaryFile(manifest.getPath()); String _bundleName = manifest.getBundleName(); final MergeableManifest2 merge = new MergeableManifest2(in, _bundleName); merge.setLineDelimiter(this.codeConfig.getLineDelimiter()); merge.addExportedPackages(manifest.getExportedPackages()); merge.addRequiredBundles(manifest.getRequiredBundles()); merge.addImportedPackages(manifest.getImportedPackages()); if (((manifest.getActivator() != null) && StringExtensions.isNullOrEmpty(merge.getBundleActivator()))) { merge.setBundleActivator(manifest.getActivator().getName()); } boolean _isModified = merge.isModified(); if (_isModified) { final ByteArrayOutputStream out = new ByteArrayOutputStream(); merge.write(out); String _path = manifest.getPath(); byte[] _byteArray = out.toByteArray(); ByteArrayInputStream _byteArrayInputStream = new ByteArrayInputStream(_byteArray); metaInf.generateFile(_path, _byteArrayInputStream); } } finally { if ((in != null)) { in.close(); } } }
Example 5
Source File: AbstractLanguageServerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected String _toExpectation(final SymbolInformation it) { StringConcatenation _builder = new StringConcatenation(); _builder.append("symbol \""); String _name = it.getName(); _builder.append(_name); _builder.append("\" {"); _builder.newLineIfNotEmpty(); _builder.append(" "); _builder.append("kind: "); int _value = it.getKind().getValue(); _builder.append(_value, " "); _builder.newLineIfNotEmpty(); _builder.append(" "); _builder.append("location: "); String _expectation = this.toExpectation(it.getLocation()); _builder.append(_expectation, " "); _builder.newLineIfNotEmpty(); { boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(it.getContainerName()); boolean _not = (!_isNullOrEmpty); if (_not) { _builder.append(" "); _builder.append("container: \""); String _containerName = it.getContainerName(); _builder.append(_containerName, " "); _builder.append("\""); _builder.newLineIfNotEmpty(); } } _builder.append("}"); _builder.newLine(); return _builder.toString(); }
Example 6
Source File: CheckImplCustom.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public String getMessage() { if (!StringExtensions.isNullOrEmpty(getGivenMessage())) { return getGivenMessage(); } else { return getLabel(); } }
Example 7
Source File: AbstractSuperTypesTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public void assertSuperTypes(final Pair<String, String> type, final String... superTypes) { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("def "); { boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(type.getValue()); boolean _not = (!_isNullOrEmpty); if (_not) { _builder.append("<"); String _value = type.getValue(); _builder.append(_value); _builder.append("> "); } } _builder.append("void method("); String _key = type.getKey(); _builder.append(_key); _builder.append(" type) {}"); final String signature = _builder.toString(); final XtendFunction function = this.function(signature.toString()); final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(function); final LightweightTypeReference subtype = this.toLightweightTypeReference(IterableExtensions.<JvmFormalParameter>head(operation.getParameters()).getParameterType()); final Function1<LightweightTypeReference, String> _function = (LightweightTypeReference it) -> { return it.getSimpleName(); }; Assert.assertEquals(IterableExtensions.<String>toList(((Iterable<String>)Conversions.doWrapArray(superTypes))), IterableExtensions.<String>toList(IterableExtensions.<LightweightTypeReference, String>map(this.collectSuperTypes(subtype), _function))); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 8
Source File: Case_2.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public String aOrB(final String a, final String b) { String _xifexpression = null; boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(a); if (_isNullOrEmpty) { _xifexpression = b; } else { _xifexpression = a; } return _xifexpression; }
Example 9
Source File: FeatureProjectFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected void enhanceProject(final IProject project, final SubMonitor subMonitor, final Shell shell) throws CoreException { super.enhanceProject(project, subMonitor, shell); this.createManifest(project, subMonitor.newChild(1)); this.createBuildProperties(project, subMonitor.newChild(1)); boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(this.mainCategoryName); boolean _not = (!_isNullOrEmpty); if (_not) { this.createCategoryFile(project, this.mainCategoryName, subMonitor.newChild(1)); } }
Example 10
Source File: ProgressReportingTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void beginTask(final String name, final int totalWork) { String _xifexpression = null; boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(name); if (_isNullOrEmpty) { _xifexpression = "("; } else { _xifexpression = " ("; } String _plus = (("BeginTask " + name) + _xifexpression); String _plus_1 = (_plus + Integer.valueOf(totalWork)); String _plus_2 = (_plus_1 + ")"); this.events.add(_plus_2); }
Example 11
Source File: FeatureProjectFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
private void createManifest(final IProject project, final IProgressMonitor monitor) { StringConcatenation _builder = new StringConcatenation(); _builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); _builder.newLine(); _builder.append("<feature id=\""); _builder.append(this.projectName); _builder.append("\""); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("label=\""); String _xifexpression = null; boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(this.featureLabel); boolean _not = (!_isNullOrEmpty); if (_not) { _xifexpression = this.featureLabel; } else { _xifexpression = (this.projectName + " Feature"); } _builder.append(_xifexpression, "\t"); _builder.append("\""); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("version=\"1.0.0.qualifier\">"); _builder.newLine(); { for(final String includedFeature : this.includedFeatures) { _builder.append("\t"); _builder.append("<includes"); _builder.newLine(); _builder.append("\t"); _builder.append("\t"); _builder.append("id=\""); _builder.append(includedFeature, "\t\t"); _builder.append("\""); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("\t"); _builder.append("version=\"0.0.0\"/>"); _builder.newLine(); } } { for(final String containedBundle : this.containedBundles) { _builder.append("\t"); _builder.append("<plugin"); _builder.newLine(); _builder.append("\t"); _builder.append("\t\t"); _builder.append("id=\""); _builder.append(containedBundle, "\t\t\t"); _builder.append("\""); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("\t\t"); _builder.append("download-size=\"0\""); _builder.newLine(); _builder.append("\t"); _builder.append("\t\t"); _builder.append("install-size=\"0\""); _builder.newLine(); _builder.append("\t"); _builder.append("\t\t"); _builder.append("version=\"0.0.0\""); _builder.newLine(); _builder.append("\t"); _builder.append("\t\t"); _builder.append("unpack=\"false\"/>"); _builder.newLine(); } } _builder.append("</feature>"); _builder.newLine(); this.writeToFile(_builder, FeatureProjectFactory.MANIFEST_FILENAME, project, monitor); }
Example 12
Source File: AbstractAssignabilityTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public void isAssignableFrom(final Pair<String, String> lhsAndParams, final String rhs, final boolean expectation) { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("def "); { boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(lhsAndParams.getValue()); boolean _not = (!_isNullOrEmpty); if (_not) { _builder.append("<"); String _value = lhsAndParams.getValue(); _builder.append(_value); _builder.append("> "); } } _builder.append("void method("); String _fixup = this.fixup(lhsAndParams.getKey()); _builder.append(_fixup); _builder.append(" lhs, "); String _fixup_1 = this.fixup(rhs); _builder.append(_fixup_1); _builder.append(" rhs) {}"); final String signature = _builder.toString(); final XtendFunction function = this.function(signature.toString()); final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(function); LightweightTypeReference _xifexpression = null; String _key = lhsAndParams.getKey(); boolean _tripleNotEquals = (_key != null); if (_tripleNotEquals) { _xifexpression = this.toLightweightTypeReference(IterableExtensions.<JvmFormalParameter>head(operation.getParameters()).getParameterType()); } else { _xifexpression = this.getOwner().newAnyTypeReference(); } final LightweightTypeReference lhsType = _xifexpression; LightweightTypeReference _xifexpression_1 = null; if ((rhs != null)) { _xifexpression_1 = this.toLightweightTypeReference(IterableExtensions.<JvmFormalParameter>last(operation.getParameters()).getParameterType()); } else { _xifexpression_1 = this.getOwner().newAnyTypeReference(); } final LightweightTypeReference rhsType = _xifexpression_1; String _simpleName = lhsType.getSimpleName(); String _plus = (_simpleName + " := "); String _simpleName_1 = rhsType.getSimpleName(); String _plus_1 = (_plus + _simpleName_1); Assert.assertEquals(_plus_1, Boolean.valueOf(expectation), Boolean.valueOf(this.testIsAssignable(lhsType, rhsType))); if (expectation) { List<LightweightTypeReference> _allSuperTypes = lhsType.getAllSuperTypes(); for (final LightweightTypeReference superType : _allSuperTypes) { if (((superType.isArray() == lhsType.isArray()) || (lhsType.isArray() == rhsType.isArray()))) { Assert.assertEquals(superType.toString(), Boolean.valueOf(expectation), Boolean.valueOf(this.testIsAssignable(superType, rhsType))); } } } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 13
Source File: SynonmyTypesTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public void hasSynonyms(final Pair<String, String> typeAndTypeParams, final String... expectedSynonyms) { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("def "); { boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(typeAndTypeParams.getValue()); boolean _not = (!_isNullOrEmpty); if (_not) { _builder.append("<"); String _value = typeAndTypeParams.getValue(); _builder.append(_value); _builder.append("> "); } } _builder.append("void method("); String _key = typeAndTypeParams.getKey(); _builder.append(_key); _builder.append(" p) {}"); final String signature = _builder.toString(); final XtendFunction function = this.function(signature.toString()); final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(function); LightweightTypeReference _xifexpression = null; String _key_1 = typeAndTypeParams.getKey(); boolean _tripleNotEquals = (_key_1 != null); if (_tripleNotEquals) { _xifexpression = this.toLightweightTypeReference(IterableExtensions.<JvmFormalParameter>head(operation.getParameters()).getParameterType()); } else { _xifexpression = this.getOwner().newAnyTypeReference(); } final LightweightTypeReference primary = _xifexpression; final HashSet<String> actualSynonyms = CollectionLiterals.<String>newHashSet(); final SynonymTypesProvider.Acceptor _function = new SynonymTypesProvider.Acceptor() { @Override protected boolean accept(final LightweightTypeReference type, final int conformance) { return actualSynonyms.add(type.getSimpleName()); } }; this._synonymTypesProvider.collectSynonymTypes(primary, _function); Assert.assertEquals(actualSynonyms.toString(), expectedSynonyms.length, actualSynonyms.size()); Assert.assertTrue(actualSynonyms.toString(), actualSynonyms.containsAll(((Collection<?>)Conversions.doWrapArray(expectedSynonyms)))); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 14
Source File: TypeReferenceAssignabilityTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public void isAssignableFrom(final Pair<String, String> lhsAndParams, final String rhs, final boolean expectation) { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("def "); { boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(lhsAndParams.getValue()); boolean _not = (!_isNullOrEmpty); if (_not) { _builder.append("<"); String _value = lhsAndParams.getValue(); _builder.append(_value); _builder.append("> "); } } _builder.append("void method("); String _fixup = this.fixup(lhsAndParams.getKey()); _builder.append(_fixup); _builder.append(" lhs, "); String _fixup_1 = this.fixup(rhs); _builder.append(_fixup_1); _builder.append(" rhs) {}"); final String signature = _builder.toString(); final XtendFunction function = this.function(signature.toString()); final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(function); EObject _rootContainer = EcoreUtil.getRootContainer(function); final XtendFile xtendFile = ((XtendFile) _rootContainer); final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> { TypeReference _xifexpression = null; String _key = lhsAndParams.getKey(); boolean _tripleNotEquals = (_key != null); if (_tripleNotEquals) { _xifexpression = it.toTypeReference(IterableExtensions.<JvmFormalParameter>head(operation.getParameters()).getParameterType()); } else { _xifexpression = it.toTypeReference(this.getOwner().newAnyTypeReference()); } final TypeReference lhsType = _xifexpression; TypeReference _xifexpression_1 = null; if ((rhs != null)) { _xifexpression_1 = it.toTypeReference(IterableExtensions.<JvmFormalParameter>last(operation.getParameters()).getParameterType()); } else { _xifexpression_1 = it.toTypeReference(this.getOwner().newAnyTypeReference()); } final TypeReference rhsType = _xifexpression_1; String _simpleName = lhsType.getSimpleName(); String _plus = (_simpleName + " := "); String _simpleName_1 = rhsType.getSimpleName(); String _plus_1 = (_plus + _simpleName_1); Assert.assertEquals(_plus_1, Boolean.valueOf(expectation), Boolean.valueOf(this.testIsAssignable(it, lhsType, rhsType))); if (expectation) { Iterable<? extends TypeReference> _declaredSuperTypes = lhsType.getDeclaredSuperTypes(); for (final TypeReference superType : _declaredSuperTypes) { if (((superType.isArray() == lhsType.isArray()) || (lhsType.isArray() == rhsType.isArray()))) { Assert.assertEquals(superType.toString(), Boolean.valueOf(expectation), Boolean.valueOf(this.testIsAssignable(it, superType, rhsType))); } } } }; this.asCompilationUnit(xtendFile, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 15
Source File: XtendCompiler.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
private boolean isEmptyEmission(XExpression expression) { return expression instanceof XStringLiteral && StringExtensions.isNullOrEmpty(((XStringLiteral)expression).getValue()) || expression instanceof XNullLiteral; }
Example 16
Source File: RichStringFormatter.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
protected void _format(final RichString richString, final IFormattableDocument doc) { RichString _containerOfType = EcoreUtil2.<RichString>getContainerOfType(richString.eContainer(), RichString.class); boolean _tripleNotEquals = (_containerOfType != null); if (_tripleNotEquals) { return; } boolean _hasSyntaxError = this.hasSyntaxError(this._iTextRegionExtensions.regionForEObject(richString)); if (_hasSyntaxError) { return; } ITextRegionAccess _textRegionAccess = this._iTextRegionExtensions.getTextRegionAccess(); final RichStringToLineModel impl = new RichStringToLineModel(_textRegionAccess, richString); DefaultIndentationHandler _defaultIndentationHandler = new DefaultIndentationHandler(); this.factory.richStringProcessor.process(richString, impl, _defaultIndentationHandler); impl.finish(); EList<XExpression> _expressions = richString.getExpressions(); for (final XExpression e : _expressions) { this.format(e, doc); } final List<Line> lines = impl.getModel().getLines(); final boolean canIndent = ((!lines.isEmpty()) && StringExtensions.isNullOrEmpty(IterableExtensions.<Line>last(lines).getContent())); for (final Line line : lines) { int _rootIndentLenght = impl.getModel().getRootIndentLenght(); boolean _greaterThan = (_rootIndentLenght > 0); if (_greaterThan) { int _xifexpression = (int) 0; if ((canIndent && Objects.equal(line, IterableExtensions.<Line>head(lines)))) { _xifexpression = 1; } else { _xifexpression = 0; } final int increaseIndentationChange = _xifexpression; int _xifexpression_1 = (int) 0; if ((canIndent && Objects.equal(line, IterableExtensions.<Line>last(lines)))) { _xifexpression_1 = 1; } else { _xifexpression_1 = 0; } final int decraseIndentationChange = _xifexpression_1; int _xifexpression_2 = (int) 0; boolean _isLeadingSemanticNewLine = line.isLeadingSemanticNewLine(); if (_isLeadingSemanticNewLine) { int _offset = line.getOffset(); int _newLineCharCount = line.getNewLineCharCount(); _xifexpression_2 = (_offset + _newLineCharCount); } else { _xifexpression_2 = line.getOffset(); } final int nloffset = _xifexpression_2; final int i = Math.min(line.getIndentLength(), impl.getModel().getRootIndentLenght()); int _xifexpression_3 = (int) 0; boolean _isLeadingSemanticNewLine_1 = line.isLeadingSemanticNewLine(); if (_isLeadingSemanticNewLine_1) { _xifexpression_3 = i; } else { int _newLineCharCount_1 = line.getNewLineCharCount(); _xifexpression_3 = (_newLineCharCount_1 + i); } final int nllength = _xifexpression_3; boolean _isLeadingSemanticNewLine_2 = line.isLeadingSemanticNewLine(); if (_isLeadingSemanticNewLine_2) { this.setNewLines(doc, nloffset, nllength, increaseIndentationChange, decraseIndentationChange, 0); } else { this.setNewLines(doc, nloffset, nllength, increaseIndentationChange, decraseIndentationChange, 1); } boolean _isEmpty = line.getChunks().isEmpty(); boolean _not = (!_isEmpty); if (_not) { final int offset = (nloffset + nllength); int _indentLength = line.getIndentLength(); int _rootIndentLenght_1 = impl.getModel().getRootIndentLenght(); final int length = (_indentLength - _rootIndentLenght_1); final Function1<Chunk, CharSequence> _function = (Chunk chunk) -> { CharSequence _switchResult = null; boolean _matched = false; if (chunk instanceof SemanticWhitespace) { _matched=true; _switchResult = ((SemanticWhitespace)chunk).getText(); } if (!_matched) { if (chunk instanceof TemplateWhitespace) { _matched=true; _switchResult = doc.getFormatter().<String>getPreference(FormatterPreferenceKeys.indentation); } } return _switchResult; }; final String text = IterableExtensions.join(ListExtensions.<Chunk, CharSequence>map(line.getChunks(), _function)); if ((length >= 0)) { this.setSpace(doc, offset, length, text); } else { RuntimeException _runtimeException = new RuntimeException(("Programmatic error: length == " + Integer.valueOf(length))); EcorePlugin.INSTANCE.log(_runtimeException); } } } } }
Example 17
Source File: CompletionTest.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override protected String _toExpectation(final CompletionItem it) { StringConcatenation _builder = new StringConcatenation(); { if (this.withKind) { _builder.append("("); CompletionItemKind _kind = it.getKind(); _builder.append(_kind); { InsertTextFormat _insertTextFormat = it.getInsertTextFormat(); boolean _tripleNotEquals = (_insertTextFormat != null); if (_tripleNotEquals) { _builder.append("|"); InsertTextFormat _insertTextFormat_1 = it.getInsertTextFormat(); _builder.append(_insertTextFormat_1); } } _builder.append(") "); } } String _label = it.getLabel(); _builder.append(_label); { boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(it.getDetail()); boolean _not = (!_isNullOrEmpty); if (_not) { _builder.append(" ("); String _detail = it.getDetail(); _builder.append(_detail); _builder.append(")"); } } { TextEdit _textEdit = it.getTextEdit(); boolean _tripleNotEquals_1 = (_textEdit != null); if (_tripleNotEquals_1) { _builder.append(" -> "); String _expectation = this.toExpectation(it.getTextEdit()); _builder.append(_expectation); { boolean _isNullOrEmpty_1 = IterableExtensions.isNullOrEmpty(it.getAdditionalTextEdits()); boolean _not_1 = (!_isNullOrEmpty_1); if (_not_1) { _builder.append(" + "); final Function1<TextEdit, String> _function = (TextEdit it_1) -> { return this.toExpectation(it_1); }; String _join = IterableExtensions.join(ListExtensions.<TextEdit, String>map(it.getAdditionalTextEdits(), _function), " + "); _builder.append(_join); } } } else { if (((it.getInsertText() != null) && (!Objects.equal(it.getInsertText(), it.getLabel())))) { _builder.append(" -> "); String _insertText = it.getInsertText(); _builder.append(_insertText); } } } _builder.newLineIfNotEmpty(); return _builder.toString(); }
Example 18
Source File: GenModelUtil2.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public static Resource getGenModelResource(final String locationInfo, final String nsURI, final ResourceSet resourceSet) { final URI genModelURI = EcorePlugin.getEPackageNsURIToGenModelLocationMap(false).get(nsURI); if ((genModelURI == null)) { boolean _equals = Objects.equal(EcorePackage.eNS_URI, nsURI); if (_equals) { return null; } EList<Resource> _resources = resourceSet.getResources(); for (final Resource res : _resources) { EList<EObject> _contents = res.getContents(); for (final EObject obj : _contents) { if ((obj instanceof GenModel)) { EList<GenPackage> _genPackages = ((GenModel)obj).getGenPackages(); for (final GenPackage genPackage : _genPackages) { String _nSURI = genPackage.getNSURI(); boolean _equals_1 = Objects.equal(_nSURI, nsURI); if (_equals_1) { return genPackage.eResource(); } } } } } StringConcatenation _builder = new StringConcatenation(); _builder.append("Could not find a GenModel for EPackage \'"); _builder.append(nsURI); _builder.append("\'"); { boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(locationInfo); boolean _not = (!_isNullOrEmpty); if (_not) { _builder.append(" from "); _builder.append(locationInfo); } } _builder.append("."); _builder.newLineIfNotEmpty(); _builder.append("If the missing GenModel has been generated via "); String _simpleName = EMFGeneratorFragment2.class.getSimpleName(); _builder.append(_simpleName); _builder.append(", make sure to run it first in the workflow."); _builder.newLineIfNotEmpty(); _builder.append("If you have a *.genmodel-file, make sure to register it via StandaloneSetup.registerGenModelFile(String)."); _builder.newLine(); throw new RuntimeException(_builder.toString()); } if ((resourceSet == null)) { StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("There is no ResourceSet for EPackage \'"); _builder_1.append(nsURI); _builder_1.append("\'. Please make sure the EPackage has been loaded from a .ecore file and not from the generated Java file."); throw new RuntimeException(_builder_1.toString()); } final Resource genModelResource = resourceSet.getResource(genModelURI, true); if ((genModelResource == null)) { StringConcatenation _builder_2 = new StringConcatenation(); _builder_2.append("Error loading GenModel "); _builder_2.append(genModelURI); throw new RuntimeException(_builder_2.toString()); } EList<EObject> _contents_1 = genModelResource.getContents(); for (final EObject content : _contents_1) { if ((content instanceof GenModel)) { ((GenModel)content).reconcile(); } } return genModelResource; }
Example 19
Source File: WebIntegrationFragment.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public void generate() { if (((this.highlightingModuleName != null) && this.highlightingModuleName.endsWith(".js"))) { int _length = this.highlightingModuleName.length(); int _minus = (_length - 3); this.highlightingModuleName = this.highlightingModuleName.substring(0, _minus); } final String langId = IterableExtensions.<String>head(this.getLanguage().getFileExtensions()); String _elvis = null; if (this.highlightingModuleName != null) { _elvis = this.highlightingModuleName; } else { String _switchResult = null; WebIntegrationFragment.Framework _get = this.framework.get(); if (_get != null) { switch (_get) { case ORION: _switchResult = (("xtext-resources/generated/" + langId) + "-syntax"); break; case ACE: case CODEMIRROR: _switchResult = ("xtext-resources/generated/mode-" + langId); break; default: break; } } _elvis = _switchResult; } final String hlModName = _elvis; if ((this.generateJsHighlighting.get() && (this.getProjectConfig().getWeb().getAssets() != null))) { boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(this.highlightingPath); if (_isNullOrEmpty) { this.highlightingPath = (hlModName + ".js"); } this.generateJsHighlighting(langId); } if ((this.generateServlet.get() && (this.getProjectConfig().getWeb().getSrc() != null))) { this.generateServlet(); } if ((this.generateJettyLauncher.get() && (this.getProjectConfig().getWeb().getSrc() != null))) { this.generateServerLauncher(); } if ((this.generateHtmlExample.get() && (this.getProjectConfig().getWeb().getAssets() != null))) { this.generateIndexDoc(hlModName); this.generateStyleSheet(); } if ((this.generateWebXml.get() && (this.getProjectConfig().getWeb().getAssets() != null))) { this.generateWebXml(); } }
Example 20
Source File: JvmModelGenerator.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public void generateFileHeader(final JvmDeclaredType it, final ITreeAppendable appendable, final GeneratorConfig config) { final FileHeaderAdapter fileHeaderAdapter = IterableExtensions.<FileHeaderAdapter>head(Iterables.<FileHeaderAdapter>filter(it.eAdapters(), FileHeaderAdapter.class)); if (((fileHeaderAdapter != null) && (!StringExtensions.isNullOrEmpty(fileHeaderAdapter.getHeaderText())))) { this.generateDocumentation(fileHeaderAdapter.getHeaderText(), this.fileHeaderProvider.getFileHeaderNodes(it.eResource()), appendable, config); } }