Ejemplo n.º 1
0
        public ImplementMembersForm(NemerleSource source, TypeBuilder ty, IEnumerable<IGrouping<FixedType.Class, IMember>> unimplementedMembers)
        {
            _source               = source;
            _ty                   = ty;
            _unimplementedMembers = unimplementedMembers;

            InitializeComponent();

            #region Init events hendlers

            _grid.CellPainting += CellPainting;
            _grid.CellValueChanged += CellValueChanged;
            _grid.CellValidating += CellValidating;
            _grid.CurrentCellDirtyStateChanged += CurrentCellDirtyStateChanged;

            #endregion
            #region Init ImageList

            imageList1.Images.AddStrip(Resources.SO_TreeViewIcons);
            _imageSize = imageList1.ImageSize.Width;
            Debug.Assert(imageList1.ImageSize.Width == imageList1.ImageSize.Height);

            #endregion

            if (_unimplementedMembers == null)
                return;

            FillTable(MakeTypeMembersMap());
        }
Ejemplo n.º 2
0
        private int GetTokenExtent(NemerleSource source, ITextSnapshot snapshot, SyntaxClassifier.SpanInfo spanInfo, out int line, out int startIdx, out int endIdx)
        {
            switch (spanInfo.Type)
            {
            case SyntaxClassifier.SpanType.String:
            case SyntaxClassifier.SpanType.RecursiveString:
            case SyntaxClassifier.SpanType.VerbatimString:
                // TODO: implement logic for $" $(x.|)  "
                goto default;

            case SyntaxClassifier.SpanType.Operator:
                if (!spanInfo.Span.IsEmpty && snapshot[spanInfo.Span.End - 1] == '.')
                {
                    return(GetDefaultExtent(out line, out startIdx, out endIdx));
                }
                else
                {
                    goto default;
                }

            default:
                var loc = Utils.ToNLocation(source.FileIndex, new SnapshotSpan(snapshot, spanInfo.Span));
                Debug.Assert(loc.Line == loc.EndLine);
                line     = loc.Line - 1;
                startIdx = loc.Column - 1;
                endIdx   = loc.EndColumn - 1;
                return(VSConstants.S_OK);
            }
        }
Ejemplo n.º 3
0
 public NemerleDeclarations(CompletionAsyncRequest result, NemerleSource source, bool isMemeberComplation)
 {
     OverloadPossibility = result.CompletionResult.CompletionList;
     Result              = result;
     Source              = source;
     ComlitionLocation   = result.ComlitionLocation;
     IsMemeberComplation = isMemeberComplation;
     Sort();
 }
 public NemerleSourceButchEditHelper(
     NemerleSource source,
     IVsTextView   view,
     bool          merge,
     string        description)
     : base(source, view, merge, description)
 {
     _fileIndex = source.FileIndex;
 }
Ejemplo n.º 5
0
 internal TextViewWrapper(IVsContainedLanguageHost languageHost, IVsIntellisenseHost intellisenseHost, IVsTextBufferCoordinator coordinator, IOleCommandTarget nextTarget, NemerleSource source)
 {
     if (null == intellisenseHost)
     {
         throw new ArgumentNullException("buffer");
     }
     this.intellisenseHost = intellisenseHost;
     this.bufferCoordinator = coordinator;
     this.languageHost = languageHost;
     this.nextTarget = nextTarget;
     this.source = source;
 }
Ejemplo n.º 6
0
 internal TextViewWrapper(IVsContainedLanguageHost languageHost, IVsIntellisenseHost intellisenseHost, IVsTextBufferCoordinator coordinator, IOleCommandTarget nextTarget, NemerleSource source)
 {
     if (null == intellisenseHost)
     {
         throw new ArgumentNullException("buffer");
     }
     this.intellisenseHost  = intellisenseHost;
     this.bufferCoordinator = coordinator;
     this.languageHost      = languageHost;
     this.nextTarget        = nextTarget;
     this.source            = source;
 }
