mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-11-03 13:13:18 +00:00 
			
		
		
		
	Merge #3774
3774: Simplify SemanticTokensBuilder build method r=matklad a=kjeremy This matches the next stable vscode api Co-authored-by: kjeremy <kjeremy@gmail.com>
This commit is contained in:
		
						commit
						159393745e
					
				@ -14,7 +14,7 @@ use lsp_types::{
 | 
				
			|||||||
    CodeAction, CodeActionResponse, CodeLens, Command, CompletionItem, Diagnostic,
 | 
					    CodeAction, CodeActionResponse, CodeLens, Command, CompletionItem, Diagnostic,
 | 
				
			||||||
    DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams,
 | 
					    DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams,
 | 
				
			||||||
    Hover, HoverContents, Location, MarkupContent, MarkupKind, Position, PrepareRenameResponse,
 | 
					    Hover, HoverContents, Location, MarkupContent, MarkupKind, Position, PrepareRenameResponse,
 | 
				
			||||||
    Range, RenameParams, SemanticTokens, SemanticTokensParams, SemanticTokensRangeParams,
 | 
					    Range, RenameParams, SemanticTokensParams, SemanticTokensRangeParams,
 | 
				
			||||||
    SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, TextDocumentIdentifier,
 | 
					    SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, TextDocumentIdentifier,
 | 
				
			||||||
    TextEdit, WorkspaceEdit,
 | 
					    TextEdit, WorkspaceEdit,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -1145,7 +1145,7 @@ pub fn handle_semantic_tokens(
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let tokens = SemanticTokens { data: builder.build(), ..Default::default() };
 | 
					    let tokens = builder.build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ok(Some(tokens.into()))
 | 
					    Ok(Some(tokens.into()))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1166,7 +1166,7 @@ pub fn handle_semantic_tokens_range(
 | 
				
			|||||||
        builder.push(highlight_range.range.conv_with(&line_index), token_type, token_modifiers);
 | 
					        builder.push(highlight_range.range.conv_with(&line_index), token_type, token_modifiers);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let tokens = SemanticTokens { data: builder.build(), ..Default::default() };
 | 
					    let tokens = builder.build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ok(Some(tokens.into()))
 | 
					    Ok(Some(tokens.into()))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use std::ops;
 | 
					use std::ops;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use lsp_types::{Range, SemanticToken, SemanticTokenModifier, SemanticTokenType};
 | 
					use lsp_types::{Range, SemanticToken, SemanticTokenModifier, SemanticTokenType, SemanticTokens};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub(crate) const ATTRIBUTE: SemanticTokenType = SemanticTokenType::new("attribute");
 | 
					pub(crate) const ATTRIBUTE: SemanticTokenType = SemanticTokenType::new("attribute");
 | 
				
			||||||
pub(crate) const BUILTIN_TYPE: SemanticTokenType = SemanticTokenType::new("builtinType");
 | 
					pub(crate) const BUILTIN_TYPE: SemanticTokenType = SemanticTokenType::new("builtinType");
 | 
				
			||||||
@ -109,8 +109,8 @@ impl SemanticTokensBuilder {
 | 
				
			|||||||
        self.prev_char = range.start.character as u32;
 | 
					        self.prev_char = range.start.character as u32;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn build(self) -> Vec<SemanticToken> {
 | 
					    pub fn build(self) -> SemanticTokens {
 | 
				
			||||||
        self.data
 | 
					        SemanticTokens { result_id: None, data: self.data }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user