Exemplo n.º 1
0
        public override NewOutlineRegion[] GetCollapsibleRegions(string text, string fname)
        {
            Cci.ParseReason reason = Cci.ParseReason.CollapsibleRegions;
            Microsoft.VisualStudio.Package.AuthoringSink aSink = new Microsoft.VisualStudio.Package.AuthoringSink(0, 0, 0);
            AuthoringSink scAsink = new AuthoringSink(aSink);

            this.scLanguageService.ParseSource(text, 0, 0, fname, scAsink, reason);
            if (scAsink.CollapsibleRegions == null)
            {
                return(null);
            }
            int n = scAsink.CollapsibleRegions.Count;

            NewOutlineRegion[] result = new NewOutlineRegion[n];
            for (int i = 0; i < n; i++)
            {
                CollapsibleRegion cr = (CollapsibleRegion)scAsink.CollapsibleRegions[i];
                if (cr == null)
                {
                    continue;
                }
                TextSpan span = new TextSpan();
                span.iStartIndex = cr.SourceContext.StartColumn - 1;
                span.iStartLine  = cr.SourceContext.StartLine - 1;
                span.iEndIndex   = cr.SourceContext.EndColumn - 1;
                span.iEndLine    = cr.SourceContext.EndLine - 1;
                NewOutlineRegion region = new NewOutlineRegion();
                region.tsHiddenText = span;
                region.dwState      = (uint)(cr.Collapsed ? HIDDEN_REGION_STATE.hrsDefault : HIDDEN_REGION_STATE.hrsExpanded);
                result[i]           = region;
            }
            return(result);
        }
Exemplo n.º 2
0
 //bool disposed = false;
 public NSAuthoringScope(AuthoringSink sink, string filename, string dirtyname, string projectfile)
     : base()
 {
     m_sink = sink;
     m_filename = filename;
     m_dirtyname = dirtyname;
     m_projectfile = projectfile;
 }
Exemplo n.º 3
0
 public NSAuthoringScope(ParseRequest req, string dirtyFile, string project)
     : base()
 {
     m_sink = req.Sink;
     m_projectfile = project;
     m_dirtyname = dirtyFile;
     m_filename = req.FileName;
 }
Exemplo n.º 4
0
 public override Microsoft.VisualStudio.Package.AuthoringScope ParseSource(string text, int line, int col, string fname,
                                                                           Microsoft.VisualStudio.Package.AuthoringSink aSink, Microsoft.VisualStudio.Package.ParseReason reason)
 {
     lock (ProjectManager.BuildLock){
         Cci.AuthoringSink  scAsink     = new AuthoringSink(aSink);
         Cci.AuthoringScope scAuthScope =
             this.scLanguageService.ParseSource(text, line, col, fname, scAsink, (Cci.ParseReason)reason);
         return(new AuthoringScope(scAuthScope, this.glyphProvider));
     }
 }
Exemplo n.º 5
0
 public virtual string OnSyncGoto(VsCommands cmd, IVsTextView textView, int line, int col, out TextSpan span){
   // synchronous parse and return definition location.
   string text = this.GetTextUpToLine(line+1);
   string fname = this.GetFilePath();
   ParseReason reason = ParseReason.Autos;
   AuthoringSink sink = new AuthoringSink(reason, line, col);
   AuthoringScope scope = this.service.ParseSource(text, line, col, fname, sink, reason);
   if (scope != null){
     return scope.Goto(cmd, textView, line, col, out span);
   }else{
     span = new TextSpan();
   }
   return null;
 }
Exemplo n.º 6
0
 public virtual string OnSyncQuickInfo(IVsTextView textView, int line, int col){
   // synchronous parse and return data tip text.
   string text = this.GetTextUpToLine(line+1);
   string fname = this.GetFilePath();
   ParseReason reason = ParseReason.Autos;
   AuthoringSink sink = new AuthoringSink(reason, line, col);
   AuthoringScope scope = this.service.ParseSource(text, line, col, fname, sink, reason);
   if (scope != null){
     TextSpan span;
     return scope.GetDataTipText(line, col, out span);
   }
   return null;
 }
