Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release new version of JetBrains plugin #488

Merged
merged 15 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions .github/workflows/appmap-analysis.yml

This file was deleted.

10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@ jobs:
uses: actions/cache/save@v3
if: runner.os == 'Linux'
with:
path: tmp/appmap
path: ./tmp/appmap
key: appmaps-${{ github.sha }}-${{ github.run_attempt }}

appmap-analysis:
permissions: write-all
if: always()
needs: [test]
uses: ./.github/workflows/appmap-analysis.yml
uses: getappmap/analyze-action/.github/workflows/appmap-analysis.yml@v1
permissions:
actions: read
contents: read
checks: write
pull-requests: write
2 changes: 1 addition & 1 deletion appland/dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appland/dist/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appland/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"webpack-cli": "^4.6"
},
"dependencies": {
"@appland/components": "^3.8.0",
"@appland/components": "^3.9.0",
"vue": "^2.7",
"vue-template-compiler": "^2.7",
"url": "^0.11"
Expand Down
45 changes: 23 additions & 22 deletions appland/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"@jridgewell/gen-mapping" "^0.3.0"
"@jridgewell/trace-mapping" "^0.3.9"

"@appland/components@^3.8.0":
version "3.8.0"
resolved "https://registry.yarnpkg.com/@appland/components/-/components-3.8.0.tgz#01aff1f9a9a504cc387a071c3ee7b857a01a9a97"
integrity sha512-dGnvT4XwkPmvEBkNj/5IWodpOdMlgFDfMwuWg1WH5jpWwTjGxFRqpyLAiYLjrei+CXWNdRmv6e5NFY2vefkquw==
"@appland/components@^3.9.0":
version "3.9.0"
resolved "https://registry.yarnpkg.com/@appland/components/-/components-3.9.0.tgz#fe2e1712e5179ba5c0e3369a97c3be608367d355"
integrity sha512-EqHydCldCxVpBNYsnF1SrSZ5uB/2SBNFy8J5RrCFqqrHblLkwoIT/ejKbNfOUcao2dHO483JaNON6UzoNmT7QQ==
dependencies:
"@appland/diagrams" "^1.7.0"
"@appland/models" "^2.6.3"
"@appland/sequence-diagram" "^1.8.1"
"@appland/models" "^2.7.0"
"@appland/sequence-diagram" "^1.9.0"
buffer "^6.0.3"
d3 "^7.8.4"
d3-flame-graph "^4.1.3"
Expand Down Expand Up @@ -49,10 +49,10 @@
"@appland/sql-parser" "^1.5.0"
crypto-js "^4.0.0"

"@appland/models@^2.6.3":
version "2.6.4"
resolved "https://registry.yarnpkg.com/@appland/models/-/models-2.6.4.tgz#a351bd48be8af10634fa3a924b5f14be9b61a639"
integrity sha512-DL13Psam8mRw4egSzrvVTxPs+yubRNFF+jV2ZzBxIIC2gPpbYWSwZgHcew9U1O8SkeEq5Q84gXQGSYTt+TU39A==
"@appland/models@^2.7.0":
version "2.7.0"
resolved "https://registry.yarnpkg.com/@appland/models/-/models-2.7.0.tgz#4c7ee7297f28d23e01c821f6c34d66a44ec83203"
integrity sha512-UwKTGnAugF+2kvNALmxkMEgmXI1Pg+FCytYzRQVrHLekV2cdtGGQRLI96ShAhRb+pVJmz0GlkM3c+1rg9PQZMw==
dependencies:
"@appland/sql-parser" "^1.5.0"
crypto-js "^4.0.0"
Expand All @@ -65,16 +65,17 @@
"@appland/models" "^2.2.0"
js-yaml "^4.1.0"

"@appland/sequence-diagram@^1.8.1":
version "1.8.1"
resolved "https://registry.yarnpkg.com/@appland/sequence-diagram/-/sequence-diagram-1.8.1.tgz#bcfc317852c3390b848a574bddf9c2c682f74366"
integrity sha512-mTzIEZn9yHL8CGLrPdSqVlLJFwhmt3rdKiivM6LXgrGtu4TAisG/NdXPYT1aquG3bQR++1N2bhZj6pbEdca62g==
"@appland/sequence-diagram@^1.9.0":
version "1.9.0"
resolved "https://registry.yarnpkg.com/@appland/sequence-diagram/-/sequence-diagram-1.9.0.tgz#c1e19ddda20b487908f693413e26127b648e9cae"
integrity sha512-e43mPehViQ0KpDyXqPjY1y6qezKY+NgUwXchvYINsVRUUGl+QdwiIjpMjIOz3ofpVs2FGoGy75cs6B8yeeZEdA==
dependencies:
"@appland/models" "^2.6.3"
"@appland/models" "^2.7.0"
"@appland/openapi" "^1.4.3"
"@datastructures-js/priority-queue" "^6.1.3"
crypto-js "^4.1.1"
diff "^5.1.0"
lru-cache "6.0.0"

"@appland/sql-parser@^1.5.0":
version "1.5.1"
Expand Down Expand Up @@ -2425,6 +2426,13 @@ lower-case@^2.0.2:
dependencies:
tslib "^2.0.3"

[email protected], lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
dependencies:
yallist "^4.0.0"

lru-cache@^4.1.2:
version "4.1.5"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
Expand All @@ -2440,13 +2448,6 @@ lru-cache@^5.1.1:
dependencies:
yallist "^3.0.2"

lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
dependencies:
yallist "^4.0.0"

make-dir@^3.0.2, make-dir@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
Expand Down
35 changes: 28 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,22 @@ allprojects {
}
}

