-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'commandblock2-debug-context-provider' into preview
- Loading branch information
Showing
17 changed files
with
462 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { BaseContextProvider } from ".."; | ||
import { | ||
ContextItem, | ||
ContextProviderDescription, | ||
ContextProviderExtras, | ||
ContextSubmenuItem, | ||
LoadSubmenuItemsArgs, | ||
} from "../.."; | ||
|
||
class LocalsProvider extends BaseContextProvider { | ||
static description: ContextProviderDescription = { | ||
title: "locals", | ||
displayTitle: "Locals", | ||
description: "Reference the contents of the local variables", | ||
type: "submenu", | ||
}; | ||
|
||
async getContextItems( | ||
query: string, | ||
extras: ContextProviderExtras | ||
): Promise<ContextItem[]> { | ||
// Assuming that the query is a number | ||
const localVariables = await extras.ide.getDebugLocals(Number(query)); | ||
const threadIndex = Number(query); | ||
const thread = (await extras.ide.getAvailableThreads()).find( | ||
(thread) => thread.id == threadIndex | ||
); | ||
const callStacksSources = await extras.ide.getTopLevelCallStackSources( | ||
threadIndex, | ||
this.options?.stackDepth || 3 | ||
); | ||
const callStackContents = callStacksSources.reduce( | ||
(acc, source, index) => | ||
acc + `\n\ncall stack ${index}\n` + "```\n" + source + "\n```", | ||
"" | ||
); | ||
return [ | ||
{ | ||
description: "The value, name and possibly type of the local variables", | ||
content: | ||
`This is a paused thread: ${thread?.name}\n` + | ||
`Current local variable contents: \n${localVariables}.\n` + | ||
`Current top level call stacks: ${callStackContents}`, | ||
name: "Locals", | ||
}, | ||
]; | ||
} | ||
|
||
async loadSubmenuItems( | ||
args: LoadSubmenuItemsArgs | ||
): Promise<ContextSubmenuItem[]> { | ||
const threads = await args.ide.getAvailableThreads(); | ||
|
||
return threads.map((thread) => ({ | ||
id: `${thread.id}`, | ||
title: thread.name, | ||
description: `${thread.id}`, | ||
})); | ||
} | ||
} | ||
|
||
export default LocalsProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1043,6 +1043,7 @@ | |
"enum": [ | ||
"diff", | ||
"terminal", | ||
"locals", | ||
"open", | ||
"google", | ||
"search", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1043,6 +1043,7 @@ | |
"enum": [ | ||
"diff", | ||
"terminal", | ||
"locals", | ||
"open", | ||
"google", | ||
"search", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1043,6 +1043,7 @@ | |
"enum": [ | ||
"diff", | ||
"terminal", | ||
"locals", | ||
"open", | ||
"google", | ||
"search", | ||
|
Oops, something went wrong.