Skip to content

Commit

Permalink
feat: the extension now indicates when its workig on a slice etc. - #97
Browse files Browse the repository at this point in the history
  • Loading branch information
allaboutmeme committed Nov 16, 2024
1 parent 8107516 commit f3833a1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { FlowrSession } from './flowr/utils'
import { selectionSlicer } from './selection-slicer'
import { positionSlicers } from './position-slicer'
import { flowrVersion } from '@eagleoutice/flowr-dev/util/version'
import { Session } from 'inspector/promises'

Check failure on line 11 in src/extension.ts

View workflow job for this annotation

GitHub Actions / test

'Session' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 11 in src/extension.ts

View workflow job for this annotation

GitHub Actions / lint

'Session' is defined but never used. Allowed unused vars must match /^_/u

export const MINIMUM_R_MAJOR = 3
export const BEST_R_MAJOR = 4
Expand Down Expand Up @@ -100,11 +101,17 @@ export function updateStatusBar() {
if(flowrSession.state === 'connected') {
tooltip.push(`R version ${flowrSession.rVersion} \nflowR version ${flowrSession.flowrVersion}`)
}
if (flowrSession.working){

Check failure on line 104 in src/extension.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected space(s) after "if"

Check failure on line 104 in src/extension.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected space(s) after "if"
text.push(`$(loading~spin) Analyzing`)

Check failure on line 105 in src/extension.ts

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

Check failure on line 105 in src/extension.ts

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
}
} else if(flowrSession instanceof FlowrInternalSession) {
text.push(`$(console) flowR ${flowrSession.state}`)
if(flowrSession.state === 'active') {
tooltip.push(`R version ${flowrSession.rVersion} \nflowR version ${flowrVersion().toString()}`)
}
if (flowrSession.working){

Check failure on line 112 in src/extension.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected space(s) after "if"

Check failure on line 112 in src/extension.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected space(s) after "if"
text.push(`$(loading~spin) Analyzing`)

Check failure on line 113 in src/extension.ts

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

Check failure on line 113 in src/extension.ts

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
}
}

