Skip to content

fix #193 Add 'isfs-readonly' scheme #195

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

Merged
merged 1 commit into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
{
"name": "Oleg Dmitrovich",
"email": "[email protected]"
},
{
"name": "John Murray",
"email": "[email protected]"
}
],
"engines": {
Expand All @@ -60,6 +64,7 @@
"onLanguage:xml",
"onView:ObjectScriptExplorer",
"onFileSystem:isfs",
"onFileSystem:isfs-readonly",
"onFileSystem:objectscript",
"onDebugInitialConfigurations"
],
Expand Down Expand Up @@ -137,7 +142,7 @@
},
{
"command": "vscode-objectscript.serverCommands.other",
"when": "vscode-objectscript.connectActive && resourceScheme == isfs || vscode-objectscript.connectActive && !editorIsOpen"
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ || vscode-objectscript.connectActive && !editorIsOpen"
},
{
"command": "vscode-objectscript.serverCommands.contextOther",
Expand Down Expand Up @@ -226,7 +231,7 @@
},
{
"command": "vscode-objectscript.serverCommands.contextOther",
"when": "resourceScheme == isfs && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"when": "resourceScheme =~ /^isfs(-readonly)?$/ && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"group": "objectscript@5"
}
],
Expand All @@ -239,7 +244,7 @@
{
"command": "vscode-objectscript.serverCommands.other",
"group": "navigation@2",
"when": "vscode-objectscript.connectActive && resourceScheme == isfs"
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/"
}

],
Expand Down Expand Up @@ -268,7 +273,7 @@
},
{
"command": "vscode-objectscript.serverCommands.contextOther",
"when": "resourceScheme == isfs && resourceLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"when": "resourceScheme =~ /^isfs(-readonly)?$/ && resourceLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"group": "objectscript@3"
}
]
Expand Down
12 changes: 10 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ import * as request from "request-promise";
import * as url from "url";
import * as vscode from "vscode";
import * as Cache from "vscode-cache";
import { config, extensionContext, FILESYSTEM_SCHEMA, workspaceState, panel, checkConnection } from "../extension";
import {
config,
extensionContext,
FILESYSTEM_SCHEMA,
FILESYSTEM_READONLY_SCHEMA,
workspaceState,
panel,
checkConnection,
} from "../extension";
import { currentWorkspaceFolder, outputConsole, outputChannel } from "../utils";

