Skip to content

Commit

Permalink
Tracing (#226)
Browse files Browse the repository at this point in the history
* bump api

* tracing (wip)

* wip

* mostly working

* small fixes

* wip

* try to fix profile converter
  • Loading branch information
marcellourbani authored Oct 24, 2024
1 parent ca4c26f commit 47fff9f
Show file tree
Hide file tree
Showing 20 changed files with 501 additions and 34 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"address": "localhost",
"smartStep": true,
"showAsyncStacks": true,
"restart": true,
"skipFiles": [
"<node_internals>/**"
],
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [1.7.14] 2024-10-23

### Added

- display performance traces

## [1.7.12] 2024-09-23

### Fixed
Expand Down
105 changes: 90 additions & 15 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"tmp-promise": "^3.0.3",
"tough-cookie": "^4.1.2",
"uuid": "^9.0.0",
"v8-inspect-profiler": "^0.1.0",
"vscode-abap-remote-fs-sharedapi": "file:../modules/sharedapi",
"vscode-debugadapter": "^1.51.0",
"vscode-debugprotocol": "^1.51.0",
Expand Down
1 change: 0 additions & 1 deletion client/src/adt/classhierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ export class ClassHierarchyLensProvider implements CodeLensProvider {
public async provideCodeLenses(doc: TextDocument, token: CancellationToken): Promise<CodeLens[]> {
const lenses: CodeLens[] = []
if (doc.uri.scheme !== ADTSCHEME) return lenses
const client = getClient(doc.uri.authority)
const obj = await findAbapObject(doc.uri)
if (!obj) return lenses
// TODO stat?
Expand Down
4 changes: 2 additions & 2 deletions client/src/adt/operations/AdtObjectFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ export function createUri(connId: string, path: string, query: string = "") {
})
}

export function findAbapObject(uri: Uri) {
const file = uriRoot(uri).getNode(uri.path)
export async function findAbapObject(uri: Uri) {
const file = await uriRoot(uri).getNodeAsync(uri.path)
if (isAbapStat(file)) return file.object
throw new Error("Not an ABAP object")
}
Expand Down
25 changes: 19 additions & 6 deletions client/src/commands/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import {
Uri,
window,
commands,
ProgressLocation
ProgressLocation,
Position,
Range
} from "vscode"
import { pickAdtRoot, RemoteManager } from "../config"
import { caughtToString, log } from "../lib"
import { caughtToString, lineRange, log, splitAdtUri } from "../lib"
import { FavouritesProvider, FavItem } from "../views/favourites"
import { findEditor } from "../langClient"
import { findEditor, vsCodeUri } from "../langClient"
import { showHideActivate } from "../listeners"
import { UnitTestRunner } from "../adt/operations/UnitTestRunner"
import { selectTransport } from "../adt/AdtTransports"
Expand Down Expand Up @@ -80,7 +82,10 @@ export function openObject(connId: string, uri: string) {
}
)
}

