дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 09:41:34 +02:00
feat(plugins): add code.semantics read-only LSP queries (#8117)
Plugin API 1.21 adds the low-risk code.semantics capability: Project::lsp_definition, lsp_type_definition, lsp_implementations, lsp_references (capped by a limit), lsp_hover_info and lsp_document_symbols query the running language servers, also for read-only jdt:// documents. Queries need a trusted project, documents are opened through the ref-counted document store and released afterwards, and locations outside the project's roots are dropped. Includes the SDK methods and MockHost helpers, a fixture plugin with a host integration test, rebuilt plugin components, the capability's description in the text catalog, and README entries. Co-authored-by: RuyimgByCN <[email protected]>
Цей коміт міститься в:
1 джерело
3a956c72b8
коміт
65e243f5fc
132 files changed
+1343
-68
No files matched your search
@@ -75,6 +75,8 @@ pub enum Capability {
|
||||
JavaAgent,
|
||||
/// Fork a recorded native agent session into a new task in the open project (API 1.18).
|
||||
Agents,
|
||||
/// Query running IDE language servers for symbol types, definitions, references and outlines (API 1.21).
|
||||
CodeSemantics,
|
||||
}
|
||||
|
||||
/// How a grant is presented (plan 4.2).
|
||||
@@ -92,9 +94,13 @@ pub enum Risk {
|
||||
impl Capability {
|
||||
pub fn risk(&self) -> Risk {
|
||||
match self {
|
||||
Self::ProjectRead | Self::EditorRead | Self::Storage | Self::Events | Self::VcsRead | Self::BuildRead => {
|
||||
Risk::Low
|
||||
}
|
||||
Self::ProjectRead
|
||||
| Self::EditorRead
|
||||
| Self::Storage
|
||||
| Self::Events
|
||||
| Self::VcsRead
|
||||
| Self::BuildRead
|
||||
| Self::CodeSemantics => Risk::Low,
|
||||
Self::EditorWrite
|
||||
| Self::DatabaseSources
|
||||
| Self::DatabaseSchema
|
||||
@@ -175,6 +181,9 @@ impl Capability {
|
||||
Self::FsWrite(path) => format!("Change files under {path}, outside the project"),
|
||||
Self::JavaAgent => "Run code inside the Java applications you start".into(),
|
||||
Self::Agents => "Fork a recorded agent session into a new task in the open project".into(),
|
||||
Self::CodeSemantics => {
|
||||
"Query language server symbol definitions, types, references and outlines in trusted projects".into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,6 +329,7 @@ impl fmt::Display for Capability {
|
||||
Self::FsWrite(p) => write!(f, "fs.write:{p}"),
|
||||
Self::JavaAgent => f.write_str("java.agent"),
|
||||
Self::Agents => f.write_str("agents"),
|
||||
Self::CodeSemantics => f.write_str("code.semantics"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,6 +416,7 @@ impl FromStr for Capability {
|
||||
"clipboard.read" => Self::ClipboardRead,
|
||||
"java.agent" => Self::JavaAgent,
|
||||
"agents" => Self::Agents,
|
||||
"code.semantics" => Self::CodeSemantics,
|
||||
_ => return Err(format!("unknown capability {s:?}")),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -436,6 +436,9 @@ impl Manifest {
|
||||
if matches!(cap, Capability::Agents) {
|
||||
self.needs_api(&format!("capability `{cap}`"), 18)?;
|
||||
}
|
||||
if matches!(cap, Capability::CodeSemantics) {
|
||||
self.needs_api(&format!("capability `{cap}`"), 21)?;
|
||||
}
|
||||
if matches!(cap, Capability::NetSetting { .. }) {
|
||||
self.needs_api(&format!("capability `{cap}`"), 18)?;
|
||||
}
|
||||
|
||||
@@ -3018,6 +3018,111 @@ impl HostApi for PluginApi {
|
||||
Ok(result.to_string())
|
||||
}
|
||||
|
||||
fn lsp_definition(
|
||||
&self,
|
||||
root: &Path,
|
||||
path: &str,
|
||||
at: ide_core::Pos,
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> Result<Vec<ide_plugin::Location>, HostError> {
|
||||
self.lsp_semantic_goto(root, path, at, ide_lsp::types::GotoKind::Definition, cancel, timeout)
|
||||
}
|
||||
|
||||
fn lsp_type_definition(
|
||||
&self,
|
||||
root: &Path,
|
||||
path: &str,
|
||||
at: ide_core::Pos,
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> Result<Vec<ide_plugin::Location>, HostError> {
|
||||
self.lsp_semantic_goto(root, path, at, ide_lsp::types::GotoKind::TypeDefinition, cancel, timeout)
|
||||
}
|
||||
|
||||
fn lsp_implementations(
|
||||
&self,
|
||||
root: &Path,
|
||||
path: &str,
|
||||
at: ide_core::Pos,
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> Result<Vec<ide_plugin::Location>, HostError> {
|
||||
self.lsp_semantic_goto(root, path, at, ide_lsp::types::GotoKind::Implementation, cancel, timeout)
|
||||
}
|
||||
|
||||
fn lsp_references(
|
||||
&self,
|
||||
root: &Path,
|
||||
path: &str,
|
||||
at: ide_core::Pos,
|
||||
limit: usize,
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> Result<Vec<ide_plugin::Location>, HostError> {
|
||||
let (host, project, doc) = self.open_semantic_doc(root, path, true)?;
|
||||
let res = host.runtime.block_on(async {
|
||||
let fut = project.lsp.references_streaming(doc.1, at, true, true, false, cancel.clone(), None);
|
||||
tokio::select! {
|
||||
_ = cancel.cancelled() => Err(ide_core::IdeError::cancelled()),
|
||||
out = tokio::time::timeout(timeout, fut) => out.map_err(|_| ide_core::IdeError::cancelled())?,
|
||||
}
|
||||
});
|
||||
drop(doc);
|
||||
let refs = res.map_err(map_lsp_err)?;
|
||||
Ok(refs
|
||||
.locations
|
||||
.into_iter()
|
||||
.filter(|l| location_allowed_for_semantics(root, &project, l))
|
||||
.take(limit)
|
||||
.map(|l| ide_plugin::Location { path: l.path.0, range: l.range })
|
||||
.collect())
|
||||
}
|
||||
|
||||
fn lsp_hover_info(
|
||||
&self,
|
||||
root: &Path,
|
||||
path: &str,
|
||||
at: ide_core::Pos,
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> Result<Option<String>, HostError> {
|
||||
let (host, project, doc) = self.open_semantic_doc(root, path, true)?;
|
||||
let res = host.runtime.block_on(async {
|
||||
let fut = project.lsp.hover(doc.1, at, cancel.clone());
|
||||
tokio::select! {
|
||||
_ = cancel.cancelled() => Err(ide_core::IdeError::cancelled()),
|
||||
out = tokio::time::timeout(timeout, fut) => out.map_err(|_| ide_core::IdeError::cancelled())?,
|
||||
}
|
||||
});
|
||||
drop(doc);
|
||||
let hover = res.map_err(map_lsp_err)?;
|
||||
Ok(hover.map(|h| h.contents.value))
|
||||
}
|
||||
|
||||
fn lsp_document_symbols(
|
||||
&self,
|
||||
root: &Path,
|
||||
path: &str,
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> Result<Vec<ide_plugin::SymbolInfo>, HostError> {
|
||||
let (host, project, doc) = self.open_semantic_doc(root, path, true)?;
|
||||
let resolved_path = doc.2.clone();
|
||||
let res = host.runtime.block_on(async {
|
||||
let fut = project.lsp.document_symbols(doc.1);
|
||||
tokio::select! {
|
||||
_ = cancel.cancelled() => Err(ide_core::IdeError::cancelled()),
|
||||
out = tokio::time::timeout(timeout, fut) => out.map_err(|_| ide_core::IdeError::cancelled())?,
|
||||
}
|
||||
});
|
||||
drop(doc);
|
||||
let items = res.map_err(map_lsp_err)?.unwrap_or_default();
|
||||
let mut out = Vec::new();
|
||||
flatten_outline_symbols(&resolved_path, None, &items, &mut out);
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
fn build_dependencies(
|
||||
&self,
|
||||
root: &Path,
|
||||
@@ -5656,6 +5761,114 @@ impl Shared {
|
||||
}
|
||||
}
|
||||
|
||||
struct SemanticDocGuard(Arc<crate::project::Project>, ide_core::DocId, PathBuf);
|
||||
impl Drop for SemanticDocGuard {
|
||||
fn drop(&mut self) {
|
||||
self.0.documents.close(self.1);
|
||||
}
|
||||
}
|
||||
|
||||
impl PluginApi {
|
||||
fn open_semantic_doc(
|
||||
&self,
|
||||
root: &Path,
|
||||
path: &str,
|
||||
allow_virtual_jdt: bool,
|
||||
) -> Result<(Arc<crate::Host>, Arc<crate::project::Project>, SemanticDocGuard), HostError> {
|
||||
self.require_api("language server semantic queries", 21)?;
|
||||
let workspace = self.shared.workspace().ok_or_else(|| HostError::NotFound("no project is open".into()))?;
|
||||
if !workspace.trusted(root) {
|
||||
return Err(HostError::Denied("project is not trusted".into()));
|
||||
}
|
||||
let host = workspace
|
||||
.database_host()
|
||||
.ok_or_else(|| HostError::Failed("semantic queries unavailable on this host".into()))?;
|
||||
let project = HostWorkspace::project_covering(&HostWorkspace(Arc::downgrade(&host)), root)
|
||||
.ok_or_else(|| HostError::NotFound("the project is no longer open".into()))?;
|
||||
if allow_virtual_jdt && path.starts_with("jdt://") {
|
||||
let vd = host.runtime.block_on(project.lsp.virtual_document(path)).map_err(map_lsp_err)?;
|
||||
let doc = project
|
||||
.documents
|
||||
.open_virtual(&vd.uri, vd.language_id, &vd.text, &vd.encoding, vd.has_bom, vd.can_reload_encoding)
|
||||
.map_err(failed)?;
|
||||
return Ok((host, project.clone(), SemanticDocGuard(project, doc.id, PathBuf::from(&vd.uri))));
|
||||
}
|
||||
let mut roots = vec![root.to_path_buf()];
|
||||
roots.extend(workspace.member_roots(root));
|
||||
let resolved = ide_plugin::resolve_in_roots(&roots, path).map_err(HostError::Invalid)?;
|
||||
let doc = project.documents.open(&resolved).map_err(failed)?;
|
||||
Ok((host, project.clone(), SemanticDocGuard(project, doc.id, resolved)))
|
||||
}
|
||||
|
||||
fn lsp_semantic_goto(
|
||||
&self,
|
||||
root: &Path,
|
||||
path: &str,
|
||||
at: ide_core::Pos,
|
||||
kind: ide_lsp::types::GotoKind,
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> Result<Vec<ide_plugin::Location>, HostError> {
|
||||
let (host, project, doc) = self.open_semantic_doc(root, path, true)?;
|
||||
let res = host.runtime.block_on(async {
|
||||
let fut = project.lsp.goto(doc.1, at, kind);
|
||||
tokio::select! {
|
||||
_ = cancel.cancelled() => Err(ide_core::IdeError::cancelled()),
|
||||
out = tokio::time::timeout(timeout, fut) => out.map_err(|_| ide_core::IdeError::cancelled())?,
|
||||
}
|
||||
});
|
||||
drop(doc);
|
||||
let locs = res.map_err(map_lsp_err)?;
|
||||
Ok(locs
|
||||
.into_iter()
|
||||
.filter(|l| location_allowed_for_semantics(root, &project, l))
|
||||
.map(|l| ide_plugin::Location { path: l.path.0, range: l.range })
|
||||
.collect())
|
||||
}
|
||||
}
|
||||
|
||||
fn location_allowed_for_semantics(root: &Path, project: &crate::project::Project, loc: &ide_core::Location) -> bool {
|
||||
if loc.uri.as_deref().is_some_and(|u| u.starts_with("jdt://")) || loc.path.0.to_string_lossy().starts_with("jdt://")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
let mut roots = vec![root.to_path_buf()];
|
||||
roots.extend(crate::project::workspace_member_roots(&project.root));
|
||||
ide_plugin::inside_roots(&roots, &loc.path.0.to_string_lossy()).unwrap_or(false)
|
||||
}
|
||||
|
||||
fn flatten_outline_symbols(
|
||||
path: &Path,
|
||||
container: Option<&str>,
|
||||
items: &[ide_core::OutlineItem],
|
||||
out: &mut Vec<ide_plugin::SymbolInfo>,
|
||||
) {
|
||||
for item in items {
|
||||
let kind = serde_json::to_value(item.kind)
|
||||
.ok()
|
||||
.and_then(|v| v.as_str().map(str::to_owned))
|
||||
.unwrap_or_else(|| "unknown".into());
|
||||
out.push(ide_plugin::SymbolInfo {
|
||||
name: item.name.clone(),
|
||||
kind,
|
||||
container: container.map(str::to_owned),
|
||||
location: ide_plugin::Location { path: path.to_path_buf(), range: item.range },
|
||||
});
|
||||
flatten_outline_symbols(path, Some(&item.name), &item.children, out);
|
||||
}
|
||||
}
|
||||
|
||||
fn map_lsp_err(e: ide_core::IdeError) -> HostError {
|
||||
use ide_core::error::ErrorKind;
|
||||
match e.kind {
|
||||
ErrorKind::NotFound | ErrorKind::Unavailable => HostError::NotFound(e.message),
|
||||
ErrorKind::InvalidInput => HostError::Invalid(e.message),
|
||||
ErrorKind::Cancelled => HostError::Cancelled,
|
||||
ErrorKind::PermissionDenied => HostError::Denied(e.message),
|
||||
_ => HostError::Failed(e.message),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod workbench_tests {
|
||||
use super::*;
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
//! API 1.21 `code.semantics`: read-only LSP semantic queries require capability & trust
|
||||
//! and confine non-virtual target locations to workspace roots.
|
||||
mod common;
|
||||
|
||||
use ide_core::error::ErrorKind;
|
||||
use ide_host::plugins::{Consent, HostWorkspace, PluginHost};
|
||||
use ide_host::{Host, HostConfig, ops};
|
||||
use ide_jsonrpc::{Handler, Peer};
|
||||
use ide_plugin::{Invocation, Limits};
|
||||
use parking_lot::Mutex;
|
||||
use serde_json::{Value, json};
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
time::Duration,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
const ID: &str = "test.code-semantics";
|
||||
|
||||
fn fixture() -> PathBuf {
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join("../ide-plugin/tests/fixtures/code-semantics")
|
||||
}
|
||||
|
||||
struct SemanticServer {
|
||||
target_uri: String,
|
||||
outside_uri: String,
|
||||
}
|
||||
|
||||
impl Handler for SemanticServer {
|
||||
fn on_notification(&self, _: &str, _: Value) {}
|
||||
fn on_request(&self, method: &str, _: Value) -> Result<Value, (i64, String)> {
|
||||
let range = json!({
|
||||
"start": {"line": 0, "character": 0},
|
||||
"end": {"line": 0, "character": 3}
|
||||
});
|
||||
Ok(match method {
|
||||
"initialize" => json!({"capabilities": {
|
||||
"textDocumentSync": {"openClose": true, "change": 1},
|
||||
"definitionProvider": true,
|
||||
"hoverProvider": true,
|
||||
"documentSymbolProvider": true
|
||||
}}),
|
||||
"textDocument/definition" => json!([
|
||||
{"uri": self.target_uri, "range": range},
|
||||
{"uri": self.outside_uri, "range": range}
|
||||
]),
|
||||
"textDocument/hover" => json!({"contents": {"kind": "markdown", "value": "type: Sym"}}),
|
||||
"textDocument/documentSymbol" => json!([{
|
||||
"name": "Sym",
|
||||
"kind": 5,
|
||||
"range": range,
|
||||
"selectionRange": range
|
||||
}]),
|
||||
_ => Value::Null,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn code_semantics_enforces_capability_trust_and_location_confinement() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let base = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let root = base.join("project");
|
||||
let outside = base.join("outside.txt");
|
||||
std::fs::create_dir(&root).unwrap();
|
||||
let main_file = root.join("main.txt");
|
||||
let target_file = root.join("target.txt");
|
||||
std::fs::write(&main_file, "sym\n").unwrap();
|
||||
std::fs::write(&target_file, "sym\n").unwrap();
|
||||
std::fs::write(&outside, "secret\n").unwrap();
|
||||
|
||||
let host =
|
||||
Arc::new(Host::new(HostConfig { local_data_dir: tmp.path().join("local"), ..common::host_config(tmp.path()) }));
|
||||
host.open_project("main", &root).unwrap();
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(("127.0.0.1", 0)).await.unwrap();
|
||||
let port = listener.local_addr().unwrap().port();
|
||||
let server = Arc::new(SemanticServer {
|
||||
target_uri: Url::from_file_path(&target_file).unwrap().to_string(),
|
||||
outside_uri: Url::from_file_path(&outside).unwrap().to_string(),
|
||||
});
|
||||
let peers = Arc::new(Mutex::new(Vec::<Peer>::new()));
|
||||
let (accepted, state) = (peers.clone(), server.clone());
|
||||
tokio::spawn(async move {
|
||||
while let Ok((stream, _)) = listener.accept().await {
|
||||
let (r, w) = stream.into_split();
|
||||
accepted.lock().push(Peer::connect(r, w, state.clone()));
|
||||
}
|
||||
});
|
||||
let cfg: ide_language::LanguageServerConfig =
|
||||
toml::from_str(&format!("name='text-server'\ncommand='no-process-required'\nconnect='127.0.0.1:{port}'"))
|
||||
.unwrap();
|
||||
let project = host.project("main").unwrap();
|
||||
project.lsp.set_servers_hook(Box::new(move |_, _| vec![cfg.clone()]));
|
||||
|
||||
let inv = || Invocation { client: Some("main".into()), workspace_root: Some(root.clone()), ..Default::default() };
|
||||
|
||||
// 1. Denied when capability is not granted (even in trusted workspace).
|
||||
ops::project::project_trust_set(&host, root.clone(), true, false).await.unwrap();
|
||||
let _doc = ops::doc::doc_open(&host, "main", main_file.clone()).await.unwrap();
|
||||
let denied_plugins = Arc::new(
|
||||
PluginHost::new(
|
||||
tmp.path().join("plugins-denied"),
|
||||
Arc::new(|_: Option<&str>, _| {}),
|
||||
Limits { timeout: Duration::from_secs(5), ..Default::default() },
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
denied_plugins.set_workspace(Some(Arc::new(HostWorkspace(Arc::downgrade(&host)))));
|
||||
denied_plugins.install_from_dir(&fixture(), &Consent { optional: vec![], signer_change: true }).unwrap();
|
||||
let p = denied_plugins.clone();
|
||||
let i = inv();
|
||||
let err = tokio::task::spawn_blocking(move || p.run_command(ID, "hover", Some("main.txt"), i))
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap_err();
|
||||
assert_eq!(err.kind, ErrorKind::PermissionDenied);
|
||||
|
||||
// 2. Denied in untrusted project even with Consent::all().
|
||||
let granted_plugins = Arc::new(
|
||||
PluginHost::new(
|
||||
tmp.path().join("plugins-granted"),
|
||||
Arc::new(|_: Option<&str>, _| {}),
|
||||
Limits { timeout: Duration::from_secs(5), ..Default::default() },
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
granted_plugins.set_workspace(Some(Arc::new(HostWorkspace(Arc::downgrade(&host)))));
|
||||
granted_plugins.install_from_dir(&fixture(), &Consent::all()).unwrap();
|
||||
ops::project::project_trust_set(&host, root.clone(), false, false).await.unwrap();
|
||||
let p = granted_plugins.clone();
|
||||
let i = inv();
|
||||
let untrusted = tokio::task::spawn_blocking(move || p.run_command(ID, "hover", Some("main.txt"), i))
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap_err();
|
||||
assert_eq!(untrusted.kind, ErrorKind::PermissionDenied);
|
||||
|
||||
// 3. Trusted + granted: returns definition (excluding out-of-root target), hover, and symbols.
|
||||
ops::project::project_trust_set(&host, root.clone(), true, false).await.unwrap();
|
||||
let p = granted_plugins.clone();
|
||||
let i = inv();
|
||||
let def = tokio::task::spawn_blocking(move || p.run_command(ID, "definition", Some("main.txt"), i))
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert!(def.contains("target.txt"), "expected target.txt in {def:?}");
|
||||
assert!(!def.contains("outside.txt"), "outside.txt should be confined: {def:?}");
|
||||
|
||||
let p = granted_plugins.clone();
|
||||
let i = inv();
|
||||
let hover =
|
||||
tokio::task::spawn_blocking(move || p.run_command(ID, "hover", Some("main.txt"), i)).await.unwrap().unwrap();
|
||||
assert_eq!(hover.as_deref(), Some("type: Sym"));
|
||||
|
||||
let p = granted_plugins.clone();
|
||||
let i = inv();
|
||||
let symbols =
|
||||
tokio::task::spawn_blocking(move || p.run_command(ID, "symbols", Some("main.txt"), i)).await.unwrap().unwrap();
|
||||
assert_eq!(symbols.as_deref(), Some("class:Sym"));
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
use crate::types::{
|
||||
CodeAction, CommitDraft, CommitProblem, CompletionItem, FileOperation, InlineSuggestion, LineMarker, Location,
|
||||
PluginHover, PluginInlayHint, PrepareRenameResult, ProviderDocument, SemanticToken,
|
||||
PluginHover, PluginInlayHint, PrepareRenameResult, ProviderDocument, SemanticToken, SymbolInfo,
|
||||
};
|
||||
use crate::types::{
|
||||
EventKind, HostError, HttpRequest, HttpResponse, HttpStreamHead, Invocation, Limits, NotificationLevel,
|
||||
@@ -177,6 +177,72 @@ pub trait HostApi: Send + Sync {
|
||||
cancel: &CancellationToken,
|
||||
timeout: Duration,
|
||||
) -> Result<String, HostError>;
|
||||
/// Read-only semantic definition query via running LSPs (`code.semantics`, API 1.21).
|
||||
fn lsp_definition(
|
||||
&self,
|
||||
_root: &Path,
|
||||
_path: &str,
|
||||
_at: ide_core::Pos,
|
||||
_cancel: &CancellationToken,
|
||||
_timeout: Duration,
|
||||
) -> Result<Vec<Location>, HostError> {
|
||||
Err(HostError::Invalid("Language server semantic queries are unavailable on this host".into()))
|
||||
}
|
||||
/// Read-only semantic type-definition query via running LSPs (`code.semantics`, API 1.21).
|
||||
fn lsp_type_definition(
|
||||
&self,
|
||||
_root: &Path,
|
||||
_path: &str,
|
||||
_at: ide_core::Pos,
|
||||
_cancel: &CancellationToken,
|
||||
_timeout: Duration,
|
||||
) -> Result<Vec<Location>, HostError> {
|
||||
Err(HostError::Invalid("Language server semantic queries are unavailable on this host".into()))
|
||||
}
|
||||
/// Read-only semantic implementations query via running LSPs (`code.semantics`, API 1.21).
|
||||
fn lsp_implementations(
|
||||
&self,
|
||||
_root: &Path,
|
||||
_path: &str,
|
||||
_at: ide_core::Pos,
|
||||
_cancel: &CancellationToken,
|
||||
_timeout: Duration,
|
||||
) -> Result<Vec<Location>, HostError> {
|
||||
Err(HostError::Invalid("Language server semantic queries are unavailable on this host".into()))
|
||||
}
|
||||
/// Read-only bounded references query via running LSPs (`code.semantics`, API 1.21).
|
||||
fn lsp_references(
|
||||
&self,
|
||||
_root: &Path,
|
||||
_path: &str,
|
||||
_at: ide_core::Pos,
|
||||
_limit: usize,
|
||||
_cancel: &CancellationToken,
|
||||
_timeout: Duration,
|
||||
) -> Result<Vec<Location>, HostError> {
|
||||
Err(HostError::Invalid("Language server semantic queries are unavailable on this host".into()))
|
||||
}
|
||||
/// Read-only hover/type signature Markdown via running LSPs (`code.semantics`, API 1.21).
|
||||
fn lsp_hover_info(
|
||||
&self,
|
||||
_root: &Path,
|
||||
_path: &str,
|
||||
_at: ide_core::Pos,
|
||||
_cancel: &CancellationToken,
|
||||
_timeout: Duration,
|
||||
) -> Result<Option<String>, HostError> {
|
||||
Err(HostError::Invalid("Language server semantic queries are unavailable on this host".into()))
|
||||
}
|
||||
/// Read-only document outline symbols via running LSPs (`code.semantics`, API 1.21).
|
||||
fn lsp_document_symbols(
|
||||
&self,
|
||||
_root: &Path,
|
||||
_path: &str,
|
||||
_cancel: &CancellationToken,
|
||||
_timeout: Duration,
|
||||
) -> Result<Vec<SymbolInfo>, HostError> {
|
||||
Err(HostError::Invalid("Language server semantic queries are unavailable on this host".into()))
|
||||
}
|
||||
/// The flat dependency graph of the Maven / Gradle builds of the project at `root`
|
||||
/// (of the module `module` only, when given), as the IDE last resolved it; never runs
|
||||
/// a build tool.
|
||||
|
||||
@@ -3758,6 +3758,153 @@ impl bindings::openidea::plugin::language_servers::Host for StoreData {
|
||||
) -> Fallible<()> {
|
||||
Ok(self.lsp_call(project, server, method, params, true)?.map(|_| ()))
|
||||
}
|
||||
fn definition(
|
||||
&mut self,
|
||||
project: Resource<ProjectRes>,
|
||||
path: String,
|
||||
at: wit::Position,
|
||||
) -> Fallible<Vec<wit::Location>> {
|
||||
if let Err(e) = self.require(Capability::CodeSemantics) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
let root = self.table.get(&project)?.root.clone();
|
||||
let at = ide_core::Pos { line: at.line, col: at.character };
|
||||
let result = self.host.lsp_definition(&root, &path, at, &self.cancel.token(), self.io_timeout());
|
||||
if result.is_err() {
|
||||
self.grant_io_error_grace();
|
||||
}
|
||||
Ok(result
|
||||
.map(|locs| {
|
||||
locs.into_iter()
|
||||
.map(|l| wit::Location { path: to_ipc(&l.path), range: range_to_wit(&l.range) })
|
||||
.collect()
|
||||
})
|
||||
.map_err(to_wit))
|
||||
}
|
||||
fn type_definition(
|
||||
&mut self,
|
||||
project: Resource<ProjectRes>,
|
||||
path: String,
|
||||
at: wit::Position,
|
||||
) -> Fallible<Vec<wit::Location>> {
|
||||
if let Err(e) = self.require(Capability::CodeSemantics) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
let root = self.table.get(&project)?.root.clone();
|
||||
let at = ide_core::Pos { line: at.line, col: at.character };
|
||||
let result = self.host.lsp_type_definition(&root, &path, at, &self.cancel.token(), self.io_timeout());
|
||||
if result.is_err() {
|
||||
self.grant_io_error_grace();
|
||||
}
|
||||
Ok(result
|
||||
.map(|locs| {
|
||||
locs.into_iter()
|
||||
.map(|l| wit::Location { path: to_ipc(&l.path), range: range_to_wit(&l.range) })
|
||||
.collect()
|
||||
})
|
||||
.map_err(to_wit))
|
||||
}
|
||||
fn implementations(
|
||||
&mut self,
|
||||
project: Resource<ProjectRes>,
|
||||
path: String,
|
||||
at: wit::Position,
|
||||
) -> Fallible<Vec<wit::Location>> {
|
||||
if let Err(e) = self.require(Capability::CodeSemantics) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
let root = self.table.get(&project)?.root.clone();
|
||||
let at = ide_core::Pos { line: at.line, col: at.character };
|
||||
let result = self.host.lsp_implementations(&root, &path, at, &self.cancel.token(), self.io_timeout());
|
||||
if result.is_err() {
|
||||
self.grant_io_error_grace();
|
||||
}
|
||||
Ok(result
|
||||
.map(|locs| {
|
||||
locs.into_iter()
|
||||
.map(|l| wit::Location { path: to_ipc(&l.path), range: range_to_wit(&l.range) })
|
||||
.collect()
|
||||
})
|
||||
.map_err(to_wit))
|
||||
}
|
||||
fn references(
|
||||
&mut self,
|
||||
project: Resource<ProjectRes>,
|
||||
path: String,
|
||||
at: wit::Position,
|
||||
limit: u32,
|
||||
) -> Fallible<Vec<wit::Location>> {
|
||||
if let Err(e) = self.require(Capability::CodeSemantics) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
let root = self.table.get(&project)?.root.clone();
|
||||
let at = ide_core::Pos { line: at.line, col: at.character };
|
||||
let result = self.host.lsp_references(
|
||||
&root,
|
||||
&path,
|
||||
at,
|
||||
limit.min(500) as usize,
|
||||
&self.cancel.token(),
|
||||
self.io_timeout(),
|
||||
);
|
||||
if result.is_err() {
|
||||
self.grant_io_error_grace();
|
||||
}
|
||||
Ok(result
|
||||
.map(|locs| {
|
||||
locs.into_iter()
|
||||
.map(|l| wit::Location { path: to_ipc(&l.path), range: range_to_wit(&l.range) })
|
||||
.collect()
|
||||
})
|
||||
.map_err(to_wit))
|
||||
}
|
||||
fn hover_info(
|
||||
&mut self,
|
||||
project: Resource<ProjectRes>,
|
||||
path: String,
|
||||
at: wit::Position,
|
||||
) -> Fallible<Option<String>> {
|
||||
if let Err(e) = self.require(Capability::CodeSemantics) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
let root = self.table.get(&project)?.root.clone();
|
||||
let at = ide_core::Pos { line: at.line, col: at.character };
|
||||
let result = self.host.lsp_hover_info(&root, &path, at, &self.cancel.token(), self.io_timeout());
|
||||
if result.is_err() {
|
||||
self.grant_io_error_grace();
|
||||
}
|
||||
Ok(result.map_err(to_wit))
|
||||
}
|
||||
fn document_symbols(
|
||||
&mut self,
|
||||
project: Resource<ProjectRes>,
|
||||
path: String,
|
||||
) -> Fallible<Vec<workspace::SymbolInfo>> {
|
||||
if let Err(e) = self.require(Capability::CodeSemantics) {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
let root = self.table.get(&project)?.root.clone();
|
||||
let result = self.host.lsp_document_symbols(&root, &path, &self.cancel.token(), self.io_timeout());
|
||||
if result.is_err() {
|
||||
self.grant_io_error_grace();
|
||||
}
|
||||
Ok(result
|
||||
.map(|symbols| {
|
||||
symbols
|
||||
.into_iter()
|
||||
.map(|s| workspace::SymbolInfo {
|
||||
name: s.name,
|
||||
kind: s.kind,
|
||||
container: s.container,
|
||||
location: wit::Location {
|
||||
path: to_ipc(&s.location.path),
|
||||
range: range_to_wit(&s.location.range),
|
||||
},
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.map_err(to_wit))
|
||||
}
|
||||
}
|
||||
|
||||
impl bindings::openidea::plugin::extensions::Host for StoreData {
|
||||
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
ec2d6d93c13e2483c7771c91ca39b73faae30779d7baa255727c7950d4d3430d
|
||||
6d8f89941e0e0acc9078ae4b4aaa947055833c7abe4ab7a3584b7aa569dd01e1
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
37ec416570ebbfdfc6d8dce1d64e81d46fbd7ff4bef09cb862f6807a60757db9
|
||||
fb67b360c95d24e1a46bfa6206629fb0c3a4fd1ad1646cfef611c267b502eb63
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
a75573631cf9f0aca3366785ad90aed3c8eebbe61a8edc3a99e81722be70e088
|
||||
1e4691d70436bbc746f74ed09acdb60b9b48b3458f49ab21573dfd804e863a8e
|
||||
+336
@@ -0,0 +1,336 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cb931c189b85683d69a5cfad41d4d418671e1ac413dd209f3f2fc31e3cfd902"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.17.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc"
|
||||
dependencies = [
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "id-arena"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
"serde",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
||||
|
||||
[[package]]
|
||||
name = "leb128fmt"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
|
||||
|
||||
[[package]]
|
||||
name = "macro-string"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e7b3a5bbb2f63aaa223a671ea1bd0e7bc16bd30ce387324cf63995deaddbbd2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||
|
||||
[[package]]
|
||||
name = "openidea-plugin"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openidea-test-code-semantics"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"openidea-plugin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prettyplease"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.154"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"serde",
|
||||
"serde_core",
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-encoder"
|
||||
version = "0.262.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4495a6f85dd94c411c749303efcbc5defade0b0cbdbc0541495241ab917a9b5a"
|
||||
dependencies = [
|
||||
"leb128fmt",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-metadata"
|
||||
version = "0.262.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c86ff6668190d9fb70372b306b4f9fe8930f0e2f57ce72e4922bf2f117900949"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"indexmap",
|
||||
"wasm-encoder",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmparser"
|
||||
version = "0.262.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "974d643b125b272607e2fff8012ea14a8328acd7621e4bafa7afb32500052b1b"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"hashbrown",
|
||||
"indexmap",
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.63.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b85a987ab61d365382d25c7d47e26edd48941b3bf6e3fbf76eff918bc71dab06"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"wit-bindgen-rust-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-core"
|
||||
version = "0.63.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "775e122e390603abfacd548027016cd0113a6e2bf2f8ce6bdd3658b013456ea8"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"wit-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rust"
|
||||
version = "0.63.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84e26e13b9d972026778d2ffb7985736de116026fdc8d9464f966e12df2eb240"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"indexmap",
|
||||
"prettyplease",
|
||||
"syn",
|
||||
"wasm-metadata",
|
||||
"wit-bindgen-core",
|
||||
"wit-component",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rust-macro"
|
||||
version = "0.63.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16a008a0d6b4840677326beb4edbeb210a2f1b7d0183fb7cc33f466b90fd7fb6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"macro-string",
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wit-bindgen-core",
|
||||
"wit-bindgen-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-component"
|
||||
version = "0.262.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "078def49fdb49cab405c3006e05793b3fdaf7069126ba6b9c97d01ec8c98fe4c"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags",
|
||||
"indexmap",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"wasm-encoder",
|
||||
"wasm-metadata",
|
||||
"wasmparser",
|
||||
"wit-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-parser"
|
||||
version = "0.262.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00f0dc051466ffe46787721fca3d088536f158ae400be044f1b1c386ba9397ad"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hashbrown",
|
||||
"id-arena",
|
||||
"indexmap",
|
||||
"log",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"unicode-ident",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
||||
@@ -0,0 +1,20 @@
|
||||
[package]
|
||||
name = "openidea-test-code-semantics"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
|
||||
[workspace]
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
openidea-plugin = { path = "../../../../../sdk/rust/openidea-plugin" }
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
lto = true
|
||||
strip = true
|
||||
codegen-units = 1
|
||||
panic = "abort"
|
||||
Бінарний файл не відображається.
@@ -0,0 +1 @@
|
||||
6cc9d187059860197baef1f64b8368bfdd0462b8f7f3bd47370c01d438df8888
|
||||
@@ -0,0 +1,20 @@
|
||||
id = "test.code-semantics"
|
||||
name = "Code semantics query fixture"
|
||||
version = "0.1.0"
|
||||
engines.openidea = "^1.21"
|
||||
wasm = "dist/plugin.wasm"
|
||||
|
||||
[capabilities]
|
||||
optional = ["code.semantics"]
|
||||
|
||||
[[contributes.commands]]
|
||||
id = "definition"
|
||||
title = "Query LSP definition"
|
||||
|
||||
[[contributes.commands]]
|
||||
id = "hover"
|
||||
title = "Query LSP hover"
|
||||
|
||||
[[contributes.commands]]
|
||||
id = "symbols"
|
||||
title = "Query LSP symbols"
|
||||
@@ -0,0 +1,27 @@
|
||||
use openidea_plugin::{Error, Invocation, Plugin, Position, register_plugin};
|
||||
|
||||
#[derive(Default)]
|
||||
struct CodeSemanticsFixture;
|
||||
|
||||
impl Plugin for CodeSemanticsFixture {
|
||||
fn run_command(&mut self, id: &str, inv: &Invocation, arg: Option<&str>) -> Result<Option<String>, Error> {
|
||||
let project = inv.project().ok_or("no project")?;
|
||||
let path = arg.unwrap_or("main.txt");
|
||||
match id {
|
||||
"definition" => {
|
||||
let locs = project.lsp_definition(path, Position::new(0, 0))?;
|
||||
let joined = locs.into_iter().map(|l| l.path).collect::<Vec<_>>().join("\n");
|
||||
Ok(Some(joined))
|
||||
}
|
||||
"hover" => project.lsp_hover_info(path, Position::new(0, 0)),
|
||||
"symbols" => {
|
||||
let syms = project.lsp_document_symbols(path)?;
|
||||
let joined = syms.into_iter().map(|s| format!("{}:{}", s.kind, s.name)).collect::<Vec<_>>().join(",");
|
||||
Ok(Some(joined))
|
||||
}
|
||||
_ => Err(Error::NotFound(id.into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
register_plugin!(CodeSemanticsFixture);
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
53732d63101502159db8bdb18baaa7b5eac0320f55a89a465a4cf1c3afccd96f
|
||||
39af04aa3cf47e414669e039c8aa571ba5335b546c389d2224b7e5947690ce9a
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
4b836e4e99baca65e73cd1a68bf323da2cc3fdb3eb6172e9e5ae35364faeaca9
|
||||
c8875162912cc4d4c91f0effd8069adb64d5585f36d2dc7a5b212e60c075314d
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
bf6b3594bf78f7798954fef4cd9acd309212c1b203e3c7e7ce1cf15421b655a6
|
||||
58f25da10075ddab4c886900fbc2b0c1cd338f464cc805aae8323dc505cee44d
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
ffbf8d5976005f76511e6d471caa6763695700a1b0765c5ef60c01cbbee5d347
|
||||
6803ce4e5f293a0a7ced8c72b13257c9729a08526e38e6c4faada736be6f9abd
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
fe0239b2d570894616552522f27df6ac4125879c9688366c8a4d718d37008d75
|
||||
f1da9b0b2206a7a19b2ed7fa04476d61e453c4765186fe733ab7594d7594aafc
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
365f97a1fa032d24657a465912c0db9f0b3659e506ec2f58ef6ec7c11b900e6b
|
||||
d4e725c280bfcb9dda0558e6ce9addd65f60a4a1dd9fc857ba6f81888d240851
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
bf68db32b4f9484577cdf6ab16d94698fa3e136c2cff34c78f1ffe69f50a428d
|
||||
66296501aea185582803436aa8ba4a625cc44965fcbf5951a5b961010dfb9262
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
823dd4687f52b2571a7241fb8b174ef786311e3fccea8553d70b218a6d1a7dbb
|
||||
e84ecec0d12c0dbb557262e3e4765145ae7ad0dde9e9d530e863b289ad06634c
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
c8eff81ea2bd47cfec18a425d2f1c191d610f4b8c032e0d3cd11f25287078ea6
|
||||
b42ebe6310465b56cb253c72ed1b77da135c7939684c154a7988d5d00d66306e
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
82224337dcf127fc2737255e7ded92b947a4769f4f479d0150e1247e997d15d7
|
||||
874f87ee70c914df7cf498655361a6b52bf607b135c029ef936285827025b359
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
96fd2ca6113a96c758bdff5747f29769134a3e210288ef1eaef8cf35795b2c56
|
||||
d4dff8c1fa4afe3bc575b54928c8ccdedb38c2bc0f207b6b36a080df28384a46
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
44a640d1c2ec5cb39085c88da530be734bc3544e76fa9c79a25789cc8c5d5e07
|
||||
a9929bd830586ec85320878fd5cf112a72c4fcd930f00e0f586421bba29f8e96
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
9cc532dbad566e6218eb3578d2427e531ec70a129117aa2f218b4547b4ce000c
|
||||
7742a83fc21f256e4ef7ff2205be24d7bbde24037f478364e005704b1a9cc616
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
f486cbaaba81bf43163a0ff34353fe08fd8773c85a6b285ed6299419d855cb41
|
||||
62826712952fd60ab8081dfed0841900a17a318f52f274243c922fda78780517
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
1bf684559d69a9594d8b25326ed09218c3d9e05adbb68632d40116f099569da5
|
||||
ff5f5bbd6596080e104c5098578bf1d876b7b7301742147d54ed26904e8ba988
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
298aa04571533d304aadefd79ca91ed406d7685efab292316ccb53ce6a3f4e47
|
||||
0b07abade1a5098bdf7eeee18c98df3981ec667029172a689b1388051dfa933f
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
8e3cc0e487e4f4a3a39b1296c65cf30b89ade4662a6d5af01d3f40e21b71d5a2
|
||||
df0af998d38c09728bb139fdca00cf46660e9fefcec48168e472164a3c67e4be
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
0234f1e63ee51e288caecabff9d0254d50ef046c1f0733078772296a2b007c06
|
||||
9af489050903d0fe8b151813d8c28a268c92601f6d07884af144552ca3f7ec11
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
4fde3d9e6ed3fd7f691ef019413cee591bbfd1364ad086a972365a6e20691657
|
||||
dffa79751649825d160b9f1599c17b084dc83082af2fb4716bd380cf2a745018
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
3963bcfa5253985e0d29b605bd7ab8783d2bb0745d3054f3a8674028ab223c35
|
||||
8a6ecc0d2e9b5a31a2bc8302403c11077750ea315810c3e2d4de5731ea576322
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
ee7f86d202d987e19c11267249645b94f2b0a8a2a2958165355631426c9f6f0e
|
||||
080a96a84b2aaa52298feaefc456c0cff180d6cb7b7fd8dac2ac4140a0fa20e2
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
332d78159369759885d7d9ec95c61970d64ac316ba809cc62243afdd085f9b24
|
||||
f0950ef5b9be1059c6d7315a2fb0485aca5a3c02212007828eedeea13ad18377
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
18722731b1e75c3e9350986179a21eea1fd5b25a748a3421538b6498209155ba
|
||||
add34d6cd1bb2c8e0e2d9f91df5afd5222e29dd9c1d57980a934574399f709c1
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
adb2c1562146e76c4fad7c97853407429b9640e8bfaf8656ae2205b56c13b789
|
||||
3444458b098036925374d789e730c0f557ba1ef88d4e48f531ce0c4092f5a89d
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
3c4d901c3caeca9831a98047da7c3ae811209c4f742312b4593fda6598e1ecb0
|
||||
a0e5207f6ddea0bf57765661c9dc372851e32dc71b8ae47d081ea4eb6f5ff4dc
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
cd90d457045fe31c95c53b1d495a72d7251a4af073a36585f8d43d1c82209ebf
|
||||
619f2fedec1d6973d917112bf7501f18dc1db158185d5e2bba6ff5e53afd4bb6
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
7cfc47fe36fa70ddda9b70d38cbff9fe52ba98e09fda51f6b98b80c4180273df
|
||||
302fedc202adf071ccb4e5bb5a5bc76929c896b1f68094b74d0938d7aced22d1
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
94dc2e2018d832584799c6b692023a1dc8b33b4e24c5f61e1ed91ce829f219e0
|
||||
ca8dd0328b19c98e6118b80b1fd5d1ec4edc714f74893c6829b520c961c2ad7f
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
8ffb0e3ccde37d767d7c99349a414a95dd656a87cd00d4526ff7f56185c401c2
|
||||
5489d46adfc3cad99188e2c8dbc126482dacafcccfb431b520fa70f19f28b6e3
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
960a18aa2f8913a6b96599cc46518a4c683bb5e9550b1023f46012c7e3cec98f
|
||||
b9a6e26ae88733d931b66310e788574afef48e716679bb4900befa59fed689d9
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
13b73ae502c74db757120c3f0f769cbbb3a43162ad00449ba6d72454c1bffc96
|
||||
c79b0e6540aa5ab4d1f385f56d1bca35bef59eb95a691fb941bf6b50619fe837
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
70982fdc139e334402d27de03180228da7e36f72f4603a59c9304c4877e055fd
|
||||
52880aa2c31ebe11f386c1d4cc53b529e18fbced30eed3a28cdd5d83b8cf30b6
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
e303bba0abab46d7d680f91b158a25192b1d1da6478698610903dc1f28ac9954
|
||||
6a7cca3aeae4a5331a2cdcf3045de550546a7e330cfe2e8a6df409e9966440df
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
4c17c279f5b803d68b30c57850bc6976739a0678f9bb6b375bf90a5cff578d00
|
||||
0546d5739d7a45ccea533c94744584bc4cf30af840afb9e27c7ce98f8154e735
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
6c487c47bcd2bb2cf886f8c28bbf8e8e26f8a826d3fcc648c7fe167cb64d2a33
|
||||
9220a009246c6f2c9d9b45acc4a8adcd6e680d0315334835ab1177f82d28728c
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
5672153e721f9530eec3db01be7bfe799453799fed993248ae0146c4b3e95875
|
||||
2cde99d475ca6ea055310a9387570bcfd08e3d3daef3e1159d9c4c407067ec82
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
45902621b144087ad8e97a52d406582ddd3083439b7c397bb9da823c7acdc3d7
|
||||
ae476f64748cc94c30e71cad57e90f2dea1779444f5d8e16b9c0958d9bbd937c
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
4da7d3ebe349655d3c1df34624cd32e9017c1f79197c068a7f50a84c499a85c3
|
||||
e54c7d1076d41835b61422cd41443b18385bdadaeb30187c51738c202be7ed09
|
||||
@@ -382,6 +382,7 @@ machine. Users can revoke optional capabilities in Settings › Plugins.
|
||||
| `clipboard` | medium | `host::copy_to_clipboard` and the clipboard API in the plugin's web views |
|
||||
| `clipboard.read` | medium | API 1.11: `host::read_clipboard`, the clipboard's text and image, only in commands and view actions the user ran |
|
||||
| `agents` | medium | API 1.18: `host::fork_agent_session`, fork a recorded native agent session into a new task in the project; trusted projects only |
|
||||
| `code.semantics` | low | API 1.21: `Project::lsp_definition`, `lsp_type_definition`, `lsp_implementations`, `lsp_references`, `lsp_hover_info`, `lsp_document_symbols`; trusted projects only |
|
||||
|
||||
`process:` capabilities are also derived from what the contributions start: a
|
||||
language's `language-servers` and `debugger` commands and a run detector's
|
||||
@@ -459,6 +460,11 @@ matching SDK. Plugins for 1.20 and earlier keep working. New in 1.21:
|
||||
`[[contributes.providers]]` and implement `RenameProvider`
|
||||
(`register_plugin!(MyPlugin, rename)`) to participate in `prepare-rename` and
|
||||
cross-file `rename` edits (confined to writable project roots).
|
||||
- **Read-only code semantics (`code.semantics`).** In trusted projects,
|
||||
`Project::lsp_definition`, `lsp_type_definition`, `lsp_implementations`,
|
||||
`lsp_references` (capped by `limit`), `lsp_hover_info` and
|
||||
`lsp_document_symbols` ask the running language servers, also for read-only
|
||||
`jdt://` documents. Results outside the project's roots are dropped.
|
||||
|
||||
### API 1.19
|
||||
|
||||
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
745bc0cbcd17a2cd9121bd01c4836acfc396a2c216b497ceeb0b57d5ce3b3084
|
||||
c68d1160eba8e7ca653fcf65d965eb93cf001ef4327bf9f47b0c8c723e329830
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
0b47be4f36694bc97c8d1cdd74c97f480741140880379cd3c11bad05bbe2789b
|
||||
1a4f84f79d3ec75e6475a8ad5e16957880d3a79d2678482dd8999c33a00e04ce
|
||||
Бінарний файл не відображається.
Loaded 100 of 132 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Заблокувати користувача