Ejemplo n.º 7
0
        public BracketFinder(NemerleSource source, int startLine,
                             int startCol, NemerleScanner scanner, IVsTextColorState colorState)
        {
            #region Init fields

            Scanner   = scanner;
            Source    = source;
            StartLine = startLine;
            Lex       = scanner.GetNewLexer();
            Lex.SetFileName(source.GetFilePath());
            ColorState = colorState;
            _lineCount = source.GetLineCount();
            var line = startLine - 1;
            _buffer = new string[1] {
                source.GetText(line, 0, line, source.GetLineLength(line))
            };
            _startBufferLine = line;

            #endregion

            #region 2. Determine that it is a paired token. 3. Determine paired token.

            // Get tokens of line under text carret into dynamic array.
            List <ScanTokenInfo> lineToks = GetLineTokens(startLine, true);
            // Find index of token which located under text carret.
            int index = FindIndex(lineToks, x => x.Token.Location.Contains(startLine, startCol));

            if (index < 0)
            {
                return;
            }

            // If index is corret get corresponding token.
            ScanTokenInfo startBraceInfo = lineToks[index];
            // Remember it, if token have paired token.
            if (IsPairedToken(startBraceInfo.Token))
            {
                StartBraceInfo = startBraceInfo;
            }
            else
            {
                // otherwise try get right-hand token...
                startBraceInfo = RightHand(lineToks, index);
                // Remember it, if token have paired token.
                if (IsPairedToken(startBraceInfo.Token))
                {
                    StartBraceInfo = startBraceInfo;
                }
            }

            #endregion
        }
Ejemplo n.º 8
0
        private void HighlightSymbol()
        {
            NemerleSource source = Source;

            if (source != null)
            {
                TextSpan span = GetSelection();
                if (source.ProjectInfo == null)
                {
                    return;
                }

                source.GetEngine().BeginHighlightUsages(source, span.iStartLine + 1, span.iStartIndex + 1);
            }
        }
Ejemplo n.º 9
0
        private void ShowAst(IVsTextView view, bool showInfo)
        {
            NemerleSource source = Source as NemerleSource;

            if (source != null && source.ProjectInfo != null)
            {
                int line, col;
                ErrorHandler.ThrowOnFailure(view.GetCaretPos(out line, out col));
                //Debug.WriteLine(
                //		string.Format("OnChangeScrollInfo line={0}, col={1}", line + 1, col + 1));
                AstToolWindow tw = (AstToolWindow)source.ProjectInfo.ProjectNode.Package
                                   .FindToolWindow(typeof(AstToolWindow), 0, true);

                if (showInfo)
                {
                    tw.ShowInfo(source);
                }

                tw.Activate(line + 1, col + 1);
            }
        }
Ejemplo n.º 10
0
        internal void ShowInfo(NemerleSource source)
        {
            if (!IsAutoUpdate)
                return;

            Action action = () =>
            {
                _checkCountLabel.Text = (++_checkCount).ToString();
                _items.Clear();
                ProjectInfo projectInfo = source.ProjectInfo;

                if (projectInfo == null || !projectInfo.Engine.IsProjectAvailable)
                    return;

                switch (_displayType.SelectedIndex)
                {
                    case 0: // Tokens
                        string code = source.GetText();

                        LexerBase lex = new LexerString((ManagerClass)projectInfo.Engine, code,
                            new Location(source.FileIndex, 1, 1));
                        //lex.BeginParseFile();
                        lex.Keywords = lex.Manager.CoreEnv.Keywords;
                        AstUtils.FillList(lex, _items);
                        break;
                    case 1: // AST
                        //var ns = projectInfo.Engine.Project.CompileUnits
                        //	                    .GetTopNamespace(source.FileIndex);
                        //AstUtils.FillList(ns, _items);
                        break;
                }

                _grid.RowCount = _items.Count;
                _grid.Invalidate();
                _grid.Update();
            };

            _checkCountLabel.BeginInvoke(action);
        }
 public NemerleTypeAndMemberDropdownBars(NemerleLanguageService langService, IVsTextView forView)
     : base(null)
 {
     _languageService = langService;
     _source = (NemerleSource)langService.GetSource(forView);
 }
Ejemplo n.º 12
0
 public NemerleSmartIndentation(NemerleSource source)
 {
     _source = source;
     _useTabs = _source.LanguageService.Preferences.InsertTabs;
     _tabSize = _source.LanguageService.Preferences.TabSize;
 }
Ejemplo n.º 13
0
 internal NemerleCompletionSet(ImageList imageList, NemerleSource source)
     : base(imageList, source)
 {
     Source = source;
 }
Ejemplo n.º 14
0
        private int GetTokenExtent(NemerleSource source, ITextSnapshot snapshot, SyntaxClassifier.SpanInfo spanInfo, out int line, out int startIdx, out int endIdx)
        {
            switch (spanInfo.Type)
              {
            case SyntaxClassifier.SpanType.String:
            case SyntaxClassifier.SpanType.RecursiveString:
            case SyntaxClassifier.SpanType.VerbatimString:
              // TODO: implement logic for $" $(x.|)  "
              goto default;

            case SyntaxClassifier.SpanType.Operator:
              if (!spanInfo.Span.IsEmpty && snapshot[spanInfo.Span.End - 1] == '.')
            return GetDefaultExtent(out line, out startIdx, out endIdx);
              else
            goto default;

            default:
              var loc = Utils.ToNLocation(source.FileIndex, new SnapshotSpan(snapshot, spanInfo.Span));
              Debug.Assert(loc.Line == loc.EndLine);
              line = loc.Line - 1;
              startIdx = loc.Column - 1;
              endIdx = loc.EndColumn - 1;
              return VSConstants.S_OK;
              }
        }
