Skip to content

Commit

Permalink
fix: Document navigation does not work correctly in Untitled documents (
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored Mar 22, 2022
1 parent e8006e9 commit 4316546
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
1 change: 1 addition & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Incorrect module layout computed when ORG instruction is used in sections with multiple location counters
- AINSERT can now do immediate variable evaluatation correctly
- Highlighting of single character strings (which could represent data attributes - e.g. `I'`, `L'`, `S'` and others) is fixed
- Document navigation does not work correctly in Untitled documents

## [1.0.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/0.15.1...1.0.0) (2022-01-31)

Expand Down
39 changes: 17 additions & 22 deletions clients/vscode-hlasmplugin/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,64 +32,59 @@ const sleep = (ms: number) => {
return new Promise((resolve) => { setTimeout(resolve, ms) });
};

function objectToString(o : any) {
if(o === null)
function objectToString(o: any) {
if (o === null)
return null;

Object.keys(o).forEach(k => {
o[k] = '' + o[k];
o[k] = '' + o[k];
});

return o;
}
}

/**
* ACTIVATION
* activates the extension
*/
export async function activate(context: vscode.ExtensionContext) {
const serverVariant = getConfig<ServerVariant>('serverVariant', 'native');

var telemetry = new Telemetry();
context.subscriptions.push(telemetry);

// setTimeout is needed, because telemetry initialization is asynchronous
// and AFAIK no event in the API is exposed to send the activation telemetry event
setTimeout(() => {telemetry.reportEvent("hlasm.activated", {server_variant:serverVariant.toString()});}, 1000);
setTimeout(() => { telemetry.reportEvent("hlasm.activated", { server_variant: serverVariant.toString() }); }, 1000);

// patterns for files and configs
const filePattern: string = '**/*';

const clientErrorHandler = new LanguageClientErrorHandler(telemetry);

// create client options
const syncFileEvents = getConfig<boolean>('syncFileEvents', true);
const clientOptions: vscodelc.LanguageClientOptions = {
documentSelector: [{ language: 'hlasm' }],
synchronize: !syncFileEvents ? undefined : {
fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
},
uriConverters: {
code2Protocol: (value: vscode.Uri) => value.toString(),
protocol2Code: (value: string) =>
vscode.Uri.file((vscode.Uri.parse(value).fsPath))
},
errorHandler: clientErrorHandler
};


// create server options
var factory = new ServerFactory();

const serverOptions = await factory.create(serverVariant);

//client init
var hlasmpluginClient = new vscodelc.LanguageClient('Hlasmplugin Language Server', serverOptions, clientOptions);

clientErrorHandler.defaultHandler = hlasmpluginClient.createDefaultErrorHandler();
// The objectToString is necessary, because telemetry reporter only takes objects with
// string properties and there are some boolean that we receive from the language server
hlasmpluginClient.onTelemetry((object) => {telemetry.reportEvent(object.method_name, objectToString(object.properties), object.measurements)});
hlasmpluginClient.onTelemetry((object) => { telemetry.reportEvent(object.method_name, objectToString(object.properties), object.measurements) });

// register all commands and objects to context
await registerToContext(context, hlasmpluginClient);
Expand Down Expand Up @@ -192,4 +187,4 @@ async function registerToContext(context: vscode.ExtensionContext, client: vscod
context.subscriptions.push(vscode.commands.registerCommand('extension.hlasm-plugin.getCurrentProgramName', () => getCurrentProgramName()));

return handler;
}
}

0 comments on commit 4316546

Please sign in to comment.