Compare commits
2 Commits
main
...
nia/all-sh
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
748678b0cf | ||
|
|
c97fcf2e63 |
@@ -127,7 +127,7 @@ impl AgentThreadEntry {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn user_message(&self) -> Option<&UserMessage> {
|
||||
pub const fn user_message(&self) -> Option<&UserMessage> {
|
||||
if let AgentThreadEntry::UserMessage(message) = self {
|
||||
Some(message)
|
||||
} else {
|
||||
@@ -536,7 +536,7 @@ impl ContentBlock {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn markdown(&self) -> Option<&Entity<Markdown>> {
|
||||
pub const fn markdown(&self) -> Option<&Entity<Markdown>> {
|
||||
match self {
|
||||
ContentBlock::Empty => None,
|
||||
ContentBlock::Markdown { markdown } => Some(markdown),
|
||||
@@ -544,7 +544,7 @@ impl ContentBlock {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn resource_link(&self) -> Option<&acp::ResourceLink> {
|
||||
pub const fn resource_link(&self) -> Option<&acp::ResourceLink> {
|
||||
match self {
|
||||
ContentBlock::ResourceLink { resource_link } => Some(resource_link),
|
||||
_ => None,
|
||||
@@ -630,7 +630,7 @@ pub enum ToolCallUpdate {
|
||||
}
|
||||
|
||||
impl ToolCallUpdate {
|
||||
fn id(&self) -> &acp::ToolCallId {
|
||||
const fn id(&self) -> &acp::ToolCallId {
|
||||
match self {
|
||||
Self::UpdateFields(update) => &update.id,
|
||||
Self::UpdateDiff(diff) => &diff.id,
|
||||
@@ -682,7 +682,7 @@ pub struct PlanStats<'a> {
|
||||
}
|
||||
|
||||
impl Plan {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
pub const fn is_empty(&self) -> bool {
|
||||
self.entries.is_empty()
|
||||
}
|
||||
|
||||
@@ -1022,11 +1022,11 @@ impl AcpThread {
|
||||
&self.connection
|
||||
}
|
||||
|
||||
pub fn action_log(&self) -> &Entity<ActionLog> {
|
||||
pub const fn action_log(&self) -> &Entity<ActionLog> {
|
||||
&self.action_log
|
||||
}
|
||||
|
||||
pub fn project(&self) -> &Entity<Project> {
|
||||
pub const fn project(&self) -> &Entity<Project> {
|
||||
&self.project
|
||||
}
|
||||
|
||||
@@ -1038,11 +1038,11 @@ impl AcpThread {
|
||||
&self.entries
|
||||
}
|
||||
|
||||
pub fn session_id(&self) -> &acp::SessionId {
|
||||
pub const fn session_id(&self) -> &acp::SessionId {
|
||||
&self.session_id
|
||||
}
|
||||
|
||||
pub fn status(&self) -> ThreadStatus {
|
||||
pub const fn status(&self) -> ThreadStatus {
|
||||
if self.send_task.is_some() {
|
||||
ThreadStatus::Generating
|
||||
} else {
|
||||
@@ -1050,7 +1050,7 @@ impl AcpThread {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn token_usage(&self) -> Option<&TokenUsage> {
|
||||
pub const fn token_usage(&self) -> Option<&TokenUsage> {
|
||||
self.token_usage.as_ref()
|
||||
}
|
||||
|
||||
@@ -1533,7 +1533,7 @@ impl AcpThread {
|
||||
first_tool_call
|
||||
}
|
||||
|
||||
pub fn plan(&self) -> &Plan {
|
||||
pub const fn plan(&self) -> &Plan {
|
||||
&self.plan
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ pub struct AuthRequired {
|
||||
}
|
||||
|
||||
impl AuthRequired {
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
description: None,
|
||||
provider_id: None,
|
||||
|
||||
@@ -129,7 +129,7 @@ impl Diff {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn multibuffer(&self) -> &Entity<MultiBuffer> {
|
||||
pub const fn multibuffer(&self) -> &Entity<MultiBuffer> {
|
||||
match self {
|
||||
Self::Pending(PendingDiff { multibuffer, .. }) => multibuffer,
|
||||
Self::Finalized(FinalizedDiff { multibuffer, .. }) => multibuffer,
|
||||
|
||||
@@ -206,7 +206,7 @@ impl MentionUri {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_link<'a>(&'a self) -> MentionLink<'a> {
|
||||
pub const fn as_link<'a>(&'a self) -> MentionLink<'a> {
|
||||
MentionLink(self)
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ impl Terminal {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &acp::TerminalId {
|
||||
pub const fn id(&self) -> &acp::TerminalId {
|
||||
&self.id
|
||||
}
|
||||
|
||||
@@ -143,23 +143,23 @@ impl Terminal {
|
||||
(content, original_content_len)
|
||||
}
|
||||
|
||||
pub fn command(&self) -> &Entity<Markdown> {
|
||||
pub const fn command(&self) -> &Entity<Markdown> {
|
||||
&self.command
|
||||
}
|
||||
|
||||
pub fn working_dir(&self) -> &Option<PathBuf> {
|
||||
pub const fn working_dir(&self) -> &Option<PathBuf> {
|
||||
&self.working_dir
|
||||
}
|
||||
|
||||
pub fn started_at(&self) -> Instant {
|
||||
pub const fn started_at(&self) -> Instant {
|
||||
self.started_at
|
||||
}
|
||||
|
||||
pub fn output(&self) -> Option<&TerminalOutput> {
|
||||
pub const fn output(&self) -> Option<&TerminalOutput> {
|
||||
self.output.as_ref()
|
||||
}
|
||||
|
||||
pub fn inner(&self) -> &Entity<terminal::Terminal> {
|
||||
pub const fn inner(&self) -> &Entity<terminal::Terminal> {
|
||||
&self.terminal
|
||||
}
|
||||
|
||||
|
||||
@@ -531,7 +531,7 @@ pub struct AcpToolsToolbarItemView {
|
||||
}
|
||||
|
||||
impl AcpToolsToolbarItemView {
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
acp_tools: None,
|
||||
just_copied: false,
|
||||
|
||||
@@ -27,7 +27,7 @@ impl ActionLog {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn project(&self) -> &Entity<Project> {
|
||||
pub const fn project(&self) -> &Entity<Project> {
|
||||
&self.project
|
||||
}
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ impl NativeAgent {
|
||||
acp_thread
|
||||
}
|
||||
|
||||
pub fn models(&self) -> &LanguageModels {
|
||||
pub const fn models(&self) -> &LanguageModels {
|
||||
&self.models
|
||||
}
|
||||
|
||||
|
||||
@@ -747,14 +747,14 @@ enum IndentDelta {
|
||||
}
|
||||
|
||||
impl IndentDelta {
|
||||
fn character(&self) -> char {
|
||||
const fn character(&self) -> char {
|
||||
match self {
|
||||
IndentDelta::Spaces(_) => ' ',
|
||||
IndentDelta::Tabs(_) => '\t',
|
||||
}
|
||||
}
|
||||
|
||||
fn len(&self) -> isize {
|
||||
const fn len(&self) -> isize {
|
||||
match self {
|
||||
IndentDelta::Spaces(n) => *n,
|
||||
IndentDelta::Tabs(n) => *n,
|
||||
|
||||
@@ -27,7 +27,7 @@ enum ParserState {
|
||||
}
|
||||
|
||||
impl CreateFileParser {
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
CreateFileParser {
|
||||
state: ParserState::Pending,
|
||||
buffer: String::new(),
|
||||
|
||||
@@ -262,7 +262,7 @@ struct SearchState {
|
||||
}
|
||||
|
||||
impl SearchState {
|
||||
fn new(cost: u32, direction: SearchDirection) -> Self {
|
||||
const fn new(cost: u32, direction: SearchDirection) -> Self {
|
||||
Self { cost, direction }
|
||||
}
|
||||
}
|
||||
@@ -274,7 +274,7 @@ struct SearchMatrix {
|
||||
}
|
||||
|
||||
impl SearchMatrix {
|
||||
fn new(cols: usize) -> Self {
|
||||
const fn new(cols: usize) -> Self {
|
||||
SearchMatrix {
|
||||
cols,
|
||||
rows: 0,
|
||||
|
||||
@@ -54,7 +54,7 @@ pub enum HistoryEntry {
|
||||
}
|
||||
|
||||
impl HistoryEntry {
|
||||
pub fn updated_at(&self) -> DateTime<Utc> {
|
||||
pub const fn updated_at(&self) -> DateTime<Utc> {
|
||||
match self {
|
||||
HistoryEntry::AcpThread(thread) => thread.updated_at,
|
||||
HistoryEntry::TextThread(context) => context.mtime.to_utc(),
|
||||
@@ -253,7 +253,7 @@ impl HistoryStore {
|
||||
cx.notify()
|
||||
}
|
||||
|
||||
pub fn is_empty(&self, _cx: &App) -> bool {
|
||||
pub const fn is_empty(&self, _cx: &App) -> bool {
|
||||
self.entries.is_empty()
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ pub enum Message {
|
||||
}
|
||||
|
||||
impl Message {
|
||||
pub fn as_agent_message(&self) -> Option<&AgentMessage> {
|
||||
pub const fn as_agent_message(&self) -> Option<&AgentMessage> {
|
||||
match self {
|
||||
Message::Agent(agent_message) => Some(agent_message),
|
||||
_ => None,
|
||||
@@ -129,7 +129,7 @@ impl Message {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn role(&self) -> Role {
|
||||
pub const fn role(&self) -> Role {
|
||||
match self {
|
||||
Message::User(_) | Message::Resume => Role::User,
|
||||
Message::Agent(_) => Role::Assistant,
|
||||
@@ -672,7 +672,7 @@ impl Thread {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &acp::SessionId {
|
||||
pub const fn id(&self) -> &acp::SessionId {
|
||||
&self.id
|
||||
}
|
||||
|
||||
@@ -975,19 +975,19 @@ impl Thread {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn project_context(&self) -> &Entity<ProjectContext> {
|
||||
pub const fn project_context(&self) -> &Entity<ProjectContext> {
|
||||
&self.project_context
|
||||
}
|
||||
|
||||
pub fn project(&self) -> &Entity<Project> {
|
||||
pub const fn project(&self) -> &Entity<Project> {
|
||||
&self.project
|
||||
}
|
||||
|
||||
pub fn action_log(&self) -> &Entity<ActionLog> {
|
||||
pub const fn action_log(&self) -> &Entity<ActionLog> {
|
||||
&self.action_log
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
pub const fn is_empty(&self) -> bool {
|
||||
self.messages.is_empty() && self.title.is_none()
|
||||
}
|
||||
|
||||
@@ -1020,7 +1020,7 @@ impl Thread {
|
||||
cx.notify()
|
||||
}
|
||||
|
||||
pub fn completion_mode(&self) -> CompletionMode {
|
||||
pub const fn completion_mode(&self) -> CompletionMode {
|
||||
self.completion_mode
|
||||
}
|
||||
|
||||
@@ -1086,7 +1086,7 @@ impl Thread {
|
||||
self.tools.remove(name).is_some()
|
||||
}
|
||||
|
||||
pub fn profile(&self) -> &AgentProfileId {
|
||||
pub const fn profile(&self) -> &AgentProfileId {
|
||||
&self.profile_id
|
||||
}
|
||||
|
||||
@@ -1658,7 +1658,7 @@ impl Thread {
|
||||
self.title.clone().unwrap_or("New Thread".into())
|
||||
}
|
||||
|
||||
pub fn is_generating_summary(&self) -> bool {
|
||||
pub const fn is_generating_summary(&self) -> bool {
|
||||
self.pending_summary_generation.is_some()
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ struct ContextServerTool {
|
||||
}
|
||||
|
||||
impl ContextServerTool {
|
||||
fn new(
|
||||
const fn new(
|
||||
store: Entity<ContextServerStore>,
|
||||
server_id: ContextServerId,
|
||||
tool: context_server::types::Tool,
|
||||
|
||||
@@ -41,7 +41,7 @@ pub struct CopyPathTool {
|
||||
}
|
||||
|
||||
impl CopyPathTool {
|
||||
pub fn new(project: Entity<Project>) -> Self {
|
||||
pub const fn new(project: Entity<Project>) -> Self {
|
||||
Self { project }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ pub struct CreateDirectoryTool {
|
||||
}
|
||||
|
||||
impl CreateDirectoryTool {
|
||||
pub fn new(project: Entity<Project>) -> Self {
|
||||
pub const fn new(project: Entity<Project>) -> Self {
|
||||
Self { project }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ pub struct DeletePathTool {
|
||||
}
|
||||
|
||||
impl DeletePathTool {
|
||||
pub fn new(project: Entity<Project>, action_log: Entity<ActionLog>) -> Self {
|
||||
pub const fn new(project: Entity<Project>, action_log: Entity<ActionLog>) -> Self {
|
||||
Self {
|
||||
project,
|
||||
action_log,
|
||||
|
||||
@@ -54,7 +54,7 @@ pub struct DiagnosticsTool {
|
||||
}
|
||||
|
||||
impl DiagnosticsTool {
|
||||
pub fn new(project: Entity<Project>) -> Self {
|
||||
pub const fn new(project: Entity<Project>) -> Self {
|
||||
Self { project }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ pub struct EditFileTool {
|
||||
}
|
||||
|
||||
impl EditFileTool {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
project: Entity<Project>,
|
||||
thread: WeakEntity<Thread>,
|
||||
language_registry: Arc<LanguageRegistry>,
|
||||
|
||||
@@ -34,7 +34,7 @@ pub struct FetchTool {
|
||||
}
|
||||
|
||||
impl FetchTool {
|
||||
pub fn new(http_client: Arc<HttpClientWithUrl>) -> Self {
|
||||
pub const fn new(http_client: Arc<HttpClientWithUrl>) -> Self {
|
||||
Self { http_client }
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ pub struct FindPathTool {
|
||||
}
|
||||
|
||||
impl FindPathTool {
|
||||
pub fn new(project: Entity<Project>) -> Self {
|
||||
pub const fn new(project: Entity<Project>) -> Self {
|
||||
Self { project }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ pub struct GrepToolInput {
|
||||
|
||||
impl GrepToolInput {
|
||||
/// Which page of search results this is.
|
||||
pub fn page(&self) -> u32 {
|
||||
pub const fn page(&self) -> u32 {
|
||||
1 + (self.offset / RESULTS_PER_PAGE)
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ pub struct GrepTool {
|
||||
}
|
||||
|
||||
impl GrepTool {
|
||||
pub fn new(project: Entity<Project>) -> Self {
|
||||
pub const fn new(project: Entity<Project>) -> Self {
|
||||
Self { project }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ pub struct ListDirectoryTool {
|
||||
}
|
||||
|
||||
impl ListDirectoryTool {
|
||||
pub fn new(project: Entity<Project>) -> Self {
|
||||
pub const fn new(project: Entity<Project>) -> Self {
|
||||
Self { project }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ pub struct MovePathTool {
|
||||
}
|
||||
|
||||
impl MovePathTool {
|
||||
pub fn new(project: Entity<Project>) -> Self {
|
||||
pub const fn new(project: Entity<Project>) -> Self {
|
||||
Self { project }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ pub struct OpenTool {
|
||||
}
|
||||
|
||||
impl OpenTool {
|
||||
pub fn new(project: Entity<Project>) -> Self {
|
||||
pub const fn new(project: Entity<Project>) -> Self {
|
||||
Self { project }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ pub struct ReadFileTool {
|
||||
}
|
||||
|
||||
impl ReadFileTool {
|
||||
pub fn new(project: Entity<Project>, action_log: Entity<ActionLog>) -> Self {
|
||||
pub const fn new(project: Entity<Project>, action_log: Entity<ActionLog>) -> Self {
|
||||
Self {
|
||||
project,
|
||||
action_log,
|
||||
|
||||
@@ -197,7 +197,7 @@ impl AcpConnection {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn prompt_capabilities(&self) -> &acp::PromptCapabilities {
|
||||
pub const fn prompt_capabilities(&self) -> &acp::PromptCapabilities {
|
||||
&self.agent_capabilities.prompt_capabilities
|
||||
}
|
||||
|
||||
@@ -548,7 +548,7 @@ struct AcpModelSelector {
|
||||
}
|
||||
|
||||
impl AcpModelSelector {
|
||||
fn new(
|
||||
const fn new(
|
||||
session_id: acp::SessionId,
|
||||
connection: Rc<acp::ClientSideConnection>,
|
||||
state: Rc<RefCell<acp::SessionModelState>>,
|
||||
|
||||
@@ -34,7 +34,7 @@ pub struct AgentServerDelegate {
|
||||
}
|
||||
|
||||
impl AgentServerDelegate {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
store: Entity<AgentServerStore>,
|
||||
project: Entity<Project>,
|
||||
status_tx: Option<watch::Sender<SharedString>>,
|
||||
@@ -48,7 +48,7 @@ impl AgentServerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn project(&self) -> &Entity<Project> {
|
||||
pub const fn project(&self) -> &Entity<Project> {
|
||||
&self.project
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ pub struct CustomAgentServer {
|
||||
}
|
||||
|
||||
impl CustomAgentServer {
|
||||
pub fn new(name: SharedString) -> Self {
|
||||
pub const fn new(name: SharedString) -> Self {
|
||||
Self { name }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ pub struct AgentProfile {
|
||||
pub type AvailableProfiles = IndexMap<AgentProfileId, SharedString>;
|
||||
|
||||
impl AgentProfile {
|
||||
pub fn new(id: AgentProfileId) -> Self {
|
||||
pub const fn new(id: AgentProfileId) -> Self {
|
||||
Self { id }
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &AgentProfileId {
|
||||
pub const fn id(&self) -> &AgentProfileId {
|
||||
&self.id
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ impl AgentSettings {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn set_message_editor_max_lines(&self) -> usize {
|
||||
pub const fn set_message_editor_max_lines(&self) -> usize {
|
||||
self.message_editor_min_lines * 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ pub struct ContextPickerCompletionProvider {
|
||||
}
|
||||
|
||||
impl ContextPickerCompletionProvider {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
message_editor: WeakEntity<MessageEditor>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
history_store: Entity<HistoryStore>,
|
||||
|
||||
@@ -32,7 +32,7 @@ pub struct EntryViewState {
|
||||
}
|
||||
|
||||
impl EntryViewState {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
workspace: WeakEntity<Workspace>,
|
||||
project: Entity<Project>,
|
||||
history_store: Entity<HistoryStore>,
|
||||
@@ -272,7 +272,7 @@ impl Entry {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn message_editor(&self) -> Option<&Entity<MessageEditor>> {
|
||||
pub const fn message_editor(&self) -> Option<&Entity<MessageEditor>> {
|
||||
match self {
|
||||
Self::UserMessage(editor) => Some(editor),
|
||||
Self::AssistantMessage(_) | Self::Content(_) => None,
|
||||
@@ -306,7 +306,7 @@ impl Entry {
|
||||
}
|
||||
}
|
||||
|
||||
fn content_map(&self) -> Option<&HashMap<EntityId, AnyEntity>> {
|
||||
const fn content_map(&self) -> Option<&HashMap<EntityId, AnyEntity>> {
|
||||
match self {
|
||||
Self::Content(map) => Some(map),
|
||||
_ => None,
|
||||
|
||||
@@ -1561,7 +1561,7 @@ impl MentionSet {
|
||||
pub struct MessageEditorAddon {}
|
||||
|
||||
impl MessageEditorAddon {
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ impl AcpModelPickerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn active_model(&self) -> Option<&AgentModelInfo> {
|
||||
pub const fn active_model(&self) -> Option<&AgentModelInfo> {
|
||||
self.selected_model.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ enum ListItemType {
|
||||
}
|
||||
|
||||
impl ListItemType {
|
||||
fn history_entry(&self) -> Option<&HistoryEntry> {
|
||||
const fn history_entry(&self) -> Option<&HistoryEntry> {
|
||||
match self {
|
||||
ListItemType::Entry { entry, .. } => Some(entry),
|
||||
ListItemType::SearchResult { entry, .. } => Some(entry),
|
||||
@@ -540,7 +540,7 @@ impl AcpHistoryEntryElement {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hovered(mut self, hovered: bool) -> Self {
|
||||
pub const fn hovered(mut self, hovered: bool) -> Self {
|
||||
self.hovered = hovered;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -820,11 +820,11 @@ impl AcpThreadView {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn workspace(&self) -> &WeakEntity<Workspace> {
|
||||
pub const fn workspace(&self) -> &WeakEntity<Workspace> {
|
||||
&self.workspace
|
||||
}
|
||||
|
||||
pub fn thread(&self) -> Option<&Entity<AcpThread>> {
|
||||
pub const fn thread(&self) -> Option<&Entity<AcpThread>> {
|
||||
match &self.thread_state {
|
||||
ThreadState::Ready { thread, .. } => Some(thread),
|
||||
ThreadState::Unauthenticated { .. }
|
||||
@@ -833,7 +833,7 @@ impl AcpThreadView {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mode_selector(&self) -> Option<&Entity<ModeSelector>> {
|
||||
pub const fn mode_selector(&self) -> Option<&Entity<ModeSelector>> {
|
||||
match &self.thread_state {
|
||||
ThreadState::Ready { mode_selector, .. } => mode_selector.as_ref(),
|
||||
ThreadState::Unauthenticated { .. }
|
||||
|
||||
@@ -19,13 +19,13 @@ pub enum LlmCompatibleProvider {
|
||||
}
|
||||
|
||||
impl LlmCompatibleProvider {
|
||||
fn name(&self) -> &'static str {
|
||||
const fn name(&self) -> &'static str {
|
||||
match self {
|
||||
LlmCompatibleProvider::OpenAi => "OpenAI",
|
||||
}
|
||||
}
|
||||
|
||||
fn api_url(&self) -> &'static str {
|
||||
const fn api_url(&self) -> &'static str {
|
||||
match self {
|
||||
LlmCompatibleProvider::OpenAi => "https://api.openai.com/v1",
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ enum ConfigurationSource {
|
||||
}
|
||||
|
||||
impl ConfigurationSource {
|
||||
fn has_configuration_options(&self) -> bool {
|
||||
const fn has_configuration_options(&self) -> bool {
|
||||
!matches!(self, ConfigurationSource::Extension { editor: None, .. })
|
||||
}
|
||||
|
||||
fn is_new(&self) -> bool {
|
||||
const fn is_new(&self) -> bool {
|
||||
matches!(self, ConfigurationSource::New { .. })
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ impl AgentType {
|
||||
}
|
||||
}
|
||||
|
||||
fn icon(&self) -> Option<IconName> {
|
||||
const fn icon(&self) -> Option<IconName> {
|
||||
match self {
|
||||
Self::NativeAgent | Self::TextThread => None,
|
||||
Self::Gemini => Some(IconName::AiGemini),
|
||||
@@ -264,7 +264,7 @@ impl From<ExternalAgent> for AgentType {
|
||||
}
|
||||
|
||||
impl ActiveView {
|
||||
pub fn which_font_size_used(&self) -> WhichFontSize {
|
||||
pub const fn which_font_size_used(&self) -> WhichFontSize {
|
||||
match self {
|
||||
ActiveView::ExternalAgentThread { .. } | ActiveView::History => {
|
||||
WhichFontSize::AgentFont
|
||||
@@ -676,23 +676,23 @@ impl AgentPanel {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn prompt_store(&self) -> &Option<Entity<PromptStore>> {
|
||||
pub(crate) const fn prompt_store(&self) -> &Option<Entity<PromptStore>> {
|
||||
&self.prompt_store
|
||||
}
|
||||
|
||||
pub(crate) fn inline_assist_context_store(&self) -> &Entity<ContextStore> {
|
||||
pub(crate) const fn inline_assist_context_store(&self) -> &Entity<ContextStore> {
|
||||
&self.inline_assist_context_store
|
||||
}
|
||||
|
||||
pub(crate) fn thread_store(&self) -> &Entity<HistoryStore> {
|
||||
pub(crate) const fn thread_store(&self) -> &Entity<HistoryStore> {
|
||||
&self.history_store
|
||||
}
|
||||
|
||||
pub(crate) fn context_server_registry(&self) -> &Entity<ContextServerRegistry> {
|
||||
pub(crate) const fn context_server_registry(&self) -> &Entity<ContextServerRegistry> {
|
||||
&self.context_server_registry
|
||||
}
|
||||
|
||||
fn active_thread_view(&self) -> Option<&Entity<AcpThreadView>> {
|
||||
const fn active_thread_view(&self) -> Option<&Entity<AcpThreadView>> {
|
||||
match &self.active_view {
|
||||
ActiveView::ExternalAgentThread { thread_view, .. } => Some(thread_view),
|
||||
ActiveView::TextThread { .. } | ActiveView::History | ActiveView::Configuration => None,
|
||||
@@ -2484,7 +2484,7 @@ struct PromptLibraryInlineAssist {
|
||||
}
|
||||
|
||||
impl PromptLibraryInlineAssist {
|
||||
pub fn new(workspace: WeakEntity<Workspace>) -> Self {
|
||||
pub const fn new(workspace: WeakEntity<Workspace>) -> Self {
|
||||
Self { workspace }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ pub struct ManageProfiles {
|
||||
}
|
||||
|
||||
impl ManageProfiles {
|
||||
pub fn customize_tools(profile_id: AgentProfileId) -> Self {
|
||||
pub const fn customize_tools(profile_id: AgentProfileId) -> Self {
|
||||
Self {
|
||||
customize_tools: Some(profile_id),
|
||||
}
|
||||
|
||||
@@ -941,7 +941,7 @@ impl<T> StripInvalidSpans<T>
|
||||
where
|
||||
T: Stream<Item = Result<String>>,
|
||||
{
|
||||
fn new(stream: T) -> Self {
|
||||
const fn new(stream: T) -> Self {
|
||||
Self {
|
||||
stream,
|
||||
stream_done: false,
|
||||
@@ -1067,7 +1067,7 @@ pub struct Diff {
|
||||
}
|
||||
|
||||
impl Diff {
|
||||
fn is_empty(&self) -> bool {
|
||||
const fn is_empty(&self) -> bool {
|
||||
self.deleted_row_ranges.is_empty() && self.inserted_row_ranges.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ pub enum ContextKind {
|
||||
}
|
||||
|
||||
impl ContextKind {
|
||||
pub fn icon(&self) -> IconName {
|
||||
pub const fn icon(&self) -> IconName {
|
||||
match self {
|
||||
ContextKind::File => IconName::File,
|
||||
ContextKind::Directory => IconName::Folder,
|
||||
@@ -68,7 +68,7 @@ pub enum AgentContextHandle {
|
||||
}
|
||||
|
||||
impl AgentContextHandle {
|
||||
pub fn id(&self) -> ContextId {
|
||||
pub const fn id(&self) -> ContextId {
|
||||
match self {
|
||||
Self::File(context) => context.context_id,
|
||||
Self::Directory(context) => context.context_id,
|
||||
@@ -82,7 +82,7 @@ impl AgentContextHandle {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn element_id(&self, name: SharedString) -> ElementId {
|
||||
pub const fn element_id(&self, name: SharedString) -> ElementId {
|
||||
ElementId::NamedInteger(name, self.id().0)
|
||||
}
|
||||
}
|
||||
@@ -130,11 +130,11 @@ impl AgentContext {
|
||||
pub struct ContextId(u64);
|
||||
|
||||
impl ContextId {
|
||||
pub fn zero() -> Self {
|
||||
pub const fn zero() -> Self {
|
||||
ContextId(0)
|
||||
}
|
||||
|
||||
fn for_lookup() -> Self {
|
||||
const fn for_lookup() -> Self {
|
||||
ContextId(u64::MAX)
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ impl FetchedUrlContext {
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn load(self) -> Task<Option<AgentContext>> {
|
||||
pub const fn load(self) -> Task<Option<AgentContext>> {
|
||||
Task::ready(Some(AgentContext::FetchedUrl(self)))
|
||||
}
|
||||
}
|
||||
@@ -649,7 +649,7 @@ impl RulesContextHandle {
|
||||
self.prompt_id.hash(state)
|
||||
}
|
||||
|
||||
pub fn lookup_key(prompt_id: UserPromptId) -> AgentContextKey {
|
||||
pub const fn lookup_key(prompt_id: UserPromptId) -> AgentContextKey {
|
||||
AgentContextKey(AgentContextHandle::Rules(RulesContextHandle {
|
||||
prompt_id,
|
||||
context_id: ContextId::for_lookup(),
|
||||
|
||||
@@ -47,21 +47,21 @@ pub(crate) enum ContextPickerEntry {
|
||||
}
|
||||
|
||||
impl ContextPickerEntry {
|
||||
pub fn keyword(&self) -> &'static str {
|
||||
pub const fn keyword(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Mode(mode) => mode.keyword(),
|
||||
Self::Action(action) => action.keyword(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn label(&self) -> &'static str {
|
||||
pub const fn label(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Mode(mode) => mode.label(),
|
||||
Self::Action(action) => action.label(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn icon(&self) -> IconName {
|
||||
pub const fn icon(&self) -> IconName {
|
||||
match self {
|
||||
Self::Mode(mode) => mode.icon(),
|
||||
Self::Action(action) => action.icon(),
|
||||
@@ -84,19 +84,19 @@ pub(crate) enum ContextPickerAction {
|
||||
}
|
||||
|
||||
impl ContextPickerAction {
|
||||
pub fn keyword(&self) -> &'static str {
|
||||
pub const fn keyword(&self) -> &'static str {
|
||||
match self {
|
||||
Self::AddSelections => "selection",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn label(&self) -> &'static str {
|
||||
pub const fn label(&self) -> &'static str {
|
||||
match self {
|
||||
Self::AddSelections => "Selection",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn icon(&self) -> IconName {
|
||||
pub const fn icon(&self) -> IconName {
|
||||
match self {
|
||||
Self::AddSelections => IconName::Reader,
|
||||
}
|
||||
@@ -119,7 +119,7 @@ impl TryFrom<&str> for ContextPickerMode {
|
||||
}
|
||||
|
||||
impl ContextPickerMode {
|
||||
pub fn keyword(&self) -> &'static str {
|
||||
pub const fn keyword(&self) -> &'static str {
|
||||
match self {
|
||||
Self::File => "file",
|
||||
Self::Symbol => "symbol",
|
||||
@@ -129,7 +129,7 @@ impl ContextPickerMode {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn label(&self) -> &'static str {
|
||||
pub const fn label(&self) -> &'static str {
|
||||
match self {
|
||||
Self::File => "Files & Directories",
|
||||
Self::Symbol => "Symbols",
|
||||
@@ -139,7 +139,7 @@ impl ContextPickerMode {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn icon(&self) -> IconName {
|
||||
pub const fn icon(&self) -> IconName {
|
||||
match self {
|
||||
Self::File => IconName::File,
|
||||
Self::Symbol => IconName::Code,
|
||||
@@ -281,7 +281,7 @@ impl ContextPicker {
|
||||
}
|
||||
|
||||
/// Whether threads are allowed as context.
|
||||
pub fn allow_threads(&self) -> bool {
|
||||
pub const fn allow_threads(&self) -> bool {
|
||||
self.thread_store.is_some()
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ pub struct ContextPickerCompletionProvider {
|
||||
}
|
||||
|
||||
impl ContextPickerCompletionProvider {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
workspace: WeakEntity<Workspace>,
|
||||
context_store: WeakEntity<ContextStore>,
|
||||
thread_store: Option<WeakEntity<HistoryStore>>,
|
||||
|
||||
@@ -59,7 +59,7 @@ pub struct FetchContextPickerDelegate {
|
||||
}
|
||||
|
||||
impl FetchContextPickerDelegate {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
context_picker: WeakEntity<ContextPicker>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
context_store: WeakEntity<ContextStore>,
|
||||
|
||||
@@ -57,7 +57,7 @@ pub struct FileContextPickerDelegate {
|
||||
}
|
||||
|
||||
impl FileContextPickerDelegate {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
context_picker: WeakEntity<ContextPicker>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
context_store: WeakEntity<ContextStore>,
|
||||
|
||||
@@ -59,7 +59,7 @@ pub struct RulesContextPickerDelegate {
|
||||
}
|
||||
|
||||
impl RulesContextPickerDelegate {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
prompt_store: WeakEntity<PromptStore>,
|
||||
context_picker: WeakEntity<ContextPicker>,
|
||||
context_store: WeakEntity<context_store::ContextStore>,
|
||||
|
||||
@@ -59,7 +59,7 @@ pub struct SymbolContextPickerDelegate {
|
||||
}
|
||||
|
||||
impl SymbolContextPickerDelegate {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
context_picker: WeakEntity<ContextPicker>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
context_store: WeakEntity<ContextStore>,
|
||||
|
||||
@@ -59,7 +59,7 @@ pub struct ThreadContextPickerDelegate {
|
||||
}
|
||||
|
||||
impl ThreadContextPickerDelegate {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
thread_store: WeakEntity<HistoryStore>,
|
||||
context_picker: WeakEntity<ContextPicker>,
|
||||
context_store: WeakEntity<context_store::ContextStore>,
|
||||
|
||||
@@ -526,7 +526,7 @@ impl ContextStore {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn thread_ids(&self) -> &HashSet<acp::SessionId> {
|
||||
pub const fn thread_ids(&self) -> &HashSet<acp::SessionId> {
|
||||
&self.context_thread_ids
|
||||
}
|
||||
}
|
||||
@@ -549,7 +549,7 @@ pub enum SuggestedContext {
|
||||
}
|
||||
|
||||
impl SuggestedContext {
|
||||
pub fn name(&self) -> &SharedString {
|
||||
pub const fn name(&self) -> &SharedString {
|
||||
match self {
|
||||
Self::File { name, .. } => name,
|
||||
// Self::Thread { name, .. } => name,
|
||||
@@ -565,7 +565,7 @@ impl SuggestedContext {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn kind(&self) -> ContextKind {
|
||||
pub const fn kind(&self) -> ContextKind {
|
||||
match self {
|
||||
Self::File { .. } => ContextKind::File,
|
||||
// Self::Thread { .. } => ContextKind::Thread,
|
||||
|
||||
@@ -1618,7 +1618,7 @@ struct InlineAssistGroup {
|
||||
}
|
||||
|
||||
impl InlineAssistGroup {
|
||||
fn new() -> Self {
|
||||
const fn new() -> Self {
|
||||
Self {
|
||||
assist_ids: Vec::new(),
|
||||
linked: true,
|
||||
@@ -1642,7 +1642,7 @@ fn build_assist_editor_renderer(editor: &Entity<PromptEditor<BufferCodegen>>) ->
|
||||
struct InlineAssistGroupId(usize);
|
||||
|
||||
impl InlineAssistGroupId {
|
||||
fn post_inc(&mut self) -> InlineAssistGroupId {
|
||||
const fn post_inc(&mut self) -> InlineAssistGroupId {
|
||||
let id = *self;
|
||||
self.0 += 1;
|
||||
id
|
||||
|
||||
@@ -759,7 +759,7 @@ pub enum PromptEditorEvent {
|
||||
pub struct InlineAssistId(pub usize);
|
||||
|
||||
impl InlineAssistId {
|
||||
pub fn post_inc(&mut self) -> InlineAssistId {
|
||||
pub const fn post_inc(&mut self) -> InlineAssistId {
|
||||
let id = *self;
|
||||
self.0 += 1;
|
||||
id
|
||||
@@ -932,7 +932,7 @@ impl PromptEditor<BufferCodegen> {
|
||||
pub struct TerminalInlineAssistId(pub usize);
|
||||
|
||||
impl TerminalInlineAssistId {
|
||||
pub fn post_inc(&mut self) -> TerminalInlineAssistId {
|
||||
pub const fn post_inc(&mut self) -> TerminalInlineAssistId {
|
||||
let id = *self;
|
||||
self.0 += 1;
|
||||
id
|
||||
@@ -1135,27 +1135,27 @@ pub enum GenerationMode {
|
||||
}
|
||||
|
||||
impl GenerationMode {
|
||||
fn start_label(self) -> &'static str {
|
||||
const fn start_label(self) -> &'static str {
|
||||
match self {
|
||||
GenerationMode::Generate => "Generate",
|
||||
GenerationMode::Transform => "Transform",
|
||||
}
|
||||
}
|
||||
fn tooltip_interrupt(self) -> &'static str {
|
||||
const fn tooltip_interrupt(self) -> &'static str {
|
||||
match self {
|
||||
GenerationMode::Generate => "Interrupt Generation",
|
||||
GenerationMode::Transform => "Interrupt Transform",
|
||||
}
|
||||
}
|
||||
|
||||
fn tooltip_restart(self) -> &'static str {
|
||||
const fn tooltip_restart(self) -> &'static str {
|
||||
match self {
|
||||
GenerationMode::Generate => "Restart Generation",
|
||||
GenerationMode::Transform => "Restart Transform",
|
||||
}
|
||||
}
|
||||
|
||||
fn tooltip_accept(self) -> &'static str {
|
||||
const fn tooltip_accept(self) -> &'static str {
|
||||
match self {
|
||||
GenerationMode::Generate => "Accept Generation",
|
||||
GenerationMode::Transform => "Accept Transform",
|
||||
|
||||
@@ -56,7 +56,7 @@ where
|
||||
T: PopoverTrigger + ButtonCommon,
|
||||
TT: Fn(&mut Window, &mut App) -> AnyView + 'static,
|
||||
{
|
||||
pub(crate) fn new(
|
||||
pub(crate) const fn new(
|
||||
working_set: Arc<SlashCommandWorkingSet>,
|
||||
active_context_editor: WeakEntity<TextThreadEditor>,
|
||||
trigger: T,
|
||||
|
||||
@@ -21,7 +21,7 @@ pub struct TerminalCodegen {
|
||||
impl EventEmitter<CodegenEvent> for TerminalCodegen {}
|
||||
|
||||
impl TerminalCodegen {
|
||||
pub fn new(terminal: Entity<Terminal>, telemetry: Option<Arc<Telemetry>>) -> Self {
|
||||
pub const fn new(terminal: Entity<Terminal>, telemetry: Option<Arc<Telemetry>>) -> Self {
|
||||
Self {
|
||||
terminal,
|
||||
telemetry,
|
||||
@@ -171,7 +171,7 @@ struct TerminalTransaction {
|
||||
}
|
||||
|
||||
impl TerminalTransaction {
|
||||
pub fn start(terminal: Entity<Terminal>) -> Self {
|
||||
pub const fn start(terminal: Entity<Terminal>) -> Self {
|
||||
Self { terminal }
|
||||
}
|
||||
|
||||
|
||||
@@ -338,11 +338,11 @@ impl TextThreadEditor {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn context(&self) -> &Entity<AssistantContext> {
|
||||
pub const fn context(&self) -> &Entity<AssistantContext> {
|
||||
&self.context
|
||||
}
|
||||
|
||||
pub fn editor(&self) -> &Entity<Editor> {
|
||||
pub const fn editor(&self) -> &Entity<Editor> {
|
||||
&self.editor
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ pub struct BurnModeTooltip {
|
||||
}
|
||||
|
||||
impl BurnModeTooltip {
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
Self { selected: false }
|
||||
}
|
||||
|
||||
pub fn selected(mut self, selected: bool) -> Self {
|
||||
pub const fn selected(mut self, selected: bool) -> Self {
|
||||
self.selected = selected;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ pub struct UnavailableEditingTooltip {
|
||||
}
|
||||
|
||||
impl UnavailableEditingTooltip {
|
||||
pub fn new(agent_name: SharedString) -> Self {
|
||||
pub const fn new(agent_name: SharedString) -> Self {
|
||||
Self { agent_name }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ pub struct UsageCallout {
|
||||
}
|
||||
|
||||
impl UsageCallout {
|
||||
pub fn new(plan: Plan, usage: ModelRequestUsage) -> Self {
|
||||
pub const fn new(plan: Plan, usage: ModelRequestUsage) -> Self {
|
||||
Self { plan, usage }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ impl Render for ApiKeysWithProviders {
|
||||
pub struct ApiKeysWithoutProviders;
|
||||
|
||||
impl ApiKeysWithoutProviders {
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ impl AiUpsellCard {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tab_index(mut self, tab_index: Option<isize>) -> Self {
|
||||
pub const fn tab_index(mut self, tab_index: Option<isize>) -> Self {
|
||||
self.tab_index = tab_index;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ pub enum Model {
|
||||
}
|
||||
|
||||
impl Model {
|
||||
pub fn default_fast() -> Self {
|
||||
pub const fn default_fast() -> Self {
|
||||
Self::Claude3_5Haiku
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ impl Model {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn max_token_count(&self) -> u64 {
|
||||
pub const fn max_token_count(&self) -> u64 {
|
||||
match self {
|
||||
Self::ClaudeOpus4
|
||||
| Self::ClaudeOpus4_1
|
||||
|
||||
@@ -62,7 +62,7 @@ impl ContextId {
|
||||
Self(Uuid::new_v4().to_string())
|
||||
}
|
||||
|
||||
pub fn from_proto(id: String) -> Self {
|
||||
pub const fn from_proto(id: String) -> Self {
|
||||
Self(id)
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ impl ContextId {
|
||||
pub struct MessageId(pub clock::Lamport);
|
||||
|
||||
impl MessageId {
|
||||
pub fn as_u64(self) -> u64 {
|
||||
pub const fn as_u64(self) -> u64 {
|
||||
self.0.as_u64()
|
||||
}
|
||||
}
|
||||
@@ -505,14 +505,14 @@ impl ContextSummary {
|
||||
.map_or_else(|| message.into(), |content| content.text.clone().into())
|
||||
}
|
||||
|
||||
pub fn content(&self) -> Option<&ContextSummaryContent> {
|
||||
pub const fn content(&self) -> Option<&ContextSummaryContent> {
|
||||
match self {
|
||||
ContextSummary::Content(content) => Some(content),
|
||||
ContextSummary::Pending | ContextSummary::Error => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn content_as_mut(&mut self) -> Option<&mut ContextSummaryContent> {
|
||||
const fn content_as_mut(&mut self) -> Option<&mut ContextSummaryContent> {
|
||||
match self {
|
||||
ContextSummary::Content(content) => Some(content),
|
||||
ContextSummary::Pending | ContextSummary::Error => None,
|
||||
@@ -530,11 +530,11 @@ impl ContextSummary {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_pending(&self) -> bool {
|
||||
pub const fn is_pending(&self) -> bool {
|
||||
matches!(self, ContextSummary::Pending)
|
||||
}
|
||||
|
||||
fn timestamp(&self) -> Option<clock::Lamport> {
|
||||
const fn timestamp(&self) -> Option<clock::Lamport> {
|
||||
match self {
|
||||
ContextSummary::Content(content) => Some(content.timestamp),
|
||||
ContextSummary::Pending | ContextSummary::Error => None,
|
||||
@@ -636,7 +636,7 @@ pub enum Content {
|
||||
}
|
||||
|
||||
impl Content {
|
||||
fn range(&self) -> Range<language::Anchor> {
|
||||
const fn range(&self) -> Range<language::Anchor> {
|
||||
match self {
|
||||
Self::Image { anchor, .. } => *anchor..*anchor,
|
||||
}
|
||||
@@ -731,11 +731,11 @@ impl AssistantContext {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn completion_mode(&self) -> agent_settings::CompletionMode {
|
||||
pub const fn completion_mode(&self) -> agent_settings::CompletionMode {
|
||||
self.completion_mode
|
||||
}
|
||||
|
||||
pub fn set_completion_mode(&mut self, completion_mode: agent_settings::CompletionMode) {
|
||||
pub const fn set_completion_mode(&mut self, completion_mode: agent_settings::CompletionMode) {
|
||||
self.completion_mode = completion_mode;
|
||||
}
|
||||
|
||||
@@ -902,11 +902,11 @@ impl AssistantContext {
|
||||
this
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &ContextId {
|
||||
pub const fn id(&self) -> &ContextId {
|
||||
&self.id
|
||||
}
|
||||
|
||||
pub fn replica_id(&self) -> ReplicaId {
|
||||
pub const fn replica_id(&self) -> ReplicaId {
|
||||
self.timestamp.replica_id
|
||||
}
|
||||
|
||||
@@ -917,7 +917,7 @@ impl AssistantContext {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn slash_commands(&self) -> &Arc<SlashCommandWorkingSet> {
|
||||
pub const fn slash_commands(&self) -> &Arc<SlashCommandWorkingSet> {
|
||||
&self.slash_commands
|
||||
}
|
||||
|
||||
@@ -1165,7 +1165,7 @@ impl AssistantContext {
|
||||
cx.emit(ContextEvent::Operation(op));
|
||||
}
|
||||
|
||||
pub fn buffer(&self) -> &Entity<Buffer> {
|
||||
pub const fn buffer(&self) -> &Entity<Buffer> {
|
||||
&self.buffer
|
||||
}
|
||||
|
||||
@@ -1181,11 +1181,11 @@ impl AssistantContext {
|
||||
self.prompt_builder.clone()
|
||||
}
|
||||
|
||||
pub fn path(&self) -> Option<&Arc<Path>> {
|
||||
pub const fn path(&self) -> Option<&Arc<Path>> {
|
||||
self.path.as_ref()
|
||||
}
|
||||
|
||||
pub fn summary(&self) -> &ContextSummary {
|
||||
pub const fn summary(&self) -> &ContextSummary {
|
||||
&self.summary
|
||||
}
|
||||
|
||||
@@ -1258,7 +1258,7 @@ impl AssistantContext {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn token_count(&self) -> Option<u64> {
|
||||
pub const fn token_count(&self) -> Option<u64> {
|
||||
self.token_count
|
||||
}
|
||||
|
||||
@@ -3046,7 +3046,7 @@ pub enum PendingToolUseStatus {
|
||||
}
|
||||
|
||||
impl PendingToolUseStatus {
|
||||
pub fn is_idle(&self) -> bool {
|
||||
pub const fn is_idle(&self) -> bool {
|
||||
matches!(self, PendingToolUseStatus::Idle)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ impl From<bool> for AfterCompletion {
|
||||
}
|
||||
|
||||
impl AfterCompletion {
|
||||
pub fn run(&self) -> bool {
|
||||
pub const fn run(&self) -> bool {
|
||||
match self {
|
||||
AfterCompletion::Run => true,
|
||||
AfterCompletion::Compose | AfterCompletion::Continue => false,
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct ContextServerSlashCommand {
|
||||
}
|
||||
|
||||
impl ContextServerSlashCommand {
|
||||
pub fn new(store: Entity<ContextServerStore>, id: ContextServerId, prompt: Prompt) -> Self {
|
||||
pub const fn new(store: Entity<ContextServerStore>, id: ContextServerId, prompt: Prompt) -> Self {
|
||||
Self {
|
||||
server_id: id,
|
||||
prompt,
|
||||
@@ -242,7 +242,7 @@ fn prompt_arguments(prompt: &Prompt, arguments: &[String]) -> Result<HashMap<Str
|
||||
/// MCP servers can return prompts with multiple arguments. Since we only
|
||||
/// support one argument, we ignore all others. This is the necessary predicate
|
||||
/// for this.
|
||||
pub fn acceptable_prompt(prompt: &Prompt) -> bool {
|
||||
pub const fn acceptable_prompt(prompt: &Prompt) -> bool {
|
||||
match &prompt.arguments {
|
||||
None => true,
|
||||
Some(args) if args.len() <= 1 => true,
|
||||
|
||||
@@ -65,7 +65,7 @@ pub enum Sound {
|
||||
}
|
||||
|
||||
impl Sound {
|
||||
fn file(&self) -> &'static str {
|
||||
const fn file(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Joined => "joined_call",
|
||||
Self::GuestJoined => "guest_joined_call",
|
||||
|
||||
@@ -67,7 +67,7 @@ pub enum AutoUpdateStatus {
|
||||
}
|
||||
|
||||
impl AutoUpdateStatus {
|
||||
pub fn is_updated(&self) -> bool {
|
||||
pub const fn is_updated(&self) -> bool {
|
||||
matches!(self, Self::Updated { .. })
|
||||
}
|
||||
}
|
||||
@@ -371,7 +371,7 @@ impl AutoUpdater {
|
||||
}));
|
||||
}
|
||||
|
||||
pub fn current_version(&self) -> SemanticVersion {
|
||||
pub const fn current_version(&self) -> SemanticVersion {
|
||||
self.current_version
|
||||
}
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ impl Model {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn max_token_count(&self) -> u64 {
|
||||
pub const fn max_token_count(&self) -> u64 {
|
||||
match self {
|
||||
Self::Claude3_5SonnetV2
|
||||
| Self::Claude3Opus
|
||||
@@ -421,7 +421,7 @@ impl Model {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_tool_use(&self) -> bool {
|
||||
pub const fn supports_tool_use(&self) -> bool {
|
||||
match self {
|
||||
// Anthropic Claude 3 models (all support tool use)
|
||||
Self::Claude3Opus
|
||||
@@ -458,7 +458,7 @@ impl Model {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_caching(&self) -> bool {
|
||||
pub const fn supports_caching(&self) -> bool {
|
||||
match self {
|
||||
// Only Claude models on Bedrock support caching
|
||||
// Nova models support only text caching
|
||||
@@ -514,7 +514,7 @@ impl Model {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mode(&self) -> BedrockModelMode {
|
||||
pub const fn mode(&self) -> BedrockModelMode {
|
||||
match self {
|
||||
Model::Claude3_7SonnetThinking => BedrockModelMode::Thinking {
|
||||
budget_tokens: Some(4096),
|
||||
|
||||
@@ -284,7 +284,7 @@ impl BufferDiffSnapshot {
|
||||
self.inner.hunks_intersecting_range_rev(range, buffer)
|
||||
}
|
||||
|
||||
pub fn base_text(&self) -> &language::BufferSnapshot {
|
||||
pub const fn base_text(&self) -> &language::BufferSnapshot {
|
||||
&self.inner.base_text
|
||||
}
|
||||
|
||||
@@ -1098,11 +1098,11 @@ impl BufferDiff {
|
||||
changed_range
|
||||
}
|
||||
|
||||
pub fn base_text(&self) -> &language::BufferSnapshot {
|
||||
pub const fn base_text(&self) -> &language::BufferSnapshot {
|
||||
&self.inner.base_text
|
||||
}
|
||||
|
||||
pub fn base_text_exists(&self) -> bool {
|
||||
pub const fn base_text_exists(&self) -> bool {
|
||||
self.inner.base_text_exists
|
||||
}
|
||||
|
||||
@@ -1248,7 +1248,7 @@ impl DiffHunk {
|
||||
}
|
||||
|
||||
impl DiffHunkStatus {
|
||||
pub fn has_secondary_hunk(&self) -> bool {
|
||||
pub const fn has_secondary_hunk(&self) -> bool {
|
||||
matches!(
|
||||
self.secondary,
|
||||
DiffHunkSecondaryStatus::HasSecondaryHunk
|
||||
@@ -1257,7 +1257,7 @@ impl DiffHunkStatus {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn is_pending(&self) -> bool {
|
||||
pub const fn is_pending(&self) -> bool {
|
||||
matches!(
|
||||
self.secondary,
|
||||
DiffHunkSecondaryStatus::SecondaryHunkAdditionPending
|
||||
@@ -1277,42 +1277,42 @@ impl DiffHunkStatus {
|
||||
self.kind == DiffHunkStatusKind::Modified
|
||||
}
|
||||
|
||||
pub fn added(secondary: DiffHunkSecondaryStatus) -> Self {
|
||||
pub const fn added(secondary: DiffHunkSecondaryStatus) -> Self {
|
||||
Self {
|
||||
kind: DiffHunkStatusKind::Added,
|
||||
secondary,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn modified(secondary: DiffHunkSecondaryStatus) -> Self {
|
||||
pub const fn modified(secondary: DiffHunkSecondaryStatus) -> Self {
|
||||
Self {
|
||||
kind: DiffHunkStatusKind::Modified,
|
||||
secondary,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deleted(secondary: DiffHunkSecondaryStatus) -> Self {
|
||||
pub const fn deleted(secondary: DiffHunkSecondaryStatus) -> Self {
|
||||
Self {
|
||||
kind: DiffHunkStatusKind::Deleted,
|
||||
secondary,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deleted_none() -> Self {
|
||||
pub const fn deleted_none() -> Self {
|
||||
Self {
|
||||
kind: DiffHunkStatusKind::Deleted,
|
||||
secondary: DiffHunkSecondaryStatus::NoSecondaryHunk,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn added_none() -> Self {
|
||||
pub const fn added_none() -> Self {
|
||||
Self {
|
||||
kind: DiffHunkStatusKind::Added,
|
||||
secondary: DiffHunkSecondaryStatus::NoSecondaryHunk,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn modified_none() -> Self {
|
||||
pub const fn modified_none() -> Self {
|
||||
Self {
|
||||
kind: DiffHunkStatusKind::Modified,
|
||||
secondary: DiffHunkSecondaryStatus::NoSecondaryHunk,
|
||||
|
||||
@@ -404,7 +404,7 @@ impl ActiveCall {
|
||||
room.update(cx, |room, cx| room.unshare_project(project, cx))
|
||||
}
|
||||
|
||||
pub fn location(&self) -> Option<&WeakEntity<Project>> {
|
||||
pub const fn location(&self) -> Option<&WeakEntity<Project>> {
|
||||
self.location.as_ref()
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ impl ActiveCall {
|
||||
self.client.clone()
|
||||
}
|
||||
|
||||
pub fn pending_invites(&self) -> &HashSet<u64> {
|
||||
pub const fn pending_invites(&self) -> &HashSet<u64> {
|
||||
&self.pending_invites
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ pub struct LocalParticipant {
|
||||
}
|
||||
|
||||
impl LocalParticipant {
|
||||
pub fn can_write(&self) -> bool {
|
||||
pub const fn can_write(&self) -> bool {
|
||||
matches!(
|
||||
self.role,
|
||||
proto::ChannelRole::Admin | proto::ChannelRole::Member
|
||||
@@ -67,7 +67,7 @@ impl RemoteParticipant {
|
||||
!self.video_tracks.is_empty()
|
||||
}
|
||||
|
||||
pub fn can_write(&self) -> bool {
|
||||
pub const fn can_write(&self) -> bool {
|
||||
matches!(
|
||||
self.role,
|
||||
proto::ChannelRole::Admin | proto::ChannelRole::Member
|
||||
|
||||
@@ -92,7 +92,7 @@ pub struct Room {
|
||||
impl EventEmitter<Event> for Room {}
|
||||
|
||||
impl Room {
|
||||
pub fn channel_id(&self) -> Option<ChannelId> {
|
||||
pub const fn channel_id(&self) -> Option<ChannelId> {
|
||||
self.channel_id
|
||||
}
|
||||
|
||||
@@ -520,15 +520,15 @@ impl Room {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn id(&self) -> u64 {
|
||||
pub const fn id(&self) -> u64 {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn status(&self) -> RoomStatus {
|
||||
pub const fn status(&self) -> RoomStatus {
|
||||
self.status
|
||||
}
|
||||
|
||||
pub fn local_participant(&self) -> &LocalParticipant {
|
||||
pub const fn local_participant(&self) -> &LocalParticipant {
|
||||
&self.local_participant
|
||||
}
|
||||
|
||||
@@ -536,7 +536,7 @@ impl Room {
|
||||
self.user_store.read(cx).current_user()
|
||||
}
|
||||
|
||||
pub fn remote_participants(&self) -> &BTreeMap<u64, RemoteParticipant> {
|
||||
pub const fn remote_participants(&self) -> &BTreeMap<u64, RemoteParticipant> {
|
||||
&self.remote_participants
|
||||
}
|
||||
|
||||
@@ -1304,7 +1304,7 @@ impl Room {
|
||||
self.live_kit.as_ref().map(|live_kit| live_kit.deafened)
|
||||
}
|
||||
|
||||
pub fn can_use_microphone(&self) -> bool {
|
||||
pub const fn can_use_microphone(&self) -> bool {
|
||||
use proto::ChannelRole::*;
|
||||
|
||||
match self.local_participant.role {
|
||||
@@ -1313,7 +1313,7 @@ impl Room {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn can_share_projects(&self) -> bool {
|
||||
pub const fn can_share_projects(&self) -> bool {
|
||||
use proto::ChannelRole::*;
|
||||
match self.local_participant.role {
|
||||
Admin | Member => true,
|
||||
@@ -1708,11 +1708,11 @@ pub enum RoomStatus {
|
||||
}
|
||||
|
||||
impl RoomStatus {
|
||||
pub fn is_offline(&self) -> bool {
|
||||
pub const fn is_offline(&self) -> bool {
|
||||
matches!(self, RoomStatus::Offline)
|
||||
}
|
||||
|
||||
pub fn is_online(&self) -> bool {
|
||||
pub const fn is_online(&self) -> bool {
|
||||
matches!(self, RoomStatus::Online)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ impl ChannelBuffer {
|
||||
self.buffer.read(cx).remote_id()
|
||||
}
|
||||
|
||||
pub fn user_store(&self) -> &Entity<UserStore> {
|
||||
pub const fn user_store(&self) -> &Entity<UserStore> {
|
||||
&self.user_store
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ impl ChannelBuffer {
|
||||
}));
|
||||
}
|
||||
|
||||
pub fn epoch(&self) -> u64 {
|
||||
pub const fn epoch(&self) -> u64 {
|
||||
self.buffer_epoch
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ impl ChannelBuffer {
|
||||
self.buffer.clone()
|
||||
}
|
||||
|
||||
pub fn collaborators(&self) -> &HashMap<PeerId, Collaborator> {
|
||||
pub const fn collaborators(&self) -> &HashMap<PeerId, Collaborator> {
|
||||
&self.collaborators
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ impl ChannelBuffer {
|
||||
cx.notify()
|
||||
}
|
||||
|
||||
pub fn is_connected(&self) -> bool {
|
||||
pub const fn is_connected(&self) -> bool {
|
||||
self.connected
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ impl Channel {
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn is_root_channel(&self) -> bool {
|
||||
pub const fn is_root_channel(&self) -> bool {
|
||||
self.parent_path.is_empty()
|
||||
}
|
||||
|
||||
@@ -797,7 +797,7 @@ impl ChannelStore {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_pending_channel_invite_response(&self, _: &Arc<Channel>) -> bool {
|
||||
pub const fn has_pending_channel_invite_response(&self, _: &Arc<Channel>) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
@@ -1114,7 +1114,7 @@ impl ChannelStore {
|
||||
}
|
||||
|
||||
impl ChannelState {
|
||||
fn set_role(&mut self, role: ChannelRole) {
|
||||
const fn set_role(&mut self, role: ChannelRole) {
|
||||
self.role = Some(role);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ pub struct ChannelIndex {
|
||||
}
|
||||
|
||||
impl ChannelIndex {
|
||||
pub fn by_id(&self) -> &BTreeMap<ChannelId, Arc<Channel>> {
|
||||
pub const fn by_id(&self) -> &BTreeMap<ChannelId, Arc<Channel>> {
|
||||
&self.channels_by_id
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ impl ChannelIndex {
|
||||
.retain(|channel_id| !channels.contains(channel_id));
|
||||
}
|
||||
|
||||
pub fn bulk_insert(&mut self) -> ChannelPathsInsertGuard<'_> {
|
||||
pub const fn bulk_insert(&mut self) -> ChannelPathsInsertGuard<'_> {
|
||||
ChannelPathsInsertGuard {
|
||||
channels_ordered: &mut self.channels_ordered,
|
||||
channels_by_id: &mut self.channels_by_id,
|
||||
|
||||
@@ -283,11 +283,11 @@ pub enum Status {
|
||||
}
|
||||
|
||||
impl Status {
|
||||
pub fn is_connected(&self) -> bool {
|
||||
pub const fn is_connected(&self) -> bool {
|
||||
matches!(self, Self::Connected { .. })
|
||||
}
|
||||
|
||||
pub fn was_connected(&self) -> bool {
|
||||
pub const fn was_connected(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::ConnectionLost
|
||||
@@ -298,18 +298,18 @@ impl Status {
|
||||
}
|
||||
|
||||
/// Returns whether the client is currently connected or was connected at some point.
|
||||
pub fn is_or_was_connected(&self) -> bool {
|
||||
pub const fn is_or_was_connected(&self) -> bool {
|
||||
self.is_connected() || self.was_connected()
|
||||
}
|
||||
|
||||
pub fn is_signing_in(&self) -> bool {
|
||||
pub const fn is_signing_in(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::Authenticating | Self::Reauthenticating | Self::Connecting | Self::Reconnecting
|
||||
)
|
||||
}
|
||||
|
||||
pub fn is_signed_out(&self) -> bool {
|
||||
pub const fn is_signed_out(&self) -> bool {
|
||||
matches!(self, Self::SignedOut | Self::UpgradeRequired)
|
||||
}
|
||||
}
|
||||
@@ -1692,7 +1692,7 @@ impl Client {
|
||||
.ok();
|
||||
}
|
||||
|
||||
pub fn telemetry(&self) -> &Arc<Telemetry> {
|
||||
pub const fn telemetry(&self) -> &Arc<Telemetry> {
|
||||
&self.telemetry
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ impl std::fmt::Display for ChannelId {
|
||||
pub struct ProjectId(pub u64);
|
||||
|
||||
impl ProjectId {
|
||||
pub fn to_proto(self) -> u64 {
|
||||
pub const fn to_proto(self) -> u64 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
@@ -320,7 +320,7 @@ impl UserStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn invite_info(&self) -> Option<&InviteInfo> {
|
||||
pub const fn invite_info(&self) -> Option<&InviteInfo> {
|
||||
self.invite_info.as_ref()
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@ impl UserStore {
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn edit_prediction_usage(&self) -> Option<EditPredictionUsage> {
|
||||
pub const fn edit_prediction_usage(&self) -> Option<EditPredictionUsage> {
|
||||
self.edit_prediction_usage
|
||||
}
|
||||
|
||||
@@ -879,7 +879,7 @@ impl UserStore {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn participant_indices(&self) -> &HashMap<u64, ParticipantIndex> {
|
||||
pub const fn participant_indices(&self) -> &HashMap<u64, ParticipantIndex> {
|
||||
&self.participant_indices
|
||||
}
|
||||
|
||||
@@ -953,7 +953,7 @@ impl Collaborator {
|
||||
}
|
||||
|
||||
impl RequestUsage {
|
||||
pub fn over_limit(&self) -> bool {
|
||||
pub const fn over_limit(&self) -> bool {
|
||||
match self.limit {
|
||||
UsageLimit::Limited(limit) => self.amount >= limit,
|
||||
UsageLimit::Unlimited => false,
|
||||
|
||||
@@ -182,18 +182,18 @@ impl Lamport {
|
||||
value: Seq::MAX,
|
||||
};
|
||||
|
||||
pub fn new(replica_id: ReplicaId) -> Self {
|
||||
pub const fn new(replica_id: ReplicaId) -> Self {
|
||||
Self {
|
||||
value: 1,
|
||||
replica_id,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_u64(self) -> u64 {
|
||||
pub const fn as_u64(self) -> u64 {
|
||||
((self.value as u64) << 32) | (self.replica_id as u64)
|
||||
}
|
||||
|
||||
pub fn tick(&mut self) -> Self {
|
||||
pub const fn tick(&mut self) -> Self {
|
||||
let timestamp = *self;
|
||||
self.value += 1;
|
||||
timestamp
|
||||
|
||||
@@ -26,7 +26,7 @@ pub struct CloudApiClient {
|
||||
}
|
||||
|
||||
impl CloudApiClient {
|
||||
pub fn new(http_client: Arc<HttpClientWithUrl>) -> Self {
|
||||
pub const fn new(http_client: Arc<HttpClientWithUrl>) -> Self {
|
||||
Self {
|
||||
credentials: RwLock::new(None),
|
||||
http_client,
|
||||
|
||||
@@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
pub struct Timestamp(pub DateTime<Utc>);
|
||||
|
||||
impl Timestamp {
|
||||
pub fn new(datetime: DateTime<Utc>) -> Self {
|
||||
pub const fn new(datetime: DateTime<Utc>) -> Self {
|
||||
Self(datetime)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ pub enum Plan {
|
||||
}
|
||||
|
||||
impl Plan {
|
||||
pub fn is_v2(&self) -> bool {
|
||||
pub const fn is_v2(&self) -> bool {
|
||||
matches!(self, Self::V2(_))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,7 +625,7 @@ fn declaration_score_density(declaration: &ReferencedDeclaration, style: Declara
|
||||
declaration_score(declaration, style) / declaration_size(declaration, style) as f32
|
||||
}
|
||||
|
||||
fn declaration_score(declaration: &ReferencedDeclaration, style: DeclarationStyle) -> f32 {
|
||||
const fn declaration_score(declaration: &ReferencedDeclaration, style: DeclarationStyle) -> f32 {
|
||||
match style {
|
||||
DeclarationStyle::Signature => declaration.signature_score,
|
||||
DeclarationStyle::Declaration => declaration.declaration_score,
|
||||
|
||||
@@ -84,7 +84,7 @@ impl Database {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn options(&self) -> &ConnectOptions {
|
||||
pub const fn options(&self) -> &ConnectOptions {
|
||||
&self.options
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ pub enum Contact {
|
||||
}
|
||||
|
||||
impl Contact {
|
||||
pub fn user_id(&self) -> UserId {
|
||||
pub const fn user_id(&self) -> UserId {
|
||||
match self {
|
||||
Contact::Accepted { user_id, .. } => *user_id,
|
||||
Contact::Outgoing { user_id } => *user_id,
|
||||
@@ -675,7 +675,7 @@ pub struct ExtensionVersionConstraints {
|
||||
}
|
||||
|
||||
impl LocalSettingsKind {
|
||||
pub fn from_proto(proto_kind: proto::LocalSettingsKind) -> Self {
|
||||
pub const fn from_proto(proto_kind: proto::LocalSettingsKind) -> Self {
|
||||
match proto_kind {
|
||||
proto::LocalSettingsKind::Settings => Self::Settings,
|
||||
proto::LocalSettingsKind::Tasks => Self::Tasks,
|
||||
@@ -684,7 +684,7 @@ impl LocalSettingsKind {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_proto(self) -> proto::LocalSettingsKind {
|
||||
pub const fn to_proto(self) -> proto::LocalSettingsKind {
|
||||
match self {
|
||||
Self::Settings => proto::LocalSettingsKind::Settings,
|
||||
Self::Tasks => proto::LocalSettingsKind::Tasks,
|
||||
|
||||
@@ -38,7 +38,7 @@ macro_rules! id_type {
|
||||
|
||||
#[allow(unused)]
|
||||
#[allow(missing_docs)]
|
||||
pub fn to_proto(self) -> u64 {
|
||||
pub const fn to_proto(self) -> u64 {
|
||||
self.0 as u64
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ pub enum ChannelRole {
|
||||
|
||||
impl ChannelRole {
|
||||
/// Returns true if this role is more powerful than the other role.
|
||||
pub fn should_override(&self, other: Self) -> bool {
|
||||
pub const fn should_override(&self, other: Self) -> bool {
|
||||
use ChannelRole::*;
|
||||
match self {
|
||||
Admin => matches!(other, Member | Banned | Talker | Guest),
|
||||
@@ -132,7 +132,7 @@ impl ChannelRole {
|
||||
}
|
||||
|
||||
/// Returns the maximal role between the two
|
||||
pub fn max(&self, other: Self) -> Self {
|
||||
pub const fn max(&self, other: Self) -> Self {
|
||||
if self.should_override(other) {
|
||||
*self
|
||||
} else {
|
||||
@@ -150,7 +150,7 @@ impl ChannelRole {
|
||||
}
|
||||
|
||||
/// True if the role allows access to all descendant channels
|
||||
pub fn can_see_all_descendants(&self) -> bool {
|
||||
pub const fn can_see_all_descendants(&self) -> bool {
|
||||
use ChannelRole::*;
|
||||
match self {
|
||||
Admin | Member => true,
|
||||
@@ -159,7 +159,7 @@ impl ChannelRole {
|
||||
}
|
||||
|
||||
/// True if the role only allows access to public descendant channels
|
||||
pub fn can_only_see_public_descendants(&self) -> bool {
|
||||
pub const fn can_only_see_public_descendants(&self) -> bool {
|
||||
use ChannelRole::*;
|
||||
match self {
|
||||
Guest | Talker => true,
|
||||
@@ -168,7 +168,7 @@ impl ChannelRole {
|
||||
}
|
||||
|
||||
/// True if the role can share screen/microphone/projects into rooms.
|
||||
pub fn can_use_microphone(&self) -> bool {
|
||||
pub const fn can_use_microphone(&self) -> bool {
|
||||
use ChannelRole::*;
|
||||
match self {
|
||||
Admin | Member | Talker => true,
|
||||
@@ -177,7 +177,7 @@ impl ChannelRole {
|
||||
}
|
||||
|
||||
/// True if the role can edit shared projects.
|
||||
pub fn can_edit_projects(&self) -> bool {
|
||||
pub const fn can_edit_projects(&self) -> bool {
|
||||
use ChannelRole::*;
|
||||
match self {
|
||||
Admin | Member => true,
|
||||
@@ -186,7 +186,7 @@ impl ChannelRole {
|
||||
}
|
||||
|
||||
/// True if the role can read shared projects.
|
||||
pub fn can_read_projects(&self) -> bool {
|
||||
pub const fn can_read_projects(&self) -> bool {
|
||||
use ChannelRole::*;
|
||||
match self {
|
||||
Admin | Member | Guest | Talker => true,
|
||||
@@ -194,7 +194,7 @@ impl ChannelRole {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn requires_cla(&self) -> bool {
|
||||
pub const fn requires_cla(&self) -> bool {
|
||||
use ChannelRole::*;
|
||||
match self {
|
||||
Admin | Member => true,
|
||||
|
||||
@@ -469,7 +469,7 @@ fn metadata_from_extension_and_version(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn convert_time_to_chrono(time: time::PrimitiveDateTime) -> chrono::DateTime<Utc> {
|
||||
pub const fn convert_time_to_chrono(time: time::PrimitiveDateTime) -> chrono::DateTime<Utc> {
|
||||
chrono::DateTime::from_naive_utc_and_offset(
|
||||
#[allow(deprecated)]
|
||||
chrono::NaiveDateTime::from_timestamp_opt(time.assume_utc().unix_timestamp(), 0).unwrap(),
|
||||
|
||||
@@ -20,7 +20,7 @@ impl Model {
|
||||
self.ancestors().last()
|
||||
}
|
||||
|
||||
pub fn is_root(&self) -> bool {
|
||||
pub const fn is_root(&self) -> bool {
|
||||
self.parent_path.is_empty()
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ pub struct Model {
|
||||
}
|
||||
|
||||
impl Model {
|
||||
pub fn connection(&self) -> ConnectionId {
|
||||
pub const fn connection(&self) -> ConnectionId {
|
||||
ConnectionId {
|
||||
owner_id: self.connection_server_id.0 as u32,
|
||||
id: self.connection_id as u32,
|
||||
|
||||
@@ -14,7 +14,7 @@ pub struct Model {
|
||||
}
|
||||
|
||||
impl Model {
|
||||
pub fn connection(&self) -> ConnectionId {
|
||||
pub const fn connection(&self) -> ConnectionId {
|
||||
ConnectionId {
|
||||
owner_id: self.connection_server_id.0 as u32,
|
||||
id: self.connection_id as u32,
|
||||
|
||||
@@ -16,14 +16,14 @@ pub struct Model {
|
||||
}
|
||||
|
||||
impl Model {
|
||||
pub fn leader_connection(&self) -> ConnectionId {
|
||||
pub const fn leader_connection(&self) -> ConnectionId {
|
||||
ConnectionId {
|
||||
owner_id: self.leader_connection_server_id.0 as u32,
|
||||
id: self.leader_connection_id as u32,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn follower_connection(&self) -> ConnectionId {
|
||||
pub const fn follower_connection(&self) -> ConnectionId {
|
||||
ConnectionId {
|
||||
owner_id: self.follower_connection_server_id.0 as u32,
|
||||
id: self.follower_connection_id as u32,
|
||||
|
||||
@@ -18,7 +18,7 @@ pub struct Model {
|
||||
}
|
||||
|
||||
impl Model {
|
||||
pub fn connection(&self) -> ConnectionId {
|
||||
pub const fn connection(&self) -> ConnectionId {
|
||||
ConnectionId {
|
||||
owner_id: self.connection_server_id.0 as u32,
|
||||
id: self.connection_id as u32,
|
||||
|
||||
@@ -225,11 +225,11 @@ pub enum ServiceMode {
|
||||
}
|
||||
|
||||
impl ServiceMode {
|
||||
pub fn is_collab(&self) -> bool {
|
||||
pub const fn is_collab(&self) -> bool {
|
||||
matches!(self, Self::Collab | Self::All)
|
||||
}
|
||||
|
||||
pub fn is_api(&self) -> bool {
|
||||
pub const fn is_api(&self) -> bool {
|
||||
matches!(self, Self::Api | Self::All)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ impl LlmDatabase {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn options(&self) -> &ConnectOptions {
|
||||
pub const fn options(&self) -> &ConnectOptions {
|
||||
&self.options
|
||||
}
|
||||
|
||||
|
||||
@@ -224,14 +224,14 @@ impl Session {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_staff(&self) -> bool {
|
||||
const fn is_staff(&self) -> bool {
|
||||
match &self.principal {
|
||||
Principal::User(user) => user.admin,
|
||||
Principal::Impersonated { .. } => true,
|
||||
}
|
||||
}
|
||||
|
||||
fn user_id(&self) -> UserId {
|
||||
const fn user_id(&self) -> UserId {
|
||||
match &self.principal {
|
||||
Principal::User(user) => user.id,
|
||||
Principal::Impersonated { user, .. } => user.id,
|
||||
@@ -2809,7 +2809,7 @@ async fn remove_contact(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn should_auto_subscribe_to_channels(version: ZedVersion) -> bool {
|
||||
const fn should_auto_subscribe_to_channels(version: ZedVersion) -> bool {
|
||||
version.0.minor() < 139
|
||||
}
|
||||
|
||||
|
||||
@@ -1871,7 +1871,7 @@ impl CollabPanel {
|
||||
});
|
||||
}
|
||||
|
||||
fn start_move_channel(
|
||||
const fn start_move_channel(
|
||||
&mut self,
|
||||
channel_id: ChannelId,
|
||||
_window: &mut Window,
|
||||
|
||||
@@ -63,7 +63,7 @@ pub struct IncomingCallNotification {
|
||||
state: Arc<IncomingCallNotificationState>,
|
||||
}
|
||||
impl IncomingCallNotificationState {
|
||||
pub fn new(call: IncomingCall, app_state: Weak<AppState>) -> Self {
|
||||
pub const fn new(call: IncomingCall, app_state: Weak<AppState>) -> Self {
|
||||
Self { call, app_state }
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ pub struct ProjectSharedNotification {
|
||||
}
|
||||
|
||||
impl ProjectSharedNotification {
|
||||
fn new(
|
||||
const fn new(
|
||||
owner: Arc<User>,
|
||||
project_id: u64,
|
||||
worktree_root_names: Vec<String>,
|
||||
|
||||
@@ -283,7 +283,7 @@ pub enum ComponentStatus {
|
||||
}
|
||||
|
||||
impl ComponentStatus {
|
||||
pub fn description(&self) -> &str {
|
||||
pub const fn description(&self) -> &str {
|
||||
match self {
|
||||
ComponentStatus::WorkInProgress => {
|
||||
"These components are still being designed or refined. They shouldn't be used in the app yet."
|
||||
|
||||
@@ -83,7 +83,7 @@ impl ComponentExample {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn width(mut self, width: Pixels) -> Self {
|
||||
pub const fn width(mut self, width: Pixels) -> Self {
|
||||
self.width = Some(width);
|
||||
self
|
||||
}
|
||||
@@ -150,7 +150,7 @@ impl RenderOnce for ComponentExampleGroup {
|
||||
}
|
||||
|
||||
impl ComponentExampleGroup {
|
||||
pub fn new(examples: Vec<ComponentExample>) -> Self {
|
||||
pub const fn new(examples: Vec<ComponentExample>) -> Self {
|
||||
Self {
|
||||
title: None,
|
||||
examples,
|
||||
@@ -168,15 +168,15 @@ impl ComponentExampleGroup {
|
||||
vertical: false,
|
||||
}
|
||||
}
|
||||
pub fn width(mut self, width: Pixels) -> Self {
|
||||
pub const fn width(mut self, width: Pixels) -> Self {
|
||||
self.width = Some(width);
|
||||
self
|
||||
}
|
||||
pub fn grow(mut self) -> Self {
|
||||
pub const fn grow(mut self) -> Self {
|
||||
self.grow = true;
|
||||
self
|
||||
}
|
||||
pub fn vertical(mut self) -> Self {
|
||||
pub const fn vertical(mut self) -> Self {
|
||||
self.vertical = true;
|
||||
self
|
||||
}
|
||||
@@ -193,7 +193,7 @@ pub fn empty_example(variant_name: impl Into<SharedString>) -> ComponentExample
|
||||
ComponentExample::new(variant_name, div().w_full().text_center().items_center().text_xs().opacity(0.4).child("This space is intentionally left blank. It indicates a case that should render nothing.").into_any_element())
|
||||
}
|
||||
|
||||
pub fn example_group(examples: Vec<ComponentExample>) -> ComponentExampleGroup {
|
||||
pub const fn example_group(examples: Vec<ComponentExample>) -> ComponentExampleGroup {
|
||||
ComponentExampleGroup::new(examples)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ pub struct ModelContextProtocol {
|
||||
}
|
||||
|
||||
impl ModelContextProtocol {
|
||||
pub(crate) fn new(inner: Client) -> Self {
|
||||
pub(crate) const fn new(inner: Client) -> Self {
|
||||
Self { inner }
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ pub enum ServerCapability {
|
||||
|
||||
impl InitializedContextServerProtocol {
|
||||
/// Check if the server supports a specific capability
|
||||
pub fn capable(&self, capability: ServerCapability) -> bool {
|
||||
pub const fn capable(&self, capability: ServerCapability) -> bool {
|
||||
match capability {
|
||||
ServerCapability::Experimental => self.initialize.capabilities.experimental.is_some(),
|
||||
ServerCapability::Logging => self.initialize.capabilities.logging.is_some(),
|
||||
|
||||
@@ -660,7 +660,7 @@ pub enum CompletionTotal {
|
||||
}
|
||||
|
||||
impl CompletionTotal {
|
||||
pub fn from_options(has_more: Option<bool>, total: Option<u32>) -> Self {
|
||||
pub const fn from_options(has_more: Option<bool>, total: Option<u32>) -> Self {
|
||||
match (has_more, total) {
|
||||
(_, Some(count)) => CompletionTotal::Exact(count),
|
||||
(Some(true), _) => CompletionTotal::HasMore,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user