Exemplo n.º 7
0
    public ParseRequest(int line, int col, TokenInfo info, string text, string fname, ParseReason reason, IVsTextView view){
      this.Line = line; this.Col = col;
      this.FileName = fname;
      this.Text = text; this.Reason = reason;
      this.View = view;
      this.Sink = new AuthoringSink(reason, line, col);
      this.TokenInfo = info;
#if LookForMemoryLeaks
      System.GC.Collect();
      this.UsedMemoryAtStartOfRequest = System.GC.GetTotalMemory(true);
#endif
    }
Exemplo n.º 8
0
 public abstract AuthoringScope ParseSource(string text, int line, int col, string fname, AuthoringSink asink, ParseReason reason);
Exemplo n.º 9
0
        private void CreateWarningsForUnknownSteps(string path, AuthoringSink sink, ParseTree parseTree, Source source)
        {
            var warningCreator = new WarningCreator
                                     {
                                         Grammar = GherkinGrammar,
                                         Root = parseTree.Root,
                                         Source = source,
                                         StepProvider = _stepProvider
                                     };
            warningCreator.CreateSpansForUndefinedSteps();

            foreach (var textSpan in warningCreator.Result)
                sink.AddError(path, "Step not (yet) defined.", textSpan, Severity.Warning);
        }
 //  TODO: consider multi-line function calls
 //  Parses starting from before line and col looking for the function name to look up
 private bool startMethodTip(Source source, AuthoringSink sink, int line, int col)
 {
     if (col <= 0)
     {
         return false;
     }
     TextSpan span = new TextSpan();
     span.iStartLine = span.iEndLine = line;
     span.iStartIndex = col - 1;
     span.iEndIndex = col;
     string pStart = source.GetText(span);
     if (pStart != "(")
     {
         return false;
     }
     TokenInfo funToken = source.GetTokenInfo(line, col - 1);
     TextSpan funSpan = new TextSpan();
     funSpan.iStartLine = funSpan.iEndLine = span.iStartLine;
     funSpan.iStartIndex = funToken.StartIndex;
     funSpan.iEndIndex = span.iStartIndex;
     string funName = source.GetText(funSpan);
     sink.StartName(funSpan, funName);
     sink.StartParameters(span);
     return true;
 }
Exemplo n.º 11
0
 public PythonSink(AuthoringSink authoringSink)
 {
     this.authoringSink = authoringSink;
 }
Exemplo n.º 12
0
 public AuthoringSink(Microsoft.VisualStudio.Package.AuthoringSink vsAuthoringSink)
 {
     Debug.Assert(vsAuthoringSink != null);
     this.vsAuthoringSink = vsAuthoringSink;
 }
Exemplo n.º 13
0
 public AuthoringSink(Microsoft.VisualStudio.Package.AuthoringSink vsAuthoringSink){
   Debug.Assert(vsAuthoringSink != null);
   this.vsAuthoringSink = vsAuthoringSink;
 }
Exemplo n.º 14
0
        private static void AddHiddenRegions(AuthoringSink sink, IEnumerable<AstNode> content)
        {
            foreach (AstNode astNode in content)
            {
                if ((astNode is XmlElement || astNode is NVForeachDirective)
                    && (astNode.Position.StartLine < astNode.Position.EndLine))
                {
            //                    NewHiddenRegion region = new NewHiddenRegion();
            //                    region.dwBehavior = (uint)HIDDEN_REGION_BEHAVIOR.hrbEditorControlled;
            //                    region.dwState = (uint)HIDDEN_REGION_STATE.hrsExpanded;
            //                    region.iType = (int)HIDDEN_REGION_TYPE.hrtCollapsible;
            //                    region.pszBanner = "..." + xmlElement.Name + "...";

                    TextSpan hiddenTextSpan = new TextSpan();
                    hiddenTextSpan.iStartLine = astNode.Position.StartLine - 1;
                    hiddenTextSpan.iStartIndex = astNode.Position.StartPos - 1;
                    hiddenTextSpan.iEndLine = astNode.Position.EndLine - 1;
                    hiddenTextSpan.iEndIndex = astNode.Position.EndPos - 1;
            //                    region.tsHiddenText = hiddenTextSpan;

                    sink.AddHiddenRegion(hiddenTextSpan);

                    // Add child regions
                    if (astNode is XmlElement)
                        AddHiddenRegions(sink, ((XmlElement)astNode).Content);
                    else if (astNode is NVForeachDirective)
                        AddHiddenRegions(sink, ((NVForeachDirective)astNode).Content);
                }
            }
        }
