public Context(DocumentContext document, int startLineNumber, int startLinePosition, int startPosition, int endLineNumber, int endLinePosition, int endPosition, JSToken token) : this(document) { StartLineNumber = startLineNumber; StartLinePosition = startLinePosition; StartPosition = startPosition; EndLineNumber = endLineNumber; EndLinePosition = endLinePosition; EndPosition = endPosition; Token = token; }
public Context(DocumentContext document, int lineNumber, int startLinePos, int startPos, int endLineNumber, int endLinePos, int endPos, JSToken token) { Document = document; StartLineNumber = lineNumber; StartLinePosition = startLinePos; StartPosition = startPos; EndLineNumber = endLineNumber; EndLinePosition = endLinePos; EndPosition = endPos; Token = token; m_errorReported = 1000000; }
public Context(DocumentContext document) { if (document == null) { throw new ArgumentNullException("document"); } Document = document; StartLineNumber = 1; EndLineNumber = 1; EndPosition = (Document.Source == null) ? -1 : Document.Source.Length; Token = JSToken.None; m_errorReported = 1000000; }
public Context(DocumentContext document) { if (document == null) { throw new ArgumentNullException("document"); } Document = document; StartLineNumber = 1; EndLineNumber = 1; EndPosition = Document.Source.IfNotNull(s => s.Length); Token = JSToken.None; }
private void InnerMinify(IAsset asset, JSParser jsParser) { string newContent; string assetUrl = asset.Url; var documentContext = new DocumentContext(asset.Content) { FileContext = assetUrl }; jsParser.CompilerError += ParserErrorHandler; try { var stringBuilder = new StringBuilder(); using (var stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture)) { Block block = jsParser.Parse(documentContext); if (block != null) { if (_jsParserConfiguration.Format == JavaScriptFormat.JSON) { // Use a JSON output visitor if (!JSONOutputVisitor.Apply(stringWriter, block, _jsParserConfiguration)) { throw new MicrosoftAjaxParsingException(Strings.Minifiers_InvalidJsonOutput); } } else { // Use normal output visitor OutputVisitor.Apply(stringWriter, block, _jsParserConfiguration); } } } newContent = stringBuilder.ToString(); } catch (MicrosoftAjaxParsingException e) { throw new AssetMinificationException( string.Format(CoreStrings.Minifiers_MinificationSyntaxError, CODE_TYPE, assetUrl, MINIFIER_NAME, e.Message), e); } catch (Exception e) { throw new AssetMinificationException( string.Format(CoreStrings.Minifiers_MinificationFailed, CODE_TYPE, assetUrl, MINIFIER_NAME, e.Message), e); } finally { jsParser.CompilerError -= ParserErrorHandler; } asset.Content = newContent; asset.Minified = true; }