Skip to content

Commit 683daec

Browse files
authored
Merge pull request #195 from gjsjohnmurray/fix-193
fix #193 Add 'isfs-readonly' scheme
2 parents 24f51fc + 124d92a commit 683daec

File tree

7 files changed

+64
-18
lines changed

7 files changed

+64
-18
lines changed

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
{
3737
"name": "Oleg Dmitrovich",
3838
"email": "[email protected]"
39+
},
40+
{
41+
"name": "John Murray",
42+
"email": "[email protected]"
3943
}
4044
],
4145
"engines": {
@@ -60,6 +64,7 @@
6064
"onLanguage:xml",
6165
"onView:ObjectScriptExplorer",
6266
"onFileSystem:isfs",
67+
"onFileSystem:isfs-readonly",
6368
"onFileSystem:objectscript",
6469
"onDebugInitialConfigurations"
6570
],
@@ -137,7 +142,7 @@
137142
},
138143
{
139144
"command": "vscode-objectscript.serverCommands.other",
140-
"when": "vscode-objectscript.connectActive && resourceScheme == isfs || vscode-objectscript.connectActive && !editorIsOpen"
145+
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ || vscode-objectscript.connectActive && !editorIsOpen"
141146
},
142147
{
143148
"command": "vscode-objectscript.serverCommands.contextOther",
@@ -226,7 +231,7 @@
226231
},
227232
{
228233
"command": "vscode-objectscript.serverCommands.contextOther",
229-
"when": "resourceScheme == isfs && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
234+
"when": "resourceScheme =~ /^isfs(-readonly)?$/ && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
230235
"group": "objectscript@5"
231236
}
232237
],
@@ -239,7 +244,7 @@
239244
{
240245
"command": "vscode-objectscript.serverCommands.other",
241246
"group": "navigation@2",
242-
"when": "vscode-objectscript.connectActive && resourceScheme == isfs"
247+
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/"
243248
}
244249

245250
],
@@ -268,7 +273,7 @@
268273
},
269274
{
270275
"command": "vscode-objectscript.serverCommands.contextOther",
271-
"when": "resourceScheme == isfs && resourceLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
276+
"when": "resourceScheme =~ /^isfs(-readonly)?$/ && resourceLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
272277
"group": "objectscript@3"
273278
}
274279
]

src/api/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ import * as request from "request-promise";
44
import * as url from "url";
55
import * as vscode from "vscode";
66
import * as Cache from "vscode-cache";
7-
import { config, extensionContext, FILESYSTEM_SCHEMA, workspaceState, panel, checkConnection } from "../extension";
7+
import {
8+
config,
9+
extensionContext,
10+
FILESYSTEM_SCHEMA,
11+
FILESYSTEM_READONLY_SCHEMA,
12+
workspaceState,
13+
panel,
14+
checkConnection,
15+
} from "../extension";
816
import { currentWorkspaceFolder, outputConsole, outputChannel } from "../utils";
917

