Skip to content

Commit 3f02f3b

Browse files
committed
Refactoring: Moved NgModule class to model folder. Now detecting is module is a routing module.
1 parent 6bcbe3e commit 3f02f3b

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

src/model/NgModule.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ArrayUtils } from "@src";
2+
3+
export class NgModule {
4+
public imports: string[] = [];
5+
public exports: string[] = [];
6+
public declarations: string[] = [];
7+
public entryComponents: string[] = [];
8+
public providers: string[] = [];
9+
public bootstrap: string[] = [];
10+
public filename: string = '';
11+
public moduleName: string = '';
12+
public isRoutingModule: boolean = false;
13+
public moduleStats(): number[] {
14+
return [
15+
this.declarations === undefined ? 0 : ArrayUtils.arrayLength(this.declarations),
16+
this.imports === undefined ? 0 : ArrayUtils.arrayLength(this.imports),
17+
this.exports === undefined ? 0 : ArrayUtils.arrayLength(this.exports),
18+
this.bootstrap === undefined ? 0 : ArrayUtils.arrayLength(this.bootstrap),
19+
this.providers === undefined ? 0 : ArrayUtils.arrayLength(this.providers),
20+
this.entryComponents === undefined ? 0 : ArrayUtils.arrayLength(this.entryComponents),
21+
];
22+
}
23+
}

src/model/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export * from './Edge';
77
export * from './GraphState';
88
export * from './NamedEntity';
99
export * from './NetworkNode';
10+
export * from './NgModule';
1011
export * from './Node';
1112
export * from './NodeType';
1213
export * from './Position';

src/moduleManager.ts

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
import * as fs from 'fs';
22
import { ArrayUtils, Config, FileSystemUtils } from "@src";
3-
import { Component, Directive, Injectable, NamedEntity, Pipe, Project } from '@model';
4-
5-
export class NgModule {
6-
public imports: string[] = [];
7-
public exports: string[] = [];
8-
public declarations: string[] = [];
9-
public entryComponents: string[] = [];
10-
public providers: string[] = [];
11-
public bootstrap: string[] = [];
12-
public filename: string = '';
13-
public moduleName: string = '';
14-
public moduleStats(): number[] {
15-
return [
16-
this.declarations === undefined ? 0 : ArrayUtils.arrayLength(this.declarations),
17-
this.imports === undefined ? 0 : ArrayUtils.arrayLength(this.imports),
18-
this.exports === undefined ? 0 : ArrayUtils.arrayLength(this.exports),
19-
this.bootstrap === undefined ? 0 : ArrayUtils.arrayLength(this.bootstrap),
20-
this.providers === undefined ? 0 : ArrayUtils.arrayLength(this.providers),
21-
this.entryComponents === undefined ? 0 : ArrayUtils.arrayLength(this.entryComponents),
22-
];
23-
}
24-
}
3+
import { Component, Directive, Injectable, NamedEntity, NgModule, Pipe, Project } from '@model';
254

265
export class ModuleManager {
276

@@ -63,9 +42,16 @@ export class ModuleManager {
6342
const module: NgModule = this.parseModuleContents(moduleContents);
6443
module.filename = filename;
6544
module.moduleName = moduleName;
45+
46+
regex = /:\s+routes\s+=\s+\[.*?\]/ims;
47+
match = regex.exec(fileContents.toString());
48+
if (match !== null) {
49+
module.isRoutingModule = true;
50+
}
51+
6652
return module;
6753
} catch (ex) {
68-
errors.push(`ModuleName: ${moduleName}\nFilename: ${filename}\nException: ${ex}\n${match[1]}\n`);
54+
errors.push(`ModuleName: ${moduleName}\nFilename: ${filename}\nException: ${ex}\n${moduleContents}\n`);
6955
return undefined;
7056
}
7157
}

0 commit comments

Comments
 (0)