interface ShowObjectArgument {
connId: string,
uri: string
}
export class AdtCommands {
@command(AbapFsCommands.showDocumentation)
private static async showAbapDoc() {
Expand Down Expand Up @@ -152,7 +157,7 @@ export class AdtCommands {
await window.withProgress(
{ location: ProgressLocation.Window, title: "Activating..." },
async () => {
const obj = findAbapObject(uri)
const obj = await findAbapObject(uri)
// if editor is dirty, save before activate
if (editor && editor.document.isDirty) {
const saved = await editor.document.save()
Expand Down Expand Up @@ -247,7 +252,15 @@ export class AdtCommands {
return window.showErrorMessage(caughtToString(e))
}
}

@command(AbapFsCommands.showObject)
private static async showObject(arg: ShowObjectArgument) {
const p = splitAdtUri(arg.uri)
const path = await vsCodeUri(arg.connId, arg.uri, true, true)
const uri = Uri.parse(path)
const doc = await workspace.openTextDocument(uri)
const selection = p.start?.line ? lineRange(p.start?.line + 1) : undefined
window.showTextDocument(doc, { selection })
}
@command(AbapFsCommands.runInGui)
private static async executeAbap() {
try {
Expand Down
5 changes: 4 additions & 1 deletion client/src/commands/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export const AbapFsCommands = {
agitAdd: "abapfs.addAbapGit",
agitRemove: "abapfs.removeAbapGit",
agitresetPwd: "abapfs.resetAbapGitPwd",
agitBranch: "abapfs.switchBranch"
agitBranch: "abapfs.switchBranch",
//traces
refreshTraces: "abapfs.refreshTraces",
deleteTrace: "abapfs.deleteTrace",
}

export const abapcmds: {
Expand Down
2 changes: 2 additions & 0 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { HttpProvider } from "./editors/httpprovider"
import { dumpProvider } from "./views/dumps/dumps"
import { registerAbapDebugger } from "./adt/debugger"
import { ATCDocumentation } from "./views/abaptestcockpit/documentation"
import { tracesProvider } from "./views/traces"

export let context: ExtensionContext

Expand Down Expand Up @@ -72,6 +73,7 @@ export async function activate(ctx: ExtensionContext): Promise<AbapFsApi> {
sub.push(window.registerTreeDataProvider("abapfs.abapgit", abapGitProvider))
sub.push(window.registerTreeDataProvider("abapfs.dumps", dumpProvider))
sub.push(window.registerTreeDataProvider("abapfs.atcFinds", atcProvider))
sub.push(window.registerTreeDataProvider("abapfs.traces", tracesProvider))
sub.push(
languages.registerCodeLensProvider(
{ language: "abap", scheme: ADTSCHEME },
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/abaptestcockpit/view.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ADTClient, AtcWorkList } from "abap-adt-api"
import { AtcWorkList } from "abap-adt-api"
import { Task } from "fp-ts/lib/Task"
import { commands, Disposable, EventEmitter, Position, TextDocumentContentChangeEvent, ThemeColor, ThemeIcon, TreeDataProvider, TreeItem, TreeItemCollapsibleState, Uri, window } from "vscode"
import { getClient } from "../../adt/conections"
Expand Down
4 changes: 2 additions & 2 deletions client/src/views/dumps/dumps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dump, Feed } from "abap-adt-api"
import { EventEmitter, Range, TreeDataProvider, TreeItem, TreeItemCollapsibleState, Uri, ViewColumn, window, workspace } from "vscode"
import { getClient, getOrCreateClient } from "../../adt/conections"
import { EventEmitter, TreeDataProvider, TreeItem, TreeItemCollapsibleState, ViewColumn, window } from "vscode"
import { getOrCreateClient } from "../../adt/conections"
import { AdtObjectFinder } from "../../adt/operations/AdtObjectFinder"
import { AbapFsCommands, command } from "../../commands"
import { connectedRoots } from "../../config"
Expand Down
33 changes: 33 additions & 0 deletions client/src/views/traces/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Command, Uri, commands } from "vscode"
import { AbapFsCommands, command } from "../../commands"
import { TraceRunItem, TraceView, tracesProvider } from "./views"
import { adtProfileUri } from "./fsProvider"
import { getOrCreateClient } from "../../adt/conections"


export class Commands {

@command(AbapFsCommands.refreshTraces)
private async openTrace(view: TraceView) {
if (view.contextValue === "configfolder" || view.contextValue === "runfolder" || view.contextValue === "system")
tracesProvider.emitter.fire(view)
}

@command(AbapFsCommands.deleteTrace)
private async deleteTraces(item: TraceView) {
if (item.contextValue === "run") {
const client = await getOrCreateClient(item.connId)
await client.tracesDelete(item.run.id)
tracesProvider.emitter.fire(tracesProvider.root(item.connId)?.runs)
}
if (item.contextValue === "configuration") {
const client = await getOrCreateClient(item.connId)
await client.tracesDeleteConfiguration(item.config.id)
tracesProvider.emitter.fire(tracesProvider.root(item.connId)?.configs)
}

}

}

export const openCommand = (uri: Uri): Command => ({ title: "Open", command: "vscode.open", arguments: [uri] })
Loading

0 comments on commit 47fff9f

Please sign in to comment.