public void FixLastLineInfo()
 {
     if (lastLineInfo != null)
     {
         lastLineInfo.SetEndLinePos(StartLine, StartPos);
         lastLineInfo = null;
     }
 }
Example #2
0
        public void AddScriptBlock(string source, string uriString, int lineNumber, Location end)
        {
            CodeSnippetTypeMember scriptSnippet = new CodeSnippetTypeMember(source);
            string fileName = SourceLineInfo.GetFileName(uriString);

            if (lineNumber > 0)
            {
                scriptSnippet.LinePragma = new CodeLinePragma(fileName, lineNumber);
                scriptUris[fileName]     = uriString;
            }
            typeDecl.Members.Add(scriptSnippet);

            this.endUri = uriString;
            this.endLoc = end;
        }
        public void AddScriptBlock(string source, string uriString, int lineNumber, int endLine, int endPos)
        {
            CodeSnippetTypeMember scriptSnippet = new CodeSnippetTypeMember(source);
            string fileName = SourceLineInfo.GetFileName(uriString);

            if (lineNumber > 0)
            {
                scriptSnippet.LinePragma = new CodeLinePragma(fileName, lineNumber);
                scriptFiles.Add(fileName);
            }
            typeDecl.Members.Add(scriptSnippet);

            this.endFileName = fileName;
            this.endLine     = endLine;
            this.endPos      = endPos;
        }
        static void OutputResults(CollectionResolutionResults results, string xmlFile, string outputXmlFile)
        {
            if (results.Count == 0)
            {
                return;
            }

            var source = new SourceLineInfo(xmlFile);

            var first_cycle = results.First();

            // The first cycle is more interesting to the user, as it is mainly external Java types
            // that could not be resolved, which often point to a missing reference jar or NuGet.
            // Thus, we're going to output these as warnings.
            var missing_types = first_cycle.Unresolvables.Select(u => u.MissingType).Distinct().OrderBy(t => t);

            foreach (var type in missing_types)
            {
                Report.LogCodedWarning(0, Report.WarningJavaTypeNotResolved, source, type);
            }

            // The remaining cycles are generally just user types that are being removed because
            // other user types have been removed. Since the root cause is actually the missing external
            // types above, these aren't as important. We'll write them to a diagnostic file
            // for the user to inspect for details if they want.
            var report_file = Path.Combine(Path.GetDirectoryName(outputXmlFile), "java-resolution-report.log");

            using (var tw = File.CreateText(report_file)) {
                for (var i = 0; i < results.Count; i++)
                {
                    WriteCycle(tw, i + 1, results [i]);
                }
            }

            // Output diagnostic messages to verbose log
            foreach (var result in results.SelectMany(r => r.Unresolvables))
            {
                Report.Verbose(0, result.GetDisplayMessage());
            }

            // Let users know about this report
            Report.LogCodedWarning(0, Report.WarningTypesNotBoundDueToMissingJavaTypes, new SourceLineInfo(report_file));
        }
        public ISourceLineInfo BuildLineInfo()
        {
            bool onAttribute = (nodeType == XPathNodeType.Attribute);

            if (lastLineInfo != null && !onAttribute)
            {
                Debug.Assert(
                    Uri == lastLineInfo.Uri &&
                    StartLine == lastLineInfo.StartLine &&
                    StartPos == lastLineInfo.StartPos &&
                    EndLine == lastLineInfo.EndLine &&
                    EndPos == lastLineInfo.EndPos
                    );
                return(lastLineInfo);
            }
            SourceLineInfo lineInfo = new SourceLineInfo(Uri, StartLine, StartPos, EndLine, EndPos);

            if (!OnTextNode && !onAttribute)
            {
                lastLineInfo = lineInfo;
            }
            return(lineInfo);
        }
Example #6
0
 public CSToolsFatalException(int en, SourceLineInfo s, string y, string m)
     : base(en, s, y, m)
 {
 }
        private Stylesheet LoadStylesheet(XmlReader reader, bool include) {
            string baseUri = reader.BaseURI;
            Debug.Assert(!documentUriInUse.Contains(baseUri), "Circular references must be checked while processing xsl:include and xsl:import");
            documentUriInUse.Add(baseUri, null);

            Stylesheet  prevStylesheet  = curStylesheet;
            XsltInput   prevInput       = input;
            Stylesheet  thisStylesheet  = include ? curStylesheet : compiler.CreateStylesheet();

            input         = new XsltInput(reader, compiler);
            curStylesheet = thisStylesheet;

            try {
                LoadDocument();
                if (!include) {
                    compiler.MergeWithStylesheet(curStylesheet);

                    List<Uri> importHrefs = curStylesheet.ImportHrefs;
                    curStylesheet.Imports = new Stylesheet[importHrefs.Count];
                    // We can't reverce imports order. Template lookup relies on it after compilation
                    // Imports should be compiled in the reverse order
                    for (int i = importHrefs.Count - 1; 0 <= i; i--) {
                        curStylesheet.Imports[i] = LoadStylesheet(importHrefs[i], /*include:*/false);
                    }
                }
            }
            catch (XslLoadException) {
                throw;
            }
            catch (Exception e) {
                if (!XmlException.IsCatchableException(e)) {
                    throw;
                }
                XmlException ex = e as XmlException;
                if (ex != null) {
                    SourceLineInfo lineInfo = new SourceLineInfo(input.Uri, ex.LineNumber, ex.LinePosition, ex.LineNumber, ex.LinePosition);
                    throw new XslLoadException(ex, lineInfo);
                }
                input.FixLastLineInfo();
                throw new XslLoadException(e, input.BuildLineInfo());
            }
            finally {
                documentUriInUse.Remove(baseUri);
                input         = prevInput;
                curStylesheet = prevStylesheet;
            }
            return thisStylesheet;
        }
 public void FixLastLineInfo() {
     if (lastLineInfo != null) {
         lastLineInfo.SetEndLinePos(StartLine, StartPos);
         lastLineInfo = null;
     }
 }
 public ISourceLineInfo BuildLineInfo() {
     bool onAttribute = (nodeType == XPathNodeType.Attribute);
     if (lastLineInfo != null && !onAttribute) {
         Debug.Assert(
             Uri       == lastLineInfo.Uri       &&
             StartLine == lastLineInfo.StartLine &&
             StartPos  == lastLineInfo.StartPos  &&
             EndLine   == lastLineInfo.EndLine   &&
             EndPos    == lastLineInfo.EndPos
         );
         return lastLineInfo;
     }
     SourceLineInfo lineInfo = new SourceLineInfo(Uri, StartLine, StartPos, EndLine, EndPos);
     if (!OnTextNode && !onAttribute) {
         lastLineInfo = lineInfo;
     }
     return lineInfo;
 }