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
13 changes: 13 additions & 0 deletions docs/releases/v0.2.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Java Support Lite 0.2.1

## 中文

- 修复 `0.2.0` 插件清单声明 `editor.actions` 权限时缺少必需的 `documents.read` 权限,导致桌面端下载后在清单校验阶段安装失败的问题。
- 识别 Ant 类路径中 `lib` 目录之外的依赖 JAR。

---

## English

- Fix `0.2.0` manifest validation failure on install by adding the required `documents.read` permission alongside `editor.actions`.
- Index workspace dependency JARs declared on Ant paths outside `lib/` directories.
52 changes: 52 additions & 0 deletions internal/backend/manifest_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package backend

import (
"encoding/json"
"os"
"path/filepath"
"slices"
"testing"
)

func TestPluginManifestPermissionsConsistent(t *testing.T) {
path := filepath.Join("..", "..", "io.github.lithe-idea.java-navigation", "plugin.json")
data, err := os.ReadFile(path)
if err != nil {
t.Fatalf("read plugin.json: %v", err)
}
var manifest struct {
Permissions []string `json:"permissions"`
LanguageServers []struct {
RequestMethods []string `json:"requestMethods"`
ForwardNotifications []string `json:"forwardNotifications"`
} `json:"languageServers"`
Backend json.RawMessage `json:"backend"`
}
if err := json.Unmarshal(data, &manifest); err != nil {
t.Fatalf("parse plugin.json: %v", err)
}
has := make(map[string]bool, len(manifest.Permissions))
for _, perm := range manifest.Permissions {
if has[perm] {
t.Errorf("duplicate permission %q in plugin.json", perm)
}
has[perm] = true
}
if !slices.IsSorted(manifest.Permissions) {
t.Errorf("permissions %v should be sorted alphabetically", manifest.Permissions)
}
if len(manifest.LanguageServers) > 0 && !has["languageServer.launch"] {
t.Errorf("languageServers requires languageServer.launch permission")
}
for _, srv := range manifest.LanguageServers {
if (len(srv.RequestMethods) > 0 || len(srv.ForwardNotifications) > 0) && !has["languageServer.request"] {
t.Errorf("requestMethods/forwardNotifications requires languageServer.request permission")
}
}
if len(manifest.Backend) > 0 && string(manifest.Backend) != "null" && !has["backend.launch"] {
t.Errorf("backend requires backend.launch permission")
}
if (has["editor.actions"] || has["editor.providers"]) && !has["documents.read"] {
t.Errorf("editor.actions/editor.providers requires documents.read permission (Core manifest rule)")
}
}
3 changes: 2 additions & 1 deletion io.github.lithe-idea.java-navigation/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schemaVersion": 0,
"id": "io.github.lithe-idea.java-navigation",
"displayName": "Java Support Lite",
"version": "0.2.0",
"version": "0.2.1",
"pluginAPIVersion": 0,
"requires": {
"backend": 0,
Expand All @@ -16,6 +16,7 @@
},
"permissions": [
"backend.launch",
"documents.read",
"editor.actions",
"languageServer.launch",
"languageServer.request",
Expand Down
13 changes: 13 additions & 0 deletions scripts/package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ const backend = manifest.backend;
if (backend?.launch?.kind !== "packaged" || backend?.launch?.path !== `bin/${BINARY}`) {
problems.push(`plugin.json must declare a packaged backend at bin/${BINARY}`);
}
const permissions = new Set(Array.isArray(manifest.permissions) ? manifest.permissions : []);
if (servers.length > 0 && !permissions.has("languageServer.launch")) {
problems.push('plugin.json declares languageServers without "languageServer.launch" permission');
}
if (servers.some((s) => (s.requestMethods?.length ?? 0) > 0 || (s.forwardNotifications?.length ?? 0) > 0) && !permissions.has("languageServer.request")) {
problems.push('plugin.json exposes language server requests/notifications without "languageServer.request" permission');
}
if (backend && !permissions.has("backend.launch")) {
problems.push('plugin.json declares backend without "backend.launch" permission');
}
if ((permissions.has("editor.actions") || permissions.has("editor.providers")) && !permissions.has("documents.read")) {
problems.push('plugin.json declares "editor.actions" or "editor.providers" without required "documents.read" permission');
}

const tagFlag = process.argv.indexOf("--expect-tag");
if (tagFlag >= 0) {
Expand Down
Loading