1018
const DEFAULT_API_VERSION = 1;
@@ -78,7 +86,7 @@ export class AtelierAPI {
7886
let namespace;
7987
if (wsOrFile) {
8088
if (wsOrFile instanceof vscode.Uri) {
81-
if (wsOrFile.scheme === FILESYSTEM_SCHEMA) {
89+
if (wsOrFile.scheme === FILESYSTEM_SCHEMA || wsOrFile.scheme === FILESYSTEM_READONLY_SCHEMA) {
8290
workspaceFolderName = wsOrFile.authority;
8391
const { query } = url.parse(decodeURIComponent(wsOrFile.toString()), true);
8492
if (query) {

src/commands/compile.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import glob = require("glob");
33
import path = require("path");
44
import vscode = require("vscode");
55
import { AtelierAPI } from "../api";
6-
import { config, documentContentProvider, FILESYSTEM_SCHEMA, fileSystemProvider } from "../extension";
6+
import {
7+
config,
8+
documentContentProvider,
9+
FILESYSTEM_SCHEMA,
10+
FILESYSTEM_READONLY_SCHEMA,
11+
fileSystemProvider,
12+
} from "../extension";
713
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
814
import { currentFile, CurrentFile, outputChannel } from "../utils";
915
import { RootNode } from "../explorer/models/rootNode";
@@ -53,7 +59,7 @@ export async function loadChanges(files: CurrentFile[]): Promise<any> {
5359
const content = (data.result.content || []).join(file.eol === vscode.EndOfLine.LF ? "\n" : "\r\n");
5460
if (file.uri.scheme === "file") {
5561
fs.writeFileSync(file.fileName, content);
56-
} else if (file.uri.scheme === FILESYSTEM_SCHEMA) {
62+
} else if (file.uri.scheme === FILESYSTEM_SCHEMA || file.uri.scheme === FILESYSTEM_READONLY_SCHEMA) {
5763
fileSystemProvider.writeFile(file.uri, Buffer.from(content), {
5864
overwrite: true,
5965
create: false,

src/commands/serverActions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from "vscode";
2-
import { config, workspaceState, checkConnection, FILESYSTEM_SCHEMA } from "../extension";
2+
import { config, workspaceState, checkConnection, FILESYSTEM_SCHEMA, FILESYSTEM_READONLY_SCHEMA } from "../extension";
33
import { currentWorkspaceFolder, terminalWithDocker, currentFile } from "../utils";
44
import { mainCommandMenu, mainSourceControlMenu } from "./studio";
55
import { AtelierAPI } from "../api";
@@ -96,7 +96,11 @@ export async function serverActions(): Promise<void> {
9696
id: "openClassReference",
9797
label: "Open Class Reference",
9898
});
99-
if (!vscode.window.activeTextEditor || vscode.window.activeTextEditor.document.uri.scheme === FILESYSTEM_SCHEMA) {
99+
if (
100+
!vscode.window.activeTextEditor ||
101+
vscode.window.activeTextEditor.document.uri.scheme === FILESYSTEM_SCHEMA ||
102+
vscode.window.activeTextEditor.document.uri.scheme === FILESYSTEM_READONLY_SCHEMA
103+
) {
100104
actions.push({
101105
id: "serverSourceControlMenu",
102106
label: "Server Source Control...",

src/debug/debugSession.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { DebugProtocol } from "vscode-debugprotocol";
1717
import WebSocket = require("ws");
1818
import { AtelierAPI } from "../api";
1919
import * as xdebug from "./xdebugConnection";
20-
import { FILESYSTEM_SCHEMA } from "../extension";
20+
import { FILESYSTEM_SCHEMA, FILESYSTEM_READONLY_SCHEMA } from "../extension";
2121
import * as url from "url";
2222
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
2323
import { formatPropertyValue } from "./utils";
@@ -40,7 +40,7 @@ interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments {
4040
export async function convertClientPathToDebugger(localPath: string, namespace: string): Promise<string> {
4141
const { protocol, pathname, query } = url.parse(decodeURIComponent(localPath), true, true);
4242
let fileName = localPath;
43-
if (protocol && protocol === `${FILESYSTEM_SCHEMA}:`) {
43+
if (protocol && (protocol === `${FILESYSTEM_SCHEMA}:` || protocol === `${FILESYSTEM_READONLY_SCHEMA}:`)) {
4444
if (query.ns && query.ns !== "") {
4545
namespace = query.ns.toString();
4646
}
@@ -205,7 +205,10 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
205205
await this._debugTargetSet.wait(1000);
206206

207207
const filePath = args.source.path;
208-
const uri = filePath.startsWith(FILESYSTEM_SCHEMA) ? vscode.Uri.parse(filePath) : vscode.Uri.file(filePath);
208+
const uri =
209+
filePath.startsWith(FILESYSTEM_SCHEMA) || filePath.startsWith(FILESYSTEM_READONLY_SCHEMA)
210+
? vscode.Uri.parse(filePath)
211+
: vscode.Uri.file(filePath);
209212
const fileUri = await convertClientPathToDebugger(args.source.path, this._namespace);
210213
const [, fileName] = fileUri.match(/\|([^|]+)$/);
211214

src/extension.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ const { workspace, window } = vscode;
77
export const OBJECTSCRIPT_FILE_SCHEMA = "objectscript";
88
export const OBJECTSCRIPTXML_FILE_SCHEMA = "objectscriptxml";
99
export const FILESYSTEM_SCHEMA = "isfs";
10-
export const schemas = [OBJECTSCRIPT_FILE_SCHEMA, OBJECTSCRIPTXML_FILE_SCHEMA, FILESYSTEM_SCHEMA];
10+
export const FILESYSTEM_READONLY_SCHEMA = "isfs-readonly";
11+
export const schemas = [
12+
OBJECTSCRIPT_FILE_SCHEMA,
13+
OBJECTSCRIPTXML_FILE_SCHEMA,
14+
FILESYSTEM_SCHEMA,
15+
FILESYSTEM_READONLY_SCHEMA,
16+
];
1117

1218
import * as url from "url";
1319
import WebSocket = require("ws");
@@ -380,9 +386,15 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
380386
packageJson.enableProposedApi && typeof vscode.workspace.registerFileSearchProvider === "function"
381387
? vscode.workspace.registerFileSearchProvider(FILESYSTEM_SCHEMA, new FileSearchProvider())
382388
: null,
389+
packageJson.enableProposedApi && typeof vscode.workspace.registerFileSearchProvider === "function"
390+
? vscode.workspace.registerFileSearchProvider(FILESYSTEM_READONLY_SCHEMA, new FileSearchProvider())
391+
: null,
383392
packageJson.enableProposedApi && typeof vscode.workspace.registerTextSearchProvider === "function"
384393
? vscode.workspace.registerTextSearchProvider(FILESYSTEM_SCHEMA, new TextSearchProvider())
385394
: null,
395+
packageJson.enableProposedApi && typeof vscode.workspace.registerTextSearchProvider === "function"
396+
? vscode.workspace.registerTextSearchProvider(FILESYSTEM_READONLY_SCHEMA, new TextSearchProvider())
397+
: null,
386398
].filter(notNull);
387399

388400
context.subscriptions.push(
@@ -518,7 +530,13 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
518530

519531
vscode.workspace.registerTextDocumentContentProvider(OBJECTSCRIPT_FILE_SCHEMA, documentContentProvider),
520532
vscode.workspace.registerTextDocumentContentProvider(OBJECTSCRIPTXML_FILE_SCHEMA, xmlContentProvider),
521-
vscode.workspace.registerFileSystemProvider(FILESYSTEM_SCHEMA, fileSystemProvider, { isCaseSensitive: true }),
533+
vscode.workspace.registerFileSystemProvider(FILESYSTEM_SCHEMA, fileSystemProvider, {
534+
isCaseSensitive: true,
535+
}),
536+
vscode.workspace.registerFileSystemProvider(FILESYSTEM_READONLY_SCHEMA, fileSystemProvider, {
537+
isCaseSensitive: true,
538+
isReadonly: true,
539+
}),
522540
vscode.languages.setLanguageConfiguration("objectscript-class", getLanguageConfiguration("class")),
523541
vscode.languages.setLanguageConfiguration("objectscript", getLanguageConfiguration("routine")),
524542
vscode.languages.setLanguageConfiguration("objectscript-macros", getLanguageConfiguration("routine")),

src/providers/DocumentContentProvider.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as vscode from "vscode";
55
import { AtelierAPI } from "../api";
66

77
import { getFileName } from "../commands/export";
8-
import { config, FILESYSTEM_SCHEMA, OBJECTSCRIPT_FILE_SCHEMA } from "../extension";
8+
import { config, FILESYSTEM_SCHEMA, FILESYSTEM_READONLY_SCHEMA, OBJECTSCRIPT_FILE_SCHEMA } from "../extension";
99
import { currentWorkspaceFolder, workspaceFolderUri } from "../utils";
1010

1111
export class DocumentContentProvider implements vscode.TextDocumentContentProvider {
@@ -27,11 +27,12 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
2727
if (vfs === undefined) {
2828
vfs = config("serverSideEditing");
2929
}
30+
let scheme = vfs ? FILESYSTEM_SCHEMA : OBJECTSCRIPT_FILE_SCHEMA;
3031
workspaceFolder = workspaceFolder && workspaceFolder !== "" ? workspaceFolder : currentWorkspaceFolder();
3132
const isCsp = name.includes("/");
3233
const wFolderUri = workspaceFolderUri(workspaceFolder);
3334
let uri: vscode.Uri;
34-
if (wFolderUri.scheme === FILESYSTEM_SCHEMA) {
35+
if (wFolderUri.scheme === FILESYSTEM_SCHEMA || wFolderUri.scheme === FILESYSTEM_READONLY_SCHEMA) {
3536
const fileExt = name.split(".").pop();
3637
const fileName = name
3738
.split(".")
@@ -42,6 +43,7 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
4243
path: `/${name}`,
4344
});
4445
vfs = true;
46+
scheme = wFolderUri.scheme;
4547
} else {
4648
const found = this.getAsFile(name, workspaceFolder);
4749
if (found) {
@@ -59,7 +61,7 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
5961
.join(fileExt.match(/cls/i) ? "/" : ".");
6062
name = fileName + "." + fileExt;
6163
uri = vscode.Uri.file(name).with({
62-
scheme: vfs ? FILESYSTEM_SCHEMA : OBJECTSCRIPT_FILE_SCHEMA,
64+
scheme: scheme,
6365
});
6466
if (workspaceFolder && workspaceFolder !== "") {
6567
uri = uri.with({

0 commit comments

Comments
 (0)