Skip to content

Commit 85feb0f

Browse files
committed
Cleanup commented scopes code
1 parent bfff2d0 commit 85feb0f

File tree

1 file changed

+0
-129
lines changed

1 file changed

+0
-129
lines changed

packages/gen-mapping/src/gen-mapping.ts

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { SetArray, put, remove } from './set-array';
22
import {
33
encode,
4-
// encodeGeneratedRanges,
5-
// encodeOriginalScopes
64
} from '@jridgewell/sourcemap-codec';
75
import { TraceMap, decodedMappings } from '@jridgewell/trace-mapping';
86

@@ -15,17 +13,12 @@ import {
1513
} from './sourcemap-segment';
1614

1715
import type { SourceMapInput } from '@jridgewell/trace-mapping';
18-
// import type { OriginalScope, GeneratedRange } from '@jridgewell/sourcemap-codec';
1916
import type { SourceMapSegment } from './sourcemap-segment';
2017
import type {
2118
DecodedSourceMap,
2219
EncodedSourceMap,
2320
Pos,
2421
Mapping,
25-
// BindingExpressionRange,
26-
// OriginalPos,
27-
// OriginalScopeInfo,
28-
// GeneratedRangeInfo,
2922
} from './types';
3023

3124
export type { DecodedSourceMap, EncodedSourceMap, Mapping };
@@ -45,8 +38,6 @@ export class GenMapping {
4538
declare private _sources: SetArray<string>;
4639
declare private _sourcesContent: (string | null)[];
4740
declare private _mappings: SourceMapSegment[][];
48-
// private declare _originalScopes: OriginalScope[][];
49-
// private declare _generatedRanges: GeneratedRange[];
5041
declare private _ignoreList: SetArray<number>;
5142
declare file: string | null | undefined;
5243
declare sourceRoot: string | null | undefined;
@@ -56,8 +47,6 @@ export class GenMapping {
5647
this._sources = new SetArray();
5748
this._sourcesContent = [];
5849
this._mappings = [];
59-
// this._originalScopes = [];
60-
// this._generatedRanges = [];
6150
this.file = file;
6251
this.sourceRoot = sourceRoot;
6352
this._ignoreList = new SetArray();
@@ -69,8 +58,6 @@ interface PublicMap {
6958
_sources: GenMapping['_sources'];
7059
_sourcesContent: GenMapping['_sourcesContent'];
7160
_mappings: GenMapping['_mappings'];
72-
// _originalScopes: GenMapping['_originalScopes'];
73-
// _generatedRanges: GenMapping['_generatedRanges'];
7461
_ignoreList: GenMapping['_ignoreList'];
7562
}
7663

@@ -230,23 +217,19 @@ export function setSourceContent(map: GenMapping, source: string, content: strin
230217
const {
231218
_sources: sources,
232219
_sourcesContent: sourcesContent,
233-
// _originalScopes: originalScopes,
234220
} = cast(map);
235221
const index = put(sources, source);
236222
sourcesContent[index] = content;
237-
// if (index === originalScopes.length) originalScopes[index] = [];
238223
}
239224

240225
export function setIgnore(map: GenMapping, source: string, ignore = true) {
241226
const {
242227
_sources: sources,
243228
_sourcesContent: sourcesContent,
244229
_ignoreList: ignoreList,
245-
// _originalScopes: originalScopes,
246230
} = cast(map);
247231
const index = put(sources, source);
248232
if (index === sourcesContent.length) sourcesContent[index] = null;
249-
// if (index === originalScopes.length) originalScopes[index] = [];
250233
if (ignore) put(ignoreList, index);
251234
else remove(ignoreList, index);
252235
}
@@ -262,8 +245,6 @@ export function toDecodedMap(map: GenMapping): DecodedSourceMap {
262245
_sourcesContent: sourcesContent,
263246
_names: names,
264247
_ignoreList: ignoreList,
265-
// _originalScopes: originalScopes,
266-
// _generatedRanges: generatedRanges,
267248
} = cast(map);
268249
removeEmptyFinalLines(mappings);
269250

@@ -275,8 +256,6 @@ export function toDecodedMap(map: GenMapping): DecodedSourceMap {
275256
sources: sources.array,
276257
sourcesContent,
277258
mappings,
278-
// originalScopes,
279-
// generatedRanges,
280259
ignoreList: ignoreList.array,
281260
};
282261
}
@@ -288,8 +267,6 @@ export function toDecodedMap(map: GenMapping): DecodedSourceMap {
288267
export function toEncodedMap(map: GenMapping): EncodedSourceMap {
289268
const decoded = toDecodedMap(map);
290269
return Object.assign({}, decoded, {
291-
// originalScopes: decoded.originalScopes.map((os) => encodeOriginalScopes(os)),
292-
// generatedRanges: encodeGeneratedRanges(decoded.generatedRanges as GeneratedRange[]),
293270
mappings: encode(decoded.mappings as SourceMapSegment[][]),
294271
});
295272
}
@@ -305,7 +282,6 @@ export function fromMap(input: SourceMapInput): GenMapping {
305282
putAll(cast(gen)._sources, map.sources as string[]);
306283
cast(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null);
307284
cast(gen)._mappings = decodedMappings(map) as GenMapping['_mappings'];
308-
// TODO: implement originalScopes/generatedRanges
309285
if (map.ignoreList) putAll(cast(gen)._ignoreList, map.ignoreList);
310286

311287
return gen;
@@ -360,7 +336,6 @@ function addSegmentInternal<S extends string | null | undefined>(
360336
_sources: sources,
361337
_sourcesContent: sourcesContent,
362338
_names: names,
363-
// _originalScopes: originalScopes,
364339
} = cast(map);
365340
const line = getIndex(mappings, genLine);
366341
const index = getColumnIndex(line, genColumn);
@@ -378,7 +353,6 @@ function addSegmentInternal<S extends string | null | undefined>(
378353
const sourcesIndex = put(sources, source);
379354
const namesIndex = name ? put(names, name) : NO_NAME;
380355
if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content ?? null;
381-
// if (sourcesIndex === originalScopes.length) originalScopes[sourcesIndex] = [];
382356

383357
if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
384358
return;
@@ -509,106 +483,3 @@ function addMappingInternal<S extends string | null | undefined>(
509483
content,
510484
);
511485
}
512-
513-
/*
514-
export function addOriginalScope(
515-
map: GenMapping,
516-
data: {
517-
start: Pos;
518-
end: Pos;
519-
source: string;
520-
kind: string;
521-
name?: string;
522-
variables?: string[];
523-
},
524-
): OriginalScopeInfo {
525-
const { start, end, source, kind, name, variables } = data;
526-
const {
527-
_sources: sources,
528-
_sourcesContent: sourcesContent,
529-
_originalScopes: originalScopes,
530-
_names: names,
531-
} = cast(map);
532-
const index = put(sources, source);
533-
if (index === sourcesContent.length) sourcesContent[index] = null;
534-
if (index === originalScopes.length) originalScopes[index] = [];
535-
536-
const kindIndex = put(names, kind);
537-
const scope: OriginalScope = name
538-
? [start.line - 1, start.column, end.line - 1, end.column, kindIndex, put(names, name)]
539-
: [start.line - 1, start.column, end.line - 1, end.column, kindIndex];
540-
if (variables) {
541-
scope.vars = variables.map((v) => put(names, v));
542-
}
543-
const len = originalScopes[index].push(scope);
544-
return [index, len - 1, variables];
545-
}
546-
*/
547-
548-
// Generated Ranges
549-
/*
550-
export function addGeneratedRange(
551-
map: GenMapping,
552-
data: {
553-
start: Pos;
554-
isScope: boolean;
555-
originalScope?: OriginalScopeInfo;
556-
callsite?: OriginalPos;
557-
},
558-
): GeneratedRangeInfo {
559-
const { start, isScope, originalScope, callsite } = data;
560-
const {
561-
_originalScopes: originalScopes,
562-
_sources: sources,
563-
_sourcesContent: sourcesContent,
564-
_generatedRanges: generatedRanges,
565-
} = cast(map);
566-
567-
const range: GeneratedRange = [
568-
start.line - 1,
569-
start.column,
570-
0,
571-
0,
572-
originalScope ? originalScope[0] : -1,
573-
originalScope ? originalScope[1] : -1,
574-
];
575-
if (originalScope?.[2]) {
576-
range.bindings = originalScope[2].map(() => [[-1]]);
577-
}
578-
if (callsite) {
579-
const index = put(sources, callsite.source);
580-
if (index === sourcesContent.length) sourcesContent[index] = null;
581-
if (index === originalScopes.length) originalScopes[index] = [];
582-
range.callsite = [index, callsite.line - 1, callsite.column];
583-
}
584-
if (isScope) range.isScope = true;
585-
generatedRanges.push(range);
586-
587-
return [range, originalScope?.[2]];
588-
}
589-
590-
export function setEndPosition(range: GeneratedRangeInfo, pos: Pos) {
591-
range[0][2] = pos.line - 1;
592-
range[0][3] = pos.column;
593-
}
594-
595-
export function addBinding(
596-
map: GenMapping,
597-
range: GeneratedRangeInfo,
598-
variable: string,
599-
expression: string | BindingExpressionRange,
600-
) {
601-
const { _names: names } = cast(map);
602-
const bindings = (range[0].bindings ||= []);
603-
const vars = range[1];
604-
605-
const index = vars!.indexOf(variable);
606-
const binding = getIndex(bindings, index);
607-
608-
if (typeof expression === 'string') binding[0] = [put(names, expression)];
609-
else {
610-
const { start } = expression;
611-
binding.push([put(names, expression.expression), start.line - 1, start.column]);
612-
}
613-
}
614-
*/

0 commit comments

Comments
 (0)