Java Code Examples for org.eclipse.emf.ecore.EObject
The following examples show how to use
org.eclipse.emf.ecore.EObject.
These examples are extracted from open source projects.
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 Project: xtext-core Author: eclipse File: AbstractXtextTests.java License: Eclipse Public License 2.0 | 6 votes |
public final XtextResource getResourceAndExpect(InputStream in, URI uri, int expectedErrors) throws Exception { XtextResource resource = doGetResource(in, uri); checkNodeModel(resource); if (expectedErrors != UNKNOWN_EXPECTATION) { if (expectedErrors == EXPECT_ERRORS) assertFalse(Joiner.on('\n').join(resource.getErrors()), resource.getErrors().isEmpty()); else assertEquals(Joiner.on('\n').join(resource.getErrors()), expectedErrors, resource.getErrors().size()); } for(Diagnostic d: resource.getErrors()) { if (d instanceof ExceptionDiagnostic) fail(d.getMessage()); } if (expectedErrors == 0 && resource.getContents().size() > 0 && shouldTestSerializer(resource)) { SerializerTestHelper tester = get(SerializerTestHelper.class); EObject obj = resource.getContents().get(0); tester.assertSerializeWithNodeModel(obj); tester.assertSerializeWithoutNodeModel(obj); } return resource; }
Example #2
Source Project: xtext-core Author: eclipse File: Bug419429Test.java License: Eclipse Public License 2.0 | 6 votes |
protected void replaceAndReparse(String model, int offset, int length, String change, String expectedReparseRegion) throws Exception { IParseResult parseResult = getParseResultAndExpect(model, UNKNOWN_EXPECTATION); PartialParsingPointers parsingPointers = getPartialParser().calculatePartialParsingPointers(parseResult, offset, length); String reparseRegion = getPartialParser().insertChangeIntoReplaceRegion(parsingPointers .getDefaultReplaceRootNode(), new ReplaceRegion(offset, length, change)); assertEquals(expectedReparseRegion, reparseRegion); final Wrapper<Boolean> unloaded = Wrapper.wrap(Boolean.FALSE); getPartialParser().setUnloader(new IReferableElementsUnloader() { @Override public void unloadRoot(EObject root) { unloaded.set(Boolean.TRUE); } }); IParseResult partiallyReparse = reparse(parseResult, offset, length, change); assertTrue("unloaded", unloaded.get()); String expectedReparseModel = model.substring(0, offset) + change + model.substring(offset + length); assertEquals(expectedReparseModel, partiallyReparse.getRootNode().getText()); compareWithFullParse(model, offset, length, change); }
Example #3
Source Project: bonita-studio Author: bonitasoft File: OperatorViewerFilter.java License: GNU General Public License v2.0 | 6 votes |
@Override public boolean select(final Viewer viewer, final Object parentElement, final Object element) { final Expression exp = operation.getLeftOperand(); if (isVariableType(exp)) { return selectFilterForVariableStorage(element, exp); } else if (isDocumentType(exp)) { final EObject referencedDocument = exp.getReferencedElements().get(0); if (referencedDocument instanceof Document) { if (((Document) referencedDocument).isMultiple()) { return ExpressionConstants.SET_LIST_DOCUMENT_OPERATOR.equals(element); } else { return ExpressionConstants.SET_DOCUMENT_OPERATOR.equals(element); } } } return ExpressionConstants.ASSIGNMENT_OPERATOR.equals(element); }
Example #4
Source Project: n4js Author: eclipse File: OrderedEmfFormatter.java License: Eclipse Public License 1.0 | 6 votes |
private static void objPath(StringBuffer b, EObject obj) { if (obj.eContainer() != null) { objPath(b, obj.eContainer()); b.append("."); b.append(obj.eContainingFeature().getName()); if (obj.eContainingFeature().isMany()) { b.append("["); b.append(((List<?>) obj.eContainer().eGet(obj.eContainingFeature())).indexOf(obj)); b.append("]"); } b.append("->"); } b.append(obj.eClass().getName()); EStructuralFeature nameF = obj.eClass().getEStructuralFeature("name"); Object name = nameF != null ? obj.eGet(nameF) : null; if (name != null) { b.append("'"); b.append(name); b.append("'"); } }
Example #5
Source Project: statecharts Author: Yakindu File: HelpIntegrationTest.java License: Eclipse Public License 1.0 | 6 votes |
private List<String> getFeaturesWithoutDocumentation(String generatorId) { Iterable<IEObjectDescription> allElements = getAllElements(generatorId); List<String> missingDocumentation = Lists.newArrayList(); for (IEObjectDescription desc : allElements) { if (desc.getEClass() != SGenPackage.Literals.FEATURE_TYPE) continue; EObject eObjectOrProxy = desc.getEObjectOrProxy(); String documentation = documentationProvider .getDocumentation(eObjectOrProxy); if (documentation == null || SGenUserHelpDocumentationProvider.EMPTY_DOCUMENTATION .equals(documentation)) { missingDocumentation.add(desc.getName().toString()); } } return missingDocumentation; }
Example #6
Source Project: kieker Author: kieker-monitoring File: TraceAdapterFactory.java License: Apache License 2.0 | 5 votes |
/** * Returns whether this factory is applicable for the type of the object. * <!-- begin-user-doc --> * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. * <!-- end-user-doc --> * @return whether this factory is applicable for the type of the object. * @generated */ @Override public boolean isFactoryForType(Object object) { if (object == modelPackage) { return true; } if (object instanceof EObject) { return ((EObject)object).eClass().getEPackage() == modelPackage; } return false; }
Example #7
Source Project: neoscada Author: eclipse File: WorldAdapterFactory.java License: Eclipse Public License 1.0 | 5 votes |
/** * Returns whether this factory is applicable for the type of the object. * <!-- begin-user-doc --> * This implementation returns <code>true</code> if the object is either the * model's package or is an instance object of the model. * <!-- end-user-doc --> * @return whether this factory is applicable for the type of the object. * @generated */ @Override public boolean isFactoryForType ( Object object ) { if ( object == modelPackage ) { return true; } if ( object instanceof EObject ) { return ( (EObject)object ).eClass ().getEPackage () == modelPackage; } return false; }
Example #8
Source Project: dsl-devkit Author: dsldevkit File: HelloWorldAdapterFactory.java License: Eclipse Public License 1.0 | 5 votes |
/** * Returns whether this factory is applicable for the type of the object. * <!-- begin-user-doc --> * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. * <!-- end-user-doc --> * @return whether this factory is applicable for the type of the object. * @generated */ @Override public boolean isFactoryForType(Object object) { if (object == modelPackage) { return true; } if (object instanceof EObject) { return ((EObject)object).eClass().getEPackage() == modelPackage; } return false; }
Example #9
Source Project: n4js Author: eclipse File: InvisibleTypeOrVariableDescription.java License: Eclipse Public License 1.0 | 5 votes |
@Override public String getIssueCode() { EObject objectOrProxy = getEObjectOrProxy(); if (objectOrProxy instanceof TFunction) { return IssueCodes.VIS_ILLEGAL_FUN_ACCESS; } else if (objectOrProxy instanceof Type) { return IssueCodes.VIS_ILLEGAL_TYPE_ACCESS; } return IssueCodes.VIS_ILLEGAL_VARIABLE_ACCESS; }
Example #10
Source Project: n4js Author: eclipse File: EditorOverlay.java License: Eclipse Public License 1.0 | 5 votes |
@Override public void paintControl(PaintEvent e) { for (EObject eo : selectedElements) { paintConture(e, eo, colorBlue); } if (hoveredElement != null) { paintConture(e, hoveredElement, colorGreen); } }
Example #11
Source Project: n4js Author: eclipse File: IdentifierRefImpl.java License: Eclipse Public License 1.0 | 5 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public IdentifiableElement getTargetElement() { final IdentifiableElement targetRaw = this.getId(); if ((targetRaw instanceof ModuleNamespaceVirtualType)) { final EObject parent = this.eContainer(); if ((parent instanceof ParameterizedPropertyAccessExpression)) { return ((ParameterizedPropertyAccessExpression)parent).getProperty(); } } return targetRaw; }
Example #12
Source Project: xtext-core Author: eclipse File: PartialParserTestLanguageAdapterFactory.java License: Eclipse Public License 2.0 | 5 votes |
/** * Returns whether this factory is applicable for the type of the object. * <!-- begin-user-doc --> * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. * <!-- end-user-doc --> * @return whether this factory is applicable for the type of the object. * @generated */ @Override public boolean isFactoryForType(Object object) { if (object == modelPackage) { return true; } if (object instanceof EObject) { return ((EObject)object).eClass().getEPackage() == modelPackage; } return false; }
Example #13
Source Project: xtext-xtend Author: eclipse File: XtendAdapterFactory.java License: Eclipse Public License 2.0 | 5 votes |
/** * Returns whether this factory is applicable for the type of the object. * <!-- begin-user-doc --> * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. * <!-- end-user-doc --> * @return whether this factory is applicable for the type of the object. * @generated */ @Override public boolean isFactoryForType(Object object) { if (object == modelPackage) { return true; } if (object instanceof EObject) { return ((EObject)object).eClass().getEPackage() == modelPackage; } return false; }
Example #14
Source Project: solidity-ide Author: Yakindu File: InlineAssemblyBlockImpl.java License: Eclipse Public License 1.0 | 5 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public EList<EObject> getItems() { if (items == null) { items = new EObjectContainmentEList<EObject>(EObject.class, this, SolidityPackage.INLINE_ASSEMBLY_BLOCK__ITEMS); } return items; }
Example #15
Source Project: eip-designer Author: lbroudoux File: EnricherPropertiesEditionPartForm.java License: Apache License 2.0 | 5 votes |
/** * */ protected void editFromChannels(EObject element) { EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(propertiesEditionComponent.getEditingContext(), propertiesEditionComponent, element, adapterFactory); PropertiesEditingProvider provider = (PropertiesEditingProvider)adapterFactory.adapt(element, PropertiesEditingProvider.class); if (provider != null) { PropertiesEditingPolicy policy = provider.getPolicy(context); if (policy != null) { policy.execute(); fromChannels.refresh(); } } }
Example #16
Source Project: xtext-core Author: eclipse File: AbstractCleaningLinker.java License: Eclipse Public License 2.0 | 5 votes |
/** * @since 2.7 */ @SuppressWarnings("serial") protected TreeIterator<EObject> getAllLinkableContents(EObject model) { return new AbstractTreeIterator<EObject>(model) { @Override public Iterator<EObject> getChildren(Object object) { return ((EObject) object).eContents().iterator(); } }; }
Example #17
Source Project: xtext-eclipse Author: eclipse File: AbstractRenameStrategy.java License: Eclipse Public License 2.0 | 5 votes |
protected EObject setName(URI targetElementURI, String newName, ResourceSet resourceSet) { EObject targetElement = resourceSet.getEObject(targetElementURI, false); if (targetElement == null) { throw new RefactoringException("Target element not loaded."); } targetElement.eSet(nameAttribute, newName); return targetElement; }
Example #18
Source Project: IfcPlugins Author: opensourceBIM File: IfcStepSerializer.java License: GNU Affero General Public License v3.0 | 5 votes |
private void writeDoubleValue(double value, EObject object, EStructuralFeature feature) throws SerializerException, IOException { if (model.isUseDoubleStrings()) { Object stringValue = object.eGet(object.eClass().getEStructuralFeature(feature.getName() + "AsString")); if (stringValue != null) { print((String)stringValue); return; } } IfcParserWriterUtils.writePrimitive(value, outputStream); }
Example #19
Source Project: xtext-core Author: eclipse File: DefaultResourceDescriptionTest.java License: Eclipse Public License 2.0 | 5 votes |
private void assertContains(Iterable<IEObjectDescription> exportedObjects, EObject ...expectedContents) { Collection<IEObjectDescription> collection = Lists.newArrayList(exportedObjects); for (EObject obj : expectedContents) { boolean found = false; for (IEObjectDescription ieObjectDescription : collection) { found = found || ieObjectDescription.getEObjectOrProxy()==obj; } assertTrue(obj+" wasn't contained",found); } assertEquals(collection.size(),expectedContents.length); }
Example #20
Source Project: n4js Author: eclipse File: ControlFlowGraphFactory.java License: Eclipse Public License 1.0 | 5 votes |
private static FinallyBlock getEnteringFinallyBlock(Node catchNode) { if (catchNode.name.equals(NodeNames.FINALLY)) { ControlFlowElement cfe = catchNode.getDelegatedControlFlowElement(); EObject cfeContainer = cfe.eContainer(); return (FinallyBlock) cfeContainer; } return null; }
Example #21
Source Project: bonita-studio Author: bonitasoft File: ConditionModelSemanticSequencer.java License: GNU General Public License v2.0 | 5 votes |
/** * Constraint: * value=STRING */ protected void sequence_Expression_String(EObject context, Expression_String semanticObject) { if(errorAcceptor != null) { if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.EXPRESSION_STRING__VALUE) == ValueTransient.YES) errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.EXPRESSION_STRING__VALUE)); } INodesForEObjectProvider nodes = createNodeProvider(semanticObject); SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes); feeder.accept(grammarAccess.getExpression_StringAccess().getValueSTRINGTerminalRuleCall_1_0(), semanticObject.getValue()); feeder.finish(); }
Example #22
Source Project: xtext-xtend Author: eclipse File: XtendProposalProvider.java License: Eclipse Public License 2.0 | 5 votes |
@Override public void completeXbaseConstructorCall_Constructor(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { completeJavaTypes( context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, true, getQualifiedNameValueConverter(), createVisibilityFilter(context), acceptor); }
Example #23
Source Project: bonita-studio Author: bonitasoft File: TabbedPropertySynchronizerListener.java License: GNU General Public License v2.0 | 5 votes |
@Override public void selectionChanged(final SelectionChangedEvent event) { final ISelection selection = event.getSelection(); if (selection.isEmpty()) { return; } final EObject element = unwrap(selection); final IEditorReference activeEditorReference = activeEditorReference(activePage); final IWorkbenchPart editorPart = activeEditorReference.getPart(false); if (editorPart instanceof DiagramEditor) { final DiagramEditor diagramEditor = (DiagramEditor) editorPart; try { final IGraphicalEditPart editPart = editPartResolver.findEditPart(diagramEditor.getDiagramEditPart(), element); final ITabbedPropertySelectionProvider defaultProvider = findDefaultProvider(editorPart, editPart); updateDiagramSelection(diagramEditor, editPart); final ITabbedPropertySelectionProvider selectionProvider = registry.findSelectionProvider(element, activeEditorReference, defaultProvider); IViewPart part = null; try { part = activePage.showView(selectionProvider.viewId()); } catch (final PartInitException e1) { return; } if (part != null) { updateSelectedTabInPage(element, selectionProvider, part); } } catch (final EditPartNotFoundException e) { BonitaStudioLog.debug("No edit part found for semantic element: " + element, Activator.PLUGIN_ID); } } }
Example #24
Source Project: xtext-eclipse Author: eclipse File: InternalTwoParametersTestLanguageParser.java License: Eclipse Public License 2.0 | 5 votes |
public final EObject entryRuleScenario7() throws RecognitionException { EObject current = null; EObject iv_ruleScenario7 = null; try { // InternalTwoParametersTestLanguage.g:677:50: (iv_ruleScenario7= ruleScenario7 EOF ) // InternalTwoParametersTestLanguage.g:678:2: iv_ruleScenario7= ruleScenario7 EOF { if ( state.backtracking==0 ) { newCompositeNode(grammarAccess.getScenario7Rule()); } pushFollow(FollowSets000.FOLLOW_1); iv_ruleScenario7=ruleScenario7(); state._fsp--; if (state.failed) return current; if ( state.backtracking==0 ) { current =iv_ruleScenario7; } match(input,EOF,FollowSets000.FOLLOW_2); if (state.failed) return current; } } catch (RecognitionException re) { recover(input,re); appendSkippedTokens(); } finally { } return current; }
Example #25
Source Project: xtext-core Author: eclipse File: InternalSimpleExpressionsParser.java License: Eclipse Public License 2.0 | 5 votes |
public final EObject entryRuleExpression() throws RecognitionException { EObject current = null; EObject iv_ruleExpression = null; try { // InternalSimpleExpressions.g:138:2: (iv_ruleExpression= ruleExpression EOF ) // InternalSimpleExpressions.g:139:2: iv_ruleExpression= ruleExpression EOF { newCompositeNode(grammarAccess.getExpressionRule()); pushFollow(FOLLOW_1); iv_ruleExpression=ruleExpression(); state._fsp--; current =iv_ruleExpression; match(input,EOF,FOLLOW_2); } } catch (RecognitionException re) { recover(input,re); appendSkippedTokens(); } finally { } return current; }
Example #26
Source Project: xtext-xtend Author: eclipse File: XtendExpressionUtil.java License: Eclipse Public License 2.0 | 5 votes |
@Override protected ITextRegion getTotalTextRegion(EObject element, INode node) { if (element.eContainer() instanceof RichString) { return getRichStringPartTextRegion(element); } return super.getTotalTextRegion(element, node); }
Example #27
Source Project: dsl-devkit Author: dsldevkit File: InternalValidParser.java License: Eclipse Public License 1.0 | 5 votes |
public final EObject entryRuleRangeRule() throws RecognitionException { EObject current = null; EObject iv_ruleRangeRule = null; try { // InternalValid.g:867:2: (iv_ruleRangeRule= ruleRangeRule EOF ) // InternalValid.g:868:2: iv_ruleRangeRule= ruleRangeRule EOF { newCompositeNode(grammarAccess.getRangeRuleRule()); pushFollow(FOLLOW_1); iv_ruleRangeRule=ruleRangeRule(); state._fsp--; current =iv_ruleRangeRule; match(input,EOF,FOLLOW_2); } } catch (RecognitionException re) { recover(input,re); appendSkippedTokens(); } finally { } return current; }
Example #28
Source Project: bonita-studio Author: bonitasoft File: OperationReturnTypesValidator.java License: GNU General Public License v2.0 | 5 votes |
private boolean isInvalidQueryExpression(final Operation operation) { if (leftOperandHasReferencedElement(operation)) { final EObject data = operation.getLeftOperand().getReferencedElements().get(0); return !(data instanceof BusinessObjectData) && Objects.equals(operation.getRightOperand().getType(), ExpressionConstants.QUERY_TYPE) && !isPrimitive(operation.getRightOperand().getReturnType()); } return false; }
Example #29
Source Project: xtext-extras Author: eclipse File: AbstractTypeProviderTest.java License: Eclipse Public License 2.0 | 5 votes |
protected void diagnose(EObject object, String... expectedUnresolvedProxies) { Resource resource = object.eResource(); for (EObject content : resource.getContents()) { Diagnostic diagnostic = diagnostician.validate(content); if (diagnostic.getSeverity() != Diagnostic.OK) { URI[] expectedUnresolvedProxyURIs = new URI[expectedUnresolvedProxies.length]; for (int i = 0; i < expectedUnresolvedProxies.length; i++) { expectedUnresolvedProxyURIs[i] = URI.createURI(expectedUnresolvedProxies[i]); } diagnose(diagnostic, expectedUnresolvedProxyURIs); } } }
Example #30
Source Project: n4js Author: eclipse File: TFormalParameterImpl.java License: Eclipse Public License 1.0 | 5 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public EObject getAstElement() { if (astElement != null && astElement.eIsProxy()) { InternalEObject oldAstElement = (InternalEObject)astElement; astElement = eResolveProxy(oldAstElement); if (astElement != oldAstElement) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, TypesPackage.TFORMAL_PARAMETER__AST_ELEMENT, oldAstElement, astElement)); } } return astElement; }