// Target to execute tests, which are incompatible with the AppMap agent.
// Only tests with category "appland.WithoutAppMapAgent" are executed.
create<Test>("testWithoutAgent") {
useJUnit {
includeCategories("appland.WithoutAppMapAgent")
}
}

named("check") {
dependsOn(named("testWithoutAgent"))
}

withType<Test> {
// all our tests need the jar, even if the agent is disabled
dependsOn(":downloadAppMapAgent")

systemProperty("idea.test.execution.policy", "appland.AppLandTestExecutionPolicy")
systemProperty("appland.testDataPath", rootProject.rootDir.resolve("src/test/data").path)
if (isCI && githubToken != null) {
Expand All @@ -135,13 +150,6 @@ allprojects {
// always execute tests, don't skip by Gradle's up-to-date checks in development
outputs.upToDateWhen { false }

// attach AppMap agent, but only if Gradle is online
dependsOn(":downloadAppMapAgent")
jvmArgs("-javaagent:$agentOutputPath",
"-Dappmap.config.file=${rootProject.file("appmap.yml")}",
"-Dappmap.output.directory=${rootProject.file("tmp/appmap")}")
systemProperty("appmap.test.withAgent", "true")

// logging setup
testLogging {
setEvents(listOf(TestLogEvent.FAILED, TestLogEvent.STANDARD_OUT, TestLogEvent.STANDARD_ERROR))
Expand All @@ -152,6 +160,19 @@ allprojects {
}
}

// only run the default test target with the AppMap agent
named<Test>("test") {
// attach AppMap agent, but only if Gradle is online
jvmArgs("-javaagent:$agentOutputPath",
"-Dappmap.config.file=${rootProject.file("appmap.yml")}",
"-Dappmap.output.directory=${rootProject.file("tmp/appmap")}")
systemProperty("appmap.test.withAgent", "true")

useJUnit {
excludeCategories("appland.WithoutAppMapAgent")
}
}

withType<RunPluginVerifierTask> {
onlyIf { this.project == rootProject }
ideVersions.set(prop("ideVersionVerifier").split(","))
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sinceBuild=213.0
untilBuild=233.*

# run plugin verifier for the earliest and latest supported versions
ideVersionVerifier=IC-2021.3.3,IC-233.6745.305
ideVersionVerifier=IC-2021.3.3,IC-233.10527.20

lombokVersion=1.18.24

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package appland.files;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.vfs.AsyncFileListener;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* Deletes corresponding AppMap index data after a *.appmap.json file was deleted.
*/
public class DeleteAppMapIndexDataFileListener implements AsyncFileListener {
@Nullable
@Override
public ChangeApplier prepareChange(@NotNull List<? extends @NotNull VFileEvent> events) {
var deletedAppMaps = events.stream()
.map(DeleteAppMapIndexDataFileListener::findIndexDirectory)
.filter(Objects::nonNull)
.collect(Collectors.toList());

return deletedAppMaps.isEmpty() ? null : new DeleteAppMapIndexDataChangeApplier(deletedAppMaps);
}

private static @Nullable VirtualFile findIndexDirectory(VFileEvent event) {
var file = event.getFile();
return file != null && event instanceof VFileDeleteEvent && AppMapFiles.isAppMap(file)
? AppMapFiles.findAppMapMetadataDirectory(file)
: null;
}

private static class DeleteAppMapIndexDataChangeApplier implements ChangeApplier {
private final @NotNull List<VirtualFile> appMapIndexDirectories;

public DeleteAppMapIndexDataChangeApplier(@NotNull List<VirtualFile> appMapIndexDirectories) {
this.appMapIndexDirectories = appMapIndexDirectories;
}

@Override
public void afterVfsChange() {
var application = ApplicationManager.getApplication();
application.invokeLater(() -> {
CommandProcessor.getInstance().runUndoTransparentAction(() -> {
application.runWriteAction(() -> {
appMapIndexDirectories.forEach(DeleteAppMapIndexDataChangeApplier::safeDeleteDirectory);
});
});
}, ModalityState.defaultModalityState());
}

private static void safeDeleteDirectory(@NotNull VirtualFile indexDirectory) {
if (!indexDirectory.isValid() || !indexDirectory.isDirectory()) {
return;
}

try {
indexDirectory.delete(DeleteAppMapIndexDataFileListener.class);
} catch (Exception e) {
var logger = Logger.getInstance(DeleteAppMapIndexDataChangeApplier.class);
logger.warn("Exception deleting AppMap index directory " + indexDirectory.getPath());
}
}
}
}
38 changes: 21 additions & 17 deletions plugin-core/src/main/java/appland/problemsView/FindingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Service managing the AppMap findings of a project.
Expand Down Expand Up @@ -233,8 +234,9 @@ public void removeFindingsFile(@NotNull String path) {

public @NotNull List<ScannerFinding> findFindingsByHash(@NotNull String hashV2) {
synchronized (lock) {
return sourceFileToProblems.values().stream()
.map(ScannerProblem::getFinding)
return Stream.concat(
getOtherProblems().stream(),
sourceFileToProblems.values().stream().map(ScannerProblem::getFinding))
.filter(p -> hashV2.equals(p.getAppMapHashWithFallback()))
.collect(Collectors.toList());
}
Expand Down Expand Up @@ -295,14 +297,24 @@ private void removeFindingsFileLocked(@NotNull String path) {

private void loadFileLocked(@NotNull VirtualFile findingsFile, @NotNull Consumer<Problem> notifier) {
var fileData = loadFindingsFile(findingsFile);
if (fileData != null && fileData.findings != null) {
for (var finding : fileData.findings) {
if (fileData != null && fileData.findingsJSON != null) {
var ruleMapping = fileData.createRuleInfoMapping();

// Multiple metadata values exist to support scanner batch mode, but this is mostly deprecated now and
// shouldn't exist for user-generated AppMap data.
var metaData = fileData.metadata != null && !fileData.metadata.isEmpty()
? fileData.metadata.values().iterator().next()
: null;

for (var findingJSON : fileData.findingsJSON) {
var finding = GsonUtils.GSON.fromJson(findingJSON, ScannerFinding.class);
finding.setFindingsFile(findingsFile);
finding.setOriginalJsonData(findingJSON);

// update rule info with the ruleId of the finding
finding.ruleInfo = ruleMapping.get(finding.ruleId);

// multiple metadata values exist to support scanner batch mode,
// but this is mostly deprecated now and shouldn't exist for user-generated AppMap data.
if (fileData.metadata != null && !fileData.metadata.isEmpty()) {
var metaData = fileData.metadata.values().iterator().next();
if (metaData != null) {
finding.setFindingsMetaData(metaData);
}

Expand Down Expand Up @@ -353,15 +365,7 @@ private boolean isNotUnderContentRoot(@NotNull VirtualFile findingsFile) {
}

try {
var data = GsonUtils.GSON.fromJson(doc.getText(), FindingsFileData.class);
if (data != null && data.findings != null && !data.findings.isEmpty()) {
var ruleMapping = data.createRuleInfoMapping();
for (var finding : data.findings) {
// update rule info with the ruleId of the finding
finding.ruleInfo = ruleMapping.get(finding.ruleId);
}
}
return data;
return GsonUtils.GSON.fromJson(doc.getText(), FindingsFileData.class);
} catch (JsonSyntaxException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Failed to load findings file: " + file.getPath(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private FindingsUtil() {
@NotNull ScannerFinding finding,
@NotNull String rulePropertyName) {
var jsonItem = new JsonObject();
jsonItem.add("finding", gson.toJsonTree(finding));
jsonItem.add("finding", finding.getOriginalJsonData());
jsonItem.add("appMapUri", createAppMapUriJson(finding));
jsonItem.add("problemLocation", createProblemLocationJson(finding));
jsonItem.add("stackLocations", ReadAction.compute(() -> createStackLocationsJson(gson, project, finding)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package appland.problemsView.model;

import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -11,7 +12,7 @@

public final class FindingsFileData {
@SerializedName("findings")
public @Nullable List<ScannerFinding> findings;
public @Nullable List<JsonObject> findingsJSON;

@SerializedName("checks")
public @Nullable List<CheckInfo> checks;
Expand Down
Loading