Skip to content
Snippets Groups Projects
Commit 8b85b75b authored by René Schöne's avatar René Schöne
Browse files

Merge branch 'visibilityscopes' into modelica

parents aa4a2304 41b21c0b
Branches
Tags
No related merge requests found
...@@ -15,7 +15,7 @@ build: ...@@ -15,7 +15,7 @@ build:
- dockered - dockered
stage: build stage: build
script: script:
- ./gradlew --console=plain --build-cache assemble - ./gradlew --console=plain --build-cache assemble -x ":drast:assemble"
cache: cache:
key: "$CI_COMMIT_REF_NAME" key: "$CI_COMMIT_REF_NAME"
policy: push policy: push
...@@ -29,7 +29,7 @@ test: ...@@ -29,7 +29,7 @@ test:
- dockered - dockered
stage: test stage: test
script: script:
- ./gradlew --continue --console=plain check - ./gradlew --continue --console=plain check -x ":drast:check"
cache: cache:
key: "$CI_COMMIT_REF_NAME" key: "$CI_COMMIT_REF_NAME"
policy: pull policy: pull
......
DrAST.cfg
plugins {
id 'java'
id 'application'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
implementation project(':scope4j')
implementation files('../tools/DrAST-1.2.2.jar')
implementation fileTree(dir: "${System.properties['java.home']}", include: '**/jfxrt.jar')
}
run {
mainClassName = 'de.tudresden.inf.st.scope4j.DrAstRunner'
doFirst { environment 'JAVA_TOOL_OPTIONS', '-Dlog4j2.disableJmx=true' }
}
run.dependsOn ':scope4j:jar'
package de.tudresden.inf.st.scope4j;
import drast.Log;
import drast.model.DrAST;
import drast.model.DrASTSettings;
import drast.model.TreeFilter;
import drast.views.gui.DrASTGUI;
import drast.views.gui.GUIData;
import drast.views.gui.controllers.Controller;
import drast.views.gui.graph.GraphView;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.stage.Screen;
import javafx.stage.Stage;
/**
* Extended runner for DrAST
*
* @author jmey - Initial contribution
*/
public class DrAstRunner extends DrASTGUI {
public static void main(String[] args) {
openView();
System.exit(0);
}
private static final GUIData mon = new GUIData();
private static Controller con;
private static boolean guiHasBeenCreated = false;
private static void openView() {
guiHasBeenCreated = true;
DrASTSettings.put(DrASTSettings.PREV_JAR, "../scope4j/scope4j.jar");
DrASTSettings.put(DrASTSettings.PREV_TAIL_ARGS, "--drast");
launch();
con.onApplicationClose();
}
public void setRoot(Object root) {
long timeStart = System.currentTimeMillis();
DrAST newAst = new DrAST(root, TreeFilter.readFilter(con.getFilter()));
Log.info("Filter update: done after %d ms", System.currentTimeMillis() - timeStart);
Platform.runLater(() -> {
mon.reset(newAst);
if (guiHasBeenCreated) {
con.onSetRoot();
} else {
openView();
}
});
}
public void start(Stage stage) throws Exception {
FXMLLoader loader = new FXMLLoader();
Parent rootView = loader.load(this.getClass().getResource("/main.fxml").openStream());
con = loader.getController();
mon.setParentStage(stage);
mon.setController(con);
mon.setDrASTUI(this);
mon.setStage(stage);
GraphView graphview = new GraphView(mon);
graphview.setOnMouseClicked((event) -> graphview.getParent().requestFocus());
mon.setGraphView(graphview);
con.init(mon);
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
stage.setTitle("Scope4J DrAST 1.2.2");
stage.setScene(new Scene(rootView, primaryScreenBounds.getWidth(), primaryScreenBounds.getHeight() - 100.0D));
stage.show();
ScrollPane center = (ScrollPane)rootView.lookup("#graphViewScrollPane");
center.setContent(graphview);
Platform.runLater(() -> graphview.setPreferredSize((int)center.getWidth(), (int)center.getHeight()));
con.loadPreviousFilter();
}
}
...@@ -16,7 +16,7 @@ aspect Shadowing { ...@@ -16,7 +16,7 @@ aspect Shadowing {
return declaration; return declaration;
} }
} }
// the look in the inherited scopes // then look in the inherited scopes
for (Scope inherited : getInheritedScopeList()) { for (Scope inherited : getInheritedScopeList()) {
Declaration shadowed = inherited.shadowedLocally(shadower); Declaration shadowed = inherited.shadowedLocally(shadower);
if (shadowed != null) { if (shadowed != null) {
......
...@@ -40,11 +40,17 @@ sourceSets.main { ...@@ -40,11 +40,17 @@ sourceSets.main {
} }
} }
configurations {
ragdoc
}
dependencies { dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'
testCompile 'org.junit.platform:junit-platform-runner:1.4.2' testCompile 'org.junit.platform:junit-platform-runner:1.4.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.4.2' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.4.2'
ragdoc files('../tools/rd-builder.jar')
} }
jastadd { jastadd {
...@@ -133,10 +139,7 @@ jastadd { ...@@ -133,10 +139,7 @@ jastadd {
} }
run { run {
mainClassName = 'org.extendj.SccChecker' mainClassName = 'org.extendj.ScopeAnalysis'
if (project.hasProperty("appArgs")) {
args Eval.me(appArgs)
}
} }
task preprocess(type: JavaExec) { task preprocess(type: JavaExec) {
...@@ -216,7 +219,7 @@ generateAst.dependsOn preprocess ...@@ -216,7 +219,7 @@ generateAst.dependsOn preprocess
mainClassName = 'org.extendj.ScopeAnalysis' mainClassName = 'org.extendj.ScopeAnalysis'
jar.manifest.attributes 'Main-Class': mainClassName jar.manifest.attributes 'Main-Class': mainClassName
jar.destinationDir = projectDir jar.destinationDirectory = projectDir
sourceCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8' targetCompatibility = '1.8'
...@@ -2,7 +2,7 @@ aspect Debugging { ...@@ -2,7 +2,7 @@ aspect Debugging {
public String ASTNode.getASTString() { public String ASTNode.getASTString() {
String result = this.getClass().getSimpleName() + "\n"; String result = this.getClass().getSimpleName() + " (@" + this.hashCode() + ")\n";
for (java.lang.reflect.Method method : this.getClass().getMethods()) { for (java.lang.reflect.Method method : this.getClass().getMethods()) {
ASTNodeAnnotation.Token annotation = method.getAnnotation(ASTNodeAnnotation.Token.class); ASTNodeAnnotation.Token annotation = method.getAnnotation(ASTNodeAnnotation.Token.class);
...@@ -14,7 +14,8 @@ aspect Debugging { ...@@ -14,7 +14,8 @@ aspect Debugging {
} else { } else {
name += ":= "; name += ":= ";
} }
result += "|--" + name + method.invoke(this); Object methodResult = method.invoke(this);
result += "|--" + name + methodResult + (methodResult == null ? "" : " (@" + methodResult.hashCode() + ")");
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} catch (java.lang.reflect.InvocationTargetException e) { } catch (java.lang.reflect.InvocationTargetException e) {
......
...@@ -28,7 +28,12 @@ aspect ProgramToScopeTree { ...@@ -28,7 +28,12 @@ aspect ProgramToScopeTree {
if (getTypeDecl().isClassDecl()) { if (getTypeDecl().isClassDecl()) {
ClassDecl classDecl = (ClassDecl)getTypeDecl(); ClassDecl classDecl = (ClassDecl)getTypeDecl();
if (classDecl.superclass().isClassDecl() && classDecl.superclass().compilationUnit().fromSource()) { if (classDecl.superclass().isClassDecl() && classDecl.superclass().compilationUnit().fromSource()) {
addInheritedScope(((ClassDecl)classDecl.superclass()).asPackageScope()); ClassDecl superDecl = (ClassDecl)classDecl.superclass();
if (classDecl.hostPackage().equals(superDecl.hostPackage())) {
addInheritedScope(superDecl.asPackageScope());
} else {
addInheritedScope(superDecl.asProtectedScope());
}
} }
} }
super.updateInheritance(); super.updateInheritance();
......
...@@ -17,6 +17,8 @@ public class ScopeAnalysis extends Frontend { ...@@ -17,6 +17,8 @@ public class ScopeAnalysis extends Frontend {
super("Java Scope Anaysis", ExtendJVersion.getVersion()); super("Java Scope Anaysis", ExtendJVersion.getVersion());
} }
@SuppressWarnings("WeakerAccess")
public static Object DrAST_root_node;
public Program getProgram() { public Program getProgram() {
return program; return program;
...@@ -24,6 +26,8 @@ public class ScopeAnalysis extends Frontend { ...@@ -24,6 +26,8 @@ public class ScopeAnalysis extends Frontend {
private Program program; private Program program;
private static boolean isDrAst = false;
/** /**
* Entry point for the Java checker. * Entry point for the Java checker.
* *
...@@ -36,9 +40,11 @@ public class ScopeAnalysis extends Frontend { ...@@ -36,9 +40,11 @@ public class ScopeAnalysis extends Frontend {
boolean debug = arguments.isEmpty() || arguments.remove("--debug"); boolean debug = arguments.isEmpty() || arguments.remove("--debug");
boolean tree = arguments.remove("--tree"); boolean tree = arguments.remove("--tree");
boolean warnings = arguments.remove("--warnings"); boolean warnings = arguments.remove("--warnings");
isDrAst = arguments.remove("--drast");
if (arguments.size() > 1) { if (arguments.size() > 1) {
System.out.println("usage: ScopeAnalysis [--debug] [--tree] [--warnings] <directory with java files>"); System.out.println("usage: ScopeAnalysis [--debug] [--tree] [--warnings] <directory with java files>");
System.out.println(arguments);
System.exit(-1); System.exit(-1);
} }
String path = arguments.isEmpty() ? "../testprograms/simpleScope" : arguments.get(arguments.size() - 1); String path = arguments.isEmpty() ? "../testprograms/simpleScope" : arguments.get(arguments.size() - 1);
...@@ -52,6 +58,11 @@ public class ScopeAnalysis extends Frontend { ...@@ -52,6 +58,11 @@ public class ScopeAnalysis extends Frontend {
} }
public void analyzeTimed(String path) { public void analyzeTimed(String path) {
if (isDrAst) {
// quick-fix for DrAst, use directory of given file
path = Paths.get(path).getParent().toFile().getPath();
}
try { try {
List<String> files = Files.walk(Paths.get(path)) List<String> files = Files.walk(Paths.get(path))
.filter(Files::isRegularFile) .filter(Files::isRegularFile)
...@@ -66,6 +77,7 @@ public class ScopeAnalysis extends Frontend { ...@@ -66,6 +77,7 @@ public class ScopeAnalysis extends Frontend {
long startGenerationTime = System.nanoTime(); long startGenerationTime = System.nanoTime();
ScopeTree scopeTree = program.scopeTree(); ScopeTree scopeTree = program.scopeTree();
DrAST_root_node = scopeTree;
long startAnalysisTime = System.nanoTime(); long startAnalysisTime = System.nanoTime();
......
...@@ -23,3 +23,5 @@ include 'extendj:java5' ...@@ -23,3 +23,5 @@ include 'extendj:java5'
include 'extendj:java6' include 'extendj:java6'
include 'extendj:java7' include 'extendj:java7'
include 'extendj:java8' include 'extendj:java8'
include 'drast'
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment