Skip to content

Commit 6906ff0

Browse files
crisbetoatscott
authored andcommitted
refactor(core): clean up clang comments and workarounds (angular#55750)
Since we aren't using clang anymore, we can remove the comments and the workarounds that were in place to prevent it from doing the wrong thing. PR Close angular#55750
1 parent cd96464 commit 6906ff0

File tree

22 files changed

+4
-66
lines changed

22 files changed

+4
-66
lines changed

packages/common/http/src/interceptor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,12 @@ function chainedInterceptorFn(
181181
interceptorFn: HttpInterceptorFn,
182182
injector: EnvironmentInjector,
183183
): ChainedInterceptorFn<unknown> {
184-
// clang-format off
185184
return (initialRequest, finalHandlerFn) =>
186185
runInInjectionContext(injector, () =>
187186
interceptorFn(initialRequest, (downstreamRequest) =>
188187
chainTailFn(downstreamRequest, finalHandlerFn),
189188
),
190189
);
191-
// clang-format on
192190
}
193191

194192
/**

packages/common/src/pipes/date_pipe.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export const DATE_PIPE_DEFAULT_OPTIONS = new InjectionToken<DatePipeConfig>(
5858
ngDevMode ? 'DATE_PIPE_DEFAULT_OPTIONS' : '',
5959
);
6060

61-
// clang-format off
6261
/**
6362
* @ngModule CommonModule
6463
* @description
@@ -217,7 +216,6 @@ export const DATE_PIPE_DEFAULT_OPTIONS = new InjectionToken<DatePipeConfig>(
217216
*
218217
* @publicApi
219218
*/
220-
// clang-format on
221219
@Pipe({
222220
name: 'date',
223221
standalone: true,

packages/compiler-cli/src/ngtsc/core/src/compiler.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,6 @@ export class NgCompiler {
14021402

14031403
// TODO(alxhub): understand why the cast here is necessary (something to do with `null`
14041404
// not being assignable to `unknown` when wrapped in `Readonly`).
1405-
// clang-format off
14061405
new DirectiveDecoratorHandler(
14071406
reflector,
14081407
evaluator,
@@ -1422,7 +1421,6 @@ export class NgCompiler {
14221421
compilationMode,
14231422
!!this.options.generateExtraImportsInLocalMode,
14241423
) as Readonly<DecoratorHandler<unknown, unknown, SemanticSymbol | null, unknown>>,
1425-
// clang-format on
14261424
// Pipe handler must be before injectable handler in list so pipe factories are printed
14271425
// before injectable factories (so injectable factories can delegate to them)
14281426
new PipeDecoratorHandler(

packages/compiler-cli/src/ngtsc/reflection/src/host.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ export interface Decorator {
2828
/**
2929
* `Import` by which the decorator was brought into the module in which it was invoked, or `null`
3030
* if the decorator was declared in the same module and not imported.
31-
*
32-
* Note: this field is declared using computed property syntax to work around a clang-format bug
33-
* that resulted in inconsistent indentation of this comment block.
3431
*/
35-
['import']: Import | null;
32+
import: Import | null;
3633

3734
/**
3835
* TypeScript reference to the decorator itself.

packages/compiler-cli/src/ngtsc/resource/src/loader.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,13 @@ export class AdapterResourceLoader implements ResourceLoader {
232232
failedLookupLocations: ReadonlyArray<string>;
233233
};
234234

235-
// clang-format off
236235
const failedLookup = ts.resolveModuleName(
237236
url + RESOURCE_MARKER,
238237
fromFile,
239238
this.options,
240239
this.lookupResolutionHost,
241240
) as ResolvedModuleWithFailedLookupLocations;
242-
// clang-format on
241+
243242
if (failedLookup.failedLookupLocations === undefined) {
244243
throw new Error(
245244
`Internal error: expected to find failedLookupLocations during resolution of resource '${url}' in context of ${fromFile}`,

packages/compiler-cli/test/ngtsc/ngtsc_spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ function getDiagnosticSourceCode(diag: ts.Diagnostic): string {
4646
return diag.file!.text.slice(diag.start!, diag.start! + diag.length!);
4747
}
4848

49-
runInEachFileSystem(allTests);
50-
51-
// Wrap all tests into a function to work around clang-format going crazy and (poorly)
52-
// reformatting the entire file.
53-
function allTests(os: string) {
49+
runInEachFileSystem((os: string) => {
5450
describe('ngtsc behavioral tests', () => {
5551
let env!: NgtscTestEnvironment;
5652

@@ -10505,4 +10501,4 @@ function allTests(os: string) {
1050510501
expect(guard(node)).toBe(true);
1050610502
return node as T;
1050710503
}
10508-
}
10504+
});

packages/compiler-cli/test/test_support.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ function createTestSupportFor(basePath: string) {
6060
'lib': Object.freeze([
6161
path.resolve(basePath, 'node_modules/typescript/lib/lib.es6.d.ts'),
6262
]) as string[],
63-
// clang-format off
6463
'paths': Object.freeze({'@angular/*': ['./node_modules/@angular/*']}) as {
6564
[index: string]: string[];
6665
},
67-
// clang-format on
6866
};
6967

7068
return {

packages/compiler/src/i18n/digest.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ function hash32(view: DataView, length: number, c: number): number {
301301
return mix(a, b, c)[2];
302302
}
303303

304-
// clang-format off
305304
function mix(a: number, b: number, c: number): [number, number, number] {
306305
a -= b;
307306
a -= c;
@@ -332,7 +331,6 @@ function mix(a: number, b: number, c: number): [number, number, number] {
332331
c ^= b >>> 15;
333332
return [a, b, c];
334333
}
335-
// clang-format on
336334

337335
// Utils
338336

packages/compiler/test/i18n/extractor_merger_spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,15 +733,12 @@ function extract(
733733
throw new Error(`unexpected errors: ${result.errors.join('\n')}`);
734734
}
735735

736-
// clang-format off
737-
// https://github.com/angular/clang-format/issues/35
738736
return result.messages.map((message) => [
739737
serializeI18nNodes(message.nodes),
740738
message.meaning,
741739
message.description,
742740
message.id,
743741
]) as [string[], string, string, string][];
744-
// clang-format on
745742
}
746743

747744
function extractErrors(

packages/compiler/test/i18n/i18n_parser_spec.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -326,45 +326,36 @@ export function _humanizeMessages(
326326
implicitTags: string[] = [],
327327
implicitAttrs: {[k: string]: string[]} = {},
328328
): [string[], string, string, string][] {
329-
// clang-format off
330-
// https://github.com/angular/clang-format/issues/35
331329
return _extractMessages(html, implicitTags, implicitAttrs).map((message) => [
332330
serializeNodes(message.nodes),
333331
message.meaning,
334332
message.description,
335333
message.id,
336334
]) as [string[], string, string, string][];
337-
// clang-format on
338335
}
339336

340337
function _humanizePlaceholders(
341338
html: string,
342339
implicitTags: string[] = [],
343340
implicitAttrs: {[k: string]: string[]} = {},
344341
): string[] {
345-
// clang-format off
346-
// https://github.com/angular/clang-format/issues/35
347342
return _extractMessages(html, implicitTags, implicitAttrs).map((msg) =>
348343
Object.keys(msg.placeholders)
349344
.map((name) => `${name}=${msg.placeholders[name].text}`)
350345
.join(', '),
351346
);
352-
// clang-format on
353347
}
354348

355349
function _humanizePlaceholdersToMessage(
356350
html: string,
357351
implicitTags: string[] = [],
358352
implicitAttrs: {[k: string]: string[]} = {},
359353
): string[] {
360-
// clang-format off
361-
// https://github.com/angular/clang-format/issues/35
362354
return _extractMessages(html, implicitTags, implicitAttrs).map((msg) =>
363355
Object.keys(msg.placeholderToMessage)
364356
.map((k) => `${k}=${digest(msg.placeholderToMessage[k])}`)
365357
.join(', '),
366358
);
367-
// clang-format on
368359
}
369360

370361
export function _extractMessages(

0 commit comments

Comments
 (0)