|
9 | 9 | import java.util.LinkedHashSet; |
10 | 10 | import java.util.Set; |
11 | 11 |
|
| 12 | +import com.semmle.extractor.html.HtmlPopulator; |
12 | 13 | import com.semmle.js.parser.JcornWrapper; |
13 | 14 | import com.semmle.util.data.StringUtil; |
14 | 15 | import com.semmle.util.exception.UserError; |
@@ -146,42 +147,6 @@ public Set<String> getPredefinedGlobals() { |
146 | 147 | } |
147 | 148 | } |
148 | 149 |
|
149 | | - /** How to handle HTML files. */ |
150 | | - public static enum HTMLHandling { |
151 | | - /** Only extract embedded scripts, not the HTML itself. */ |
152 | | - SCRIPTS(false, false), |
153 | | - /** Only extract elements and embedded scripts, not text. */ |
154 | | - ELEMENTS(true, false), |
155 | | - /** Extract elements, embedded scripts, and text. */ |
156 | | - ALL(true, true); |
157 | | - |
158 | | - private final boolean extractElements; |
159 | | - |
160 | | - private final boolean extractText; |
161 | | - |
162 | | - private HTMLHandling(boolean extractElements, boolean extractText) { |
163 | | - this.extractElements = extractElements; |
164 | | - this.extractText = extractText; |
165 | | - } |
166 | | - |
167 | | - public boolean extractElements() { |
168 | | - return extractElements; |
169 | | - } |
170 | | - |
171 | | - public boolean extractText() { |
172 | | - return extractText; |
173 | | - } |
174 | | - |
175 | | - public boolean extractComments() { |
176 | | - return extractElements; |
177 | | - } |
178 | | - |
179 | | - @Override |
180 | | - public String toString() { |
181 | | - return StringUtil.lc(name()); |
182 | | - } |
183 | | - } |
184 | | - |
185 | 150 | /** Which language version is the source code parsed as? */ |
186 | 151 | private ECMAVersion ecmaVersion; |
187 | 152 |
|
@@ -213,7 +178,7 @@ public String toString() { |
213 | 178 | private boolean tolerateParseErrors; |
214 | 179 |
|
215 | 180 | /** How should HTML files be extracted? */ |
216 | | - private HTMLHandling htmlHandling; |
| 181 | + private HtmlPopulator.Config htmlHandling; |
217 | 182 |
|
218 | 183 | /** |
219 | 184 | * Which {@link FileExtractor.FileType} should this code be parsed as? |
@@ -244,7 +209,7 @@ public ExtractorConfig(boolean experimental) { |
244 | 209 | this.platform = Platform.AUTO; |
245 | 210 | this.jsx = true; |
246 | 211 | this.sourceType = SourceType.AUTO; |
247 | | - this.htmlHandling = HTMLHandling.ELEMENTS; |
| 212 | + this.htmlHandling = HtmlPopulator.Config.ELEMENTS; |
248 | 213 | this.tolerateParseErrors = true; |
249 | 214 | if (experimental) { |
250 | 215 | this.mozExtensions = true; |
@@ -403,11 +368,11 @@ public ExtractorConfig withJsx(boolean jsx) { |
403 | 368 | return res; |
404 | 369 | } |
405 | 370 |
|
406 | | - public HTMLHandling getHtmlHandling() { |
| 371 | + public HtmlPopulator.Config getHtmlHandling() { |
407 | 372 | return htmlHandling; |
408 | 373 | } |
409 | 374 |
|
410 | | - public ExtractorConfig withHtmlHandling(HTMLHandling htmlHandling) { |
| 375 | + public ExtractorConfig withHtmlHandling(HtmlPopulator.Config htmlHandling) { |
411 | 376 | ExtractorConfig res = new ExtractorConfig(this); |
412 | 377 | res.htmlHandling = htmlHandling; |
413 | 378 | return res; |
|
0 commit comments