module lang::java::m3::Core
rascal-0.34.0
Extends the M3 Core model with Java specific concepts such as inheritance and overriding.
Usage
import lang::java::m3::Core;
Dependencies
extend lang::java::m3::TypeSymbol;
import lang::java::m3::AST;
extend analysis::m3::Core;
import analysis::graphs::Graph;
import analysis::m3::Registry;
import IO;
import String;
import Relation;
import Set;
import List;
import util::FileSystem;
import util::Reflective;
data M3
data M3 (
rel[loc from, loc to] extends = {}, // classes extending classes and interfaces extending interfaces
rel[loc from, loc to] implements = {}, // classes implementing interfaces
rel[loc from, loc to] methodInvocation = {}, // methods calling each other (including constructors)
rel[loc from, loc to] fieldAccess = {}, // code using data (like fields)
rel[loc from, loc to] typeDependency = {}, // using a type literal in some code (types of variables, annotations)
rel[loc from, loc to] methodOverrides = {}, // which method override which other methods
rel[loc declaration, loc annotation] annotations = {}
)
data Language
data Language (str version="")
= java()
;
function composeJavaM3
M3 composeJavaM3(loc id, set[M3] models)
function diffJavaM3
M3 diffJavaM3(loc id, list[M3] models)
function createM3FromFile
M3 createM3FromFile(loc file, bool errorRecovery = false, list[loc] sourcePath = [], list[loc] classPath = [], str javaVersion = "1.7")
function createM3sFromFiles
set[M3] createM3sFromFiles(set[loc] files, bool errorRecovery = false, list[loc] sourcePath = [], list[loc] classPath = [], str javaVersion = "1.7")
function createM3FromFiles
M3 createM3FromFiles(loc projectName, set[loc] files, bool errorRecovery = false, list[loc] sourcePath = [], list[loc] classPath = [], str javaVersion = "1.7")
function createM3sAndAstsFromFiles
tuple[set[M3], set[Declaration]] createM3sAndAstsFromFiles(set[loc] files, bool errorRecovery = false, list[loc] sourcePath = [], list[loc] classPath = [], str javaVersion = "1.7")
function createM3FromString
M3 createM3FromString(loc fileName, str contents, bool errorRecovery = false, list[loc] sourcePath = [], list[loc] classPath = [], str javaVersion = "1.7")
function createM3FromJarClass
M3 createM3FromJarClass(loc jarClass, list[loc] classPath = [])
function createM3FromSingleClass
M3 createM3FromSingleClass(loc jarClass, str className)
function createM3FromJarFile
M3 createM3FromJarFile(loc jarLoc, list[loc] classPath = [])
function createM3FromDirectory
Globs for jars, class files and java files in a directory and tries to compile all source files into an M3 model
M3 createM3FromDirectory(loc project, bool errorRecovery = false, bool includeJarModels=false, str javaVersion = "1.7", list[loc] classPath = [])
function createM3FromMavenProject
Globs for jars, class files and java files in a directory and tries to compile all source files into an M3 model
M3 createM3FromMavenProject(loc project, bool errorRecovery = false, bool includeJarModels=false, str javaVersion = "1.7", list[loc] classPath = [])
function createM3FromJar
Extract an M3 model from all the class files in a jar
M3 createM3FromJar(loc jarFile, list[loc] classPath = [])
We use Create M3 From Jar to extract an initial M3 model and then a number of steps enrich the M3 towards a model that could have come from the original source.
In particular:
typeDependency
is enriched by addingextends
andimplements
methodOverrides
is recovered fromextends
andimplements
, but restricted to the actual overriden methods.
function unregisterJavaProject
void unregisterJavaProject(loc project)
function getMethodSignature
str getMethodSignature(loc method)
function isCompilationUnit
bool isCompilationUnit(loc entity)
function isPackage
bool isPackage(loc entity)
function isClass
bool isClass(loc entity)
function isConstructor
bool isConstructor(loc entity)
function isMethod
bool isMethod(loc entity)
function isParameter
bool isParameter(loc entity)
function isVariable
bool isVariable(loc entity)
function isField
bool isField(loc entity)
function isInterface
bool isInterface(loc entity)
function isEnum
bool isEnum(loc entity)
function isType
bool isType(loc entity)
function files
set[loc] files(rel[loc, loc] containment)
function declaredMethods
rel[loc, loc] declaredMethods(M3 m, set[Modifier] checkModifiers = {})
function declaredFields
rel[loc, loc] declaredFields(M3 m, set[Modifier] checkModifiers = {})
function declaredFieldsX
rel[loc, loc] declaredFieldsX(M3 m, set[Modifier] checkModifiers = {})
function declaredTopTypes
rel[loc, loc] declaredTopTypes(M3 m)
function declaredSubTypes
rel[loc, loc] declaredSubTypes(M3 m)
function classes
set[loc] classes(M3 m)
function interfaces
set[loc] interfaces(M3 m)
function packages
set[loc] packages(M3 m)
function variables
set[loc] variables(M3 m)
function parameters
set[loc] parameters(M3 m)
function fields
set[loc] fields(M3 m)
function methods
set[loc] methods(M3 m)
function constructors
set[loc] constructors(M3 m)
function enums
set[loc] enums(M3 m)
function types
set[loc] types(M3 m)
function elements
set[loc] elements(M3 m, loc parent)
function fields
set[loc] fields(M3 m, loc class)
function methods
set[loc] methods(M3 m, loc class)
function constructors
set[loc] constructors(M3 m, loc class)
function nestedClasses
set[loc] nestedClasses(M3 m, loc class)