1
1
import { MethodDeclaration } from "typescript" ;
2
2
import { INameGetter } from "../getter/interface/INameGetter" ;
3
3
import { ISourceFilePropertiesGetter } from "../getter/interface/ISourceFilePropertiesGetter" ;
4
- import { IValueExpressionGetter } from "../getter/interface/IValueExpressionGetter" ;
5
- import { IValueResolvedGetter } from "../getter/interface/IValueResolvedGetter" ;
6
4
import { isStaticKeyword } from "../predicate/PredicateFunctions" ;
7
- import { IdentifierMapKind , IMethodDeclaration , INonNullableValueable } from "../service/interface/ICodeAnalyzer" ;
8
- import { ITracer } from "../tracer/interface/ITracer" ;
5
+ import { IdentifierMapKind , IMethodDeclaration } from "../service/interface/ICodeAnalyzer" ;
9
6
import { FunctionLikeFormatter } from "./FunctionLikeFormatter" ;
10
7
import { IDecoratorsFormatter } from "./interface/IDecoratorsFormatter" ;
11
8
import { IMethodFormatter } from "./interface/IMethodFormatter" ;
12
9
import { IModifiersFormatter } from "./interface/IModifiersFormatter" ;
13
10
import { IParametersFormatter } from "./interface/IParametersFormatter" ;
11
+ import { IValueableFormatter } from "./interface/IValueableFormatter" ;
14
12
15
13
export class MethodFormatter extends FunctionLikeFormatter implements IMethodFormatter {
16
14
17
- constructor ( private tracer : ITracer ,
18
- private nameGetter : INameGetter ,
19
- private valueExpressionGetter : IValueExpressionGetter ,
20
- private valueResolvedGetter : IValueResolvedGetter ,
15
+ constructor ( private nameGetter : INameGetter ,
21
16
sourceFilePropertiesGetter : ISourceFilePropertiesGetter ,
22
17
decoratorsFormatter : IDecoratorsFormatter ,
23
18
modifiersFormatter : IModifiersFormatter ,
24
- parametersFormatter : IParametersFormatter ) {
25
- super ( sourceFilePropertiesGetter , decoratorsFormatter , modifiersFormatter , parametersFormatter ) ;
19
+ parametersFormatter : IParametersFormatter ,
20
+ valueableFormatter : IValueableFormatter ) {
21
+ super ( sourceFilePropertiesGetter , decoratorsFormatter , modifiersFormatter , parametersFormatter , valueableFormatter ) ;
26
22
}
27
23
28
24
/**
@@ -36,9 +32,6 @@ export class MethodFormatter extends FunctionLikeFormatter implements IMethodFor
36
32
37
33
const isStatic = declaration . modifiers == null ? false : declaration . modifiers . find ( modifier => isStaticKeyword ( modifier ) ) != null ;
38
34
const filePath = this . sourceFilePropertiesGetter . getSourceFileProperties ( declaration ) . filePath ;
39
- const valueExpression = declaration . body == null ? null : this . valueExpressionGetter . getValueExpression ( declaration . body ) ;
40
- const that = this ;
41
- const scope = this . tracer . traceThis ( declaration ) ;
42
35
43
36
const map : IMethodDeclaration = {
44
37
...this . formatFunctionLikeDeclaration ( declaration ) ,
@@ -48,25 +41,7 @@ export class MethodFormatter extends FunctionLikeFormatter implements IMethodFor
48
41
name,
49
42
className,
50
43
filePath,
51
- value : {
52
- expression : valueExpression ,
53
- resolving : false ,
54
- resolved : undefined ,
55
- resolvedPrecompute : undefined ,
56
- hasDoneFirstResolve ( ) {
57
- return map . value . resolved !== undefined ;
58
- } ,
59
- resolve ( insideThisScope : boolean = false ) {
60
- if ( map . value . expression == null ) {
61
- map . value . resolved = map . value . resolvedPrecompute = null ;
62
- } else {
63
- const [ computed , flattened ] = that . valueResolvedGetter . getValueResolved ( < INonNullableValueable > map . value , declaration , scope , undefined , insideThisScope ) ;
64
- map . value . resolved = computed ;
65
- map . value . resolvedPrecompute = flattened ;
66
- }
67
- return map . value . resolved ;
68
- }
69
- }
44
+ value : this . valueableFormatter . format ( declaration , undefined , declaration . body )
70
45
}
71
46
} ;
72
47
0 commit comments