Exemplo n.º 1
0
        public bool TryResolveType(IViewExplorer viewExplorer, string codeSnippit, out Type resolvedType, out string remainingCode)
        {
            resolvedType  = null;
            remainingCode = codeSnippit;

            var fragments = codeSnippit.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries).Reverse();

            string instanceName = string.Empty;

            foreach (var fragment in fragments)
            {
                resolvedType = GetResolvedTypeByInstance(viewExplorer, fragment, out instanceName) ?? GetResolvedTypeByName(fragment);
                if (resolvedType != null)
                {
                    break;
                }
            }

            if (resolvedType != null)
            {
                remainingCode = GetRemainingCode(fragments, resolvedType, instanceName);
            }

            return(resolvedType != null);
        }
Exemplo n.º 2
0
 public CompletionSource(ITextBuffer textBuffer, IProjectExplorer projectExplorer)
 {
     _textBuffer          = textBuffer;
     _projectExplorer     = projectExplorer;
     _viewExplorer        = _projectExplorer.GetViewExplorer(textBuffer);
     _textBuffer.Changed += TextBuffer_Changed;
 }
Exemplo n.º 3
0
 public void Setup()
 {
     _mockViewExplorer = MockRepository.GenerateMock <IViewExplorer>();
     _stubSnapshot     = MockRepository.GenerateStub <ITextSnapshot>();
     _stubViewExplorer = MockRepository.GenerateStub <IViewExplorer>();
     _stubTrackingSpan = MockRepository.GenerateStub <ITrackingSpan>();
 }
Exemplo n.º 4
0
        public MenuItem AddMenuItem(IViewExplorer explorer,
                                    VLoopMenus MenuType,
                                    ToolBarButton TBButton,
                                    string MenuText,
                                    Shortcut MenuShortcut,
                                    Icon menuIcon)
        {
            Menu menu = GetMenu(MenuType);

            AfniMenuItem item = new AfniMenuItem();


            item.Text     = MenuText;
            item.Shortcut = MenuShortcut;
            item.Click   += new System.EventHandler(this.OnMenuClick);
            item.Icon     = menuIcon;
            item.Key      = explorer;

            menu.MenuItems.Add(item);
            if (TBButton != null)
            {
                _app.ParentForm.VLoopToolBar.Buttons.Add(TBButton);
            }

            return(item);
        }
Exemplo n.º 5
0
 public CompletionSource(ITextBuffer textBuffer, ITextStructureNavigator textNavigator, IProjectExplorer projectExplorer)
 {
     _textBuffer = textBuffer;
     _textNavigator = textNavigator;
     _projectExplorer = projectExplorer;
     _viewExplorer = ViewExplorer.CreateFromActiveDocument(_projectExplorer);
 }
Exemplo n.º 6
0
        private Type GetResolvedTypeFromViewVariables(string fragment, IViewExplorer viewExplorer)
        {
            Type resolvedType = null;
            var  locals       = viewExplorer.GetLocalVariableChunks();
            var  viewData     = viewExplorer.GetViewDataVariableChunks();

            if (locals != null)
            {
                var localFound = locals.Where(x => x.Value == fragment).FirstOrDefault();
                if (localFound != null)
                {
                    resolvedType = Type.GetType(localFound.Type, false);
                }
            }
            if (viewData != null)
            {
                var viewDataFound = viewData.Where(x => x.Key == fragment).FirstOrDefault();
                if (resolvedType == null && viewDataFound != null)
                {
                    resolvedType = Type.GetType(viewDataFound.Type, false);
                }
            }

            return(resolvedType);
        }
