Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modules: extraction of the model module
- Loading branch information
1 parent
f4b07b1
commit 4a18b1e
Showing
104 changed files
with
532 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...ore/src/main/java/me/tomassetti/symbolsolver/model/typesystem/ReferenceTypeUsageImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package me.tomassetti.symbolsolver.model.typesystem; | ||
|
||
import me.tomassetti.symbolsolver.model.declarations.TypeDeclaration; | ||
import me.tomassetti.symbolsolver.model.resolution.TypeParameter; | ||
import me.tomassetti.symbolsolver.model.resolution.TypeSolver; | ||
import me.tomassetti.symbolsolver.resolution.javaparser.LambdaArgumentTypeUsagePlaceholder; | ||
import me.tomassetti.symbolsolver.resolution.javaparser.declarations.JavaParserTypeVariableDeclaration; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
import java.util.function.Predicate; | ||
|
||
// TODO Remove references to typeSolver: it is needed to instantiate other instances of ReferenceTypeUsage | ||
// and to get the Object type declaration | ||
public class ReferenceTypeUsageImpl extends ReferenceTypeUsage { | ||
|
||
@Override | ||
protected ReferenceTypeUsage create(TypeDeclaration typeDeclaration, List<TypeUsage> typeParametersCorrected, TypeSolver typeSolver) { | ||
return new ReferenceTypeUsageImpl(typeDeclaration, typeParametersCorrected, typeSolver); | ||
} | ||
|
||
@Override | ||
protected ReferenceTypeUsage create(TypeDeclaration typeDeclaration, TypeSolver typeSolver) { | ||
return new ReferenceTypeUsageImpl(typeDeclaration, typeSolver); | ||
} | ||
|
||
public ReferenceTypeUsageImpl(TypeDeclaration typeDeclaration, TypeSolver typeSolver) { | ||
super(typeDeclaration, typeSolver); | ||
} | ||
|
||
public ReferenceTypeUsageImpl(TypeDeclaration typeDeclaration, List<TypeUsage> typeParameters, TypeSolver typeSolver) { | ||
super(typeDeclaration, typeParameters, typeSolver); | ||
} | ||
|
||
@Override | ||
public TypeParameter asTypeParameter() { | ||
if (this.typeDeclaration instanceof JavaParserTypeVariableDeclaration) { | ||
JavaParserTypeVariableDeclaration javaParserTypeVariableDeclaration = (JavaParserTypeVariableDeclaration) this.typeDeclaration; | ||
return javaParserTypeVariableDeclaration.asTypeParameter(); | ||
} | ||
throw new UnsupportedOperationException(this.typeDeclaration.getClass().getCanonicalName()); | ||
} | ||
|
||
@Override | ||
public boolean isAssignableBy(TypeUsage other) { | ||
if (other instanceof NullTypeUsage) { | ||
return !this.isPrimitive(); | ||
} | ||
// consider boxing | ||
if (other.isPrimitive()) { | ||
if (this.getQualifiedName().equals(Object.class.getCanonicalName())) { | ||
return true; | ||
} else { | ||
return isCorrespondingBoxingType(other.describe()); | ||
} | ||
} | ||
if (other instanceof LambdaArgumentTypeUsagePlaceholder) { | ||
return this.getQualifiedName().equals(Predicate.class.getCanonicalName()) || this.getQualifiedName().equals(Function.class.getCanonicalName()); | ||
} else if (other instanceof ReferenceTypeUsageImpl) { | ||
ReferenceTypeUsageImpl otherRef = (ReferenceTypeUsageImpl) other; | ||
if (compareConsideringTypeParameters(otherRef)) { | ||
return true; | ||
} | ||
for (ReferenceTypeUsage otherAncestor : otherRef.getAllAncestors()) { | ||
if (compareConsideringTypeParameters(otherAncestor)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} else if (other.isTypeVariable()) { | ||
// TODO look bounds... | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../src/main/java/me/tomassetti/symbolsolver/reflectionmodel/ReflectionFieldDeclaration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.