/// <summary> /// Creates DAX Document Properties object, stores in private member and returns the reference to it. /// </summary> /// <param name="mgr"></param> /// <returns>Reference to DAX Document Properties.</returns> public override DocumentProperties CreateDocumentProperties(CodeWindowManager mgr) { DaxDocumentProperties daxDocumentProperties = new DaxDocumentProperties(mgr); // Initialize BismProvider for given Document/Source/CodeWindowManager Babel.Source babelSource = mgr.Source as Babel.Source; if (babelSource != null) { BismProvider = new BismInfoProvider(daxDocumentProperties); babelSource.BismInfoProvider = BismProvider; } return(daxDocumentProperties); }
public override Microsoft.VisualStudio.Package.AuthoringScope ParseSource(ParseRequest req) { Babel.Source source = (Babel.Source) this.GetSource(req.FileName); bool yyparseResult = false; // req.DirtySpan seems to be set even though no changes have occurred // source.IsDirty also behaves strangely // might be possible to use source.ChangeCount to sync instead if (req.DirtySpan.iStartIndex != req.DirtySpan.iEndIndex || req.DirtySpan.iStartLine != req.DirtySpan.iEndLine) { ErrorHandler handler = new ErrorHandler(); Scanner scanner = new Scanner(); // string interface Parser parser = new Parser(); // use noarg constructor parser.scanner = scanner; scanner.Handler = handler; parser.SetHandler(handler); scanner.SetSource(req.Text, 0); parser.MBWInit(req); yyparseResult = parser.Parse(); // store the parse results // source.ParseResult = aast; source.ParseResult = null; source.Braces = parser.Braces; // for the time being, just pull errors back from the error handler if (handler.ErrNum > 0) { foreach (Babel.Parser.Error error in handler.SortedErrorList()) { TextSpan span = new TextSpan(); span.iStartLine = span.iEndLine = error.line - 1; span.iStartIndex = error.column; span.iEndIndex = error.column + error.length; req.Sink.AddError(req.FileName, error.message, span, Severity.Error); } } } switch (req.Reason) { case ParseReason.Check: case ParseReason.HighlightBraces: case ParseReason.MatchBraces: case ParseReason.MemberSelectAndHighlightBraces: // send matches to sink // this should (probably?) be filtered on req.Line / col if (source.Braces != null) { foreach (TextSpan[] brace in source.Braces) { if (brace.Length == 2) { req.Sink.MatchPair(brace[0], brace[1], 1); } else if (brace.Length >= 3) { req.Sink.MatchTriple(brace[0], brace[1], brace[2], 1); } } } break; default: break; } return(new AuthoringScope(req.Text)); }