Exemplo n.º 7
0
        private void OnMenuClick(object sender, System.EventArgs e)
        {
            try
            {
                //the key is either an action or an IViewExplorer.
                object key = ((AfniMenuItem)sender).Key;


                VLoopCommand cmd = key as VLoopCommand;
                if (cmd != null)
                {
                    cmd.Execute( );
                }
                else
                {
                    IViewExplorer explorer = key as IViewExplorer;
                    if (explorer != null)
                    {
                        _app.LoadExplorer(explorer);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Unable to perform action.",
                                "VLoop Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 8
0
 public CompletionSource(ITextBuffer textBuffer, IProjectExplorer projectExplorer)
 {
     _textBuffer = textBuffer;
     _projectExplorer = projectExplorer;
     _viewExplorer = _projectExplorer.GetViewExplorer(textBuffer);
     _textBuffer.Changed += TextBuffer_Changed;
 }
Exemplo n.º 9
0
 public CompletionSource(ITextBuffer textBuffer, ITextStructureNavigator textNavigator, IProjectExplorer projectExplorer)
 {
     _textBuffer      = textBuffer;
     _textNavigator   = textNavigator;
     _projectExplorer = projectExplorer;
     _viewExplorer    = ViewExplorer.CreateFromActiveDocument(_projectExplorer);
 }
 public void Setup()
 {
     _mockViewExplorer = MockRepository.GenerateMock<IViewExplorer>();
     _stubSnapshot = MockRepository.GenerateStub<ITextSnapshot>();
     _stubViewExplorer = MockRepository.GenerateStub<IViewExplorer>();
     _stubTrackingSpan = MockRepository.GenerateStub<ITrackingSpan>();
 }
Exemplo n.º 11
0
 public static CompletionSet Create <T>(IViewExplorer viewExplorer, ITrackingSpan trackingSpan) where T : SparkCompletionSetFactory, new()
 {
     _viewExplorer = viewExplorer;
     return(new T {
         ApplicableTo = trackingSpan
     });
 }
Exemplo n.º 12
0
 /// <summary>
 /// Creates the IViewExplorer objects
 /// and adds them to the _explorers collection
 /// </summary>
 private void CreateExplorers()
 {
     _explorers      = new ArrayList();
     _activeExplorer = new XPBarViewExplorer(this, _parent_form.ExplorerSplitter);
     _explorers.Add(new FolderViewExplorer(this, _parent_form.ExplorerSplitter));
     _explorers.Add(_activeExplorer);
     _activeExplorer.Show();
 }
Exemplo n.º 13
0
 protected void GivenReferencedTypes(IEnumerable<Type> types)
 {
     TheTypeNavigator = new TypeNavigator(types);
     TheViewExplorer = MockRepository.GenerateMock<IViewExplorer>();
     TheViewExplorer.Expect(x => x.GetTypeNavigator()).Return(TheTypeNavigator);
     TheViewExplorer.Expect(x => x.GetLocalVariableChunks()).Return(null);
     TheViewExplorer.Expect(x => x.GetViewDataVariableChunks()).Return(null);
 }
Exemplo n.º 14
0
 protected void GivenReferencedTypes(IEnumerable <Type> types)
 {
     TheTypeNavigator = new TypeNavigator(types);
     TheViewExplorer  = MockRepository.GenerateMock <IViewExplorer>();
     TheViewExplorer.Expect(x => x.GetTypeNavigator()).Return(TheTypeNavigator);
     TheViewExplorer.Expect(x => x.GetLocalVariableChunks()).Return(null);
     TheViewExplorer.Expect(x => x.GetViewDataVariableChunks()).Return(null);
 }
Exemplo n.º 15
0
 public CompletionBuilder(IViewExplorer viewExplorer)
 {
     if (viewExplorer == null)
     {
         throw new ArgumentNullException("viewExplorer");
     }
     _viewExplorer  = viewExplorer;
     _typeNavigator = viewExplorer.GetTypeNavigator();
 }
Exemplo n.º 16
0
 public static CompletionSet Create <T>(SnapshotPoint triggerPoint, ITrackingSpan trackingSpan, IViewExplorer viewExplorer) where T : CompletionSetFactory, new()
 {
     _triggerPoint      = triggerPoint;
     _viewExplorer      = viewExplorer;
     _completionBuilder = new CompletionBuilder(_viewExplorer);
     return(new T {
         ApplicableTo = trackingSpan
     });
 }
Exemplo n.º 17
0
        public void LoadExplorer(IViewExplorer viewExplorer)
        {
            if (_activeExplorer != null)
            {
                _activeExplorer.Hide();
            }

            _activeExplorer = viewExplorer;
            viewExplorer.Show();
        }
        public void Setup()
        {
            _stubSession       = MockRepository.GenerateStub <ICompletionSession>();
            _stubTextBuffer    = MockRepository.GenerateStub <ITextBuffer>();
            _stubViewExplorer  = MockRepository.GenerateStub <IViewExplorer>();
            _stubTrackingPoint = MockRepository.GenerateStub <ITrackingPoint>();
            _stubTrackingSpan  = MockRepository.GenerateStub <ITrackingSpan>();
            _stubSnapshot      = MockRepository.GenerateStub <ITextSnapshot>();

            _stubTextBuffer.Stub(x => x.CurrentSnapshot).Return(_stubSnapshot);
            _stubSession.Stub(x => x.GetTriggerPoint(_stubTextBuffer)).Return(_stubTrackingPoint);
            _stubTrackingPoint.Stub(x => x.GetPoint(_stubSnapshot)).Return(new SnapshotPoint(_stubSnapshot, 0));
            _stubViewExplorer.Stub(x => x.GetRelatedPartials()).Return(new List <string>());
        }
Exemplo n.º 19
0
        public void Setup()
        {
            _stubSession = MockRepository.GenerateStub<ICompletionSession>();
            _stubTextBuffer = MockRepository.GenerateStub<ITextBuffer>();
            _stubViewExplorer = MockRepository.GenerateStub<IViewExplorer>();
            _stubTrackingPoint = MockRepository.GenerateStub<ITrackingPoint>();
            _stubTrackingSpan = MockRepository.GenerateStub<ITrackingSpan>();
            _stubSnapshot = MockRepository.GenerateStub<ITextSnapshot>();

            _stubTextBuffer.Stub(x => x.CurrentSnapshot).Return(_stubSnapshot);
            _stubSession.Stub(x => x.GetTriggerPoint(_stubTextBuffer)).Return(_stubTrackingPoint);
            _stubTrackingPoint.Stub(x => x.GetPoint(_stubSnapshot)).Return(new SnapshotPoint(_stubSnapshot, 0));
            _stubViewExplorer.Stub(x => x.GetRelatedPartials()).Return(new List<string>());
        }
Exemplo n.º 20
0
        private Type GetResolvedTypeByInstance(IViewExplorer viewExplorer, string fragment, out string instanceName)
        {
            instanceName = string.Empty;
            Type resolvedType = null;

            if (fragment == "this")
            {
                instanceName = "this";
                IEnumerable <Type> resolvedTypes = Types.Where(t => typeof(SparkViewBase).IsAssignableFrom(t));
                //BUG: This will potentially return the wrong Type if there is more than one inheritor of SparkViewBase
                resolvedType = resolvedTypes.FirstOrDefault(t => t.Name != typeof(SparkViewBase).Name);
            }
            else
            {
                resolvedType = GetResolvedTypeFromViewVariables(fragment, viewExplorer);
                instanceName = resolvedType != null ? fragment : string.Empty;
            }

            return(resolvedType);
        }
Exemplo n.º 21
0
        public bool TryResolveType(IViewExplorer viewExplorer, string codeSnippit, out Type resolvedType, out string remainingCode)
        {
            resolvedType = null;
            remainingCode = codeSnippit;

            var fragments = codeSnippit.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries).Reverse();

            string instanceName = string.Empty;
            foreach (var fragment in fragments)
            {
                resolvedType = GetResolvedTypeByInstance(viewExplorer, fragment, out instanceName) ?? GetResolvedTypeByName(fragment);
                if (resolvedType != null)
                    break;
            }

            if (resolvedType != null) remainingCode = GetRemainingCode(fragments, resolvedType, instanceName);

            return resolvedType != null;
        }
Exemplo n.º 22
0
        public static CompletionSet GetCompletionSetFor(SnapshotPoint triggerPoint, ITrackingSpan trackingSpan, IViewExplorer viewExplorer)
        {
            Type currentContext = SparkSyntax.ParseContext(triggerPoint.Snapshot.GetText(), triggerPoint);

            if (currentContext == typeof(ElementNode))
            {
                return(Create <ElementCompletionSet>(triggerPoint, trackingSpan, viewExplorer));
            }
            if (currentContext == typeof(AttributeNode))
            {
                return(Create <AttributeCompletionSet>(triggerPoint, trackingSpan, viewExplorer));
            }
            if (currentContext == typeof(ExpressionNode))
            {
                return(Create <ExpressionCompletionSet>(triggerPoint, trackingSpan, viewExplorer));
            }
            return(null);
        }
Exemplo n.º 23
0
        private Type GetResolvedTypeFromViewVariables(string fragment, IViewExplorer viewExplorer)
        {
            Type resolvedType = null;
            var locals = viewExplorer.GetLocalVariableChunks();
            var viewData = viewExplorer.GetViewDataVariableChunks();
            if (locals != null)
            {
                var localFound = locals.Where(x => x.Value == fragment).FirstOrDefault();
                if (localFound != null) resolvedType = Type.GetType(localFound.Type, false);
            }
            if (viewData != null)
            {
                var viewDataFound = viewData.Where(x => x.Key == fragment).FirstOrDefault();
                if (resolvedType == null && viewDataFound != null) resolvedType = Type.GetType(viewDataFound.Type, false);
            }

            return resolvedType;
        }
Exemplo n.º 24
0
 public CompletionBuilder(IViewExplorer viewExplorer)
 {
     if (viewExplorer == null) throw new ArgumentNullException("viewExplorer");
     _viewExplorer = viewExplorer;
     _typeNavigator = viewExplorer.GetTypeNavigator();
 }
 public void Cleanup()
 {
     _mockViewExplorer.VerifyAllExpectations();
     _mockViewExplorer = null;
 }
Exemplo n.º 26
0
 public CompletionSource(ITextBuffer textBuffer, IProjectExplorer projectExplorer)
 {
     _textBuffer = textBuffer;
     _projectExplorer = projectExplorer;
     _viewExplorer = new ViewExplorer(_projectExplorer);
 }
Exemplo n.º 27
0
        private Type GetResolvedTypeByInstance(IViewExplorer viewExplorer, string fragment, out string instanceName)
        {
            instanceName = string.Empty;
            Type resolvedType = null;
            if (fragment == "this")
            {
                instanceName = "this";
                IEnumerable<Type> resolvedTypes = Types.Where(t => typeof(SparkViewBase).IsAssignableFrom(t));
                //BUG: This will potentially return the wrong Type if there is more than one inheritor of SparkViewBase
                resolvedType = resolvedTypes.FirstOrDefault(t => t.Name != typeof(SparkViewBase).Name);
            }
            else
            {
                resolvedType = GetResolvedTypeFromViewVariables(fragment, viewExplorer);
                instanceName = resolvedType != null ? fragment : string.Empty;
            }

            return resolvedType;
        }
Exemplo n.º 28
0
 public void Cleanup()
 {
     _mockViewExplorer.VerifyAllExpectations();
     _mockViewExplorer = null;
 }