mirror of
https://github.com/latex-lsp/texlab.git
synced 2025-08-04 18:58:31 +00:00
Fix clippy warnings (#1113)
This commit is contained in:
parent
025242be9d
commit
fb78a16541
26 changed files with 86 additions and 139 deletions
|
@ -3,7 +3,7 @@ use std::time::Duration;
|
|||
use parser::SyntaxConfig;
|
||||
use regex::Regex;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Config {
|
||||
pub root_dir: Option<String>,
|
||||
pub build: BuildConfig,
|
||||
|
@ -36,7 +36,7 @@ pub struct DiagnosticsConfig {
|
|||
pub delay: Duration,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct ChktexConfig {
|
||||
pub on_open: bool,
|
||||
pub on_save: bool,
|
||||
|
@ -65,13 +65,13 @@ pub enum Formatter {
|
|||
LatexIndent,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct LatexIndentConfig {
|
||||
pub local: Option<String>,
|
||||
pub modify_line_breaks: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct SymbolConfig {
|
||||
pub allowed_patterns: Vec<Regex>,
|
||||
pub ignored_patterns: Vec<Regex>,
|
||||
|
@ -96,22 +96,6 @@ pub enum MatchingAlgo {
|
|||
PrefixIgnoreCase,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
root_dir: None,
|
||||
build: BuildConfig::default(),
|
||||
diagnostics: DiagnosticsConfig::default(),
|
||||
formatting: FormattingConfig::default(),
|
||||
synctex: None,
|
||||
symbols: SymbolConfig::default(),
|
||||
syntax: SyntaxConfig::default(),
|
||||
completion: CompletionConfig::default(),
|
||||
inlay_hints: InlayHintConfig::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for BuildConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
@ -141,17 +125,6 @@ impl Default for DiagnosticsConfig {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for ChktexConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
on_open: false,
|
||||
on_save: false,
|
||||
on_edit: false,
|
||||
additional_args: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for FormattingConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
@ -163,24 +136,6 @@ impl Default for FormattingConfig {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for LatexIndentConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
local: None,
|
||||
modify_line_breaks: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SymbolConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
allowed_patterns: Vec::new(),
|
||||
ignored_patterns: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for InlayHintConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
|
|
@ -22,7 +22,7 @@ pub struct Edge {
|
|||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
|
||||
pub enum EdgeData {
|
||||
DirectLink(DirectLinkData),
|
||||
DirectLink(Box<DirectLinkData>),
|
||||
AdditionalFiles,
|
||||
Artifact,
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ impl Graph {
|
|||
self.edges.push(Edge {
|
||||
source: start.source.uri.clone(),
|
||||
target: target.uri.clone(),
|
||||
data: EdgeData::DirectLink(link_data),
|
||||
data: EdgeData::DirectLink(Box::new(link_data)),
|
||||
});
|
||||
|
||||
break;
|
||||
|
|
|
@ -36,7 +36,7 @@ impl Semantics {
|
|||
Some(group)
|
||||
})?;
|
||||
|
||||
let text = group.content_text()?.replace('{', "").replace('}', "");
|
||||
let text = group.content_text()?.replace(['{', '}'], "");
|
||||
self.label_numbers.insert(name, text);
|
||||
Some(())
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ pub struct Options {
|
|||
impl Options {
|
||||
fn indent(&self) -> String {
|
||||
if self.insert_spaces {
|
||||
std::iter::repeat(' ').take(self.tab_size).collect()
|
||||
" ".repeat(self.tab_size)
|
||||
} else {
|
||||
String::from("\t")
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ impl<'a> Formatter<'a> {
|
|||
if length + current_length + space_length > self.options.line_length {
|
||||
self.output.push('\n');
|
||||
self.output.push_str(self.indent.as_ref());
|
||||
for _ in 0..=align - self.options.tab_size as usize {
|
||||
for _ in 0..=align - self.options.tab_size {
|
||||
self.output.push(' ');
|
||||
}
|
||||
length = align;
|
||||
|
|
|
@ -45,6 +45,6 @@ mod tests {
|
|||
&[('f', "foo")],
|
||||
);
|
||||
|
||||
assert_eq!(output, vec!["foo".into(), "%f", "%f".into(), "foobar"]);
|
||||
assert_eq!(output, vec!["foo", "%f", "%f", "foobar"]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ impl<'a, 'b> Processor<'a, 'b> {
|
|||
let data = CompletionItemData::Command(CommandData {
|
||||
name: &command.name,
|
||||
glyph: command.glyph.as_deref(),
|
||||
image: command.image.as_deref(),
|
||||
image: command.image,
|
||||
package: Some(package),
|
||||
});
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn complete_environments<'a>(
|
|||
.and_then(|env| env.begin())
|
||||
.and_then(|begin| begin.name())
|
||||
.and_then(|name| name.key())
|
||||
.map_or_else(|| String::new(), |name| name.to_string());
|
||||
.map_or_else(String::new, |name| name.to_string());
|
||||
|
||||
let mut proc = Processor {
|
||||
inner: ProviderContext {
|
||||
|
|
|
@ -58,7 +58,7 @@ impl<'a, 'b> Processor<'a, 'b> {
|
|||
for name in data
|
||||
.root_node()
|
||||
.descendants()
|
||||
.filter_map(|node| extract(node))
|
||||
.filter_map(&extract)
|
||||
.filter_map(|name| name.key())
|
||||
.map(|name| name.to_string())
|
||||
{
|
||||
|
|
|
@ -19,9 +19,7 @@ pub fn complete_includes<'a>(
|
|||
params: &'a CompletionParams<'a>,
|
||||
builder: &mut CompletionBuilder<'a>,
|
||||
) -> Option<()> {
|
||||
if params.feature.document.path.is_none() {
|
||||
return None;
|
||||
}
|
||||
params.feature.document.path.as_ref()?;
|
||||
|
||||
let (cursor, group) = find_curly_group_word_list(params)?;
|
||||
|
||||
|
|
|
@ -28,13 +28,11 @@ pub(super) fn goto_definition(context: &mut DefinitionContext) -> Option<()> {
|
|||
process_old_definition(node.clone()).or_else(|| process_new_definition(node))
|
||||
})
|
||||
.filter(|(_, command)| command.text() == name.text())
|
||||
.filter_map(|(target_range, command)| {
|
||||
Some(DefinitionResult {
|
||||
origin_selection_range,
|
||||
target: document,
|
||||
target_range,
|
||||
target_selection_range: command.text_range(),
|
||||
})
|
||||
.map(|(target_range, command)| DefinitionResult {
|
||||
origin_selection_range,
|
||||
target: document,
|
||||
target_range,
|
||||
target_selection_range: command.text_range(),
|
||||
});
|
||||
|
||||
context.results.extend(results);
|
||||
|
|
|
@ -11,7 +11,7 @@ fn check(input: &str) {
|
|||
.locations()
|
||||
.filter(|location| location.document == origin_document)
|
||||
.find(|location| location.range.contains_inclusive(offset))
|
||||
.map_or_else(|| TextRange::default(), |location| location.range);
|
||||
.map_or_else(TextRange::default, |location| location.range);
|
||||
|
||||
let mut expected = FxHashSet::default();
|
||||
for document in &fixture.documents {
|
||||
|
|
|
@ -74,7 +74,7 @@ impl Command {
|
|||
.build(stdout),
|
||||
);
|
||||
|
||||
for line in reader.lines().flatten() {
|
||||
for line in reader.lines().map_while(Result::ok) {
|
||||
let captures = LINE_REGEX.captures(&line).unwrap();
|
||||
let line = captures[1].parse::<u32>().unwrap() - 1;
|
||||
let character = captures[2].parse::<u32>().unwrap() - 1;
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn detect_undefined_citations<'a>(
|
|||
|
||||
for citation in &data.semantics.citations {
|
||||
let name = citation.name_text();
|
||||
if name != "*" && !entries.contains(name) && !name.contains("#") {
|
||||
if name != "*" && !entries.contains(name) && !name.contains('#') {
|
||||
let diagnostic = Diagnostic::Tex(citation.name.range, TexError::UndefinedCitation);
|
||||
results
|
||||
.entry(document.uri.clone())
|
||||
|
@ -65,8 +65,8 @@ pub fn detect_unused_entries<'a>(
|
|||
Some(())
|
||||
}
|
||||
|
||||
pub fn detect_duplicate_entries<'a>(
|
||||
workspace: &'a Workspace,
|
||||
pub fn detect_duplicate_entries(
|
||||
workspace: &Workspace,
|
||||
results: &mut FxHashMap<Url, Vec<Diagnostic>>,
|
||||
) {
|
||||
for conflict in queries::Conflict::find_all::<Entry>(workspace) {
|
||||
|
|
|
@ -89,13 +89,9 @@ impl Manager {
|
|||
|
||||
let config = &workspace.config().diagnostics;
|
||||
|
||||
results.retain(|uri, _| {
|
||||
workspace
|
||||
.lookup(uri)
|
||||
.map_or(false, |document| Self::is_relevant(document))
|
||||
});
|
||||
results.retain(|uri, _| workspace.lookup(uri).map_or(false, Self::is_relevant));
|
||||
|
||||
for (_, diagnostics) in &mut results {
|
||||
for diagnostics in results.values_mut() {
|
||||
diagnostics.retain(|diagnostic| {
|
||||
filter_regex_patterns(
|
||||
diagnostic.message(),
|
||||
|
|
|
@ -9,7 +9,6 @@ use crate::{InlayHint, InlayHintBuilder, InlayHintData};
|
|||
|
||||
pub(super) fn find_hints(builder: &mut InlayHintBuilder) -> Option<()> {
|
||||
let definitions = base_db::semantics::tex::Label::find_all(&builder.params.feature.project)
|
||||
.into_iter()
|
||||
.filter(|(_, label)| label.kind == LabelKind::Definition)
|
||||
.map(|(_, label)| (label.name_text(), label))
|
||||
.collect::<FxHashMap<_, _>>();
|
||||
|
|
|
@ -36,7 +36,7 @@ pub fn parse_build_log(log: &str) -> BuildLog {
|
|||
let warnings = extract_matches(&log, &ranges, &WARNING_REGEX, BuildErrorLevel::Warning);
|
||||
let bad_boxes = extract_matches(&log, &ranges, &BAD_BOX_REGEX, BuildErrorLevel::Warning);
|
||||
|
||||
let errors = vec![tex_errors, warnings, bad_boxes].concat();
|
||||
let errors = [tex_errors, warnings, bad_boxes].concat();
|
||||
BuildLog { errors }
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ mod v484 {
|
|||
let mut it = lines
|
||||
.skip_while(|line| !line.starts_with("Latexmk: Normalized aux dir and out dirs:"))
|
||||
.nth(1)?
|
||||
.split(",");
|
||||
.split(',');
|
||||
|
||||
let aux_dir = it.next()?.trim().strip_prefix('\'')?.strip_suffix('\'')?;
|
||||
|
||||
|
@ -133,7 +133,7 @@ pub fn parse_latexmkrc(input: &str, src_dir: &Path) -> std::io::Result<Latexmkrc
|
|||
.as_ref()
|
||||
.and_then(|line| Some((line.find("Version")?, line)))
|
||||
.and_then(|(i, line)| line[i..].trim_end().strip_prefix("Version "))
|
||||
.and_then(|text| versions::Versioning::new(text));
|
||||
.and_then(versions::Versioning::new);
|
||||
|
||||
let result = if version.map_or(false, |v| v >= versions::Versioning::new("4.84").unwrap()) {
|
||||
v484::parse_latexmkrc(input, src_dir)
|
||||
|
|
|
@ -32,7 +32,7 @@ pub(super) fn find_all(context: &mut ReferenceContext) -> Option<()> {
|
|||
.collect();
|
||||
|
||||
for command in &data.semantics.commands {
|
||||
if command.text == &token.text()[1..] {
|
||||
if command.text == token.text()[1..] {
|
||||
let kind = if defs.contains(command) {
|
||||
ReferenceKind::Definition
|
||||
} else {
|
||||
|
|
|
@ -19,7 +19,7 @@ pub(super) fn prepare_rename(params: &RenameParams) -> Option<Span> {
|
|||
))
|
||||
}
|
||||
|
||||
pub(super) fn rename<'a>(builder: &mut RenameBuilder) -> Option<()> {
|
||||
pub(super) fn rename(builder: &mut RenameBuilder) -> Option<()> {
|
||||
let name = prepare_rename(&builder.params)?;
|
||||
|
||||
for document in &builder.params.feature.project.documents {
|
||||
|
|
|
@ -30,7 +30,7 @@ pub(super) fn prepare_rename(params: &RenameParams) -> Option<Span> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn rename<'a>(builder: &mut RenameBuilder) -> Option<()> {
|
||||
pub(super) fn rename(builder: &mut RenameBuilder) -> Option<()> {
|
||||
let name = prepare_rename(&builder.params)?;
|
||||
|
||||
let project = &builder.params.feature.project;
|
||||
|
|
|
@ -29,7 +29,7 @@ pub fn prepare_rename(params: &RenameParams) -> Option<TextRange> {
|
|||
.map(|span| span.range)
|
||||
}
|
||||
|
||||
pub fn rename<'a>(params: RenameParams<'a>) -> RenameResult<'a> {
|
||||
pub fn rename(params: RenameParams) -> RenameResult {
|
||||
let result = RenameResult::default();
|
||||
let mut builder = RenameBuilder { params, result };
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ fn setup_logger(opts: &Opts) {
|
|||
OpenOptions::new()
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.open(log_file)
|
||||
.expect("failed to open log file"),
|
||||
),
|
||||
|
|
|
@ -46,7 +46,7 @@ use self::{
|
|||
#[derive(Debug)]
|
||||
enum InternalMessage {
|
||||
SetDistro(Distro),
|
||||
SetOptions(Options),
|
||||
SetOptions(Box<Options>),
|
||||
FileEvent(Vec<DebouncedEvent>),
|
||||
Diagnostics,
|
||||
ChktexFinished(Url, Vec<diagnostics::Diagnostic>),
|
||||
|
@ -309,7 +309,9 @@ impl Server {
|
|||
.parse_options(json.pop().expect("invalid configuration request"))
|
||||
.unwrap();
|
||||
|
||||
sender.send(InternalMessage::SetOptions(options)).unwrap();
|
||||
sender
|
||||
.send(InternalMessage::SetOptions(Box::new(options)))
|
||||
.unwrap();
|
||||
}
|
||||
Err(why) => {
|
||||
log::error!("Retrieving configuration failed: {}", why);
|
||||
|
@ -700,19 +702,19 @@ impl Server {
|
|||
|
||||
let status = if pending_builds.lock().remove(&pid) {
|
||||
if result?.success() {
|
||||
BuildStatus::SUCCESS
|
||||
BuildStatus::Success
|
||||
} else {
|
||||
BuildStatus::ERROR
|
||||
BuildStatus::Error
|
||||
}
|
||||
} else {
|
||||
BuildStatus::CANCELLED
|
||||
BuildStatus::Cancelled
|
||||
};
|
||||
|
||||
Ok(status)
|
||||
})
|
||||
.unwrap_or_else(|why| {
|
||||
log::error!("Failed to compile document \"{uri}\": {why}");
|
||||
BuildStatus::FAILURE
|
||||
BuildStatus::Failure
|
||||
});
|
||||
|
||||
drop(progress_reporter);
|
||||
|
@ -723,7 +725,7 @@ impl Server {
|
|||
let _ = client.send_response(lsp_server::Response::new_ok(id, result));
|
||||
}
|
||||
|
||||
if fwd_search_after && status != BuildStatus::CANCELLED {
|
||||
if fwd_search_after && status != BuildStatus::Cancelled {
|
||||
let _ = internal.send(InternalMessage::ForwardSearch(uri, params.position));
|
||||
}
|
||||
});
|
||||
|
@ -760,7 +762,7 @@ impl Server {
|
|||
|
||||
self.pool.execute(move || {
|
||||
let status = match command.and_then(ForwardSearch::run) {
|
||||
Ok(()) => ForwardSearchStatus::SUCCESS,
|
||||
Ok(()) => ForwardSearchStatus::Success,
|
||||
Err(why) => {
|
||||
log::error!("Failed to execute forward search: {why}");
|
||||
ForwardSearchStatus::from(why)
|
||||
|
@ -1071,7 +1073,7 @@ impl Server {
|
|||
self.workspace.write().set_distro(distro);
|
||||
}
|
||||
InternalMessage::SetOptions(options) => {
|
||||
self.update_options(options);
|
||||
self.update_options(*options);
|
||||
}
|
||||
InternalMessage::FileEvent(events) => {
|
||||
for event in events {
|
||||
|
|
|
@ -33,10 +33,10 @@ pub struct BuildResult {
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize_repr, Deserialize_repr)]
|
||||
#[repr(i32)]
|
||||
pub enum BuildStatus {
|
||||
SUCCESS = 0,
|
||||
ERROR = 1,
|
||||
FAILURE = 2,
|
||||
CANCELLED = 3,
|
||||
Success = 0,
|
||||
Error = 1,
|
||||
Failure = 2,
|
||||
Cancelled = 3,
|
||||
}
|
||||
|
||||
pub struct ForwardSearchRequest;
|
||||
|
@ -52,21 +52,21 @@ impl lsp_types::request::Request for ForwardSearchRequest {
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize_repr, Deserialize_repr)]
|
||||
#[repr(i32)]
|
||||
pub enum ForwardSearchStatus {
|
||||
SUCCESS = 0,
|
||||
ERROR = 1,
|
||||
FAILURE = 2,
|
||||
UNCONFIGURED = 3,
|
||||
Success = 0,
|
||||
Error = 1,
|
||||
Failure = 2,
|
||||
Unconfigured = 3,
|
||||
}
|
||||
|
||||
impl From<ForwardSearchError> for ForwardSearchStatus {
|
||||
fn from(why: ForwardSearchError) -> Self {
|
||||
match why {
|
||||
ForwardSearchError::Unconfigured => ForwardSearchStatus::UNCONFIGURED,
|
||||
ForwardSearchError::NotLocal(_) => ForwardSearchStatus::FAILURE,
|
||||
ForwardSearchError::InvalidPath(_) => ForwardSearchStatus::ERROR,
|
||||
ForwardSearchError::TexNotFound(_) => ForwardSearchStatus::FAILURE,
|
||||
ForwardSearchError::PdfNotFound(_) => ForwardSearchStatus::ERROR,
|
||||
ForwardSearchError::LaunchViewer(_) => ForwardSearchStatus::ERROR,
|
||||
ForwardSearchError::Unconfigured => ForwardSearchStatus::Unconfigured,
|
||||
ForwardSearchError::NotLocal(_) => ForwardSearchStatus::Failure,
|
||||
ForwardSearchError::InvalidPath(_) => ForwardSearchStatus::Error,
|
||||
ForwardSearchError::TexNotFound(_) => ForwardSearchStatus::Failure,
|
||||
ForwardSearchError::PdfNotFound(_) => ForwardSearchStatus::Error,
|
||||
ForwardSearchError::LaunchViewer(_) => ForwardSearchStatus::Error,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ pub fn normalize_uri(uri: &mut lsp_types::Url) {
|
|||
}
|
||||
|
||||
fn fix_drive_letter(text: &str) -> Option<String> {
|
||||
if !text.is_ascii() || text.len() == 0 {
|
||||
if !text.is_ascii() || text.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,20 +121,17 @@ pub fn client_flags(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn rename_params<'a>(
|
||||
workspace: &'a Workspace,
|
||||
pub fn rename_params(
|
||||
workspace: &Workspace,
|
||||
params: lsp_types::TextDocumentPositionParams,
|
||||
) -> Option<RenameParams<'a>> {
|
||||
) -> Option<RenameParams> {
|
||||
let (feature, offset) =
|
||||
feature_params_offset(workspace, params.text_document, params.position)?;
|
||||
|
||||
Some(RenameParams { feature, offset })
|
||||
}
|
||||
|
||||
pub fn hover_params<'a>(
|
||||
workspace: &'a Workspace,
|
||||
params: lsp_types::HoverParams,
|
||||
) -> Option<HoverParams<'a>> {
|
||||
pub fn hover_params(workspace: &Workspace, params: lsp_types::HoverParams) -> Option<HoverParams> {
|
||||
let (feature, offset) = feature_params_offset(
|
||||
workspace,
|
||||
params.text_document_position_params.text_document,
|
||||
|
@ -144,8 +141,8 @@ pub fn hover_params<'a>(
|
|||
Some(HoverParams { feature, offset })
|
||||
}
|
||||
|
||||
pub fn inlay_hint_params<'a>(
|
||||
workspace: &'a Workspace,
|
||||
pub fn inlay_hint_params(
|
||||
workspace: &Workspace,
|
||||
params: lsp_types::InlayHintParams,
|
||||
) -> Option<InlayHintParams> {
|
||||
let feature = feature_params(workspace, params.text_document)?;
|
||||
|
@ -153,10 +150,10 @@ pub fn inlay_hint_params<'a>(
|
|||
Some(InlayHintParams { feature, range })
|
||||
}
|
||||
|
||||
pub fn highlight_params<'a>(
|
||||
workspace: &'a Workspace,
|
||||
pub fn highlight_params(
|
||||
workspace: &Workspace,
|
||||
params: lsp_types::DocumentHighlightParams,
|
||||
) -> Option<HighlightParams<'a>> {
|
||||
) -> Option<HighlightParams<'_>> {
|
||||
let (feature, offset) = feature_params_offset(
|
||||
workspace,
|
||||
params.text_document_position_params.text_document,
|
||||
|
@ -166,10 +163,10 @@ pub fn highlight_params<'a>(
|
|||
Some(HighlightParams { feature, offset })
|
||||
}
|
||||
|
||||
pub fn definition_params<'a>(
|
||||
workspace: &'a Workspace,
|
||||
pub fn definition_params(
|
||||
workspace: &Workspace,
|
||||
params: lsp_types::GotoDefinitionParams,
|
||||
) -> Option<DefinitionParams<'a>> {
|
||||
) -> Option<DefinitionParams> {
|
||||
let (feature, offset) = feature_params_offset(
|
||||
workspace,
|
||||
params.text_document_position_params.text_document,
|
||||
|
@ -179,10 +176,10 @@ pub fn definition_params<'a>(
|
|||
Some(DefinitionParams { feature, offset })
|
||||
}
|
||||
|
||||
pub fn completion_params<'a>(
|
||||
workspace: &'a Workspace,
|
||||
pub fn completion_params(
|
||||
workspace: &Workspace,
|
||||
params: lsp_types::CompletionParams,
|
||||
) -> Option<CompletionParams<'a>> {
|
||||
) -> Option<CompletionParams> {
|
||||
let (feature, offset) = feature_params_offset(
|
||||
workspace,
|
||||
params.text_document_position.text_document,
|
||||
|
@ -192,10 +189,10 @@ pub fn completion_params<'a>(
|
|||
Some(CompletionParams { feature, offset })
|
||||
}
|
||||
|
||||
pub fn reference_params<'a>(
|
||||
workspace: &'a Workspace,
|
||||
pub fn reference_params(
|
||||
workspace: &Workspace,
|
||||
params: lsp_types::ReferenceParams,
|
||||
) -> Option<ReferenceParams<'a>> {
|
||||
) -> Option<ReferenceParams> {
|
||||
let (feature, offset) = feature_params_offset(
|
||||
workspace,
|
||||
params.text_document_position.text_document,
|
||||
|
@ -210,19 +207,19 @@ pub fn reference_params<'a>(
|
|||
})
|
||||
}
|
||||
|
||||
pub fn feature_params<'a>(
|
||||
workspace: &'a Workspace,
|
||||
pub fn feature_params(
|
||||
workspace: &Workspace,
|
||||
text_document: lsp_types::TextDocumentIdentifier,
|
||||
) -> Option<FeatureParams<'a>> {
|
||||
) -> Option<FeatureParams> {
|
||||
let document = workspace.lookup(&text_document.uri)?;
|
||||
Some(FeatureParams::new(workspace, document))
|
||||
}
|
||||
|
||||
pub fn feature_params_offset<'a>(
|
||||
workspace: &'a Workspace,
|
||||
pub fn feature_params_offset(
|
||||
workspace: &Workspace,
|
||||
text_document: lsp_types::TextDocumentIdentifier,
|
||||
position: lsp_types::Position,
|
||||
) -> Option<(FeatureParams<'a>, TextSize)> {
|
||||
) -> Option<(FeatureParams, TextSize)> {
|
||||
let feature = feature_params(workspace, text_document)?;
|
||||
let offset = feature.document.line_index.offset_lsp(position)?;
|
||||
Some((feature, offset))
|
||||
|
@ -236,7 +233,6 @@ pub fn completion_resolve_info(item: &mut lsp_types::CompletionItem) -> Option<R
|
|||
|
||||
pub fn config(value: Options) -> Config {
|
||||
let mut config = Config::default();
|
||||
config.root_dir = value.root_directory;
|
||||
|
||||
config.build.program = value.build.executable.unwrap_or(config.build.program);
|
||||
config.build.args = value.build.args.unwrap_or(config.build.args);
|
||||
|
@ -365,5 +361,7 @@ pub fn config(value: Options) -> Config {
|
|||
.label_reference_commands
|
||||
.extend(value.experimental.label_reference_commands);
|
||||
|
||||
config.root_dir = value.root_directory;
|
||||
|
||||
config
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue