示例#1
0
 internal static void WriteOutputMessage(string strMessage)
 {
     if (XSettings.EnableCodeCompletionLog && XSettings.EnableLogging)
     {
         XSettings.LogMessage(strMessage);
     }
 }
示例#2
0
 void WriteOutputMessage(string sMessage)
 {
     if (XSettings.EnableBraceMatchLog && XSettings.EnableLogging)
     {
         XSettings.LogMessage("Keyword Matching: " + sMessage);
     }
 }
示例#3
0
        internal XSharpLibraryProject(XProject prj, IVsHierarchy hierarchy)
            : base(prj.Name, LibraryNodeType.Package, prj.FileName)
        {
            this.ownerHierarchy = hierarchy;
            //
            //this.displayData.hImageList = XSharpProjectNode.ImageList.Handle;
            //this.displayData.Image = (ushort)XSharpProjectNode.XSharpProjectImageName.Project;
            //this.displayData.SelectedImage = (ushort)XSharpProjectNode.XSharpProjectImageName.Project;
            //
            this.NodeType = LibraryNodeType.Package;
            //
            //prj.ProjectNode
            this._defaultNameSpace = prj.ProjectNode.RootNameSpace;
            if (String.IsNullOrEmpty(this._defaultNameSpace))
            {
                this._defaultNameSpace = "Default Namespace";
            }
            //
            XSharpLibraryNode defaultNS = new XSharpLibraryNode(_defaultNameSpace, LibraryNodeType.Namespaces, "");

            defaultNS.displayData.Image         = (ushort)IconImageIndex._Namespace;
            defaultNS.displayData.SelectedImage = (ushort)IconImageIndex._Namespace;
            this.AddNode(defaultNS);
            XSettings.LogMessage("Added LibraryProject " + prj.Name);
            //
        }
示例#4
0
 internal void Debug(string strMessage)
 {
     if (XSettings.EnableParameterLog && XSettings.EnableLogging)
     {
         XSettings.LogMessage(strMessage);
     }
 }
示例#5
0
 internal void WriteOutputMessage(string strMessage)
 {
     if (XSettings.EnableParameterLog && XSettings.EnableLogging)
     {
         XSettings.LogMessage("XSharp.ParameterInfo:" + strMessage);
     }
 }
 internal void WriteOutputMessage(string strMessage)
 {
     if (XSettings.EnableCodeCompletionLog && XSettings.EnableLogging)
     {
         XSettings.LogMessage("XSharp.Completion:" + strMessage);
     }
 }
 internal void WriteOutputMessage(string message)
 {
     if (XSettings.EnableQuickInfoLog && XSettings.EnableLogging)
     {
         XSettings.LogMessage("XSharp.QuickInfoSource :" + message);
     }
 }
示例#8
0
 internal void WriteOutputMessage(string strMessage)
 {
     if (XSettings.EnableLogging)
     {
         XSettings.LogMessage("XSharp.LightBulb:" + strMessage);
     }
 }
示例#9
0
 static void InternalTraceCall(int levels)
 {
     System.Diagnostics.StackFrame stack;
     stack = new System.Diagnostics.StackFrame(levels);
     System.Reflection.MethodBase method = stack.GetMethod();
     if (method != null)
     {
         string name = method.Name + " \tin class " + method.DeclaringType.Name;
         XSettings.LogMessage("Call Trace: \t" + name);
     }
 }
示例#10
0
        /// <summary>
        /// This function asks to the QueryEditQuerySave service if it is possible to
        /// edit the file.
        /// </summary>
        protected bool CanEditFile(string documentMoniker)
        {
            XSettings.LogMessage(String.Format(CultureInfo.CurrentCulture, "\t**** CanEditFile called ****"));

            // Check the status of the recursion guard
            if (this.gettingCheckoutStatus)
            {
                return(false);
            }

            try
            {
                // Set the recursion guard
                this.gettingCheckoutStatus = true;
                ThreadHelper.ThrowIfNotOnUIThread();

                // Get the QueryEditQuerySave service
                IVsQueryEditQuerySave2 queryEditQuerySave = (IVsQueryEditQuerySave2)this.projectMgr.GetService(typeof(SVsQueryEditQuerySave));

                // Now call the QueryEdit method to find the edit status of this file
                string[] documents = { documentMoniker };
                uint     result;
                uint     outFlags;

                // Note that this function can popup a dialog to ask the user to checkout the file.
                // When this dialog is visible, it is possible to receive other request to change
                // the file and this is the reason for the recursion guard.
                int hr = queryEditQuerySave.QueryEditFiles(
                    0,              // Flags
                    1,              // Number of elements in the array
                    documents,      // Files to edit
                    null,           // Input flags
                    null,           // Input array of VSQEQS_FILE_ATTRIBUTE_DATA
                    out result,     // result of the checkout
                    out outFlags    // Additional flags
                    );

                if (ErrorHandler.Succeeded(hr) && (result == (uint)tagVSQueryEditResult.QER_EditOK))
                {
                    // In this case (and only in this case) we can return true from this function.
                    return(true);
                }
            }
            finally
            {
                this.gettingCheckoutStatus = false;
            }

            return(false);
        }
        private IList <ClassificationSpan> BuildRegionTags(IList <XSourceEntity> entities, IList <XSourceBlock> blocks, ITextSnapshot snapshot, IClassificationType _, IClassificationType _1)
        {
            if (XSettings.DisableRegions)
            {
                return(new List <ClassificationSpan>());
            }
            XSettings.LogMessage("-->> XSharpClassifier.BuildRegionTags()");
            var regions = new List <ClassificationSpan>();

            foreach (var entity in entities)
            {
                if (entity is XSourceMemberSymbol member)
                {
                    if (member.SingleLine)
                    {
                        continue;
                    }
                }
                var startPos = entity.Interval.Start;
                var endPos   = entity.Interval.Stop;
                AddRegionSpan(regions, snapshot, startPos, endPos);
            }

            foreach (var block in blocks)
            {
                var startPos = block.Token1.StartIndex;
                var endPos   = block.Last.Token2.StopIndex;

                AddRegionSpan(regions, snapshot, startPos, endPos);
                if (block.Children.Count > 1)
                {
                    var lastline = block.Token1.Line;
                    foreach (var child in block.Children)
                    {
                        if (child.Token1.Line > lastline + 1 && child.Token1.Line >= 2)
                        {
                            // the child is a line with CASE, ELSE, ELSEIF CATCH etc.
                            // we want the last token of the previous like to be the end of the previous block
                            endPos = snapshot.GetLineFromLineNumber(child.Token1.Line - 2).End;
                            AddRegionSpan(regions, snapshot, startPos, endPos);
                        }
                        startPos = child.Token1.StartIndex;
                        lastline = child.Token1.Line;
                    }
                }
            }
            XSettings.LogMessage("<<-- XSharpClassifier.BuildRegionTags()");
            return(regions);
        }
 private void TriggerRepaint(ITextSnapshot snapshot)
 {
     if (ClassificationChanged != null)
     {
         XSettings.LogMessage("-->> XSharpClassifier.triggerRepaint()");
         if (snapshot != null && _buffer?.CurrentSnapshot != null)
         {
             // tell the editor that we have new info
             if (!_first)
             {
                 ClassificationChanged(this, new ClassificationChangedEventArgs(
                                           new SnapshotSpan(snapshot, Span.FromBounds(0, snapshot.Length))));
             }
         }
         XSettings.LogMessage("<<-- XSharpClassifier.triggerRepaint()");
     }
 }
        private async Task ParseAsync()
        {
            if (XSettings.DisableEntityParsing)
            {
                return;
            }
            if (IsLexing)
            {
                return;
            }

            var snapshot  = _buffer.CurrentSnapshot;
            var xDocument = GetDocument();

            if (xDocument.SnapShot != snapshot)
            {
                XSettings.LogMessage($"XSharpClassifier.ParseAsync() aborted because snapshot is version {xDocument.SnapShot.Version} and buffer has version {snapshot.Version}");
                return;
            }

            await TaskScheduler.Default;

            XSettings.LogMessage("-->> XSharpClassifier.ParseAsync()");
            // Note this runs in the background
            // parse for positional keywords that change the colors
            // and get a reference to the tokenstream
            // do we need to create a new tree
            // this happens the first time in the buffer only
            var tokens = xDocument.TokenStream;

            if (tokens != null)
            {
                Debug("Starting model build  at {0}, version {1}", DateTime.Now, snapshot.Version.ToString());
                _sourceWalker.SaveToDisk = true;
                _sourceWalker.ParseTokens(tokens, true, false);
                RegisterEntityBoundaries();
                var regionTags = BuildRegionTags(_sourceWalker.EntityList, _sourceWalker.BlockList, snapshot, xsharpRegionStart, xsharpRegionStop);
                lock (gate)
                {
                    _parserRegions = regionTags.ToArray();
                }
                DoRepaintRegions();
                Debug("Ending model build  at {0}, version {1}", DateTime.Now, snapshot.Version.ToString());
            }
            XSettings.LogMessage("<<-- XSharpClassifier.ParseAsync()");
        }
        public override int OnAfterOpenProject(IVsHierarchy hierarchy, int added)
        {
            // If this is a new project and our project. We use here that it is only our project that will implement the "internal"  IBuildDependencyOnProjectContainer.
            ThreadHelper.ThrowIfNotOnUIThread();

            if (added != 0 && hierarchy is IBuildDependencyUpdate)
            {
                IVsUIHierarchy uiHierarchy = hierarchy as IVsUIHierarchy;
                Debug.Assert(uiHierarchy != null, "The ProjectNode should implement IVsUIHierarchy");
                if (uiHierarchy == null)
                {
                    return(VSConstants.E_FAIL);
                }
                // Expand and select project node
                IServiceProvider provider = (IServiceProvider)this.ServiceProvider;


                IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(provider, HierarchyNode.SolutionExplorer);
                if (uiWindow != null)
                {
                    __VSHIERARCHYITEMSTATE state;
                    uint stateAsInt;
                    if (uiWindow.GetItemState(uiHierarchy, VSConstants.VSITEMID_ROOT, (uint)__VSHIERARCHYITEMSTATE.HIS_Expanded, out stateAsInt) == VSConstants.S_OK)
                    {
                        state = (__VSHIERARCHYITEMSTATE)stateAsInt;
                        if (state != __VSHIERARCHYITEMSTATE.HIS_Expanded)
                        {
                            int hr;
                            hr = uiWindow.ExpandItem(uiHierarchy, VSConstants.VSITEMID_ROOT, EXPANDFLAGS.EXPF_ExpandParentsToShowItem);
                            if (ErrorHandler.Failed(hr))
                            {
                                XSettings.LogMessage("Failed to expand project node");
                            }
                            hr = uiWindow.ExpandItem(uiHierarchy, VSConstants.VSITEMID_ROOT, EXPANDFLAGS.EXPF_SelectItem);
                            if (ErrorHandler.Failed(hr))
                            {
                                XSettings.LogMessage("Failed to select project node");
                            }

                            return(hr);
                        }
                    }
                }
            }
            return(VSConstants.S_OK);
        }
示例#15
0
        public void Suspend()
        {
            if (this.isSuspending)
            {
                return;
            }

            IntPtr docData = IntPtr.Zero;

            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                IVsRunningDocumentTable rdt = this.site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;

                IVsHierarchy    hierarchy;
                uint            itemId;
                uint            docCookie;
                IVsFileChangeEx fileChange;

                if (rdt == null)
                {
                    return;
                }

                ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, this.documentFileName, out hierarchy, out itemId, out docData, out docCookie));

                if ((docCookie == (uint)ShellConstants.VSDOCCOOKIE_NIL) || docData == IntPtr.Zero)
                {
                    return;
                }

                fileChange = this.site.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx;

                if (fileChange != null)
                {
                    this.isSuspending = true;
                    ErrorHandler.ThrowOnFailure(fileChange.IgnoreFile(0, this.documentFileName, 1));
                    if (docData != IntPtr.Zero)
                    {
                        IVsPersistDocData persistDocData = null;

                        // if interface is not supported, return null
                        object unknown = Marshal.GetObjectForIUnknown(docData);
                        if (unknown is IVsPersistDocData)
                        {
                            persistDocData = (IVsPersistDocData)unknown;
                            if (persistDocData is IVsDocDataFileChangeControl)
                            {
                                this.fileChangeControl = (IVsDocDataFileChangeControl)persistDocData;
                                if (this.fileChangeControl != null)
                                {
                                    ErrorHandler.ThrowOnFailure(this.fileChangeControl.IgnoreFileChanges(1));
                                }
                            }
                        }
                    }
                }
            }
            catch (InvalidCastException e)
            {
                XSettings.LogMessage("Exception" + e.Message);
            }
            finally
            {
                if (docData != IntPtr.Zero)
                {
                    Marshal.Release(docData);
                }
            }
            return;
        }
示例#16
0
 static public void TraceData(string strOutput)
 {
     XSettings.LogMessage("Data Trace: \t" + strOutput);
 }
示例#17
0
 static public void Trace(string strOutput)
 {
     XSettings.LogMessage(strOutput);
 }
示例#18
0
 static public void TraceCall(string strParameters)
 {
     CCITracing.InternalTraceCall(2);
     XSettings.LogMessage("\tParameters: \t" + strParameters);
 }