16
16
package com .schibsted .spt .data .jslt .impl ;
17
17
18
18
import java .util .Map ;
19
+ import java .util .List ;
19
20
import java .util .HashMap ;
20
21
import java .util .ArrayList ;
21
22
import java .util .Collection ;
@@ -39,10 +40,18 @@ public class ParseContext {
39
40
*/
40
41
private String source ;
41
42
/**
42
- * Imported modules listed under their prefixes.
43
+ * Imported modules listed under their prefixes. This is scoped per
44
+ * source file, since each has a different name-module mapping.
43
45
*/
44
46
private Map <String , Module > modules ;
45
- private Collection <FunctionExpression > funcalls ; // delayed function resolution
47
+ /**
48
+ * Tracks all loaded JSLT files. Shared between all contexts.
49
+ */
50
+ private List <JstlFile > files ;
51
+ /**
52
+ * Function expressions, used for delayed name-to-function resolution.
53
+ */
54
+ private Collection <FunctionExpression > funcalls ;
46
55
private ParseContext parent ;
47
56
private ResourceResolver resolver ;
48
57
/**
@@ -57,13 +66,15 @@ public class ParseContext {
57
66
public ParseContext (Collection <Function > extensions , String source ,
58
67
ResourceResolver resolver ,
59
68
Map <String , Module > namedModules ,
69
+ List <JstlFile > files ,
60
70
PreparationContext preparationContext ) {
61
71
this .extensions = extensions ;
62
72
this .functions = new HashMap ();
63
73
for (Function func : extensions )
64
74
functions .put (func .getName (), func );
65
75
66
76
this .source = source ;
77
+ this .files = files ;
67
78
this .funcalls = new ArrayList ();
68
79
this .modules = new HashMap ();
69
80
this .resolver = resolver ;
@@ -75,7 +86,7 @@ public ParseContext(Collection<Function> extensions, String source,
75
86
76
87
public ParseContext (String source ) {
77
88
this (Collections .EMPTY_SET , source , new ClasspathResourceResolver (),
78
- new HashMap (), new PreparationContext ());
89
+ new HashMap (), new ArrayList (), new PreparationContext ());
79
90
}
80
91
81
92
public void setParent (ParseContext parent ) {
@@ -165,11 +176,11 @@ public ResourceResolver getResolver() {
165
176
return resolver ;
166
177
}
167
178
168
- public Scope evaluateGlobalModuleVariables ( int stackFrameSize ) {
169
- Scope scope = Scope . getRoot ( stackFrameSize ) ;
170
- for ( Module m : modules . values ())
171
- if ( m instanceof JstlFile )
172
- (( JstlFile ) m ). evaluateLetsOnly ( scope );
173
- return scope ;
179
+ public List < JstlFile > getFiles ( ) {
180
+ return files ;
181
+ }
182
+
183
+ public void registerJsltFile ( JstlFile file ) {
184
+ files . add ( file ) ;
174
185
}
175
186
}
0 commit comments