/** * In no classpath, the model of the super interface isn't always correct. */ private boolean isCorrectTypeReference(TypeReference ref) { if (ref.resolvedType == null) { return false; } if (!(ref.resolvedType instanceof ProblemReferenceBinding)) { return true; } final String[] compoundName = CharOperation.charArrayToStringArray(((ProblemReferenceBinding) ref.resolvedType).compoundName); final String[] typeName = CharOperation.charArrayToStringArray(ref.getTypeName()); if (compoundName.length == 0 || typeName.length == 0) { return false; } return compoundName[compoundName.length - 1].equals(typeName[typeName.length - 1]); }
/** * @return char[][] * TODO (jerome) should merge back into #getTypeName() */ public char [][] getParameterizedTypeName(){ return getTypeName(); } protected abstract TypeBinding getTypeBinding(Scope scope);
final String[] namesParameterized = CharOperation.charArrayToStringArray(ref.getParameterizedTypeName()); String nameParameterized = CharOperation.toString(ref.getParameterizedTypeName()); String typeName = CharOperation.toString(ref.getTypeName());
public static boolean isTypeUseCompatible(TypeReference reference, Scope scope) { if (reference != null && !(reference instanceof SingleTypeReference)) { Binding binding = scope.getPackage(reference.getTypeName()); // In case of ProblemReferenceBinding, don't report additional error if (binding instanceof PackageBinding) { return false; } } return true; }
private static Service createService(TypeReference service, TypeReference[] with) { Service ser = new Service(); ser.provides = CharOperation.concatWith(service.getTypeName(), '.'); ser.with = new char[with.length][]; for (int i = 0; i < with.length; i++) { ser.with[i] = CharOperation.concatWith(with[i].getTypeName(), '.'); } return ser; } private static PackageExportImpl createPackageOpen(OpensStatement ref) {
private static ServiceInfo createService(ProvidesStatement provides) { ServiceInfo info = new ServiceInfo(); info.serviceName = CharOperation.concatWith(provides.serviceInterface.getTypeName(), '.'); TypeReference[] implementations = provides.implementations; info.implNames = new char[implementations.length][]; for(int i = 0; i < implementations.length; i++) { info.implNames[i] = CharOperation.concatWith(implementations[i].getTypeName(), '.'); } return info; }
public void illegalVararg(Argument argType, AbstractMethodDeclaration methodDecl) { String[] arguments = new String[] {CharOperation.toString(argType.type.getTypeName()), new String(methodDecl.selector)}; this.handle( IProblem.IllegalVararg, arguments, arguments, argType.sourceStart, argType.sourceEnd); } public void illegalVarargInLambda(Argument argType) {
public void illegalVararg(Argument argType, AbstractMethodDeclaration methodDecl) { String[] arguments = new String[] {CharOperation.toString(argType.type.getTypeName()), new String(methodDecl.selector)}; this.handle( IProblem.IllegalVararg, arguments, arguments, argType.sourceStart, argType.sourceEnd); } public void illegalVarargInLambda(Argument argType) {
@Override protected void consumeMarkerAnnotation(boolean isTypeAnnotation) { super.consumeMarkerAnnotation(isTypeAnnotation); Annotation annotation = (Annotation) (isTypeAnnotation ? this.typeAnnotationStack[this.typeAnnotationPtr] : this.expressionStack[this.expressionPtr]); if (this.reportReferenceInfo) { // accept annotation type reference this.requestor.acceptAnnotationTypeReference(annotation.type.getTypeName(), annotation.sourceStart, annotation.sourceEnd); } } @Override
@Override protected void consumeProvidesStatement() { super.consumeProvidesStatement(); ProvidesStatement service = (ProvidesStatement) this.astStack[this.astPtr]; TypeReference ref = service.serviceInterface; this.requestor.acceptTypeReference(ref.getTypeName(), ref.sourceStart, ref.sourceEnd); } @Override
@Override protected void consumeWithClause() { super.consumeWithClause(); ProvidesStatement service = (ProvidesStatement) this.astStack[this.astPtr]; for (int i = 0; i < service.implementations.length; i++) { TypeReference ref = service.implementations[i]; this.requestor.acceptTypeReference(ref.getTypeName(), ref.sourceStart, ref.sourceEnd); } } @Override
public char [][] getTypeName() { switch (this.kind) { case Wildcard.UNBOUND : return new char[][] { WILDCARD_NAME }; case Wildcard.EXTENDS : return new char[][] { CharOperation.concat(WILDCARD_NAME, WILDCARD_EXTENDS, CharOperation.concatWith(this.bound.getTypeName(), '.')) }; default: // SUPER return new char[][] { CharOperation.concat(WILDCARD_NAME, WILDCARD_SUPER, CharOperation.concatWith(this.bound.getTypeName(), '.')) }; } }
public char [][] getTypeName() { switch (this.kind) { case Wildcard.UNBOUND : return new char[][] { WILDCARD_NAME }; case Wildcard.EXTENDS : return new char[][] { CharOperation.concat(WILDCARD_NAME, WILDCARD_EXTENDS, CharOperation.concatWith(this.bound.getTypeName(), '.')) }; default: // SUPER return new char[][] { CharOperation.concat(WILDCARD_NAME, WILDCARD_SUPER, CharOperation.concatWith(this.bound.getTypeName(), '.')) }; } }
public void illegalVarargInLambda(Argument argType) { String[] arguments = new String[] { CharOperation.toString(argType.type.getTypeName())}; this.handle( IProblem.IllegalVarargInLambda, arguments, arguments, argType.sourceStart, argType.sourceEnd); } public void illegalThisDeclaration(Argument argument) {
public void illegalVarargInLambda(Argument argType) { String[] arguments = new String[] { CharOperation.toString(argType.type.getTypeName())}; this.handle( IProblem.IllegalVarargInLambda, arguments, arguments, argType.sourceStart, argType.sourceEnd); } public void illegalThisDeclaration(Argument argument) {
protected int resolveLevel(AllocationExpression allocation) { // constructor name is simple type name char[][] typeName = allocation.type.getTypeName(); if (this.pattern.declaringSimpleName != null && !matchesName(this.pattern.declaringSimpleName, typeName[typeName.length-1])) return IMPOSSIBLE_MATCH; return resolveLevel(allocation.binding); } protected int resolveLevel(FieldDeclaration field) {
protected void consumeUsesStatement() { super.consumeUsesStatement(); UsesStatement ref = (UsesStatement) this.astStack[this.astPtr]; this.requestor.acceptTypeReference(ref.serviceInterface.getTypeName(), ref.sourceStart, ref.sourceEnd); } protected void consumeWithClause() {
for (int position = type.getTypeName().length - 1; position >= 0; position--) { if (currentReference == null) { break;
@Override protected void consumeSingleMemberAnnotation(boolean isTypeAnnotation) { super.consumeSingleMemberAnnotation(isTypeAnnotation); SingleMemberAnnotation member = (SingleMemberAnnotation) (isTypeAnnotation ? this.typeAnnotationStack[this.typeAnnotationPtr] : this.expressionStack[this.expressionPtr]); if (this.reportReferenceInfo) { this.requestor.acceptAnnotationTypeReference(member.type.getTypeName(), member.sourceStart, member.sourceEnd); this.requestor.acceptMethodReference(TypeConstants.VALUE, 0, member.sourceStart); } } @Override
protected void consumeSingleMemberAnnotation(boolean isTypeAnnotation) { super.consumeSingleMemberAnnotation(isTypeAnnotation); SingleMemberAnnotation member = (SingleMemberAnnotation) (isTypeAnnotation ? this.typeAnnotationStack[this.typeAnnotationPtr] : this.expressionStack[this.expressionPtr]); if (this.reportReferenceInfo) { this.requestor.acceptAnnotationTypeReference(member.type.getTypeName(), member.sourceStart, member.sourceEnd); this.requestor.acceptMethodReference(TypeConstants.VALUE, 0, member.sourceStart); } } protected void consumeSingleStaticImportDeclarationName() {