Java Code Examples for org.eclipse.xtext.common.types.JvmType#getQualifiedName()
The following examples show how to use
org.eclipse.xtext.common.types.JvmType#getQualifiedName() .
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: SerializerScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected IScope doGetTypeScope(XMemberFeatureCall call, JvmType type) { if (call.isPackageFragment()) { if (type instanceof JvmDeclaredType) { int segmentIndex = countSegments(call); String packageName = ((JvmDeclaredType) type).getPackageName(); List<String> splitted = Strings.split(packageName, '.'); String segment = splitted.get(segmentIndex); return new SingletonScope(EObjectDescription.create(segment, type), IScope.NULLSCOPE); } return IScope.NULLSCOPE; } else { if (type instanceof JvmDeclaredType && ((JvmDeclaredType) type).getDeclaringType() == null) { return new SingletonScope(EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE); } else { XAbstractFeatureCall target = (XAbstractFeatureCall) call.getMemberCallTarget(); if (target.isPackageFragment()) { String qualifiedName = type.getQualifiedName(); int dot = qualifiedName.lastIndexOf('.'); String simpleName = qualifiedName.substring(dot + 1); return new SingletonScope(EObjectDescription.create(simpleName, type), IScope.NULLSCOPE); } else { return new SingletonScope(EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE); } } } }
Example 2
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 3
Source File: KnownTypesScope.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected JvmType getExactMatch(JvmType type, int index, QualifiedName name) { String qn = type.getQualifiedName(); if (Strings.isEmpty(qn)) { return null; } QualifiedName typeName = QualifiedName.create(Strings.split(qn, '.')); if (name.equals(typeName)) { return type; } if (name.startsWith(typeName)) { JvmType result = findNestedType(type, index, name.skipFirst(typeName.getSegmentCount()-1)); return result; } if (name.getSegmentCount() > typeName.getSegmentCount()) { if (typeName.skipLast(1).equals(name.skipLast(1))) { if (typeName.getLastSegment().equals(name.skipFirst(typeName.getSegmentCount() - 1).toString("$"))) { return type; } } } return null; }
Example 4
Source File: NestedTypesScope.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void addDescriptions(JvmDeclaredType type, JvmType declarator, List<IEObjectDescription> result) { String typeName = type.getQualifiedName('.'); String declaratorName = declarator.getQualifiedName('.'); int declaratorLength = declaratorName.length(); String subName = typeName.substring(declaratorLength + 1); List<String> segments = Strings.split(subName, '.'); result.add(EObjectDescription.create(QualifiedName.create(segments), type)); result.add(EObjectDescription.create(subName.replace('.', '$'), type)); for(JvmDeclaredType nestedType: type.getAllNestedTypes()) { addDescriptions(nestedType, declarator, result); } }
Example 5
Source File: ImportManager.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public boolean addImportFor(JvmType type) { final String qualifiedName = type.getQualifiedName(getInnerTypeSeparator()); final String simpleName = type.getSimpleName(); final Map<String, String> imps = internalGetImports(); if (!allowsSimpleName(qualifiedName, simpleName) && !needsQualifiedName(qualifiedName, simpleName) && !imps.containsKey(simpleName)) { imps.put(simpleName, qualifiedName); return true; } return false; }
Example 6
Source File: JvmTypeReferenceImplCustom.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public String getQualifiedName(char innerClassDelimiter) { JvmType type = getType(); if (type != null) return type.getQualifiedName(innerClassDelimiter); return null; }
Example 7
Source File: XbaseWithAnnotationsProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private String getRawReturnType(JvmOperation singleOperation) { JvmTypeReference returnType = singleOperation.getReturnType(); if (returnType == null) return null; JvmType rawType = returnType.getType(); if (rawType == null) { return null; } return rawType.getQualifiedName(); }
Example 8
Source File: JavaElementFinder.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private String getQualifiedParameterType(JvmFormalParameter formalParameter) { JvmTypeReference parameterType = formalParameter.getParameterType(); if (parameterType == null) return null; JvmType type = parameterType.getType(); if (type == null) return null; return type.getQualifiedName('.'); }
Example 9
Source File: NestedTypesScope.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected void doGetDescriptions(JvmType type, JvmType declarator, int index, List<IEObjectDescription> result) { String typeName = type.getQualifiedName('.'); String declaratorName = declarator.getQualifiedName('.'); int declaratorLength = declaratorName.length(); String subName = typeName.substring(declaratorLength + 1); List<String> segments = Strings.split(subName, '.'); result.add(EObjectDescription.create(QualifiedName.create(segments), type)); result.add(EObjectDescription.create(subName.replace('.', '$'), type)); }
Example 10
Source File: KnownTypesScope.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected void doGetDescriptions(JvmType type, JvmType knownType, int index, List<IEObjectDescription> result) { if (type == knownType) { result.add(EObjectDescription.create(QualifiedName.create(type.getSimpleName()), type)); } else if (type.eContainer() == knownType) { result.add(EObjectDescription.create(QualifiedName.create(knownType.getSimpleName(), type.getSimpleName()), type)); result.add(EObjectDescription.create(QualifiedName.create(knownType.getSimpleName() + '$' + type.getSimpleName()), type)); } else { String knownTypeName = knownType.getQualifiedName(); String withDollar = type.getQualifiedName('$'); String withDot = type.getQualifiedName('.'); result.add(EObjectDescription.create(QualifiedName.create(Strings.split(withDot.substring(knownTypeName.length()), '.')), type)); result.add(EObjectDescription.create(QualifiedName.create(withDollar.substring(knownTypeName.length())), type)); } }
Example 11
Source File: AbstractExtraLanguageValidator.java From sarl with Apache License 2.0 | 5 votes |
/** Do a type mapping check. * * @param source the source of the type. * @param type the type to check. * @param errorHandler the error handler. * @return {@code true} if a type mapping is defined. */ protected boolean doTypeMappingCheck(EObject source, JvmType type, Procedure3<? super EObject, ? super JvmType, ? super String> errorHandler) { if (source != null && type != null) { final ExtraLanguageTypeConverter converter = getTypeConverter(); final String qn = type.getQualifiedName(); if (converter != null && !converter.hasConversion(qn)) { if (errorHandler != null) { errorHandler.apply(source, type, qn); } return false; } } return true; }
Example 12
Source File: JvmModelGenerator.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
private String reassignSuperType(final ITreeAppendable b, final JvmDeclaredType declaredType, final GeneratorConfig config) { String _xblockexpression = null; { JvmTypeReference _extendedClass = declaredType.getExtendedClass(); JvmType _type = null; if (_extendedClass!=null) { _type=_extendedClass.getType(); } final JvmType superType = _type; boolean _hasObject = b.hasObject("super"); if (_hasObject) { final Object element = b.getObject("this"); if ((element instanceof JvmDeclaredType)) { final Object superElement = b.getObject("super"); final String superVariable = b.getName(superElement); boolean _equals = "super".equals(superVariable); if (_equals) { String _simpleName = ((JvmDeclaredType)element).getSimpleName(); final String proposedName = (_simpleName + ".super"); b.declareVariable(superElement, proposedName); } } } boolean _isAtLeast = config.getJavaSourceVersion().isAtLeast(JavaVersion.JAVA8); if (_isAtLeast) { Iterable<JvmTypeReference> _extendedInterfaces = declaredType.getExtendedInterfaces(); for (final JvmTypeReference interfaceRef : _extendedInterfaces) { { final JvmType interfaze = interfaceRef.getType(); String _simpleName_1 = interfaze.getSimpleName(); final String simpleVarName = (_simpleName_1 + ".super"); boolean _hasObject_1 = b.hasObject(simpleVarName); if (_hasObject_1) { final Object element_1 = b.getObject(simpleVarName); boolean _notEquals = (!Objects.equal(element_1, interfaceRef)); if (_notEquals) { String _qualifiedName = interfaze.getQualifiedName(); final String qualifiedVarName = (_qualifiedName + ".super"); b.declareVariable(interfaze, qualifiedVarName); } } else { b.declareVariable(interfaze, simpleVarName); } } } } String _xifexpression = null; if ((superType != null)) { _xifexpression = b.declareVariable(superType, "super"); } _xblockexpression = _xifexpression; } return _xblockexpression; }
Example 13
Source File: JavaResource.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override protected String getTypeName(JvmType type) { return type.getQualifiedName('$'); }