Skip to content

Commit 985de87

Browse files
Merge remote-tracking branch 'origin/main' into proofReordering
2 parents ff7df07 + 735d579 commit 985de87

77 files changed

Lines changed: 713 additions & 793 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitlab-ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ cache:
1818
variables:
1919
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=2 -Dorg.gradle.configureondemand=true"
2020
GIT_DEPTH: 0
21-
SONAR_SCANNER_OPTS: -Xmx8G
2221

2322
before_script:
2423
# - echo `pwd` # debug

build.gradle

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ plugins {
1717
//Some Licenses requires an entry in the credits (MIT, BSD)
1818
id "com.github.hierynomus.license-report" version "0.16.1"
1919

20-
id "org.sonarqube" version "4.1.0.3113"
21-
2220
// Gives `gradle dependencyUpdate` to show which dependency has a newer version
2321
// id "com.github.ben-manes.versions" version "0.39.0"
2422

@@ -54,14 +52,6 @@ def build = System.env.BUILD_NUMBER == null ? "" : "-${System.env.BUILD_NUMBER}"
5452
group = "org.key_project"
5553
version = "2.11.0$build"
5654

57-
sonarqube {
58-
properties {
59-
property "sonar.projectKey", "key-main"
60-
property "sonar.organization", "keyproject"
61-
property "sonar.host.url", "https://sonarcloud.io"
62-
}
63-
}
64-
6555
subprojects {
6656
apply plugin: "java"
6757
apply plugin: "java-library"

key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3780,16 +3780,6 @@ public static boolean isBaseHeap(Operator op, HeapLDT heapLDT) {
37803780
return op == heapLDT.getHeapForName(HeapLDT.BASE_HEAP_NAME);
37813781
}
37823782

3783-
/**
3784-
* Returns the path to the source file defined by the given {@link PositionInfo}.
3785-
*
3786-
* @param posInfo The {@link PositionInfo} to extract source file from.
3787-
* @return The source file name or {@code null} if not available.
3788-
*/
3789-
public static String getSourcePath(PositionInfo posInfo) {
3790-
return MiscTools.getSourcePath(posInfo);
3791-
}
3792-
37933783
/**
37943784
* Checks if the given {@link Term} is a select on a heap.
37953785
*

key.core/src/main/java/de/uka/ilkd/key/java/ParseExceptionInFile.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ public Location getLocation() throws MalformedURLException {
4141
// This kind of exception has a filename but no line/col information
4242
// Retrieve the latter from the cause. location remains null if
4343
// no line/col is available in cause.
44-
Location location = null;
4544
if (getCause() != null) {
46-
location = ExceptionTools.getLocation(getCause());
47-
if (location != null) {
48-
location = new Location(getFilename(), location.getPosition());
45+
var location = ExceptionTools.getLocation(getCause());
46+
if (location.isEmpty()) {
47+
return null;
4948
}
49+
return Location.fromFileName(getFilename(), location.get().getPosition());
5050
}
51-
return location;
51+
return null;
5252
}
5353
}

key.core/src/main/java/de/uka/ilkd/key/java/PosConvertException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ public Location getLocation() throws MalformedURLException {
7676
this.file = dataloc.substring(dataloc.indexOf(':') + 1);
7777
}
7878
}
79-
return new Location(file, position);
79+
return Location.fromFileName(file, position);
8080
}
8181
}

key.core/src/main/java/de/uka/ilkd/key/java/PositionInfo.java

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package de.uka.ilkd.key.java;
22

3+
import java.net.MalformedURLException;
34
import java.net.URI;
5+
import java.net.URL;
46
import java.nio.file.Paths;
7+
import java.util.Optional;
8+
import javax.annotation.Nullable;
59

610
import recoder.java.SourceElement;
711

@@ -13,6 +17,7 @@
1317
public class PositionInfo {
1418
/** Unknown URI (enables us to always have a non-null value for fileURI) */
1519
public static final URI UNKNOWN_URI = URI.create("UNKNOWN://unknown");
20+
public static final URI UNKNOWN_URII = URI.create("urn:UNKNOWN:unknown");
1621

1722
/** PositionInfo with undefined positions. */
1823
public static final PositionInfo UNDEFINED = new PositionInfo();
@@ -29,9 +34,9 @@ public class PositionInfo {
2934
private final Position endPos;
3035

3136
/**
32-
* The URI of the resource this location refers to. Either a meaningful value or
33-
* {@link #UNKNOWN_URI}, but never null.
37+
* The URI of the resource this location refers to. Either a meaningful value or null.
3438
*/
39+
@Nullable
3540
private final URI fileURI;
3641

3742
/**
@@ -44,7 +49,7 @@ private PositionInfo() {
4449
this.relPos = SourceElement.Position.UNDEFINED;
4550
this.startPos = Position.UNDEFINED;
4651
this.endPos = Position.UNDEFINED;
47-
fileURI = UNKNOWN_URI;
52+
fileURI = null;
4853
}
4954

5055
/**
@@ -58,7 +63,7 @@ public PositionInfo(SourceElement.Position relPos, Position startPos, Position e
5863
this.relPos = relPos;
5964
this.startPos = startPos;
6065
this.endPos = endPos;
61-
fileURI = UNKNOWN_URI;
66+
fileURI = null;
6267
}
6368

6469
/**
@@ -75,8 +80,11 @@ public PositionInfo(SourceElement.Position relPos, Position startPos, Position e
7580
this.startPos = startPos;
7681
this.endPos = endPos;
7782
if (fileURI == null) {
78-
this.fileURI = UNKNOWN_URI; // fileURI must not be null!
83+
this.fileURI = null;
7984
} else {
85+
if (fileURI.toString().contains("unknown")) {
86+
int i = 0;
87+
}
8088
this.fileURI = fileURI.normalize();
8189
}
8290
}
@@ -116,7 +124,7 @@ public String getParentClass() {
116124
*/
117125
@Deprecated // only kept for compatibility reasons
118126
public String getFileName() {
119-
if (fileURI.getScheme().equals("file")) {
127+
if (fileURI != null && fileURI.getScheme().equals("file")) {
120128
return Paths.get(fileURI).toString();
121129
}
122130
return null;
@@ -126,8 +134,12 @@ public URI getParentClassURI() {
126134
return parentClassURI;
127135
}
128136

129-
public URI getURI() {
130-
return fileURI;
137+
public Optional<URI> getURI() {
138+
return Optional.ofNullable(fileURI);
139+
}
140+
141+
public Optional<URL> getURL() throws MalformedURLException {
142+
return fileURI == null ? Optional.empty() : Optional.of(fileURI.toURL());
131143
}
132144

133145
public SourceElement.Position getRelativePosition() {
@@ -183,7 +195,8 @@ public static PositionInfo join(PositionInfo p1, PositionInfo p2) {
183195
end = p2.endPos;
184196
}
185197
// TODO: join relative position as well
186-
return new PositionInfo(SourceElement.Position.UNDEFINED, start, end, p1.getURI());
198+
return new PositionInfo(SourceElement.Position.UNDEFINED, start, end,
199+
p1.getURI().orElse(null));
187200
}
188201

189202
/**
@@ -201,7 +214,7 @@ public String toString() {
201214
if (this == PositionInfo.UNDEFINED) {
202215
return "UNDEFINED";
203216
} else {
204-
return ((fileURI == UNKNOWN_URI ? "" : fileURI) + " rel. Pos: " + relPos
217+
return ((fileURI == null ? "" : fileURI) + " rel. Pos: " + relPos
205218
+ " start Pos: " + startPos + " end Pos: " + endPos);
206219
}
207220
}

key.core/src/main/java/de/uka/ilkd/key/java/Recoder2KeY.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.uka.ilkd.key.java;
22

33
import java.io.*;
4+
import java.net.MalformedURLException;
45
import java.nio.charset.StandardCharsets;
56
import java.nio.file.Paths;
67
import java.util.*;
@@ -21,6 +22,7 @@
2122
import de.uka.ilkd.key.util.*;
2223
import de.uka.ilkd.key.util.LinkedHashMap;
2324
import de.uka.ilkd.key.util.Pair;
25+
import de.uka.ilkd.key.util.parsing.HasLocation;
2426

2527
import org.key_project.util.collection.ImmutableList;
2628
import org.key_project.util.collection.ImmutableSLList;
@@ -1203,6 +1205,7 @@ private static String trim(String s, int length) {
12031205
/**
12041206
* tries to parse recoders exception position information
12051207
*/
1208+
@Nullable
12061209
private static Pair<String, Position> extractPositionInfo(String errorMessage) {
12071210
if (errorMessage == null || errorMessage.indexOf('@') == -1) {
12081211
return null;
@@ -1255,17 +1258,31 @@ public static void reportError(String message, Throwable t) {
12551258
throw (PosConvertException) cause;
12561259
}
12571260

1258-
Pair<String, Position> pos = extractPositionInfo(cause.toString());
1259-
if (pos != null) {
1260-
reportErrorWithPositionInFile(message, cause, pos.second, pos.first);
1261-
} else {
1262-
reportErrorWithPositionInFile(message, cause, null, null);
1261+
Position pos = null;
1262+
String file = null;
1263+
if (cause instanceof HasLocation) {
1264+
try {
1265+
var location = ((HasLocation) cause).getLocation();
1266+
if (location != null) {
1267+
pos = location.getPosition();
1268+
file = location.getFileURI().toString();
1269+
}
1270+
} catch (MalformedURLException ignored) {
1271+
}
1272+
}
1273+
if (pos == null) {
1274+
Pair<String, Position> info = extractPositionInfo(cause.toString());
1275+
if (info != null) {
1276+
pos = info.second;
1277+
file = info.first;
1278+
}
12631279
}
1280+
reportErrorWithPositionInFile(message, cause, pos, file);
12641281
}
12651282

12661283
public static void reportErrorWithPositionInFile(String message, Throwable cause,
12671284
@Nullable Position pos,
1268-
String file) {
1285+
@Nullable String file) {
12691286
final RuntimeException rte;
12701287
if (pos != null) {
12711288
rte = new PosConvertException(message, pos, file);

key.core/src/main/java/de/uka/ilkd/key/java/Recoder2KeYConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public IProgramMethod processDefaultConstructor(recoder.abstraction.DefaultConst
8989

9090
public CompilationUnit processCompilationUnit(recoder.java.CompilationUnit cu,
9191
DataLocation context) {
92-
currentClassURI = MiscTools.extractURI(context);
92+
currentClassURI = MiscTools.extractURI(context).orElse(null);
9393
Object result = process(cu);
9494
currentClassURI = null;
9595

@@ -1467,7 +1467,7 @@ public MethodReference convert(recoder.java.reference.MethodReference mr) {
14671467
? ((recoder.java.CompilationUnit) tdc).getOriginalDataLocation()
14681468
: null;
14691469

1470-
currentClassURI = MiscTools.extractURI(loc);
1470+
currentClassURI = MiscTools.extractURI(loc).orElse(null);
14711471
pm = convert((recoder.java.declaration.MethodDeclaration) method);
14721472
// because of cycles when reading recursive programs
14731473
currentClassURI = oldCurrent;

0 commit comments

Comments
 (0)