org.eclipse.xtext.common.types.JvmVoid Java Examples
The following examples show how to use
org.eclipse.xtext.common.types.JvmVoid.
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: TypeInsteadOfConstructorLinkingCandidate.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public boolean validate(IAcceptor<? super AbstractDiagnostic> result) { JvmType type = (JvmType) description.getElementOrProxy(); String typeKind = ""; if (type instanceof JvmPrimitiveType || type instanceof JvmVoid) { typeKind = "primitive type"; } else if (type instanceof JvmAnnotationType) { typeKind = "annotation type"; } else if (type instanceof JvmEnumerationType) { typeKind = "enum type"; } else if (type instanceof JvmGenericType && ((JvmGenericType) type).isInterface()) { typeKind = "interface type"; } else if (type instanceof JvmTypeParameter) { typeKind = "type parameter"; } String message = String.format("Cannot instantiate the %s %s", typeKind, type.getSimpleName()); AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.ILLEGAL_CLASS_INSTANTIATION, message, getExpression(), XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, -1, null); result.accept(diagnostic); return false; }
Example #2
Source File: IndexingLightweightTypeReferenceFactory.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public boolean isProcedure(XFunctionTypeRefImplCustom it) { JvmTypeReference returnType = it.getReturnType(); if (returnType == null) { return true; } JvmType type = getType(returnType); if (type == null) { return false; } if (type.eIsProxy()) { return false; } if (type instanceof JvmVoid) { return true; } return false; }
Example #3
Source File: DocumentSourceAppender.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public void appendType(final /* @NonNull */ JvmType type, /* @NonNull */ StringBuilder builder) { if (type instanceof JvmPrimitiveType || type instanceof JvmVoid || type instanceof JvmTypeParameter) { builder.append(type.getQualifiedName(getInnerTypeSeparator())); } else if (type instanceof JvmArrayType) { appendType(((JvmArrayType) type).getComponentType(), builder); builder.append("[]"); } else { final String qualifiedName = type.getQualifiedName(getInnerTypeSeparator()); final String simpleName = type.getSimpleName(); JvmDeclaredType importedType = getImportedType(type); if (importedType == type) { builder.append(simpleName); } else if (importedType == null) { importSection.addImport((JvmDeclaredType) type); builder.append(simpleName); } else { builder.append(qualifiedName); } } }
Example #4
Source File: JvmTypeConstraintImplCustom.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * Constraint bounds are definitely invalid if they are <code>not null</code> and point to a primitive type. * {@link JvmSpecializedTypeReference} will not be resolved by this check thus they may lead to finally * invalid constraint bounds. * * @param constraintBound the reference that shall be come the new constraint. * @return <code>false</code> if the given constraint is definitely invalid. */ protected boolean isLikelyAValidConstraintBound(JvmTypeReference constraintBound) { if (constraintBound == null) return true; if (constraintBound instanceof JvmSpecializedTypeReference) { JvmTypeReference equivalent = (JvmTypeReference) constraintBound.eGet(TypesPackage.Literals.JVM_SPECIALIZED_TYPE_REFERENCE__EQUIVALENT, false); if (equivalent != null) { return isLikelyAValidConstraintBound(equivalent); } return true; } boolean invalid = (constraintBound.getType() instanceof JvmPrimitiveType || (constraintBound.getType() instanceof JvmVoid && !constraintBound.getType().eIsProxy())); return !invalid; }
Example #5
Source File: FormalParameterBuilderImpl.java From sarl with Apache License 2.0 | 5 votes |
/** Replies the JvmIdentifiable that corresponds to the formal parameter. * * @param container the feature call that is supposed to contains the replied identifiable element. */ public void setReferenceInto(XFeatureCall container) { JvmVoid jvmVoid = this.jvmTypesFactory.createJvmVoid(); if (jvmVoid instanceof InternalEObject) { final InternalEObject jvmVoidProxy = (InternalEObject) jvmVoid; final EObject param = getSarlFormalParameter(); final Resource resource = param.eResource(); // Get the derived object final SarlFormalParameter jvmParam = getAssociatedElement(SarlFormalParameter.class, param, resource); // Set the proxy URI final URI uri = EcoreUtil2.getNormalizedURI(jvmParam); jvmVoidProxy.eSetProxyURI(uri); } container.setFeature(jvmVoid); }
Example #6
Source File: PrimitiveAwareScope.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected void doGetElements(JvmType type, List<IEObjectDescription> result) { if (type instanceof JvmVoid) { result.add(EObjectDescription.create("void", type)); return; } if (type instanceof JvmPrimitiveType) { result.add(EObjectDescription.create(((JvmPrimitiveType) type).getSimpleName(), type)); return; } parent.doGetElements(type, result); }
Example #7
Source File: LinkingErrorTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testNoException_02() throws Exception { XtendFunction function = function("def noException() {\n" + // exception case is i " val closure = [ i| return i]\n" + " for (x : 1..100) closure.apply(x)\n" + " }"); JvmTypeReference type = associations.getDirectlyInferredOperation(function).getReturnType(); assertTrue(type.getType() instanceof JvmVoid); assertFalse(type.getType().eIsProxy()); assertNoExceptions(function); }
Example #8
Source File: LinkingErrorTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testNoException_01() throws Exception { XtendFunction function = function("def noException() {\n" + // exception case is Integeri " val closure = [Integeri| return i]\n" + " for (x : 1..100) closure.apply(x)\n" + " }"); JvmTypeReference type = associations.getDirectlyInferredOperation(function).getReturnType(); assertTrue(type.getType() instanceof JvmVoid); assertFalse(type.getType().eIsProxy()); assertNoExceptions(function); }
Example #9
Source File: JdtTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testBug300216() { JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName("java.lang.Object"); assertTrue(type.getSuperTypes().isEmpty()); URI unresolveableType = URI.createURI("java:/Objects/Something#Something"); JvmVoid proxy = TypesFactory.eINSTANCE.createJvmVoid(); JvmParameterizedTypeReference typeReference = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference(); typeReference.setType(proxy); ((InternalEObject) proxy).eSetProxyURI(unresolveableType); type.getSuperTypes().add(typeReference); assertTrue(type.getSuperTypes().get(0).getType().eIsProxy()); assertEquals(2, type.eResource().getResourceSet().getResources().size()); }
Example #10
Source File: XFunctionTypeRefImplCustom.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
private boolean isProcedure() { JvmTypeReference returnType = getReturnType(); if (returnType == null) return true; JvmType type = returnType.getType(); if (type == null) return false; if (type.eIsProxy()) return false; if (type instanceof JvmVoid) return true; return false; }
Example #11
Source File: AbstractXbaseCompiler.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected boolean isPrimitiveVoid(JvmTypeReference typeRef) { JvmType type = typeRef.getType(); if (type instanceof JvmVoid) { return !type.eIsProxy(); } return false; }
Example #12
Source File: FeatureCallCompiler.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void appendNullValue(JvmTypeReference type, EObject context, ITreeAppendable b) { if (!primitives.isPrimitive(type)) { if (!(type.getType() instanceof JvmVoid)) { b.append("("); serialize(type, context, b); b.append(")"); } b.append("null"); } else { b.append(getDefaultLiteral((JvmPrimitiveType) type.getType())); } }
Example #13
Source File: JvmTypeReferencesValidator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Check public void checkFunctionTypeArgsNonVoid(XFunctionTypeRef typeRef) { for (JvmTypeReference paramType : typeRef.getParamTypes()) { JvmType type = paramType.getType(); if (type instanceof JvmVoid && !type.eIsProxy()) { error("The primitive 'void' cannot be the type of a function parameter. ", paramType, null, -1, INVALID_USE_OF_TYPE); } } }
Example #14
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected boolean isPrimitiveVoid(JvmTypeReference typeReference) { return typeReference != null && typeReference.getType() != null && !typeReference.getType().eIsProxy() && typeReference.getType() instanceof JvmVoid; }
Example #15
Source File: AbstractConstructorScopeTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Test public void testGetElementByInstance_02() { JvmVoid voidType = TypesFactory.eINSTANCE.createJvmVoid(); IEObjectDescription element = getConstructorScope().getSingleElement(voidType); assertNull(element); }
Example #16
Source File: AbstractTypeScopeTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Test public void testGetElementByInstance_01() { JvmVoid voidType = TypesFactory.eINSTANCE.createJvmVoid(); IEObjectDescription element = getTypeScope().getSingleElement(voidType); assertNotNull(element); assertEquals(voidType.getIdentifier(), element.getName().toString()); }
Example #17
Source File: AbstractTypeScopeTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Test public void testGetElementByInstance_01() { JvmVoid voidType = TypesFactory.eINSTANCE.createJvmVoid(); IEObjectDescription element = getTypeScope().getSingleElement(voidType); assertNotNull(element); assertEquals(voidType.getIdentifier(), element.getName().toString()); }
Example #18
Source File: AbstractConstructorScopeTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Test public void testGetElementByInstance_02() { JvmVoid voidType = TypesFactory.eINSTANCE.createJvmVoid(); IEObjectDescription element = getConstructorScope().getSingleElement(voidType); assertNull(element); }