Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.util.SystemInfo;

import java.util.Arrays;
import java.util.List;

public class Platform {
//Set Plugin location in host machine. Location will be used as download location.
public static final String pluginDirectory = PluginManagerCore.getPlugin(
Expand Down Expand Up @@ -32,4 +35,8 @@ private static Platform detect() {
}

public static final Platform current = detect();

// Set supported file names
public static final List<String> supportedManifestFiles = Arrays.asList("pom.xml",
"package.json", "go.mod", "requirements.txt", "requirements-dev.txt");
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PreloadingActivity;
import com.intellij.openapi.progress.ProgressIndicator;
Expand All @@ -14,14 +15,13 @@ public final class PreloadLanguageServer extends PreloadingActivity {
private final ICookie cookies = ServiceManager.getService(Settings.class);

private void attachLanguageClient(final File cliFile) {
final String[] EXTENSIONS = {"xml", "json", "txt"};
final String[] cmds = {cliFile.toString(), "--stdio"};
ApplicationManager.getApplication().invokeAndWait(() -> {
for (String ext : EXTENSIONS) {
Platform.supportedManifestFiles.stream().map(s -> s.substring(s.lastIndexOf('.') + 1)).distinct().forEach(ext -> {
AnalyticsLanguageServerDefinition serverDefinition = new AnalyticsLanguageServerDefinition(ext, cmds);
IntellijLanguageClient.addServerDefinition(serverDefinition);
IntellijLanguageClient.addExtensionManager(ext, serverDefinition);
}
IntellijLanguageClient.addExtensionManager(ext, serverDefinition);}
);
});
log.warn(String.format("lsp registration done %s", cliFile));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;

import org.jboss.tools.intellij.analytics.Platform;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.List;


public class SaAction extends AnAction {
Expand Down Expand Up @@ -69,16 +68,12 @@ public void actionPerformed(@NotNull AnActionEvent event) {
*/
@Override
public void update(AnActionEvent event) {
// Set supported file names
List<String> supportedManifestFiles = Arrays.asList("pom.xml", "package.json",
"requirements.txt", "requirements-dev.txt", "go.mod");

PsiFile psiFile = event.getData(CommonDataKeys.PSI_FILE);

// Check if file where context menu is opened is type of supported extension.
// If yes then show the action for SA in menu
if (psiFile != null) {
event.getPresentation().setEnabledAndVisible(supportedManifestFiles
event.getPresentation().setEnabledAndVisible(Platform.supportedManifestFiles
.contains(psiFile.getName()));
} else {
event.getPresentation().setEnabledAndVisible(false);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<h2>Quick Start</h2>
<ul>
<li>Install the extension.</li>
<li>Opening or editing a manifest file (<code>pom.xml</code> / <code>package.json</code> / <code>requirements.txt</code>) scans your application for security vulnerabilities.</li>
<li>Opening or editing a manifest file (<code>pom.xml</code> / <code>package.json</code> / <code>requirements.txt</code> / <code>go.mod</code>) scans your application for security vulnerabilities.</li>
<li>Opening or editing a manifest file (pom.xml / package.json / requirements.txt / go.mod) scans your application for security vulnerabilities.</li>
<li>Click on icon from 'Navigation bar' or right click on a manifest file (pom.xml/package.json / requirements.txt / go.mod) in the 'File explorer' or 'File editor' to display 'Dependency Analytics Report' for your application.</li>
</ul>
Expand Down