@Override protected String getTypeName(final JvmType type) { return type.getQualifiedName('$'); }
protected JvmTypeReference getFirstForRawType(Multimap<JvmType, JvmTypeReference> all, JvmType rawType) { Iterator<JvmTypeReference> iterator = all.get(rawType).iterator(); while(iterator.hasNext()) { JvmTypeReference result = iterator.next(); if (result instanceof JvmParameterizedTypeReference || result instanceof JvmGenericArrayTypeReference) { return result; } } throw new IllegalStateException(all.toString() + " does not contain a useful type reference for rawtype " + rawType.getQualifiedName()); }
@Override public String getQualifiedName(char innerClassDelimiter) { JvmType type = getType(); if (type != null) return type.getQualifiedName(innerClassDelimiter); return null; }
@Override public String getQualifiedName(char innerClassDelimiter) { JvmType type = getType(); if (type != null) return type.getQualifiedName(innerClassDelimiter); return null; }
protected Class<?> getJavaType(JvmType type) throws ClassNotFoundException { return classFinder.forName(type.getQualifiedName()); }
@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)); }
protected Object translateJvmTypeToResult(JvmType type, int arrayDims) { try { String arrayDimensions = ""; for (int i=0;i<arrayDims;i++) arrayDimensions+="[]"; return classFinder.forName(type.getQualifiedName()+arrayDimensions); } catch (ClassNotFoundException e) { throw new EvaluationException(e); } }
private static void appendType(JvmParameterizedTypeReference typeReference, char innerClassDelimiter, NameType nameType, StringBuilder result) { JvmType type = typeReference.getType(); if (type != null) { switch(nameType) { case ID: result.append(type.getIdentifier()); break; case QUALIFIED: result.append(type.getQualifiedName(innerClassDelimiter)); break; case SIMPLE: result.append(type.getSimpleName()); break; case TO_STRING: result.append(type.getIdentifier()); break; } } }
public String getTypeString(final Variable variable) { final JvmTypeReference ref = this.typeInferrer.getJvmType(variable, variable); String _xifexpression = null; if (((ref == null) || (ref instanceof JvmUnknownTypeReference))) { _xifexpression = ""; } else { _xifexpression = ref.getType().getQualifiedName(); } return _xifexpression; }
/** Replies if the given annotation is a forbidden active annotation. * * @param annotation the annotation. * @return {@code true} if the annotation is forbidden. */ @SuppressWarnings("static-method") protected boolean isForbiddenActiveAnnotation(XAnnotation annotation) { final String name = annotation.getAnnotationType().getQualifiedName(); return Strings.equal(EqualsHashCode.class.getName(), name) || Strings.equal(FinalFieldsConstructor.class.getName(), name); }
public String getTypeString(final IInputKey type, final EObject context) { final JvmTypeReference ref = this.typeSystem.toJvmTypeReference(type, context); String _xifexpression = null; if (((ref == null) || (ref instanceof JvmUnknownTypeReference))) { _xifexpression = ""; } else { _xifexpression = ref.getType().getQualifiedName(); } return _xifexpression; }
/** Replies if the given annotation is an active annotation for object-oriented elements. * * @param annotation the annotation. * @return {@code true} if the annotation should be used only for OO elements. */ @SuppressWarnings("static-method") protected boolean isOOActiveAnnotation(XAnnotation annotation) { final String name = annotation.getAnnotationType().getQualifiedName(); return Strings.equal(Accessors.class.getName(), name) || Strings.equal(Data.class.getName(), name) || Strings.equal(Delegate.class.getName(), name) || Strings.equal(ToString.class.getName(), name); }
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); } }
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; }
public void appendType(final JvmType type, IAcceptor<String> content) { // don't import if a local variable with the same name is on the scope //TODO logic should be moved to ImportManager eventually. if (hasObject(type.getSimpleName())) { content.accept(type.getQualifiedName('.')); } else { StringBuilder builder = new StringBuilder(); importManager.appendType(type, builder); content.accept(builder.toString()); } }
@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)); } }
private boolean isIgnored(JvmType type, ITextRegion refRegion) { IParseResult parseResult = getResource().getParseResult(); if (parseResult == null) { return false; } String completeText = parseResult.getRootNode().getText(); CharSequence refText = completeText.subSequence(refRegion.getOffset(), refRegion.getOffset() + refRegion.getLength()); return type.getQualifiedName().equals(refText); }
@Override public boolean addImportFor(JvmType type) { final String qualifiedName = convertQualifiedName(type.getQualifiedName(getInnerTypeSeparator())); if (qualifiedName == null) { return false; } final String simpleName = getSimpleName(qualifiedName); if (!allowsSimpleName(qualifiedName, simpleName) && !needsQualifiedName(qualifiedName, simpleName) && !internalGetImports().containsKey(simpleName)) { internalGetImports().put(simpleName, qualifiedName); return true; } return false; }
@Override public PParameter apply(Variable var) { if (var == null) { return new PParameter("", ""); } else { IEMFTypeProvider typeProvider = XtextInjectorProvider.INSTANCE.getInjector().getInstance(IEMFTypeProvider.class); JvmTypeReference ref = typeProvider.getVariableType(var); // bug 411866: JvmUnknownTypeReference.getType() returns null in Xtext 2.4 String clazz = (ref == null || ref instanceof JvmUnknownTypeReference) ? "" : ref.getType() .getQualifiedName(); return new PParameter(var.getName(), clazz); } }
@Check public void checkPatternName(Pattern pattern) { if (pattern.getName() != null && !SourceVersion.isName(pattern.getName())) { JvmType inferredSpecification = inferrerUtil.findInferredSpecification(pattern); if (inferredSpecification != null && !inferredSpecification.eIsProxy() && !SourceVersion.isName(inferredSpecification.getQualifiedName())) { error(String.format("The pattern name %s is not a valid Java classname", pattern.getName()), PatternLanguagePackage.Literals.PATTERN__NAME, IssueCodes.OTHER_ISSUE); } } }