const DEFAULT_API_VERSION = 1;
Expand Down Expand Up @@ -78,7 +86,7 @@ export class AtelierAPI {
let namespace;
if (wsOrFile) {
if (wsOrFile instanceof vscode.Uri) {
if (wsOrFile.scheme === FILESYSTEM_SCHEMA) {
if (wsOrFile.scheme === FILESYSTEM_SCHEMA || wsOrFile.scheme === FILESYSTEM_READONLY_SCHEMA) {
workspaceFolderName = wsOrFile.authority;
const { query } = url.parse(decodeURIComponent(wsOrFile.toString()), true);
if (query) {
Expand Down
10 changes: 8 additions & 2 deletions src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import glob = require("glob");
import path = require("path");
import vscode = require("vscode");
import { AtelierAPI } from "../api";
import { config, documentContentProvider, FILESYSTEM_SCHEMA, fileSystemProvider } from "../extension";
import {
config,
documentContentProvider,
FILESYSTEM_SCHEMA,
FILESYSTEM_READONLY_SCHEMA,
fileSystemProvider,
} from "../extension";
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
import { currentFile, CurrentFile, outputChannel } from "../utils";
import { RootNode } from "../explorer/models/rootNode";
Expand Down Expand Up @@ -53,7 +59,7 @@ export async function loadChanges(files: CurrentFile[]): Promise<any> {
const content = (data.result.content || []).join(file.eol === vscode.EndOfLine.LF ? "\n" : "\r\n");
if (file.uri.scheme === "file") {
fs.writeFileSync(file.fileName, content);
} else if (file.uri.scheme === FILESYSTEM_SCHEMA) {
} else if (file.uri.scheme === FILESYSTEM_SCHEMA || file.uri.scheme === FILESYSTEM_READONLY_SCHEMA) {
fileSystemProvider.writeFile(file.uri, Buffer.from(content), {
overwrite: true,
create: false,
Expand Down
8 changes: 6 additions & 2 deletions src/commands/serverActions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from "vscode";
import { config, workspaceState, checkConnection, FILESYSTEM_SCHEMA } from "../extension";
import { config, workspaceState, checkConnection, FILESYSTEM_SCHEMA, FILESYSTEM_READONLY_SCHEMA } from "../extension";
import { currentWorkspaceFolder, terminalWithDocker, currentFile } from "../utils";
import { mainCommandMenu, mainSourceControlMenu } from "./studio";
import { AtelierAPI } from "../api";
Expand Down Expand Up @@ -96,7 +96,11 @@ export async function serverActions(): Promise<void> {
id: "openClassReference",
label: "Open Class Reference",
});
if (!vscode.window.activeTextEditor || vscode.window.activeTextEditor.document.uri.scheme === FILESYSTEM_SCHEMA) {
if (
!vscode.window.activeTextEditor ||
vscode.window.activeTextEditor.document.uri.scheme === FILESYSTEM_SCHEMA ||
vscode.window.activeTextEditor.document.uri.scheme === FILESYSTEM_READONLY_SCHEMA
) {
actions.push({
id: "serverSourceControlMenu",
label: "Server Source Control...",
Expand Down
9 changes: 6 additions & 3 deletions src/debug/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { DebugProtocol } from "vscode-debugprotocol";
import WebSocket = require("ws");
import { AtelierAPI } from "../api";
import * as xdebug from "./xdebugConnection";
import { FILESYSTEM_SCHEMA } from "../extension";
import { FILESYSTEM_SCHEMA, FILESYSTEM_READONLY_SCHEMA } from "../extension";
import * as url from "url";
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
import { formatPropertyValue } from "./utils";
Expand All @@ -40,7 +40,7 @@ interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments {
export async function convertClientPathToDebugger(localPath: string, namespace: string): Promise<string> {
const { protocol, pathname, query } = url.parse(decodeURIComponent(localPath), true, true);
let fileName = localPath;
if (protocol && protocol === `${FILESYSTEM_SCHEMA}:`) {
if (protocol && (protocol === `${FILESYSTEM_SCHEMA}:` || protocol === `${FILESYSTEM_READONLY_SCHEMA}:`)) {
if (query.ns && query.ns !== "") {
namespace = query.ns.toString();
}
Expand Down Expand Up @@ -205,7 +205,10 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
await this._debugTargetSet.wait(1000);

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

Expand Down
22 changes: 20 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ const { workspace, window } = vscode;
export const OBJECTSCRIPT_FILE_SCHEMA = "objectscript";
export const OBJECTSCRIPTXML_FILE_SCHEMA = "objectscriptxml";
export const FILESYSTEM_SCHEMA = "isfs";
export const schemas = [OBJECTSCRIPT_FILE_SCHEMA, OBJECTSCRIPTXML_FILE_SCHEMA, FILESYSTEM_SCHEMA];
export const FILESYSTEM_READONLY_SCHEMA = "isfs-readonly";
export const schemas = [
OBJECTSCRIPT_FILE_SCHEMA,
OBJECTSCRIPTXML_FILE_SCHEMA,
FILESYSTEM_SCHEMA,
FILESYSTEM_READONLY_SCHEMA,
];

import * as url from "url";
import WebSocket = require("ws");
Expand Down Expand Up @@ -380,9 +386,15 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
packageJson.enableProposedApi && typeof vscode.workspace.registerFileSearchProvider === "function"
? vscode.workspace.registerFileSearchProvider(FILESYSTEM_SCHEMA, new FileSearchProvider())
: null,
packageJson.enableProposedApi && typeof vscode.workspace.registerFileSearchProvider === "function"
? vscode.workspace.registerFileSearchProvider(FILESYSTEM_READONLY_SCHEMA, new FileSearchProvider())
: null,
packageJson.enableProposedApi && typeof vscode.workspace.registerTextSearchProvider === "function"
? vscode.workspace.registerTextSearchProvider(FILESYSTEM_SCHEMA, new TextSearchProvider())
: null,
packageJson.enableProposedApi && typeof vscode.workspace.registerTextSearchProvider === "function"
? vscode.workspace.registerTextSearchProvider(FILESYSTEM_READONLY_SCHEMA, new TextSearchProvider())
: null,
].filter(notNull);

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

vscode.workspace.registerTextDocumentContentProvider(OBJECTSCRIPT_FILE_SCHEMA, documentContentProvider),
vscode.workspace.registerTextDocumentContentProvider(OBJECTSCRIPTXML_FILE_SCHEMA, xmlContentProvider),
vscode.workspace.registerFileSystemProvider(FILESYSTEM_SCHEMA, fileSystemProvider, { isCaseSensitive: true }),
vscode.workspace.registerFileSystemProvider(FILESYSTEM_SCHEMA, fileSystemProvider, {
isCaseSensitive: true,
}),
vscode.workspace.registerFileSystemProvider(FILESYSTEM_READONLY_SCHEMA, fileSystemProvider, {
isCaseSensitive: true,
isReadonly: true,
}),
vscode.languages.setLanguageConfiguration("objectscript-class", getLanguageConfiguration("class")),
vscode.languages.setLanguageConfiguration("objectscript", getLanguageConfiguration("routine")),
vscode.languages.setLanguageConfiguration("objectscript-macros", getLanguageConfiguration("routine")),
Expand Down
8 changes: 5 additions & 3 deletions src/providers/DocumentContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as vscode from "vscode";
import { AtelierAPI } from "../api";

import { getFileName } from "../commands/export";
import { config, FILESYSTEM_SCHEMA, OBJECTSCRIPT_FILE_SCHEMA } from "../extension";
import { config, FILESYSTEM_SCHEMA, FILESYSTEM_READONLY_SCHEMA, OBJECTSCRIPT_FILE_SCHEMA } from "../extension";
import { currentWorkspaceFolder, workspaceFolderUri } from "../utils";

export class DocumentContentProvider implements vscode.TextDocumentContentProvider {
Expand All @@ -27,11 +27,12 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
if (vfs === undefined) {
vfs = config("serverSideEditing");
}
let scheme = vfs ? FILESYSTEM_SCHEMA : OBJECTSCRIPT_FILE_SCHEMA;
workspaceFolder = workspaceFolder && workspaceFolder !== "" ? workspaceFolder : currentWorkspaceFolder();
const isCsp = name.includes("/");
const wFolderUri = workspaceFolderUri(workspaceFolder);
let uri: vscode.Uri;
if (wFolderUri.scheme === FILESYSTEM_SCHEMA) {
if (wFolderUri.scheme === FILESYSTEM_SCHEMA || wFolderUri.scheme === FILESYSTEM_READONLY_SCHEMA) {
const fileExt = name.split(".").pop();
const fileName = name
.split(".")
Expand All @@ -42,6 +43,7 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
path: `/${name}`,
});
vfs = true;
scheme = wFolderUri.scheme;
} else {
const found = this.getAsFile(name, workspaceFolder);
if (found) {
Expand All @@ -59,7 +61,7 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
.join(fileExt.match(/cls/i) ? "/" : ".");
name = fileName + "." + fileExt;
uri = vscode.Uri.file(name).with({
scheme: vfs ? FILESYSTEM_SCHEMA : OBJECTSCRIPT_FILE_SCHEMA,
scheme: scheme,
});
if (workspaceFolder && workspaceFolder !== "") {
uri = uri.with({
Expand Down