aclement 13 роки тому
джерело
коміт
c584cedda7

+ 33
- 27
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java Переглянути файл

@@ -10,7 +10,6 @@
* PARC initial implementation
* ******************************************************************/


package org.aspectj.ajdt.internal.compiler.lookup;

import java.util.HashMap;
@@ -31,7 +30,8 @@ import org.aspectj.weaver.BCException;
public class InterTypeScope extends ClassScope {
ReferenceBinding onType;
List aliases;
Map /* real type variable > alias letter */ usedAliases; // Used later when reconstructing the resolved member
Map<TypeVariableBinding, String> /* real type variable > alias letter */usedAliases; // Used later when reconstructing the
// resolved member

public InterTypeScope(Scope parent, ReferenceBinding onType) {
super(parent, null);
@@ -41,47 +41,53 @@ public class InterTypeScope extends ClassScope {
}

public InterTypeScope(Scope parent, ReferenceBinding rb, List list) {
this(parent,rb);
this(parent, rb);
this.aliases = list;
}
public String getAnyAliasForTypeVariableBinding(TypeVariableBinding tvb) {
if (usedAliases==null) return null;
return (String)usedAliases.get(tvb);
if (usedAliases == null)
return null;
return (String) usedAliases.get(tvb);
}

// this method depends on the fact that BinaryTypeBinding extends SourceTypeBinding
private SourceTypeBinding makeSourceTypeBinding(ReferenceBinding onType) {
if (onType instanceof SourceTypeBinding) return (SourceTypeBinding)onType;
if (onType instanceof SourceTypeBinding)
return (SourceTypeBinding) onType;
else if (onType instanceof ParameterizedTypeBinding) {
ReferenceBinding rb = ((ParameterizedTypeBinding)onType).type;
if (rb instanceof SourceTypeBinding) return (SourceTypeBinding)rb;
else throw new BCException("In parameterized type "+onType+", can't handle reference binding "+rb);
} else if (onType instanceof ProblemReferenceBinding) {
ReferenceBinding rb = ((ParameterizedTypeBinding) onType).type;
if (rb instanceof SourceTypeBinding)
return (SourceTypeBinding) rb;
else
throw new BCException("In parameterized type " + onType + ", can't handle reference binding " + rb);
} else if (onType instanceof ProblemReferenceBinding) {
return null;
} else if (onType instanceof TypeVariableBinding) {
// Problem will have already been reported, cant ITD on a type variable.
return null;
}
throw new BCException("can't handle: " + onType);
}

public SourceTypeBinding invocationType() {
return parent.enclosingSourceType();
}
public int addDepth() {
return 0;
}

public TypeVariableBinding findTypeVariable(char[] name, SourceTypeBinding sourceType) {
if (sourceType == null) {
return null;
}
String variableName = new String(name);
int aliased = (aliases==null?-1:aliases.indexOf(variableName));
if (aliased!=-1) {
if (aliased>sourceType.typeVariables.length || sourceType.typeVariables.length==0) {
TypeVariableBinding tvb = new TypeVariableBinding("fake".toCharArray(),null,0);
int aliased = (aliases == null ? -1 : aliases.indexOf(variableName));
if (aliased != -1) {
if (aliased > sourceType.typeVariables.length || sourceType.typeVariables.length == 0) {
TypeVariableBinding tvb = new TypeVariableBinding("fake".toCharArray(), null, 0);
tvb.superclass = getJavaLangObject();
tvb.fPackage = new PackageBinding(environment());
return tvb;
@@ -89,22 +95,22 @@ public class InterTypeScope extends ClassScope {
}
TypeVariableBinding tvb = sourceType.typeVariables()[aliased];
tvb.fPackage = sourceType.fPackage;
if (usedAliases==null) usedAliases = new HashMap();
usedAliases.put(tvb,variableName);
if (usedAliases == null)
usedAliases = new HashMap<TypeVariableBinding, String>();
usedAliases.put(tvb, variableName);
return tvb;
} else {
TypeVariableBinding variableBinding = sourceType.getTypeVariable(name);
if (variableBinding == null) { // GENERICITDFIX
// Inside generic aspect, might want the type var attached to us
variableBinding = parent.findTypeVariable(name,((ClassScope) parent).referenceContext.binding);
}
return variableBinding;
TypeVariableBinding variableBinding = sourceType.getTypeVariable(name);
if (variableBinding == null) { // GENERICITDFIX
// Inside generic aspect, might want the type var attached to us
variableBinding = parent.findTypeVariable(name, ((ClassScope) parent).referenceContext.binding);
}
return variableBinding;
}
}

public Map getRecoveryAliases() {
return usedAliases;
}

}

Завантаження…
Відмінити
Зберегти