/** Replies the identifier of the associated type. * * @return the identifier of the context's type. */ public String getTypeIdentifier() { return this.target.getIdentifier(); }
protected String computeIdentifier() { if (simpleName == null) return null; JvmDeclaredType declaringType = getDeclaringType(); if (declaringType == null) return simpleName; return declaringType.getIdentifier() + "." + simpleName; }
protected String computeIdentifier() { if (simpleName == null) return null; JvmDeclaredType declaringType = getDeclaringType(); if (declaringType == null) return simpleName; return declaringType.getIdentifier() + "." + simpleName; }
public FunctionTypeKind getFunctionTypeKind(ParameterizedTypeReference typeReference) { JvmType type = typeReference.getType(); if (type.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) { JvmDeclaredType outerType = ((JvmGenericType) type).getDeclaringType(); if (outerType != null) { if (Procedures.class.getName().equals(outerType.getIdentifier())) { return FunctionTypeKind.PROCEDURE; } if (Functions.class.getName().equals(outerType.getIdentifier())) { return FunctionTypeKind.FUNCTION; } } } return FunctionTypeKind.NONE; }
protected boolean isGetClass(JvmIdentifiableElement feature) { if (feature instanceof JvmOperation && feature.getSimpleName().equals("getClass")) { JvmOperation getClassOperation = (JvmOperation) feature; if (getClassOperation.getParameters().isEmpty() && "java.lang.Object".equals(getClassOperation.getDeclaringType().getIdentifier())) { return true; } } return false; }
private boolean isValidFunction(JvmOperation op) { // TODO we need context here - the op has to be visible if (op.isAbstract()) { if (Object.class.getName().equals(op.getDeclaringType().getIdentifier())) return false; final String name = op.getSimpleName(); if (name.equals("toString") && op.getParameters().isEmpty()) return false; if (name.equals("equals") && op.getParameters().size() == 1) return false; if (name.equals("hashCode") && op.getParameters().isEmpty()) return false; return true; } return false; }
@Override protected String computeIdentifier() { if (simpleName == null) return null; JvmDeclaredType declaringType = internalGetDeclaringType(); if (declaringType == null) { if (Strings.isEmpty(packageName)) return simpleName; return packageName + "." + simpleName; } String parentName = declaringType.getIdentifier(); if (parentName == null) return null; return parentName + '$' + simpleName; }
@Override protected String computeIdentifier() { if (simpleName == null) return null; JvmDeclaredType declaringType = getDeclaringType(); if (declaringType == null) { if (Strings.isEmpty(packageName)) return simpleName; return packageName + "." + simpleName; } String parentName = declaringType.getIdentifier(); if (parentName == null) return null; return parentName + '$' + simpleName; }
@Override protected ISelectable internalGetAllDescriptions(final Resource resource) { final List<IEObjectDescription> descriptions = Lists.newArrayList(); for (final EObject content: resource.getContents()) { if (content instanceof JvmDeclaredType) { // Begin fixing of issue #356. final JvmDeclaredType type = (JvmDeclaredType) content; if (!Strings.isNullOrEmpty(type.getIdentifier())) { // End of fixing doGetAllDescriptions(type, descriptions); } } } return new MultimapBasedSelectable(descriptions); }
private boolean isPotentialJavaOperation(XAbstractFeatureCall featureCall) { if (featureCall.isOperation()) { return true; } if (featureCall.eClass() == XbasePackage.Literals.XMEMBER_FEATURE_CALL && featureCall.isStatic() && featureCall.isExtension() && featureCall.getActualArguments().size() == 2) { JvmIdentifiableElement feature = featureCall.getFeature(); if (feature.eClass() == TypesPackage.Literals.JVM_OPERATION) { JvmDeclaredType declarator = ((JvmOperation) feature).getDeclaringType(); if (IntegerExtensions.class.getName().equals(declarator.getIdentifier()) || LongExtensions.class.getName().equals(declarator.getIdentifier())) { String simpleName = feature.getSimpleName(); if (simpleName.startsWith("bitwise") || simpleName.startsWith("shift")) { return true; } } } } return false; }
private String typeName(final EntityType type) { if ((type instanceof ClassType)) { return ((ClassType)type).getClassname().getName(); } else { if ((type instanceof JavaType)) { return ((JavaType)type).getClassRef().getIdentifier(); } } return null; }
@Override protected ISelectable internalGetAllDescriptions(final Resource resource) { List<IEObjectDescription> descriptions = Lists.newArrayList(); for (EObject content: resource.getContents()) { if (content instanceof JvmDeclaredType) { JvmDeclaredType type = (JvmDeclaredType) content; if (!Strings.isEmpty(type.getIdentifier())) { doGetAllDescriptions(type, descriptions); } } } return new MultimapBasedSelectable(descriptions); }
@SuppressWarnings("unused") protected void _computeTypes(Map<JvmIdentifiableElement, ResolvedTypes> preparedResolvedTypes, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmDeclaredType type) { ResolvedTypes childResolvedTypes = preparedResolvedTypes.get(type); if (childResolvedTypes == null) throw new IllegalStateException("No resolved type found. Type was: " + type.getIdentifier()); IFeatureScopeSession capturedState = LocalVariableCapturerImpl.findCapturedState(type); if (capturedState != null) { featureScopeSession = capturedState; } IFeatureScopeSession childSession = addThisAndSuper(featureScopeSession, childResolvedTypes.getReferenceOwner(), type); computeMemberTypes(preparedResolvedTypes, childResolvedTypes, childSession, type); computeAnnotationTypes(childResolvedTypes, featureScopeSession, type); mergeChildTypes(childResolvedTypes); }
private void gatherTypeConstraint(TypeCheckConstraint constraint, PatternModelAcceptor<?> acceptor) { String variableName = getVariableName(constraint.getVar(), acceptor); String className = ((JavaType)constraint.getType()).getClassRef().getIdentifier(); IInputKey inputKey = new JavaTransitiveInstancesKey(className); acceptor.acceptTypeCheckConstraint(ImmutableList.of(variableName), inputKey); }
@Override protected void preApply() { XAbstractFeatureCall expression = getExpression(); JvmType type = getType(); if (expression instanceof XMemberFeatureCall) { if (type instanceof JvmDeclaredType) { JvmDeclaredType declaredType = (JvmDeclaredType) type; if (declaredType.getDeclaringType() == null) { helper.applyPackageFragment((XMemberFeatureCall) expression, declaredType); } else { String queriedName = description.getName().toString(); // may be Map$Entry String qualifiedName = declaredType.getIdentifier(); String packageName = Strings.emptyIfNull(declaredType.getPackageName()); if (packageName.length() + 1 + queriedName.length() == qualifiedName.length()) { helper.applyPackageFragment((XMemberFeatureCall) expression, declaredType); } } } } }
private void doGetAllDescriptions(JvmDeclaredType type, List<IEObjectDescription> descriptions) { descriptions.add(EObjectDescription.create(getQualifiedNameConverter().toQualifiedName(type.getIdentifier()), type)); EList<JvmMember> members = null; if (type instanceof JvmDeclaredTypeImplCustom) { members = ((JvmDeclaredTypeImplCustom)type).basicGetMembers(); } else { members = type.getMembers(); } for(JvmMember member: members) { if (member instanceof JvmDeclaredType) { // add nested types also with the dot delimiter descriptions.add(EObjectDescription.create(getQualifiedNameConverter().toQualifiedName(member.getQualifiedName('.')), member)); doGetAllDescriptions((JvmDeclaredType) member, descriptions); } } }
private void preprocessParameters(PatternModelAcceptor<?> acceptor) { for (Variable variable : pattern.getParameters()) { if (variable.getType() instanceof ClassType) { EClassifier classifier = ((ClassType) variable.getType()).getClassname(); IInputKey inputKey = typeSystem.classifierToInputKey(classifier); acceptor.acceptTypeConstraint(ImmutableList.of(variable.getName()), inputKey); } else if (variable.getType() instanceof JavaType) { JvmDeclaredType classRef = ((JavaType) variable.getType()).getClassRef(); IInputKey inputKey = new JavaTransitiveInstancesKey(classRef.getIdentifier()); acceptor.acceptTypeCheckConstraint(ImmutableList.of(variable.getName()), inputKey); } } acceptor.acceptExportedParameters(pattern.getParameters().stream().map(Variable::getName).collect(Collectors.toList())); }
public String getHash(final JvmDeclaredType type) { if(type.eResource() instanceof TypeResource) { IMirror mirror = ((TypeResource)type.eResource()).getMirror(); if(mirror instanceof IMirrorExtension && ((IMirrorExtension) mirror).isSealed()) return type.getIdentifier(); } return cache.get(Tuples.create(HASH_CACHE_KEY, type), type.eResource(), new Provider<String>() { @Override public String get() { return signatureBuilderProvider.get().appendSignature(type).hash(); } }); }
private void doGetAllDescriptions(JvmDeclaredType type, List<IEObjectDescription> descriptions) { descriptions.add(EObjectDescription.create(getQualifiedNameConverter().toQualifiedName(type.getIdentifier()), type)); final EList<JvmMember> members; if (type instanceof JvmDeclaredTypeImplCustom) { members = ((JvmDeclaredTypeImplCustom) type).basicGetMembers(); } else { members = type.getMembers(); } for (final JvmMember member: members) { if (member instanceof JvmDeclaredType) { // add nested types also with the dot delimiter descriptions.add(EObjectDescription.create(getQualifiedNameConverter().toQualifiedName( member.getQualifiedName('.')), member)); doGetAllDescriptions((JvmDeclaredType) member, descriptions); } } }
public SignatureHashBuilder appendSignature(JvmDeclaredType type) { if (type.getVisibility() != JvmVisibility.PRIVATE) { appendAnnotationReferences(type); appendVisibility(type.getVisibility()).append(" "); if (type.isAbstract()) append("abstract "); if (type.isStatic()) append("static "); if (type.isFinal()) append("final "); append("class ").append(type.getIdentifier()); if (type instanceof JvmTypeParameterDeclarator) appendTypeParameters((JvmTypeParameterDeclarator) type); append("\n").appendSuperTypeSignatures(type).appendMemberSignatures(type, false); } return this; }