Exemplo n.º 15
0
    public virtual void GetPairExtents(int line, int col, out TextSpan span){

      span = new TextSpan();

      // Synchronously return the matching brace location.      
      string text = this.GetTextUpToLine(0); // Might be matching forwards so we have to search the whole file.
      string fname = this.GetFilePath();
      ParseReason reason = ParseReason.MatchBraces;
      AuthoringSink sink = new AuthoringSink(reason, line, col);
      AuthoringScope scope = this.service.ParseSource(text, line, col, fname, sink, reason);

      if (sink.Spans.Count == 0)
        return;

      //transform spanList into an array of spans
      TextSpan[] spans = (TextSpan[])sink.Spans.ToArray(typeof(TextSpan));      
      int spanCount = spans.Length;

      //called from ViewFilter::GetPairExtents
      if (spans[0].iStartLine < spans[spanCount-1].iStartLine ||
        (spans[0].iStartLine == spans[spanCount-1].iStartLine && spans[0].iStartIndex <= spans[spanCount-1].iStartIndex )){
        span.iStartLine  = spans[0].iStartLine;
        span.iStartIndex = spans[0].iStartIndex;
        span.iEndLine    = spans[spanCount-1].iStartLine;
        span.iEndIndex   = spans[spanCount-1].iStartIndex;
      }
      else{
        span.iStartLine  = spans[spanCount-1].iStartLine;
        span.iStartIndex = spans[spanCount-1].iStartIndex;
        span.iEndLine    = spans[0].iStartLine;
        span.iEndIndex   = spans[0].iStartIndex;
      }

      if (span.iStartLine == span.iEndLine && span.iStartIndex == span.iEndIndex)
        NativeHelpers.RaiseComError(HResult.S_FALSE);

      return;
    }
Exemplo n.º 16
0
 /// <include file='doc\LanguageService.uex' path='docs/doc[@for="ParseRequest.ParseRequest1"]/*' />
 public ParseRequest(int line, int col, TokenInfo info, string src, string fname, ParseReason reason, IVsTextView view, AuthoringSink sink) {
     this.Line = line;
     this.Col = col;
     this.FileName = fname;
     this.Text = src;
     this.Reason = reason;
     this.View = view;
     this.Sink = sink;
     this.TokenInfo = info;
 }
Exemplo n.º 17
0
        private void AddMessages(Source source, AuthoringSink sink, ParseTree parseTree)
        {
            var messages = parseTree.ParserMessages;
            foreach (var message in messages)
            {
                var line = source.GetLine(message.Location.Line);
                var nextSpace = line.Length;

                if (line.Length > message.Location.Column)
                    nextSpace = line.IndexOfAny(" \t\n\r".ToCharArray(), message.Location.Column + 1);

                if (nextSpace == -1)
                    nextSpace = line.Length;

                var span = new TextSpan
                                {
                                    iStartLine = message.Location.Line,
                                    iStartIndex = message.Location.Column,
                                    iEndLine = message.Location.Line,
                                    iEndIndex = nextSpace
                                };

                var severity = Severity.Hint;
                switch (message.Level)
                {
                    case ParserErrorLevel.Info:
                        severity = Severity.Hint;
                        break;

                    case ParserErrorLevel.Warning:
                        severity = Severity.Warning;
                        break;

                    case ParserErrorLevel.Error:
                        severity = Severity.Error;
                        break;
                }
                sink.AddError(source.GetFilePath(), message.Message, span, severity);
            }
        }
Exemplo n.º 18
0
        private void CreateHiddenRegions(AuthoringSink sink, ParseTree parseTree, Source source)
        {
            var regionCreator = new RegionCreator
                                    {
                                        Root = parseTree.Root,
                                        Source = source
                                    };
            regionCreator.CreateRegionsFor(GherkinGrammar.Description, GherkinGrammar.GivenWhenThenClause);

            sink.ProcessHiddenRegions = true;
            foreach (var textSpan in regionCreator.Result)
                sink.AddHiddenRegion(textSpan);
        }
Exemplo n.º 19
0
 //constructor
 public HLSLAuthoringSink(AuthoringSink sink)
 {
     this.sink = sink;
 }