@Check public void checkUniqueResultColumnAliases(SelectList list) { EList<ColumnSource> cols = list.getResultColumns(); for (int i = 0; i < cols.size(); i++) { ColumnSource subject = cols.get(i); int matches = 0; for (int j = 0; j < cols.size(); j++) { ColumnSource target = cols.get(j); if (subject.getName() != null && target.getName() != null && subject.getName().equalsIgnoreCase(target.getName())) { matches++; } if (matches > 1) { error( "Duplicate alias not allowed", target, SqliteModelPackage.Literals.COLUMN_SOURCE__NAME, -1); return; } } } }
private static int[] getPathPos(PathNameCS pathNameCS) { EList<SimpleNameCS> sequenceOfNames = pathNameCS.getSimpleNames(); if (sequenceOfNames.size() == 1) { return null; } int size = sequenceOfNames.size() - 1; int[] positions = new int[size]; Arrays.fill(positions, -1); IToken startToken = pathNameCS.getStartToken(); IToken endToken = pathNameCS.getEndToken(); IPrsStream prsStream = startToken.getIPrsStream(); IToken nextToken = startToken; int tokenIndex = 1; int i = 0; while (nextToken != endToken) { nextToken = prsStream.getIToken(startToken.getTokenIndex() + tokenIndex++); if (nextToken.getKind() == QVTOParsersym.TK_IDENTIFIER) { positions[i++] = nextToken.getStartOffset(); if (i == positions.length) { // safety exit in case we have inconsistent start end token break; } } } return positions; }
@Check public void checkUseArguments(final SpeciesReference reference) { EList<Feature> _arguments = reference.getArguments(); final int argSize = _arguments.size(); Species _species = reference.getSpecies(); EList<Feature> _parameters = _species.getParameters(); final int paramSize = _parameters.size(); if ((argSize == paramSize)) { int i = 0; final ComponentPart part = reference.getPart(); while ((i < argSize)) { { Species _species_1 = reference.getSpecies(); EList<Feature> _parameters_1 = _species_1.getParameters(); Feature _get = _parameters_1.get(i); final LightweightTypeReference typeFrom = this._speADLUtils.resolveType(_get, part); EList<Feature> _arguments_1 = reference.getArguments(); Feature _get_1 = _arguments_1.get(i); final LightweightTypeReference typeTo = this._speADLUtils.getTypeRef(_get_1); boolean _isAssignableFrom = typeFrom.isAssignableFrom(typeTo); boolean _not = (!_isAssignableFrom); if (_not) { this.error( ((("Incompatible types: " + typeFrom) + " is not the same or a supertype of ") + typeTo), SpeadlPackage.Literals.SPECIES_REFERENCE__ARGUMENTS, i); } i = (i + 1); } } } }
@Test(timeout = 1000) public void checkParserResult() throws Exception { final String text = this.getTextFromFile("res/Test0002_SimpleDefine.cmd"); final Model Model_0_Var = this.parseHelper.parse(text); this.valHelper.assertNoErrors(Model_0_Var); Assert.assertNotNull(Model_0_Var); final EList<? extends EObject> Lines_0_list = Model_0_Var.getLines(); Assert.assertNotNull(Lines_0_list); Assert.assertEquals(1, Lines_0_list.size()); // 0 final CmdLine CmdLine_1_Var = (CmdLine) Lines_0_list.get(0); Assert.assertNotNull(CmdLine_1_Var); Assert.assertEquals("foobar.o", CmdLine_1_Var.getStart()); final EList<? extends EObject> Arguments_1_list = CmdLine_1_Var.getArguments(); Assert.assertNotNull(Arguments_1_list); Assert.assertEquals(1, Arguments_1_list.size()); // 1 final Argument Argument_2_Var = (Argument) Arguments_1_list.get(0); Assert.assertNotNull(Argument_2_Var); // 2 final SimpleMacro SimpleMacro_3_Var = (SimpleMacro) Argument_2_Var.getMacro(); Assert.assertNotNull(SimpleMacro_3_Var); Assert.assertEquals("__FOO__BAR__", SimpleMacro_3_Var.getName()); }
public void testRemoveEqualValues() { E e = refFactory.createE(); String s0 = "0"; String s1 = "1"; String s2 = "2"; String s3 = new String(s1); EList<String> labels = e.getLabels(); labels.add(s0); labels.add(s1); labels.add(s3); labels.add(s2); labels.add(s1); Collection<String> collection = new ArrayList<String>(); collection.add(s1); collection.add(s1); collection.add(s1); Command remove = RemoveCommand.create(editingDomain, e, refPackage.getE_Labels(), collection); assertEquals(5, labels.size()); assertSame(s0, labels.get(0)); assertSame(s1, labels.get(1)); assertSame(s3, labels.get(2)); assertSame(s2, labels.get(3)); assertSame(s1, labels.get(4)); assertNotSame(s1, labels.get(2)); assertTrue(remove.canExecute()); CommandStack stack = editingDomain.getCommandStack(); stack.execute(remove); assertEquals(2, labels.size()); assertSame(s0, labels.get(0)); assertSame(s2, labels.get(1)); assertTrue(stack.canUndo()); stack.undo(); assertEquals(5, labels.size()); assertSame(s0, labels.get(0)); assertSame(s1, labels.get(1)); assertSame(s3, labels.get(2)); assertSame(s2, labels.get(3)); assertSame(s1, labels.get(4)); assertNotSame(s1, labels.get(2)); assertTrue(stack.canRedo()); stack.redo(); assertEquals(2, labels.size()); assertSame(s0, labels.get(0)); assertSame(s2, labels.get(1)); assertTrue(stack.canUndo()); }
@Check(CheckType.FAST) public void checkOperationArguments_FeatureCall(final FeatureCall call) { if (call.getFeature() instanceof Operation) { Operation operation = (Operation) call.getFeature(); EList<Parameter> parameters = operation.getParameters(); EList<Expression> args = call.getArgs(); if (parameters.size() != args.size()) { error("Wrong number of arguments, expected " + parameters, null); } } }
private static void checkObject( EObject expected, EObject actual, Set<EStructuralFeature> excludeFeatures, Set<EObject> visited) { if (expected == null) { assertThat(actual, is(nullValue())); return; } if (visited.contains(expected)) return; visited.add(expected); assertThat( "Actual instance for type '" + expected.eClass().getName() + "' must not be null", actual, is(notNullValue())); for (EAttribute attribute : expected.eClass().getEAllAttributes()) { if (!excludeFeatures.contains(attribute)) assertThat( "Attribute '" + attribute.getName() + "' on class '" + expected.eClass().getName() + "' did not match", actual.eGet(attribute), is(expected.eGet(attribute))); } for (EReference reference : expected.eClass().getEAllReferences()) { if (excludeFeatures.contains(reference)) continue; if (reference.isMany()) { @SuppressWarnings("unchecked") EList<EObject> expectedObjects = (EList<EObject>) expected.eGet(reference); @SuppressWarnings("unchecked") EList<EObject> actualObjects = (EList<EObject>) actual.eGet(reference); assertThat( "Reference size for '" + reference.getName() + "' does not match", actualObjects.size(), is(expectedObjects.size())); for (int i = 0; i < expectedObjects.size(); i++) checkObject(expectedObjects.get(i), actualObjects.get(i), excludeFeatures, visited); } else checkObject( (EObject) expected.eGet(reference), (EObject) actual.eGet(reference), excludeFeatures, visited); } }
private void initiateProgressMonitor(boolean generateCode, EList<InstanceSpecification> nodes) { // -- calc # of steps for progress monitor // 1 (tmpModel creation) + 1 (reification) + 1 (tmpModel save) // 5x on each deployed node (see below) // problem? Connector reification is a single, relatively long step int steps = 3; steps += 5 * nodes.size(); if (generateCode) { steps += nodes.size(); } monitor.beginTask(Messages.InstantiateDepPlan_InfoGeneratingModel, steps); }
public String[] getValidInsertElements() { VEXDocument doc = this.getDocument(); if (doc == null) return new String[0]; Validator validator = doc.getValidator(); if (validator == null) return new String[0]; int startOffset = this.getCaretOffset(); int endOffset = this.getCaretOffset(); if (this.hasSelection()) { startOffset = this.getSelectionStart(); endOffset = this.getSelectionEnd(); } VEXElement parent = doc.getElementAt(startOffset); Set<String> validItems = validator.getValidItems(parent.getName()); List<String> candidates = new ArrayList<String>(validItems); candidates.remove(Validator.PCDATA); // filter invalid sequences EList<String> nodesBefore = doc.getNodeNames(parent.getStartOffset() + 1, startOffset); EList<String> nodesAfter = doc.getNodeNames(endOffset, parent.getEndOffset()); int sequenceLength = nodesBefore.size() + 1 + nodesAfter.size(); for (Iterator<String> iter = candidates.iterator(); iter.hasNext(); ) { String candidate = iter.next(); EList<String> sequence = new BasicEList<String>(sequenceLength); sequence.addAll(nodesBefore); sequence.add(candidate); sequence.addAll(nodesAfter); if (!validator.isValidSequence(parent.getName(), sequence, true)) { iter.remove(); } } // If there's a selection, root out those candidates that can't // contain it. if (hasSelection()) { EList<String> selectedNodes = doc.getNodeNames(startOffset, endOffset); for (Iterator<String> iter = candidates.iterator(); iter.hasNext(); ) { String candidate = iter.next(); if (!validator.isValidSequence(candidate, selectedNodes, true)) { iter.remove(); } } } Collections.sort(candidates); return (String[]) candidates.toArray(new String[candidates.size()]); }
/** * Compare current classpath with given one to see if any different. Note that the argument * classpath contains its binary output. * * @param newMindpath EList<MindPathEntry>] * @param otherMindpath EList<MindPathEntry> * @return boolean true if equals */ public static boolean areMindpathsEqual( EList<MindPathEntry> newMindpath, EList<MindPathEntry> otherMindpath) { if (otherMindpath == null || otherMindpath.size() == 0) return false; int length = otherMindpath.size(); if (length != newMindpath.size()) return false; // compare classpath entries for (int i = 0; i < length; i++) { if (!MindPathEntryCustomImpl.equals(otherMindpath.get(i), newMindpath.get(i))) return false; } return true; }
public void rebuildInputTable( InputTable inputTable, IMetadataTable metadataTable, PigMapData mapData) { if (metadataTable != null && metadataTable.getListColumns() != null) { List<IMetadataColumn> listColumns = metadataTable.getListColumns(); EList<TableNode> nodes = inputTable.getNodes(); for (int i = 0; i < listColumns.size(); i++) { IMetadataColumn column = listColumns.get(i); TableNode found = null; int j = 0; for (; j < nodes.size(); j++) { TableNode node = nodes.get(j); if (node.getName() != null && node.getName().equals(column.getLabel())) { found = node; break; } } if (found != null) { // set in case talend type changed in metadata found.setType(column.getTalendType()); if (i != j) { // do switch to keep the same sequence TableNode temp = nodes.get(j); nodes.remove(j); nodes.add(i, temp); } } else { found = PigmapFactory.eINSTANCE.createTableNode(); found.setName(column.getLabel()); found.setType(column.getTalendType()); found.setNullable(column.isNullable()); nodes.add(i, found); } } if (nodes.size() > listColumns.size()) { List unUsed = new ArrayList(); for (int i = listColumns.size(); i < nodes.size(); i++) { PigMapUtil.detachNodeConnections(nodes.get(i), mapData); unUsed.add(nodes.get(i)); } nodes.removeAll(unUsed); } } // re-build the connections in case any unnecessary connections are created because of previous // bugs and can't // be deleted if (inputTable.isLookup()) { rebuildInputNodesConnections(inputTable.getNodes(), mapData); } }
@Test public void testDuplicateDiagramModel() { ArchimateTestModel tm = new ArchimateTestModel(); IArchimateModel model = tm.createNewModel(); IDiagramModel dm = model.getDefaultDiagramModel(); IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor(); IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor); dmo1.setName("dm"); dm.getChildren().add(dmo1); IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole(); IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role); dm.getChildren().add(dmo2); IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship(); relation.setSource(actor); relation.setTarget(role); IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation); dmc1.connect(dmo1, dmo2); DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] {dm}); handler.duplicate(); assertEquals(2, model.getDiagramModels().size()); IDiagramModel dmCopy = model.getDiagramModels().get(1); assertNotSame(dm, dmCopy); assertEquals(dm.getName() + " (copy)", dmCopy.getName()); EList<IDiagramModelObject> children = dmCopy.getChildren(); assertEquals(2, children.size()); IDiagramModelArchimateObject dmo1Copy = (IDiagramModelArchimateObject) children.get(0); IDiagramModelArchimateObject dmo2Copy = (IDiagramModelArchimateObject) children.get(1); assertNotSame(dmo1, dmo1Copy); assertNotSame(dmo2, dmo2Copy); assertSame(actor, dmo1Copy.getArchimateConcept()); assertSame(role, dmo2Copy.getArchimateConcept()); EList<IDiagramModelConnection> connections = dmo1Copy.getSourceConnections(); assertEquals(1, connections.size()); IDiagramModelArchimateConnection dmc1Copy = (IDiagramModelArchimateConnection) connections.get(0); assertNotSame(dmc1, dmc1Copy); assertSame(relation, dmc1Copy.getArchimateConcept()); }
public org.eclipse.core.runtime.IStatus build( org.emftext.language.efactory.resource.efactory.mopp.EfactoryResource resource, org.eclipse.core.runtime.IProgressMonitor monitor) { if (resource.getErrors().size() == 0) { EList<EObject> contents = resource.getContents(); if (contents.size() > 0) { EObject rootObject = contents.get(0); if (rootObject instanceof Factory) { Factory factory = (Factory) rootObject; Builder builder = new Builder(); Map<EObject, String> problems = new LinkedHashMap<EObject, String>(); List<EObject> roots = builder.build(factory, problems); URI xmiURI = resource.getURI().trimFileExtension().appendFileExtension("xmi"); Resource xmiResource = new ResourceSetImpl().createResource(xmiURI); xmiResource.getContents().addAll(roots); try { Map<Object, Object> options = new HashMap<Object, Object>(); options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); xmiResource.save(options); } catch (IOException e) { e.printStackTrace(); } for (Entry<EObject, String> problem : problems.entrySet()) { resource.addError( problem.getValue(), EfactoryEProblemType.BUILDER_ERROR, problem.getKey()); } } } } return org.eclipse.core.runtime.Status.OK_STATUS; }
@Override public int category(Object element) { if (element instanceof RepositoryNode) { RepositoryNode node = (RepositoryNode) element; if (ERepositoryObjectType.METADATA_CON_COLUMN.equals( node.getProperties(EProperties.CONTENT_TYPE))) { RepositoryNode parent = node.getParent().getParent(); if (parent != null && ERepositoryObjectType.METADATA_CON_TABLE.equals( parent.getProperties(EProperties.CONTENT_TYPE)) && parent.getObject() instanceof MetadataTableRepositoryObject) { MetadataTableRepositoryObject tableObject = (MetadataTableRepositoryObject) parent.getObject(); MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) ((RepositoryNode) element).getObject(); MetadataColumn tColumn = columnObject.getTdColumn(); EList<MetadataColumn> columns = tableObject.getTable().getColumns(); for (int i = 0; i < columns.size(); i++) { MetadataColumn column = columns.get(i); if (column.getName() != null && column.getName().equals(tColumn.getName())) { return i; } } } } } return super.category(element); }
public MavenMetadata(URI uri) throws CoreException { Resource resource = getResourceSet().getResource(uri, true); EList<EObject> content = resource.getContents(); if (content.size() != 1) throw ExceptionUtils.fromMessage( "ECore Resource did not contain one resource. It had %d", Integer.valueOf(content.size())); documentRoot = (DocumentRoot) content.get(0); Diagnostic diag = Diagnostician.INSTANCE.validate(documentRoot); if (diag.getSeverity() == Diagnostic.ERROR) { for (Diagnostic childDiag : diag.getChildren()) LogUtils.error(childDiag.getMessage()); throw ExceptionUtils.fromMessage( "Maven Metadata model validation failed: %s", diag.getMessage()); } }
private void initTreeNavigatorNodes() { List<String> selectedNames = new ArrayList<String>(); EList<SalesforceModuleUnit> modules = temConnection.getModules(); // EList<SalesforceModuleUnit> modules = getConnection().getModules(); for (int i = 0; i < modules.size(); i++) { if (modules.get(i).getModuleName().equals(moduleName)) { for (int j = 0; j < modules.get(i).getTables().size(); j++) { selectedNames.add(modules.get(i).getTables().get(j).getLabel()); } break; } } tableNavigator.removeAll(); TableItem subItem = null; String lastSelectName = null; if (selectedNames != null && selectedNames.size() >= 1) { for (int i = 0; i < selectedNames.size(); i++) { subItem = new TableItem(tableNavigator, SWT.NULL); subItem.setText(selectedNames.get(i)); lastSelectName = selectedNames.get(i); } metadataNameText.setText(subItem.getText()); tableNavigator.setSelection(subItem); metadataTable = getTableByLabel(lastSelectName); } else { subItem = new TableItem(tableNavigator, SWT.NULL); subItem.setText(moduleName); } metadataEditor.setMetadataTable(metadataTable); }
public void testTransientResource() throws Exception { final URI uri = URI.createURI("cdo:/test1"); msg("Creating resourceSet"); ResourceSet resourceSet = new ResourceSetImpl(); SessionUtil.prepareResourceSet(resourceSet); msg("Creating resource"); CDOResource resource = (CDOResource) resourceSet.createResource(uri); assertTransient(resource); msg("Creating supplier"); Supplier supplier = getModel1Factory().createSupplier(); assertTransient(supplier); assertEquals(null, supplier.eContainer()); msg("Verifying contents"); EList<EObject> contents = resource.getContents(); assertNotNull(contents); assertEquals(true, contents.isEmpty()); assertEquals(0, contents.size()); assertTransient(resource); msg("Adding supplier"); contents.add(supplier); assertTransient(resource); assertTransient(supplier); assertContent(resource, supplier); assertEquals(true, resourceSet.getResources().contains(resource)); resource.delete(null); assertEquals(false, resourceSet.getResources().contains(resource)); assertTransient(supplier); }
/** * Retrieves the target from an entry. TODO: validation of preconditions for entry targets e.g * every region needs an entry with appropriate target */ public State target(final Entry entry) { State _xifexpression = null; EList<Transition> _outgoingTransitions = entry == null ? (EList<Transition>) null : entry.getOutgoingTransitions(); boolean _notEquals = (!Objects.equal(_outgoingTransitions, null)); if (_notEquals) { State _xifexpression_1 = null; EList<Transition> _outgoingTransitions_1 = entry.getOutgoingTransitions(); int _size = _outgoingTransitions_1.size(); boolean _greaterThan = (_size > 0); if (_greaterThan) { State _xblockexpression = null; { EList<Transition> _outgoingTransitions_2 = entry.getOutgoingTransitions(); Transition _get = _outgoingTransitions_2.get(0); final Vertex target = _get.getTarget(); State _xifexpression_2 = null; if ((target instanceof State)) { _xifexpression_2 = ((State) target); } _xblockexpression = (_xifexpression_2); } _xifexpression_1 = _xblockexpression; } _xifexpression = _xifexpression_1; } return _xifexpression; }
protected static List<String> getActivityNames(EList<EPlanChild> children) { List<String> result = new ArrayList<String>(children.size()); for (EPlanChild child : children) { result.add(child.getName()); } return result; }
@Override public HyperLinkEditor getHyperLinkObjectForEAnnotation(EAnnotation eAnnotation) { if (eAnnotation.getSource().equals(HyperLinkDiagramConstants.HYPERLINK_DIAGRAM)) { HyperLinkDiagram hyperLinkDiagram = new HyperLinkDiagram(); EList<EObject> list = eAnnotation.getReferences(); if (list.size() > 0) { if (eAnnotation.getReferences().get(0).eResource() != null) { hyperLinkDiagram.setDiagram((Diagram) eAnnotation.getReferences().get(0)); hyperLinkDiagram.setTooltipText( eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_TOOLTYPE_TEXT)); if (eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_IS_DEFAULT_NAVIGATION) != null) { String stringboolean = eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_IS_DEFAULT_NAVIGATION); boolean isDefaultNaviagation = Boolean.parseBoolean(stringboolean); hyperLinkDiagram.setIsDefault(isDefaultNaviagation); } else { hyperLinkDiagram.setIsDefault(false); } return hyperLinkDiagram; } } } return null; }
public boolean canLayout(ILayoutContext context) { // return true, if pictogram element is linked to an EClass PictogramElement pe = context.getPictogramElement(); if (!(pe instanceof ContainerShape)) return false; EList<EObject> businessObjects = pe.getLink().getBusinessObjects(); return businessObjects.size() == 1 && businessObjects.get(0) instanceof EClass; }
private void addResultToList( org.emftext.sdk.concretesyntax.resource.cs.ICsReferenceMapping<ReferenceType> mapping, org.eclipse.emf.ecore.EObject proxy, org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> list) { org.eclipse.emf.ecore.EObject target = null; int proxyPosition = list.indexOf(proxy); if (mapping instanceof org.emftext.sdk.concretesyntax.resource.cs.ICsElementMapping<?>) { target = ((org.emftext.sdk.concretesyntax.resource.cs.ICsElementMapping<ReferenceType>) mapping) .getTargetElement(); } else if (mapping instanceof org.emftext.sdk.concretesyntax.resource.cs.ICsURIMapping<?>) { target = org.eclipse.emf.ecore.util.EcoreUtil.copy(proxy); org.eclipse.emf.common.util.URI uri = ((org.emftext.sdk.concretesyntax.resource.cs.ICsURIMapping<ReferenceType>) mapping) .getTargetIdentifier(); ((org.eclipse.emf.ecore.InternalEObject) target).eSetProxyURI(uri); } else { assert false; } try { // if target is an another proxy and list is "unique" add() will try to resolve // the new proxy to check for uniqueness. There seems to be no way to avoid that. // Until now this does not cause any problems. if (proxyPosition + 1 == list.size()) { list.add(target); } else { list.add(proxyPosition + 1, target); } } catch (Exception e1) { e1.printStackTrace(); } }
@Test(timeout = 1000) public void checkParserResult() throws Exception { final String text = this.getTextFromFile("res/Test0030_ObjectLikeMacro.c"); final Preprocess Preprocess_0_Var = this.parseHelper.parse(text); this.valHelper.assertNoErrors(Preprocess_0_Var); Assert.assertNotNull(Preprocess_0_Var); // 0 final GroupOpt GroupOpt_1_Var = (GroupOpt) Preprocess_0_Var.getGroup(); Assert.assertNotNull(GroupOpt_1_Var); final EList<? extends EObject> Lines_1_list = GroupOpt_1_Var.getLines(); Assert.assertNotNull(Lines_1_list); Assert.assertEquals(3, Lines_1_list.size()); // 1 final Code Code_2_Var = (Code) Lines_1_list.get(0); Assert.assertNotNull(Code_2_Var); Assert.assertEquals("int foo1 = BAR;", Code_2_Var.getCode()); // 2 final PreprocessorDirectives PreprocessorDirectives_3_Var = (PreprocessorDirectives) Lines_1_list.get(1); Assert.assertNotNull(PreprocessorDirectives_3_Var); // 3 final DefineObjectMacro DefineObjectMacro_4_Var = (DefineObjectMacro) PreprocessorDirectives_3_Var.getDirective(); Assert.assertNotNull(DefineObjectMacro_4_Var); Assert.assertEquals("BAR", DefineObjectMacro_4_Var.getIdent()); Assert.assertEquals("0", DefineObjectMacro_4_Var.getString()); // 4 final Code Code_5_Var = (Code) Lines_1_list.get(2); Assert.assertNotNull(Code_5_Var); Assert.assertEquals("int foo2 = BAR;", Code_5_Var.getCode()); }
public List<String> initialHiddenTokens(final Grammar it) { List<String> _xblockexpression = null; { boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens(); if (_isDefinesHiddenTokens) { EList<AbstractRule> _hiddenTokens = it.getHiddenTokens(); final Function1<AbstractRule, String> _function = new Function1<AbstractRule, String>() { @Override public String apply(final AbstractRule it) { return GrammarAccessExtensions.this.ruleName(it); } }; List<String> _map = ListExtensions.<AbstractRule, String>map(_hiddenTokens, _function); return IterableExtensions.<String>toList(_map); } EList<Grammar> _usedGrammars = it.getUsedGrammars(); int _size = _usedGrammars.size(); boolean _equals = (_size == 1); if (_equals) { EList<Grammar> _usedGrammars_1 = it.getUsedGrammars(); Grammar _head = IterableExtensions.<Grammar>head(_usedGrammars_1); return this.initialHiddenTokens(_head); } _xblockexpression = CollectionLiterals.<String>emptyList(); } return _xblockexpression; }
/** * This returns the label text for the adapted class. * <!-- begin-user-doc * --> * <!-- end-user-doc --> * * @generated NOT * @param object the object to be described * @return the description of the given object */ @Override public String getText(Object object) { if (object instanceof CreateDeleteOperation) { CreateDeleteOperation op = (CreateDeleteOperation) object; EObject modelElement = op.getModelElement(); int childrenCount = ModelUtil.getAllContainedModelElements(modelElement, false).size(); String description; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(modelElement.eClass().getName()); stringBuilder.append(getModelElementName(op.getModelElementId())); String elementClassAndName = stringBuilder.toString(); if (op.isDelete()) { description = "Deleted " + elementClassAndName; } else { description = "Created " + elementClassAndName; } if (childrenCount > 0) { description += " including " + childrenCount + " sibling(s)"; } EList<ReferenceOperation> subOperations = op.getSubOperations(); int subOperationCount = subOperations.size(); if (op.isDelete() && subOperationCount > 0) { ReferenceOperation referenceOperation = subOperations.get(subOperationCount - 1); if (referenceOperation.getContainmentType().equals(ContainmentType.CONTAINMENT)) { description += " from its parent " + getModelElementClassAndName(referenceOperation.getModelElementId()); } } return description; } return super.getText(object); }
StyledString text(ResourceExpression ele) { int resourceClassifier = ClassifierAdapterFactory.eINSTANCE.adapt(ele).getClassifier(); if (resourceClassifier == ClassifierAdapter.UNKNOWN) validator.checkResourceExpression(ele); resourceClassifier = ClassifierAdapterFactory.eINSTANCE.adapt(ele).getClassifier(); StyledString label = new StyledString(); Object name = doGetText(ele.getResourceExpr()); appendStyled(label, name); final EList<ResourceBody> bodyList = ele.getResourceData(); final int bodyListSize = bodyList.size(); if (resourceClassifier == ClassifierAdapter.RESOURCE_IS_REGULAR) { // append the first named resource body, and add , ... if more than one if (bodyList.size() >= 1) { Object bodyLabel = doGetText(bodyList.get(0).getNameExpr()); label.append(" "); appendStyled(label, bodyLabel, StyledString.QUALIFIER_STYLER); if (bodyListSize > 1) label.append(", ...", StyledString.QUALIFIER_STYLER); } } StyledString typeLabel = new StyledString(); switch (resourceClassifier) { case ClassifierAdapter.UNKNOWN: typeLabel.append(" : ", StyledString.DECORATIONS_STYLER); typeLabel.append("Unknown type of Resource expression", ERROR_STYLER); break; case ClassifierAdapter.RESOURCE_IS_BAD: typeLabel.append(" : ", StyledString.DECORATIONS_STYLER); typeLabel.append("Invalid Resource", ERROR_STYLER); break; case ClassifierAdapter.RESOURCE_IS_DEFAULT: typeLabel.append(" : Resource Defaults", StyledString.DECORATIONS_STYLER); break; case ClassifierAdapter.RESOURCE_IS_OVERRIDE: typeLabel.append(" : Resource Override", StyledString.DECORATIONS_STYLER); break; case ClassifierAdapter.RESOURCE_IS_REGULAR: typeLabel.append( " : Resource" + (bodyListSize > 1 ? "s" : ""), StyledString.DECORATIONS_STYLER); break; } label.append(typeLabel); return label; }
@Override public EObject getEObject(String uriFragment) { EList<EObject> contents = getContents(); String name = URI.decode(uriFragment); for (int i = 0; i < contents.size(); i++) { EObject root = contents.get(i); EList<EObject> children = root.eContents(); for (int j = 0; j < children.size(); j++) { EObject child = children.get(j); if (child instanceof NameSupport && name.equals(((NameSupport) child).getName())) return child; } } return super.getEObject(uriFragment); }
@Override public ResolvedStructType caseStructType(StructType object) { EList<Type> types = object.getTypes(); List<ResolvedType> resolvedTypes = new ArrayList<ResolvedType>(types.size()); for (Type t : types) { resolvedTypes.add(resolve(t)); } return new ResolvedStructType(resolvedTypes, object.getPacked() != null, false); }
@Override public ResolvedStructType caseStructureConstant(StructureConstant object) { EList<TypedConstant> values = object.getList().getTypedConstants(); List<ResolvedType> resolvedTypes = new ArrayList<ResolvedType>(values.size()); for (TypedConstant tc : values) { resolvedTypes.add(resolve(tc.getType())); } return new ResolvedStructType(resolvedTypes, object.getPacked() != null, true); }
private int[] initDomainValues(DiscreteDomain domain) { EList<DomainValue> values = domain.getValues(); int[] valueArray = new int[values.size()]; Iterator<DomainValue> iterator = values.iterator(); for (int i = 0; i < valueArray.length; i++) { valueArray[i] = iterator.next().getInt(); } return valueArray; }