Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
nimakarimipour committed Oct 3, 2024
2 parents bf4f438 + 7cfb5c6 commit 494ada5
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 43 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
build-without-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
Expand All @@ -19,9 +19,9 @@ jobs:
build-with-setup-java-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
Expand All @@ -31,9 +31,9 @@ jobs:
build-with-gradle-build-action-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
Expand All @@ -43,26 +43,26 @@ jobs:
build-with-upload-artifact:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
cache: gradle
- name: Build with Gradle
run: ./gradlew build --scan --no-daemon
- name: Archive test report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Test report
path: build/reports/tests/test
parallel-processing-enabled-caching-disabled:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
Expand All @@ -73,9 +73,9 @@ jobs:
parallel-processing-disabled-caching-disabled:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
Expand All @@ -87,9 +87,9 @@ jobs:
parser-coinfiguration-17:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ public void analyzeDownstreamDependencies() {
.map(
location ->
new Fix(
new AddMarkerAnnotation(location, context.config.nullableAnnot),
"null",
false))
new AddMarkerAnnotation(location, context.config.nullableAnnot), "null"))
.collect(ImmutableSet.toImmutableSet());
DownstreamImpactEvaluator evaluator = new DownstreamImpactEvaluator(supplier);
ImmutableSet<Report> reports = evaluator.evaluate(fixes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ private NullAwayError deserializeErrorFromTSVLine(ModuleInfo moduleInfo, String
nonnullTarget == null
? Set.of()
: Set.of(new AddMarkerAnnotation(nonnullTarget, config.nullableAnnot));

return createError(
errorType,
errorMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public NullAwayError(
@Override
protected Set<Fix> computeFixesFromAnnotations(Set<AddAnnotation> annotations) {
return annotations.stream()
.map(annot -> new Fix(annot, messageType, true))
.map(annot -> new Fix(annot, messageType))
.collect(Collectors.toSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ public void updateStatus(
public void mergeTriggered() {
this.tree.addAll(Error.getResolvingFixesOfErrors(this.triggeredErrors));
this.tree.addAll(triggeredFixesFromDownstreamErrors);
this.tree.forEach(fix -> fix.fixSourceIsInTarget = true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ protected Set<Fix> getTriggeredFixesFromDownstreamErrors(Node node) {
new Fix(
new AddMarkerAnnotation(
error.toResolvingLocation(), context.config.nullableAnnot),
"PASSING_NULLABLE",
false))
"PASSING_NULLABLE"))
.collect(Collectors.toSet());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,18 @@ public class Fix {
public final Set<AddAnnotation> changes;
/** Reasons this fix is suggested by NullAway in string. */
public final ImmutableSet<String> reasons;
/**
* If true, the fix is suggested due to an error in the target module, false if the fix is
* suggested due to error in downstream dependencies.
*/
public boolean fixSourceIsInTarget;

public Fix(AddAnnotation change, String reason, boolean fixSourceIsInTarget) {
this(change, ImmutableSet.of(reason), fixSourceIsInTarget);
public Fix(AddAnnotation change, String reason) {
this(change, ImmutableSet.of(reason));
}

public Fix(AddAnnotation change, ImmutableSet<String> reasons, boolean fixSourceIsInTarget) {
this(ImmutableSet.of(change), reasons, fixSourceIsInTarget);
public Fix(AddAnnotation change, ImmutableSet<String> reasons) {
this(ImmutableSet.of(change), reasons);
}

public Fix(
Set<AddAnnotation> changes, ImmutableSet<String> reasons, boolean fixSourceIsInTarget) {
this.changes = changes;
public Fix(ImmutableSet<AddAnnotation> change, ImmutableSet<String> reasons) {
this.changes = change;
this.reasons = reasons;
this.fixSourceIsInTarget = fixSourceIsInTarget;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ public ImmutableSet<Fix> extendForGeneratedFixes(Set<Fix> fixes) {
new Fix(
new AddMarkerAnnotation(
getterMethod.location, change.getAnnotationName().fullName),
fix.reasons,
fix.fixSourceIsInTarget));
fix.reasons));
}
})));
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public TError(Location location) {
@Override
protected Set<Fix> computeFixesFromAnnotations(Set<AddAnnotation> annotations) {
return annotations.stream()
.map(addAnnotation -> new Fix(addAnnotation, ImmutableSet.of(messageType), true))
.map(addAnnotation -> new Fix(addAnnotation, ImmutableSet.of(messageType)))
.collect(Collectors.toSet());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
public class TFix extends Fix {

public TFix(Location location) {
super(new DefaultAnnotation(location), ImmutableSet.of(), true);
super(new DefaultAnnotation(location), ImmutableSet.of());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public TReport(Location root, int effect) {

public TReport(Location root, int effect, Tag tag) {
super(
new Fix(
new AddMarkerAnnotation(root, "javax.annotation.Nullable"), ImmutableSet.of(), true),
new Fix(new AddMarkerAnnotation(root, "javax.annotation.Nullable"), ImmutableSet.of()),
effect);
this.expectedValue = effect;
if (tag != null) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def versions = [
errorProne : defaultErrorProneVersion,
errorProneApi : project.hasProperty("epApiVersion") ? epApiVersion : oldestErrorProneApi,
autoService : "1.0-rc7",
javaparser : "3.26.0",
javaparser : "3.26.2",
json : "1.1.1",
guava : "31.0.1-jre",
cli : "1.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import static java.util.stream.Collectors.groupingBy;

import com.github.javaparser.ParseProblemException;
import com.github.javaparser.ParserConfiguration;
import com.github.javaparser.StaticJavaParser;
import com.github.javaparser.ast.CompilationUnit;
Expand All @@ -33,6 +34,7 @@
import edu.ucr.cs.riple.injector.changes.AnnotationChange;
import edu.ucr.cs.riple.injector.changes.ChangeVisitor;
import edu.ucr.cs.riple.injector.changes.RemoveAnnotation;
import edu.ucr.cs.riple.injector.exceptions.ParseException;
import edu.ucr.cs.riple.injector.modifications.Modification;
import edu.ucr.cs.riple.injector.offsets.FileOffsetStore;
import java.io.IOException;
Expand Down Expand Up @@ -171,6 +173,9 @@ public static CompilationUnit parse(
StaticJavaParser.setConfiguration(parserConfiguration);
try {
return StaticJavaParser.parse(path);
} catch (ParseProblemException e) {
// The original exception is not useful for the user. We should provide a more informative one
throw new ParseException(path, e);
} catch (NoSuchFileException e) {
return null;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024 University of California, Riverside.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package edu.ucr.cs.riple.injector.exceptions;

import com.github.javaparser.ParseProblemException;
import java.nio.file.Path;

/**
* Exception indicating that an error occurred while parsing a source file.
*
* <p>This serves as a wrapper for the {@link ParseProblemException} class, providing a more concise
* representation of the underlying issue.
*/
public class ParseException extends RuntimeException {

public ParseException(Path path, ParseProblemException exception) {
super(retrieveExceptionMessage(path, exception), exception);
}

private static String retrieveExceptionMessage(Path path, ParseProblemException e) {
String message = e.getMessage();
// If the message contains the stack trace, we should remove it. It does not contain any useful
// information.
int index = message.indexOf("Problem stacktrace :");
message = index == -1 ? message : message.substring(0, index);
return "javaparser was not able to parse file at: " + path + "\nParse problem:" + message;
}
}

0 comments on commit 494ada5

Please sign in to comment.