Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

520 update organizing of imports #626

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"editor.formatOnSave": true,
"editor.tabSize": 4,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll.eslint": "explicit"
},
"[typescript]": {
Expand All @@ -30,5 +31,6 @@
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"workbench.colorCustomizations": {}
"workbench.colorCustomizations": {},
"typescript.preferences.importModuleSpecifier": "non-relative"
}
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ const config = {
},
};

module.exports = config;
module.exports = config;
12 changes: 6 additions & 6 deletions src/common/OpenEdgeJsonReaded.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PfParser } from '../view/app/utils/PfParser';
import { IConfig } from '../view/app/model';
import * as path from 'path';
import { IConfig } from '@app/model';
import { PfParser } from '@app/utils/PfParser';
import * as fs from 'fs';
import * as path from 'path';

export function readFile(fileName: string): string {
while (fileName.charAt(0) === '/') {
Expand All @@ -12,10 +12,10 @@ export function readFile(fileName: string): string {
return allFileContents;
}

export function getOEVersion(fileContent: string){
export function getOEVersion(fileContent: string) {
const data = JSON.parse(fileContent);
const {oeversion} = data;
const { oeversion } = data;

return oeversion;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/commands/fieldsCommands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ICommand } from '../../view/app/model';
import { ICommand } from '@app/model';

export interface HighlightFieldsCommand extends ICommand {
column: string;
Expand Down
10 changes: 6 additions & 4 deletions src/common/hooks/UseFocusRef.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { useLayoutEffect } from '@src/common/hooks/UseLayoutEffect';
import { useRef } from 'react';
import { useLayoutEffect } from './UseLayoutEffect';

export function useFocusRef<T extends HTMLOrSVGElement>(isSelected: boolean) {
const ref = useRef<T>(null);

useLayoutEffect(() => {
if (!isSelected) {return;}
if (!isSelected) {
return;
}
ref.current?.focus({ preventScroll: true });
}, [isSelected]);

return {
ref,
tabIndex: isSelected ? 0 : -1
tabIndex: isSelected ? 0 : -1,
};
}
}
2 changes: 1 addition & 1 deletion src/db/IProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { IProcessor as ProcessorAlias } from '../repo/processor/IProcessor';
import { IProcessor as ProcessorAlias } from '@src/repo/processor/IProcessor';

export type IProcessor = ProcessorAlias;
50 changes: 25 additions & 25 deletions src/db/Oe.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
import { Column } from 'react-data-grid';

export interface IOEVersion {
dbversion: string;
proversion: string;
dbversion: string;
proversion: string;
}

export interface IOEError {
error: number;
description: string;
trace: string;
error: number;
description: string;
trace: string;
}

export interface IOETablesList {
tables: ITable[];
tables: ITable[];
}

export interface IOEParams {
connectionString: string;
command: string;
params?: any;
connectionString: string;
command: string;
params?: any;
}

export interface IOETableData {
columns: Column<string, unknown>[];
data: string[];
columns: Column<string, unknown>[];
data: string[];
}

interface ITable {
name: string;
tableType: string;
name: string;
tableType: string;
}

export interface IExportDumpData {
rawData: any[];
columns: IOeColumn[];
psc: IOePsc;
rawData: any[];
columns: IOeColumn[];
psc: IOePsc;
}

interface IOeColumn {
name: string;
key: string;
label: string;
type: string;
format: string | null;
name: string;
key: string;
label: string;
type: string;
format: string | null;
}
export interface IOePsc {
cpstream: string;
dateformat: string;
numformat: string;
timestamp: string;
cpstream: string;
dateformat: string;
numformat: string;
timestamp: string;
}
80 changes: 42 additions & 38 deletions src/db/OeClient.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as Net from 'net';
import { Constants } from '@src/common/Constants';
import * as cp from 'child_process';
import { Constants } from '../common/Constants';
import * as vscode from 'vscode';
import * as fs from 'fs';
import * as Net from 'net';
import * as vscode from 'vscode';
import path = require('path');

class OEClient {
Expand Down Expand Up @@ -35,36 +35,37 @@ class OEClient {

public init(): Promise<any> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return this.runProc().then((resolve) => {
this.client = new Net.Socket();
this.client.connect(this.port, this.host, () => {
console.log(
'TCP connection established with the server at ' +
this.port.toString() +
'.'
);
});
// The client can also receive data from the server by reading from its socket.
this.client.on('data', (chunk) => {
console.log('Data received from the server');
this.data += chunk.toString();
if (this.data.endsWith('\n')) {
this.dataFinish(this.data);
}
return this.runProc()
.then((resolve) => {
this.client = new Net.Socket();
this.client.connect(this.port, this.host, () => {
console.log(
'TCP connection established with the server at ' +
this.port.toString() +
'.'
);
});
// The client can also receive data from the server by reading from its socket.
this.client.on('data', (chunk) => {
console.log('Data received from the server');
this.data += chunk.toString();
if (this.data.endsWith('\n')) {
this.dataFinish(this.data);
}
});

this.client.on('end', () => {
console.log('Requested an end to the TCP connection');
});

console.log('V1: OE Client initialized');
return this;
})
.catch((err) => {
return new Promise(() => {
throw new Error(err);
});
});

this.client.on('end', () => {
console.log('Requested an end to the TCP connection');
});

console.log('V1: OE Client initialized');
return this;
})
.catch((err) => {
return new Promise(() => {
throw new Error(err);
});
});
}

private runProc(): Promise<any> {
Expand Down Expand Up @@ -167,11 +168,14 @@ class OEClient {
)
) {
this.procFinish(dataString);
}
else if (dataString.startsWith('Failed to initialize client:')){
return this.procFinish(new Promise(() => {
throw new Error(dataString);
}));
} else if (
dataString.startsWith('Failed to initialize client:')
) {
return this.procFinish(
new Promise(() => {
throw new Error(dataString);
})
);
}
});

Expand Down Expand Up @@ -233,7 +237,7 @@ async function getOEClient(): Promise<any> {

try {
return await client.init();
} catch (err : any) {
} catch (err: any) {
return new Promise(() => {
throw new Error(err.message);
});
Expand Down
46 changes: 23 additions & 23 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import * as vscode from 'vscode';
import { QuickPickItem } from 'vscode';
import { ConnectionEditor } from './webview/ConnectionEditor';
import { Constants } from './common/Constants';
import { QueryEditor } from './webview/QueryEditor';
import { DbConnectionNode } from './treeview/DbConnectionNode';
import { FieldsViewProvider } from './webview/FieldsViewProvider';
import { IndexesViewProvider } from './webview/IndexesViewProvider';
import { GroupListProvider } from './treeview/GroupListProvider';
import { TableNode } from './treeview/TableNode';
import { TablesListProvider } from './treeview/TablesListProvider';
import { DbConnectionUpdater } from './treeview/DbConnectionUpdater';
import { IPort, IConfig } from './view/app/model';
import {
readFile,
getOEVersion,
parseOEFile,
} from './common/OpenEdgeJsonReaded';

import { VersionChecker } from './view/app/Welcome/VersionChecker';
import { WelcomePageProvider } from './webview/WelcomePageProvider';
import { AblHoverProvider } from './providers/AblHoverProvider';
import { queryEditorCache } from './webview/queryEditor/queryEditorCache';
import { FavoritesProvider } from './treeview/FavoritesProvider';
import { CustomViewProvider } from './treeview/CustomViewProvider';
import { CustomViewNode } from './treeview/CustomViewNode';
readFile,
} from '@src/common/OpenEdgeJsonReaded';
import * as vscode from 'vscode';
import { QuickPickItem } from 'vscode';

import { IConfig, IPort } from '@app/model';
import { VersionChecker } from '@app/Welcome/VersionChecker';
import { Constants } from '@src/common/Constants';
import { AblHoverProvider } from '@src/providers/AblHoverProvider';
import { CustomViewNode } from '@src/treeview/CustomViewNode';
import { CustomViewProvider } from '@src/treeview/CustomViewProvider';
import { DbConnectionNode } from '@src/treeview/DbConnectionNode';
import { DbConnectionUpdater } from '@src/treeview/DbConnectionUpdater';
import { FavoritesProvider } from '@src/treeview/FavoritesProvider';
import { GroupListProvider } from '@src/treeview/GroupListProvider';
import { TableNode } from '@src/treeview/TableNode';
import { TablesListProvider } from '@src/treeview/TablesListProvider';
import { ConnectionEditor } from '@src/webview/ConnectionEditor';
import { FieldsViewProvider } from '@src/webview/FieldsViewProvider';
import { IndexesViewProvider } from '@src/webview/IndexesViewProvider';
import { QueryEditor } from '@src/webview/QueryEditor';
import { queryEditorCache } from '@src/webview/queryEditor/queryEditorCache';
import { WelcomePageProvider } from '@src/webview/WelcomePageProvider';

export async function activate(context: vscode.ExtensionContext) {
let extensionPort: number;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/AblHoverProvider.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TablesListProvider } from '@src/treeview/TablesListProvider';
import {
Hover,
HoverProvider,
Expand All @@ -6,7 +7,6 @@ import {
ProviderResult,
TextDocument,
} from 'vscode';
import { TablesListProvider } from '../treeview/TablesListProvider';

export class AblHoverProvider implements HoverProvider {
private tableListProvider: TablesListProvider;
Expand Down
6 changes: 3 additions & 3 deletions src/repo/client/AClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConnectionParams } from '@app/model';
import * as Net from 'net';
import { ConnectionParams } from '../../view/app/model';

export class AClient {
protected connectionParams: ConnectionParams;
Expand All @@ -24,8 +24,8 @@ export class AClient {
() => {
console.log(
'V2: TCP connection established with the server at ' +
this.connectionParams.port.toString() +
'.'
this.connectionParams.port.toString() +
'.'
);
}
);
Expand Down
Loading