Skip to content

Commit 0fa8b8c

Browse files
Merge branch 'develop' into main
2 parents e3708c4 + 3b9c524 commit 0fa8b8c

30 files changed

+105
-126
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Code style revamp! We reworked how routines, routine methods, properties, and st
3434

3535
- When generating ENVI and IDL tasks, using our new case libraries, we attempt to make a pretty display name from parameter names. For example converting the keyword "my_keyword" to "My Keyword". This applied to task and parameter display names.
3636

37+
## 4.1.2 December 2023
38+
39+
Change the way we extract comments to reduce memory and speed up parsing by about 10%
40+
3741
## 4.1.1 December 2023
3842

3943
Added a new preference for notebooks called "Quiet Mode" that allows you to control the IDL preference for `!quiet` when executing notebook cells.

libs/assembling/formatters/src/lib/fiddle/formatters/comment-formatter.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ export const COMMENT_FORMATTER: TokenFormatter<CommentToken> = (
1919
if (meta.scope.slice(-1)[0] === TOKEN_NAMES.COMMENT_BLOCK) {
2020
token.match[0] = `;${token.match[0].substring(1)}`.trimEnd();
2121
} else {
22-
// get everything by the first match, join together, remove excess comments
23-
token.match[0] = `; ${token.match
24-
.slice(1, token.match.length)
25-
.map((el) => el.trim())
26-
.join(' ')
27-
.trim()}`;
22+
token.match[0] = `; ${token.match[0].substring(1).trim()}`;
2823
}
2924
};

libs/assembling/styles/src/lib/default/style-routine-docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export function ReplaceRoutineDocs(parsed: IParsed, style: ICodeStyle) {
247247
type: BRANCH_TYPES.BASIC,
248248
name: TOKEN_NAMES.COMMENT,
249249
pos: [start + j, 0, docs[j].length],
250-
match: [docs[j], docs[j].substring(2)],
250+
match: [docs[j]],
251251
idx: j,
252252
parseProblems: [],
253253
scope: scope,

libs/parsing/syntax-validators/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export * from './lib/helpers/is-single-line';
33
export * from './lib/validators/after-line-continuation';
44
export * from './lib/validators/args-first';
55
export * from './lib/validators/class-no-params';
6-
export * from './lib/validators/comments';
6+
export * from './lib/validators/comment-to-do';
77
export * from './lib/validators/compile-opt';
88
export * from './lib/validators/continue-break';
99
export * from './lib/validators/dot-and-arrow';

libs/parsing/syntax-validators/src/lib/validators/comments.ts renamed to libs/parsing/syntax-validators/src/lib/validators/comment-to-do.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,28 @@ import {
55
} from '@idl/parsing/syntax-tree';
66
import { TOKEN_NAMES } from '@idl/parsing/tokenizer';
77

8+
/**
9+
* Regex to extract TODO statements
10+
*/
11+
const TODO_REGEX = /^TODO:/im;
12+
813
/**
914
* Extract TODO statements from comments
1015
*/
1116
IDL_SYNTAX_TREE_VALIDATOR.onBasicToken(TOKEN_NAMES.COMMENT, (token, parsed) => {
17+
/**
18+
* Remove leading comment
19+
*/
20+
const sub = token.match[0].substring(1).trim();
21+
1222
// make sure we have a TODO which means three capture groups
1323
// see comments.spec.ts for some examples
14-
if (token.match.length === 3) {
24+
if (TODO_REGEX.test(sub)) {
1525
token.parseProblems.push(IDL_PROBLEM_CODES.TODO);
1626
parsed.parseProblems.push(
1727
SyntaxProblemWithoutTranslation(
1828
IDL_PROBLEM_CODES.TODO,
19-
`TODO: ${token.match[2].trim()}`,
29+
`TODO: ${sub.substring(5).trim()}`,
2030
token.pos,
2131
token.pos
2232
)

libs/parsing/tokenizer/src/lib/token-matches.interface.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { AccessPropertyMatches } from './tokens/defs/access-property.interface';
2424
import {
2525
CommentBlockMatches,
2626
CommentMatches,
27-
CommentWithToDoMatches,
2827
} from './tokens/defs/comment.interface';
2928
import {
3029
KeywordBinaryMatches,
@@ -64,7 +63,7 @@ export type TokenStartMatches<T extends TokenName> =
6463
: T extends CallProcedureMethodToken
6564
? CallProcedureMethodMatches
6665
: T extends CommentToken
67-
? CommentMatches | CommentWithToDoMatches
66+
? CommentMatches
6867
: T extends CommentBlockToken
6968
? CommentBlockMatches
7069
: T extends KeywordBinaryToken

libs/parsing/tokenizer/src/lib/tokens/defs/comment.interface.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,29 @@ import {
55
TOKEN_NAMES,
66
} from '../../tokens.interface';
77

8+
/**
9+
* Token definition for comment
10+
*/
811
export type CommentTokenDef = ITokenDef<CommentToken>;
912

1013
/**
1114
* For matching comments
1215
*/
1316
export const COMMENT: CommentTokenDef = {
1417
name: TOKEN_NAMES.COMMENT,
15-
match: /;\s*(TODO:)?(.*)$/im,
18+
match: /;\s*.*$/im,
1619
};
1720

1821
/**
19-
* Comment match without TODO
22+
* Comment match
2023
*
2124
* @param {string} full Full match including the start of the comment
22-
* @param {string} comment Text after the semi-colon
2325
*/
24-
export type CommentMatches = [full: string, comment: string];
26+
export type CommentMatches = [full: string];
2527

2628
/**
27-
* Comment match with TODO
28-
*
29-
* @param {string} full Full match including the start of the comment
30-
* @param {string} todo TODO text, including semi-colon
31-
* @param {string} comment Statement to do
29+
* Token definition for comment blocks
3230
*/
33-
export type CommentWithToDoMatches = [
34-
full: string,
35-
todo: string,
36-
comment: string
37-
];
38-
3931
export type CommentBlockTokenDef = ITokenDef<CommentBlockToken>;
4032

4133
/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/**
22
* Version of the extension
33
*/
4-
export const VERSION = '4.1.1';
4+
export const VERSION = '4.1.2';

libs/tests/assembler/src/lib/format.comments.1.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe(`[auto generated] Verify comment`, () => {
5454
const expectedFormatting: string[] = [
5555
`a = 42 ; comment OK`,
5656
`; ; comment bad, now fixed`,
57-
`; TODO: something super crazy`,
57+
`; TODO: something super crazy`,
5858
`compile_opt idl2`,
5959
``,
6060
`end`,

libs/tests/syntax-post-processors/src/lib/arg-defs.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe(`[auto generated] Correctly extract argument definitions from code`, ()
155155
type: '1',
156156
name: 15,
157157
pos: [0, 39, 10],
158-
match: ['; commment', 'commment'],
158+
match: ['; commment'],
159159
idx: 0,
160160
scope: [72, 71, 31],
161161
parseProblems: [],
@@ -421,7 +421,7 @@ describe(`[auto generated] Correctly extract argument definitions from code`, ()
421421
type: '1',
422422
name: 15,
423423
pos: [0, 39, 10],
424-
match: ['; commment', 'commment'],
424+
match: ['; commment'],
425425
idx: 0,
426426
scope: [72, 71, 31],
427427
parseProblems: [],

0 commit comments

Comments
 (0)