Ejemplo n.º 15
0
 public NemerleSmartIndentation(NemerleSource source)
 {
     _source  = source;
     _useTabs = _source.LanguageService.Preferences.InsertTabs;
     _tabSize = _source.LanguageService.Preferences.TabSize;
 }
Ejemplo n.º 16
0
        public override Source CreateSource(IVsTextLines buffer)
        {
            var source = new NemerleSource(this, buffer);

            return(source);
        }
Ejemplo n.º 17
0
        public int GetTextViewFilter(IVsIntellisenseHost pISenseHost, IOleCommandTarget pNextCmdTarget, out IVsTextViewFilter pTextViewFilter)
        {
            pTextViewFilter = null;

            IVsTextLines buffer;

            ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer));

            var secondaryFilePath = FilePathUtilities.GetFilePath(buffer);

            if (secondaryFilePath == null)
            {
                secondaryFilePath = NemerleSource.GetStubFileForSecondaryBuffer(buffer);
            }

            var secondaryFileIndex = Location.GetFileIndex(secondaryFilePath);
            var primaryFileindex   = Location.GetFileIndex(_filePath);

            bool doOutlining = LanguageService.Preferences.AutoOutlining;

            LanguageService.Preferences.AutoOutlining = false;

            if (_projectInfo != null && LanguageService.GetSource(buffer) == null)
            {
                // создаем и регистрируем в проекте временный source, чтобы не сломалась логика
                // конструктора NemerleSource (см вызов LanguageService.AddEditableSource)
                //_projectInfo.ReplaseOrAddSource(new FileNemerleSource(secondaryFileIndex));
                _projectInfo.AddEditableSource((NemerleSource)LanguageService.CreateSource(buffer));
            }

            NemerleSource source = LanguageService.GetOrCreateSource(buffer) as NemerleSource;

            source.SetBufferCoordinator(bufferCoordinator);

            if (_projectInfo != null)
            {
                _projectInfo.Engine.RequestOnBuildTypesTree();
            }

            LanguageService.Preferences.AutoOutlining = doOutlining;

            _windowManager = LanguageService.CreateCodeWindowManager(null, source);

            language.AddCodeWindowManager(_windowManager);

            // увеличиваем внутренний счетчик openCount, для того чтобы впоследствии корректно отработала логика закрытия соурса
            source.Open();

            TextViewWrapper view = new TextViewWrapper(languageHost, pISenseHost, bufferCoordinator, pNextCmdTarget, source);

            _windowManager.OnNewView(view);

            pTextViewFilter = view.InstalledFilter;
            NemerleViewFilter nemerleFilter = pTextViewFilter as NemerleViewFilter;

            if (null != nemerleFilter)
            {
                nemerleFilter.BufferCoordinator = this.bufferCoordinator;
            }

            // сохраним значение DocumentEvents в переменной класса, чтобы исключить преждевременное уничтожение
            // объекта и автоматическоей отписывание от событий.
            //
            // Источник решения:
            // PRB: Visual Studio .NET events being disconnected from add-in (http://www.mztools.com/articles/2005/mz2005012.aspx)
            _documentEvents = _projectItem.DTE.Events.get_DocumentEvents(_projectItem.Document);

            _documentEvents.DocumentClosing += _documentClosingEventHandler;

            return(VSConstants.S_OK);
        }
Ejemplo n.º 18
0
 internal NemerleCompletionSet(ImageList imageList, NemerleSource source)
     : base(imageList, source)
 {
     Source = source;
 }
Ejemplo n.º 19
0
 public NemerleCodeWindowManager(Microsoft.VisualStudio.Package.LanguageService service, IVsCodeWindow codeWindow, NemerleSource source)
     : base(service, codeWindow, source)
 {
     _source = source;
 }
Ejemplo n.º 20
0
 public NemerleCodeWindowManager(Microsoft.VisualStudio.Package.LanguageService service, IVsCodeWindow codeWindow, NemerleSource source)
     : base(service, codeWindow, source)
 {
     _source = source;
 }