Skip to content

Commit

Permalink
fix(codefactor): resolve codefactor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Paraskos committed Aug 6, 2023
1 parent ba90aea commit 5972275
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 113 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ This is a Language Server extension for [fountain](https://fountain.io/) files.
* The statistics panel uses [d3](https://d3js.org/), covered by the [BSD-3-Clause License](https://github.com/d3/d3/blob/master/LICENSE).

* The project was built using Microsoft's language server example extension as a boilerplate.

20 changes: 10 additions & 10 deletions client/src/FountainPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class FountainPanel {

// Update the content based on view changes
this._panel.onDidChangeViewState(
e => {
() => {
if (this._panel.visible) {
return this._update();
}
Expand All @@ -98,7 +98,7 @@ export class FountainPanel {
);

this.setUri(uri);
})
});
}

public updateSceneStats(uri: string, stats: unknown) {
Expand All @@ -123,30 +123,30 @@ export class FountainPanel {
this._panel.webview.postMessage({ command: 'opened', uri });
}

private async handleOpenLink(message: any) {
console.log("handleOpenLink")
private async handleOpenLink(message: {link: string}) {
console.log("handleOpenLink");
const link = URI.parse(message.link);
const line = link.fragment ? (+link.fragment.substring(1)) - 1 : 0;
const candidates = await vscode.workspace.findFiles(link.path);
const absolutePath = Utils.joinPath(vscode.workspace.workspaceFolders[0].uri, link.path);
if(candidates.length > 0) {
const doc = await vscode.workspace.openTextDocument(candidates[0])
const doc = await vscode.workspace.openTextDocument(candidates[0]);
const editor = await vscode.window.showTextDocument(doc, {});
editor.revealRange(new vscode.Range(line, 0, line, 0), vscode.TextEditorRevealType.InCenterIfOutsideViewport);
} else {
if (link.query.includes('create')) {
console.log("create")
console.log("create");
try {
await vscode.workspace.fs.writeFile(absolutePath, new Uint8Array([20,20,20]))
const doc = await vscode.workspace.openTextDocument(absolutePath)
await vscode.workspace.fs.writeFile(absolutePath, new Uint8Array([20,20,20]));
const doc = await vscode.workspace.openTextDocument(absolutePath);
const editor = await vscode.window.showTextDocument(doc, {});
editor.revealRange(new vscode.Range(line, 0, line, 0), vscode.TextEditorRevealType.InCenterIfOutsideViewport);
} catch (e) {
console.log(`create failed ${e}`)
console.log(`create failed ${e}`);
await vscode.window.showErrorMessage(`Could not create ${absolutePath}, ${e}`);
}
} else {
console.log("nocreate")
console.log("nocreate");
await vscode.window.showErrorMessage(`Could not find ${link}`);
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function activate(context: ExtensionContext) {
if (vscode.window.registerWebviewPanelSerializer) {
// Make sure we register a serializer in activation event
vscode.window.registerWebviewPanelSerializer(FountainPanel.viewType, {
async deserializeWebviewPanel(webviewPanel: vscode.WebviewPanel, state: any) {
async deserializeWebviewPanel(webviewPanel: vscode.WebviewPanel, state: Record<string, unknown> & {uri: string}) {
console.log(`Got state: ${state}`);
// Reset the webview options so we use latest uri for `localResourceRoots`.
webviewPanel.webview.options = FountainPanel.getWebviewOptions(context.extensionUri);
Expand Down
3 changes: 0 additions & 3 deletions client/src/webview.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import * as vscode from 'vscode';
import { readFile } from 'fs/promises';
import { join, basename } from 'path';
import { LanguageClient, RequestType } from 'vscode-languageclient/node';
import { URI, Utils } from 'vscode-uri';
import { FountainPanel } from './FountainPanel';

export async function updateLocationStats(panel: FountainPanel, client: LanguageClient, uri: string) {
Expand Down
1 change: 1 addition & 0 deletions sample/.fountainrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 0 additions & 1 deletion server/src/parser/types/FountainElement.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Position } from 'vscode-languageserver';
import { logger } from '../../logger';
import { positionInRange, tokensToRange } from '../../util/range';
import { FountainToken } from "./FountainTokenType";

Expand Down
4 changes: 2 additions & 2 deletions webviews/src/chart-series-backgrounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function pathPattern(defs: Selection<SVGDefsElement, undefined, null, undefined>
.attr('style', 'fill:#fff;fill-opacity:0.25;');
return pattern;
}
export function applySeriesBaackgrounds(svg: Selection<SVGSVGElement, undefined, null, undefined>, visualImpaired: boolean = false) {
export function applySeriesBaackgrounds(svg: Selection<SVGSVGElement, undefined, null, undefined>, visualImpaired = false) {
const size = 10;
const halfSize = 0.5 * size;
const defs = svg.append("defs");
Expand All @@ -30,7 +30,7 @@ export function applySeriesBaackgrounds(svg: Selection<SVGSVGElement, undefined,
light_cyan,
thulian_pink,
sandy_brown,
apple_green]
apple_green];

pathPattern(defs, [
`M${halfSize},0l${halfSize},${halfSize}l-${halfSize},${halfSize}l-${halfSize},-${halfSize}l${halfSize},-${halfSize}Z`,
Expand Down
3 changes: 1 addition & 2 deletions webviews/src/charts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './bar-chart';
export * from './donut-chart';
export * from './script-timeline';
export * from './file-link';
export * from './script-timeline';
79 changes: 0 additions & 79 deletions webviews/src/file-link.ts

This file was deleted.

6 changes: 2 additions & 4 deletions webviews/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ function updateCharacterTable(stats: CharacterStats[]) {
}

function onMessage(ev: MessageEvent) {
console.log("onMessage")
// eslint-disable-next-line no-debugger
if (ev.data.command == "fountain.statistics.characters") {
state.statistics.characters = ev.data.stats;
Expand Down Expand Up @@ -135,13 +134,12 @@ function onMessage(ev: MessageEvent) {
}

if(ev.data.command == "opened") {
vscode.setState({ ...state, uri: ev.data.uri })
vscode.setState({ ...state, uri: ev.data.uri });
}
}

function handleHrefButton(e: Event) {
const href = (e.target as HTMLElement).getAttribute('data-href')
console.log("open file in vscode " + href)
const href = (e.target as HTMLElement).getAttribute('data-href');
vscode.postMessage({
command: "open",
link: href
Expand Down
10 changes: 0 additions & 10 deletions webviews/src/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,3 @@ if (!window._vscode)

/** @ts-ignore @type {{ getState: function():any, setState: function(any):void, postMessage: function(any):void }} */
export const vscode = window._vscode;


// function debugg() {
// const output = document.getElementById("test-data-out")!;
// output.innerHTML = JSON.stringify(vscode.getState(), null, 4);

// }
// window.addEventListener("DOMContentLoaded", debugg)
// setInterval(debugg, 1000);
console.log({state: vscode.getState()});

0 comments on commit 5972275

Please sign in to comment.