Skip to content

Commit

Permalink
qmlls: Use only 6.7.2 or newer versions
Browse files Browse the repository at this point in the history
Since the `qmlls` is not stable prior to 6.7.2, we should restrict to 6.7.2 or newer.

Change-Id: Ibc3d2ae75f29ad6288fde24716adb88db65c9c33
Reviewed-by: Marcus Tillmanns <[email protected]>
  • Loading branch information
OrkunTokdemir committed Jul 8, 2024
1 parent 49a6d8d commit 3c139d8
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/qmlls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import { createLogger } from '@/logger';
const logger = createLogger('qmlls');
const QMLLS_CONFIG = 'qt-official.qmlls';

interface QmllsExeConfig {
qmllsPath: string;
qtVersion: string;
}

export class Qmlls {
private _client: LanguageClient | undefined;
private _channel: vscode.OutputChannel | undefined;
Expand Down Expand Up @@ -52,12 +57,22 @@ export class Qmlls {

this.startLanguageClient(customPath);
} else {
const qmllsPath = await findMostRecentExecutableQmlLS();
if (!qmllsPath) {
const qmllsExeConfig = await findMostRecentExecutableQmlLS();
if (!qmllsExeConfig) {
throw new Error('not found');
}
// Don't start the language server if the version is older than 6.7.2
// Because older versions of the qmlls are not stable
if (
versionutil.compareVersions(qmllsExeConfig.qtVersion, '6.7.2') < 0
) {
const errorMessage =
'QML Language Server version is older than 6.7.2';
logger.error(errorMessage);
throw new Error(errorMessage);
}

this.startLanguageClient(qmllsPath);
this.startLanguageClient(qmllsExeConfig.qmllsPath);
}
} catch (error) {
if (util.isError(error)) {
Expand Down Expand Up @@ -140,18 +155,17 @@ export class Qmlls {
}
}

async function findMostRecentExecutableQmlLS(): Promise<string | undefined> {
async function findMostRecentExecutableQmlLS(): Promise<
QmllsExeConfig | undefined
> {
const allQtFolders = [
KitManager.getCurrentGlobalQtFolder(),
...Array.from(projectManager.getProjects()).map((project) => {
return KitManager.getWorkspaceFolderQtFolder(project.folder);
})
];

const found: {
qmllsPath: string;
qtVersion: string;
}[] = [];
const found: QmllsExeConfig[] = [];

for (const qtFolder of allQtFolders) {
const versionRegex = /^\d+\.\d+\.\d+$/;
Expand Down Expand Up @@ -182,7 +196,7 @@ async function findMostRecentExecutableQmlLS(): Promise<string | undefined> {
for (const item of found) {
const res = spawnSync(item.qmllsPath, ['--help'], { timeout: 1000 });
if (res.status === 0) {
return item.qmllsPath;
return item;
}
}

Expand Down

0 comments on commit 3c139d8

Please sign in to comment.