Skip to content
Open
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
32 changes: 32 additions & 0 deletions src/utils/config-wizard-annotation-checker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,36 @@ describe('configWizardAnnotationChecker', () => {

await expect(configWizardAnnotationChecker.hasAnnotations(filePath)).resolves.toBe(true);
});

describe('semicolon marker support', () => {
it('returns true when semicolon marker is within first 100 lines', async () => {
const filePath = path.join(testFolder, 'semicolon-within-100.s');
const lines = Array.from({ length: 99 }, () => '; bootstrap');
lines.push('; <<< Use Configuration Wizard in Context Menu >>>');
writeTextFile(filePath, lines.join('\n'));

await expect(configWizardAnnotationChecker.hasAnnotations(filePath)).resolves.toBe(true);
});

it('returns true for decorated semicolon marker lines', async () => {
const filePath = path.join(testFolder, 'decorated-semicolon-marker.s');
const lines = [
'; file header',
';-------- <<< Use Configuration Wizard in Context Menu >>> --------------------',
'AREA RESET, CODE, READONLY'
];
writeTextFile(filePath, lines.join('\n'));

await expect(configWizardAnnotationChecker.hasAnnotations(filePath)).resolves.toBe(true);
});

it('returns false when semicolon marker appears after first 100 lines', async () => {
const filePath = path.join(testFolder, 'semicolon-after-100.s');
const lines = Array.from({ length: 100 }, () => '; warmup');
lines.push('; <<< Use Configuration Wizard in Context Menu >>>');
writeTextFile(filePath, lines.join('\n'));

await expect(configWizardAnnotationChecker.hasAnnotations(filePath)).resolves.toBe(false);
});
});
});
2 changes: 1 addition & 1 deletion src/utils/config-wizard-annotation-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface ConfigWizardAnnotationChecker {

class ConfigWizardAnnotationCheckerImpl implements ConfigWizardAnnotationChecker {
private static readonly MAX_LINES_TO_SCAN = 100;
private static readonly wizardStartMarkerRegex = /^\s*\/\/.*<<<\s*use configuration wizard in context menu\s*>>>.*$/i;
private static readonly wizardStartMarkerRegex = /^\s*(?:\/\/|;).*<<<\s*use configuration wizard in context menu\s*>>>.*$/i;

public async hasAnnotations(filePath: string): Promise<boolean> {
if (!fs.existsSync(filePath)) {
Expand Down
21 changes: 21 additions & 0 deletions src/views/config-wizard/parser/comment-style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright 2026 Arm Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Comment thread
mguzmanm marked this conversation as resolved.

export type ConfwizLineCommentPrefix = '//' | ';';

export const DEFAULT_LINE_COMMENT_PREFIX: ConfwizLineCommentPrefix = '//';

export const SUPPORTED_LINE_COMMENT_PREFIXES: readonly ConfwizLineCommentPrefix[] = ['//', ';'];
12 changes: 4 additions & 8 deletions src/views/config-wizard/parser/cw-comment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2026 Arm Limited
* Copyright 2023-2026 Arm Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,6 @@
* limitations under the License.
*/

/*
* Copyright (C) 2023-2026 Arm Limited
*/

import { CwItem } from './cw-item';
import { NumberType } from './number-type';
import { Token } from './tokenizer';
Expand Down Expand Up @@ -103,7 +99,7 @@ export class CwComment extends CwItem {
const linesStart = this.commentStartAfterLineNo + 1;
const linesEnd = this.lineNoEnd;

const val = new RwValue(linesStart, linesEnd, this.offset.val, lines, ValueType.comment);
const val = new RwValue(linesStart, linesEnd, this.offset.val, lines, ValueType.comment, undefined, this.lineCommentPrefix);

const numVal = val.value;
let commentState = false;
Expand Down Expand Up @@ -137,7 +133,7 @@ export class CwComment extends CwItem {

const linesStart = this.commentStartAfterLineNo + 1;
const linesEnd = this.lineNoEnd;
const rwVal = new RwValue(linesStart, linesEnd, this.offset.val, lines, ValueType.comment);
const rwVal = new RwValue(linesStart, linesEnd, this.offset.val, lines, ValueType.comment, undefined, this.lineCommentPrefix);

const curVal = rwVal.value;
let newState = false;
Expand All @@ -151,7 +147,7 @@ export class CwComment extends CwItem {
return false;
}

const editText = newState ? '//' : '';
const editText = newState ? this.lineCommentPrefix : '';

const multiEditArr = rwVal.multiEdit; // Change text to modify
multiEditArr.forEach(multiEdit => multiEdit.text = editText);
Expand Down
10 changes: 3 additions & 7 deletions src/views/config-wizard/parser/cw-heading.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2026 Arm Limited
* Copyright 2023-2026 Arm Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,6 @@
* limitations under the License.
*/

/*
* Copyright (C) 2023-2026 Arm Limited
*/

import { CwItem } from './cw-item';
import { NumberType } from './number-type';
import { Token } from './tokenizer';
Expand Down Expand Up @@ -129,7 +125,7 @@ export class CwHeading extends CwItem {
return { value: '', readOnly: false };
}

const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number, undefined, this.lineCommentPrefix);

const v = val.value;
if (!(v instanceof NumberType)) { // apply bitfield if number
Expand All @@ -148,7 +144,7 @@ export class CwHeading extends CwItem {
return false;
}

const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number, undefined, this.lineCommentPrefix);
const newValNum = new NumberType(newValue.value);
if (newValNum == undefined || !(val.value instanceof NumberType)) {
return false;
Expand Down
18 changes: 12 additions & 6 deletions src/views/config-wizard/parser/cw-item.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2026 Arm Limited
* Copyright 2023-2026 Arm Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,6 @@
* limitations under the License.
*/

/*
* Copyright (C) 2023-2026 Arm Limited
*/

import { TextType } from './text-type';
import { AddText } from './cw-utils';
import { Token } from './tokenizer';
Expand All @@ -28,6 +24,7 @@ import { CwInfo } from './cw-info';
import { CwDefault } from './cw-default';
import { CwFormat } from './cw-format';
import { LogErr } from './error';
import { ConfwizLineCommentPrefix, DEFAULT_LINE_COMMENT_PREFIX } from './comment-style';

//https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/configWizard.html
export type ConfwizTypes = 'none' |
Expand Down Expand Up @@ -57,17 +54,26 @@ export class CwItem {
private readonly _infos: CwInfo[] = [];
private readonly _defaults: CwDefault[] = [];
private _format?: CwFormat;
private _lineCommentPrefix: ConfwizLineCommentPrefix = DEFAULT_LINE_COMMENT_PREFIX;

private _parent?: CwItem;
private readonly _children: CwItem[] = [];

constructor(parent?: CwItem) {
if (parent instanceof CwItem) {
this._parent = parent;
this._lineCommentPrefix = parent.lineCommentPrefix;
parent.addChild(this);
}
}

public get lineCommentPrefix(): ConfwizLineCommentPrefix {
return this._lineCommentPrefix;
}
public set lineCommentPrefix(prefix: ConfwizLineCommentPrefix) {
this._lineCommentPrefix = prefix;
}

public addInfo(item: CwInfo) {
this._infos.push(item);
}
Expand Down Expand Up @@ -157,7 +163,7 @@ export class CwItem {
}

public getGuiValue(lines: string[]): GuiValue {
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number, undefined, this.lineCommentPrefix);

const v = val.value;
if (v === undefined) {
Expand Down
22 changes: 9 additions & 13 deletions src/views/config-wizard/parser/cw-option.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2026 Arm Limited
* Copyright 2023-2026 Arm Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,6 @@
* limitations under the License.
*/

/*
* Copyright (C) 2023 - 2026 Arm Limited
*/

import { CwItem } from './cw-item';
import { NumberType } from './number-type';
import { Token } from './tokenizer';
Expand Down Expand Up @@ -261,7 +257,7 @@ export class CwOption extends CwItem {

protected getGuiValueSymbolExchange(lines: string[]): GuiValue {
const keyWord = this.identifierName;
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.exchangeSymbol, keyWord);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.exchangeSymbol, keyWord, this.lineCommentPrefix);

return val.getGuiValue();
}
Expand All @@ -272,7 +268,7 @@ export class CwOption extends CwItem {
return { value: keyWord.getGuiString(), readOnly: true, editRect: { line: 0, col: { start: 0, end: 0 } } };
}

const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.identifier, keyWord);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.identifier, keyWord, this.lineCommentPrefix);

const option = this.getOption(val.value);
if (option === undefined) {
Expand All @@ -288,7 +284,7 @@ export class CwOption extends CwItem {
}

public getGuiValueDropOption(lines: string[]): GuiValue {
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number, undefined, this.lineCommentPrefix);

const v = val.value;
if (v === undefined) {
Expand Down Expand Up @@ -356,7 +352,7 @@ export class CwOption extends CwItem {
}

public getGuiValueNumber(lines: string[]): GuiValue {
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number, undefined, this.lineCommentPrefix);
const v = val.value;
if (!(v instanceof NumberType)) {
return val.getGuiValue();
Expand All @@ -375,7 +371,7 @@ export class CwOption extends CwItem {
}

public setGuiValueNumber(lines: string[], newValue: GuiValue): boolean {
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number, undefined, this.lineCommentPrefix);
const newValNum = new NumberType(newValue.value);
if (newValNum === undefined || !(val.value instanceof NumberType)) {
return false;
Expand Down Expand Up @@ -419,7 +415,7 @@ export class CwOption extends CwItem {
}

public setGuiValueDropOption(lines: string[], newValue: GuiValue): boolean {
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.number, undefined, this.lineCommentPrefix);
const oldVal = val.value;
if (oldVal === undefined) {
return false;
Expand All @@ -445,7 +441,7 @@ export class CwOption extends CwItem {
}

public setGuiValueSymbolExchange(lines: string[], newValue: GuiValue): boolean {
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.exchangeSymbol);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.exchangeSymbol, undefined, this.lineCommentPrefix);
const oldVal = val.value;
if (oldVal === undefined || !(oldVal instanceof TextType)) {
return false;
Expand All @@ -457,7 +453,7 @@ export class CwOption extends CwItem {
}

public setGuiValueIdentifierName(lines: string[], newValue: GuiValue): boolean {
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.identifier);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.identifier, undefined, this.lineCommentPrefix);
const oldVal = val.value;
if (oldVal === undefined || !(oldVal instanceof TextType)) {
return false;
Expand Down
8 changes: 2 additions & 6 deletions src/views/config-wizard/parser/cw-string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2026 Arm Limited
* Copyright 2023-2026 Arm Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,6 @@
* limitations under the License.
*/

/*
* Copyright (C) 2023-2026 Arm Limited
*/

import { CwItem } from './cw-item';
import { Token } from './tokenizer';
import { NumberType } from './number-type';
Expand Down Expand Up @@ -122,7 +118,7 @@ export class CwString extends CwItem {
}

public getGuiValue(lines: string[]): GuiValue {
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.text);
const val = new RwValue(this.lineNo, this.lineNoEnd, this.offset.val, lines, ValueType.text, undefined, this.lineCommentPrefix);

return val.getGuiValue();
}
Expand Down
Loading