const slicingTypes: string[] = []
Expand Down
27 changes: 23 additions & 4 deletions src/flowr/internal-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class FlowrInternalSession implements FlowrSession {

public state: 'inactive' | 'loading' | 'active' | 'failure'
public rVersion: string | undefined
public working: boolean = false

Check failure on line 20 in src/flowr/internal-session.ts

View workflow job for this annotation

GitHub Actions / test

Missing space before value for key 'working'

Check failure on line 20 in src/flowr/internal-session.ts

View workflow job for this annotation

GitHub Actions / lint

Missing space before value for key 'working'

private readonly outputChannel: vscode.OutputChannel
private shell: RShell | undefined
Expand All @@ -28,6 +29,11 @@ export class FlowrInternalSession implements FlowrSession {
updateStatusBar()
}

setWorking(working: boolean): void {
this.working = working
updateStatusBar()
}

async initialize() {
this.state = 'loading'
updateStatusBar()
Expand Down Expand Up @@ -91,7 +97,10 @@ export class FlowrInternalSession implements FlowrSession {
}
}
try {
return await this.extractSlice(this.shell, document, positions)
this.setWorking(true)
let result = await this.extractSlice(this.shell, document, positions)

Check failure on line 101 in src/flowr/internal-session.ts

View workflow job for this annotation

GitHub Actions / test

'result' is never reassigned. Use 'const' instead

Check failure on line 101 in src/flowr/internal-session.ts

View workflow job for this annotation

GitHub Actions / lint

'result' is never reassigned. Use 'const' instead
this.setWorking(false)
return result
} catch(e) {
this.outputChannel.appendLine('Error: ' + (e as Error)?.message);
(e as Error).stack?.split('\n').forEach(l => this.outputChannel.appendLine(l))
Expand All @@ -109,33 +118,43 @@ export class FlowrInternalSession implements FlowrSession {
if(!this.shell) {
return ''
}
this.setWorking(true)
const result = await new PipelineExecutor(DEFAULT_DATAFLOW_PIPELINE,{
shell: this.shell,
request: requestFromInput(consolidateNewlines(document.getText()))
}).allRemainingSteps()
return dataflowGraphToMermaid(result.dataflow)
let dataflow = dataflowGraphToMermaid(result.dataflow)

Check failure on line 126 in src/flowr/internal-session.ts

View workflow job for this annotation

GitHub Actions / test

'dataflow' is never reassigned. Use 'const' instead

Check failure on line 126 in src/flowr/internal-session.ts

View workflow job for this annotation

GitHub Actions / lint

'dataflow' is never reassigned. Use 'const' instead
this.setWorking(false)
return dataflow

}

async retrieveAstMermaid(document: vscode.TextDocument): Promise<string> {
if(!this.shell) {
return ''
}
this.setWorking(true)
const result = await new PipelineExecutor(DEFAULT_NORMALIZE_PIPELINE, {
shell: this.shell,
request: requestFromInput(consolidateNewlines(document.getText()))
}).allRemainingSteps()
return normalizedAstToMermaid(result.normalize.ast)
let ast = normalizedAstToMermaid(result.normalize.ast)

Check failure on line 141 in src/flowr/internal-session.ts

View workflow job for this annotation

GitHub Actions / test

'ast' is never reassigned. Use 'const' instead

Check failure on line 141 in src/flowr/internal-session.ts

View workflow job for this annotation

GitHub Actions / lint

'ast' is never reassigned. Use 'const' instead
this.setWorking(false)
return ast
}

async retrieveCfgMermaid(document: vscode.TextDocument): Promise<string> {
if(!this.shell) {
return ''
}
this.setWorking(true)
const result = await new PipelineExecutor(DEFAULT_NORMALIZE_PIPELINE, {
shell: this.shell,
request: requestFromInput(consolidateNewlines(document.getText()))
}).allRemainingSteps()
return cfgToMermaid(extractCFG(result.normalize), result.normalize)
let cfg = cfgToMermaid(extractCFG(result.normalize), result.normalize)

Check failure on line 155 in src/flowr/internal-session.ts

View workflow job for this annotation

GitHub Actions / test

'cfg' is never reassigned. Use 'const' instead

Check failure on line 155 in src/flowr/internal-session.ts

View workflow job for this annotation

GitHub Actions / lint

'cfg' is never reassigned. Use 'const' instead
this.setWorking(false)
return cfg
}

private async extractSlice(shell: RShell, document: vscode.TextDocument, positions: vscode.Position[]): Promise<SliceReturn> {
Expand Down
7 changes: 7 additions & 0 deletions src/flowr/server-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class FlowrServerSession implements FlowrSession {
public state: 'inactive' | 'connecting' | 'connected' | 'not connected'
public flowrVersion: string | undefined
public rVersion: string | undefined
public working: boolean = false

private readonly outputChannel: vscode.OutputChannel
private connection: Connection | undefined
Expand Down Expand Up @@ -122,6 +123,8 @@ export class FlowrServerSession implements FlowrSession {
}
this.onceOnLineReceived?.(message)
this.onceOnLineReceived = undefined
this.working = false
updateStatusBar()
}

private onceOnLineReceived: undefined | ((line: string) => void)
Expand All @@ -138,6 +141,8 @@ export class FlowrServerSession implements FlowrSession {
}

async sendCommandWithResponse<Target>(command: FlowrMessage): Promise<Target> {
this.working = true
updateStatusBar()
const response = this.awaitResponse()
this.sendCommand(command)
return JSON.parse(await response) as Target
Expand Down Expand Up @@ -174,6 +179,8 @@ export class FlowrServerSession implements FlowrSession {
async retrieveSlice(positions: vscode.Position[], document: vscode.TextDocument): Promise<SliceReturn> {
const criteria = makeSlicingCriteria(positions, document, isVerbose())



const response = await this.requestFileAnalysis(document)
// now we want to collect all ids from response in a map again (id -> location)
const idToLocation = new Map<NodeId, SourceRange>()
Expand Down

0 comments on commit f3833a1

Please sign in to comment.