Пример #1
0
 internal void WriteOutputMessage(string message)
 {
     if (XSettings.EnableQuickInfoLog && XSettings.EnableLogging)
     {
         XSettings.DisplayOutputMessage("XSharp.QuickInfoSource :" + message);
     }
 }
Пример #2
0
            private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e)
            {
                if (XSharpProjectPackage.Instance.DebuggerIsRunning)
                {
                    return;
                }
                try
                {
                    //find the mouse position by mapping down to the subject buffer
                    SnapshotPoint?point = m_textView.BufferGraph.MapDownToFirstMatch
                                              (new SnapshotPoint(m_textView.TextSnapshot, e.Position),
                                              PointTrackingMode.Positive,
                                              snapshot => m_subjectBuffers.Contains(snapshot.TextBuffer),
                                              PositionAffinity.Predecessor);

                    if (point.HasValue && point.Value.Position != lastPointPosition)
                    {
                        lastPointPosition = point.Value.Position;
                        if (!m_provider.QuickInfoBroker.IsQuickInfoActive(m_textView))
                        {
                            ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position,
                                                                                                   PointTrackingMode.Positive);
                            m_session = m_provider.QuickInfoBroker.TriggerQuickInfo(m_textView, triggerPoint, true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    XSettings.DisplayOutputMessage("XSharpQuickInfo.OnTextViewMouseHover failed");
                    XSettings.DisplayException(ex);
                }
            }
Пример #3
0
 internal void WriteOutputMessage(string strMessage)
 {
     if (XSettings.EnableParameterLog && XSettings.EnableLogging)
     {
         XSettings.LogMessage("XSharp.ParameterInfo:" + strMessage);
     }
 }
Пример #4
0
        public static List <InvoiceAttachment> ConvertPdfToPng(string pathToDocument, string folderPath)
        {
            XSettings.InstallLicense(ConfigurationManager.AppSettings["ABCPdfKey"]);
            pathToDocument = LocalizePath(pathToDocument);

            var convertedFileName    = string.Empty;
            var convertedAttachments = new List <InvoiceAttachment>();
            var pdfToConvert         = new Doc();

            pdfToConvert.Read(pathToDocument);

            // loop through the pages

            var n = pdfToConvert.PageCount;

            for (var i = 1; i <= n; i++)
            {
                pdfToConvert.PageNumber  = i;
                pdfToConvert.Rect.String = pdfToConvert.CropBox.String;
                convertedFileName        = $"{folderPath}\\{Path.GetFileNameWithoutExtension(pathToDocument)}{i}.png";
                pdfToConvert.Rendering.Save(convertedFileName);
                var newDoc = new InvoiceAttachment
                {
                    DocumentPath = convertedFileName
                };
                convertedAttachments.Add(newDoc);
                newDoc = null;
            }
            pdfToConvert.Clear();
            return(convertedAttachments);
        }
Пример #5
0
 void WriteOutputMessage(string sMessage)
 {
     if (XSettings.EnableBraceMatchLog && XSettings.EnableLogging)
     {
         XSettings.DisplayOutputMessage("Brace Matching: " + sMessage);
     }
 }
Пример #6
0
            internal void AddVarInfo(List <Inline> list, IXVariable var)
            {
                Run temp;
                var name     = var.Name;
                var hasValue = !string.IsNullOrEmpty(var.Value);

                if (var.Kind == Kind.DbField)
                {
                    if (hasValue)
                    {
                        name = var.Value + "->" + name;
                    }
                }
                temp            = new Run(name + " ");
                temp.Foreground = txtBrush;
                list.Add(temp);
                if (hasValue && var.Kind != Kind.DbField) // default value
                {
                    temp            = new Run(" :=  " + var.Value + " ");
                    temp.Foreground = txtBrush;
                    list.Add(temp);
                }
                temp            = new Run(XSettings.FormatKeyword(var.ParamTypeDesc) + " ");
                temp.Foreground = this.kwBrush;
                list.Add(temp);
                temp            = new Run(var.TypeName);
                temp.Foreground = this.txtBrush;
                list.Add(temp);
                if (var.IsArray)
                {
                    temp            = new Run("[] ");
                    temp.Foreground = this.txtBrush;
                    list.Add(temp);
                }
            }
 internal void WriteOutputMessage(string strMessage)
 {
     if (XSettings.EnableCodeCompletionLog && XSettings.EnableLogging)
     {
         XSettings.DisplayOutputMessage(strMessage);
     }
 }
 internal void WriteOutputMessage(string strMessage)
 {
     if (XSettings.EnableCodeCompletionLog && XSettings.EnableLogging)
     {
         XSettings.LogMessage("XSharp.Completion:" + strMessage);
     }
 }
Пример #9
0
        static void Main(string[] args)
        {
            //not working

            XSettings.Register();
            XSettings.InstallLicense("cd9b5c07db69df2bf57c0a04d9bca58b10c44889c9fb197984e592f49addfce5ec5fe85d7b9205bc");
            XSettings.InstallSystemLicense("cd9b5c07db69df2bf57c0a04d9bca58b10c44889c9fb197984e592f49addfce5ec5fe85d7b9205bc");
            XSettings.InstallRedistributionLicense("cd9b5c07db69df2bf57c0a04d9bca58b10c44889c9fb197984e592f49addfce5ec5fe85d7b9205bc");
            XSettings.InstallTrialLicense("cd9b5c07db69df2bf57c0a04d9bca58b10c44889c9fb197984e592f49addfce5ec5fe85d7b9205bc");
            XSettings.Register();
            Doc theDoc = new Doc();

            theDoc.FontSize = 72;
            theDoc.AddTextStyled("<b>Gallia</b> est omnis divisa in partes tres, quarum unam incolunt <b>Belgae</b>, aliam <b>Aquitani</b>, tertiam qui ipsorum lingua <b>Celtae</b>, nostra <b>Galli</b> appellantur.");
            theDoc.Save("../../testingC.pdf"); //need licence
            theDoc.Clear();

            Signature theSig = (Signature)theDoc.Form["Signature"];

            theSig.Location = "here";
            theSig.Reason   = "test";
            //pfx + password
            theSig.Sign("../../../test.pfx", "123456");
            theDoc.Save("../../testingC signed.pdf");
        }
Пример #10
0
 internal static void WriteOutputMessage(string strMessage)
 {
     if (XSettings.EnableCodeCompletionLog && XSettings.EnableLogging)
     {
         XSettings.LogMessage(strMessage);
     }
 }
Пример #11
0
 void WriteOutputMessage(string sMessage)
 {
     if (XSettings.EnableBraceMatchLog && XSettings.EnableLogging)
     {
         XSettings.LogMessage("Keyword Matching: " + sMessage);
     }
 }
Пример #12
0
 internal void Debug(string strMessage)
 {
     if (XSettings.EnableParameterLog && XSettings.EnableLogging)
     {
         XSettings.LogMessage(strMessage);
     }
 }
Пример #13
0
 internal void WriteOutputMessage(string strMessage)
 {
     if (XSettings.EnableLogging)
     {
         XSettings.LogMessage("XSharp.LightBulb:" + strMessage);
     }
 }
Пример #14
0
        /// <devdoc>
        /// Please use this "approved" method to compare file names.
        /// </devdoc>
        public static bool IsSamePath(string file1, string file2)
        {
            if (file1 == null || file1.Length == 0)
            {
                return(file2 == null || file2.Length == 0);
            }

            Uri uri1 = null;
            Uri uri2 = null;

            try
            {
                if (!Uri.TryCreate(file1, UriKind.Absolute, out uri1) || !Uri.TryCreate(file2, UriKind.Absolute, out uri2))
                {
                    return(false);
                }

                if (uri1 != null && uri1.IsFile && uri2 != null && uri2.IsFile)
                {
                    return(0 == String.Compare(uri1.LocalPath, uri2.LocalPath, StringComparison.OrdinalIgnoreCase));
                }

                return(file1 == file2);
            }
            catch (UriFormatException e)
            {
                XSettings.LogException(e, "IsSamePath");
            }

            return(false);
        }
Пример #15
0
 private bool FindMatchingOpenTag(List <ClassificationSpan> sortedTags, int indexTag, ITextSnapshot snapshot, out SnapshotSpan pairSpan)
 {
     pairSpan = new SnapshotSpan(snapshot, 1, 1);
     try
     {
         ClassificationSpan currentTag = sortedTags[indexTag];
         ITextSnapshotLine  line       = currentTag.Span.Start.GetContainingLine();
         int lineNumber = line.LineNumber;
         int nested     = 0;
         for (int i = indexTag - 1; i >= 0; i--)
         {
             var openTag = sortedTags[i];
             if (openTag.ClassificationType.IsOfType(ColorizerConstants.XSharpKwOpenFormat))
             {
                 nested--;
                 if (nested < 0)
                 {
                     pairSpan = new SnapshotSpan(snapshot, openTag.Span);
                     return(true);
                 }
             }
             else
             {
                 nested++;
             }
         }
     }
     catch (Exception e)
     {
         XSettings.LogException(e, "FindMatchingOpenTag failed");
     }
     return(false);
 }
Пример #16
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);
            //
        }
 private void Textbuffer_Changing(object sender, TextContentChangingEventArgs e)
 {
     if (XSettings.DebuggerIsRunning)
     {
         XSettings.ShowMessageBox("Cannot edit source code while debugging");
         e.Cancel();
     }
 }
        public virtual int OpenChildren()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution;

            Debug.Assert(solution != null, "Could not retrieve the solution from the services provided by this project");
            if (solution == null)
            {
                return(VSConstants.E_FAIL);
            }

            IntPtr iUnKnownForSolution = IntPtr.Zero;
            int    returnValue         = VSConstants.S_OK; // be optimistic.

            try
            {
                this.DisableQueryEdit    = true;
                this.EventTriggeringFlag = ProjectNode.EventTriggering.DoNotTriggerHierarchyEvents | ProjectNode.EventTriggering.DoNotTriggerTrackerEvents;
                iUnKnownForSolution      = Marshal.GetIUnknownForObject(solution);

                // notify SolutionEvents listeners that we are about to add children
                IVsFireSolutionEvents fireSolutionEvents = Marshal.GetTypedObjectForIUnknown(iUnKnownForSolution, typeof(IVsFireSolutionEvents)) as IVsFireSolutionEvents;
                ErrorHandler.ThrowOnFailure(fireSolutionEvents.FireOnBeforeOpeningChildren(this));

                this.AddVirtualProjects();

                ErrorHandler.ThrowOnFailure(fireSolutionEvents.FireOnAfterOpeningChildren(this));
            }
            catch (Exception e)
            {
                // Exceptions are digested by the caller but we want then to be shown if not a ComException and if not in automation.
                if (!(e is COMException) && !Utilities.IsInAutomationFunction(this.Site))
                {
                    string title = null;
                    VS.MessageBox.ShowError(title, e.Message);
                }

                XSettings.LogException(e, "OpenChildren");
                throw;
            }
            finally
            {
                this.DisableQueryEdit = false;

                if (iUnKnownForSolution != IntPtr.Zero)
                {
                    Marshal.Release(iUnKnownForSolution);
                }

                this.EventTriggeringFlag = ProjectNode.EventTriggering.TriggerAll;
            }

            return(returnValue);
        }
        int IVsLanguageDebugInfo.GetProximityExpressions(IVsTextBuffer pBuffer, int iLine, int iCol, int cLines, out IVsEnumBSTR ppEnum)
        {
            ppEnum = null;
            var      file = getFile(pBuffer);
            var      list = new List <String>();
            XElement member;

            // We use our orignal syntax here (so SELF and ":"). The expression compiler
            // in the debugger takes care of translating SELF to this and ':' to '.'
            if (file != null)
            {
                member = file.FindMemberAtRow(iLine);
                switch (member.Kind)
                {
                case Kind.Method:
                case Kind.Access:
                case Kind.Assign:
                case Kind.Property:
                case Kind.Event:
                case Kind.Field:
                case Kind.Constructor:
                case Kind.Destructor:
                case Kind.Operator:
                    if (!member.Modifiers.HasFlag(Modifiers.Static))
                    {
                        list.Add(XSettings.FormatKeyword("SELF"));
                    }
                    break;
                }
                var buffer = _editorAdaptersFactoryService.GetDataBuffer(pBuffer);
                Dictionary <string, XVariable> locals = null;
                if (member != null)
                {
                    if (member is XMemberDefinition)
                    {
                        locals = new Dictionary <string, XVariable>(StringComparer.OrdinalIgnoreCase);
                        var tm   = member as XMemberDefinition;
                        var vars = tm.GetLocals(buffer.CurrentSnapshot, iLine, file.Project.ParseOptions.Dialect);
                        foreach (var v in vars)
                        {
                            locals.Add(v.Name, (XVariable)v);
                        }
                        foreach (var p in tm.Parameters)
                        {
                            locals.Add(p.Name, (XVariable)p);
                        }
                    }
                    addtokens(buffer, iLine, list, file, locals);
                }
            }


            ppEnum = new VsEnumBSTR(list);
            return(VSConstants.S_OK);
        }
Пример #20
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);
     }
 }
Пример #21
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints => {
                endpoints.MapGet("/", async context => {
                    context.Response.Clear();
                    try {
                        // When running as an App Service we need to install the license in code otherwise you will
                        // get a licensing exception. ABCpdf automatically installs a trial license if no license is
                        // found.
                        // Your trial license may be found by uncommenting the line below WHEN RUNNING ON YOUR LOCAL
                        // COMPUTER. NB XSettings.Key returns an empty string for purchased licenses.
                        // throw new Exception(XSettings.Key);

                        // Paste either the ABCpdf 12 key provided at time of purchase, or the value obtained from
                        // uncommenting the line above. This must be set correctly prior to running on Azure.
                        XSettings.InstallLicense("PASTE YOUR LICENSE HERE");

                        using (Doc doc = new Doc()) {
                            doc.HtmlOptions.Engine = EngineType.WebKit;
                            doc.HtmlOptions.Media  = MediaType.Screen;
                            int id = doc.AddImageUrl("https://www.websupergoo.com");

                            // AddImageUrl only adds the first page. The following code adds any additional pages:
                            while (doc.Chainable(id))
                            {
                                doc.Page = doc.AddPage();
                                id       = doc.AddImageToChain(id);
                            }
                            // Compress output:
                            for (int i = 1; i <= doc.PageCount; i++)
                            {
                                doc.PageNumber = i;
                                doc.Flatten();
                            }
                            // This will ensure page is served in a web-efficient manner:
                            doc.SaveOptions.Linearize = true;
                            // Finally serve the page:
                            context.Response.ContentType = "Application/Pdf";
                            await context.Response.BodyWriter.WriteAsync(doc.GetData());
                        }
                    } catch (Exception ex) {
                        await context.Response.WriteAsync(ex.Message);
                    }
                    await context.Response.CompleteAsync();
                });
            });
        }
        public override int OnAfterRenameProject(IVsHierarchy hierarchy)
        {
            if (hierarchy == null)
            {
                return(VSConstants.E_INVALIDARG);
            }
            ThreadHelper.ThrowIfNotOnUIThread();

            try
            {
                List <ProjectReferenceNode> projectReferences = this.GetProjectReferencesContainingThisProject(hierarchy);

                // Collect data that is needed to initialize the new project reference node.
                string projectRef;
                ErrorHandler.ThrowOnFailure(this.Solution.GetProjrefOfProject(hierarchy, out projectRef));

                object nameAsObject;
                ErrorHandler.ThrowOnFailure(hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_Name, out nameAsObject));
                string projectName = (string)nameAsObject;

                string projectPath = String.Empty;

                IVsProject3 project = hierarchy as IVsProject3;

                if (project != null)
                {
                    ErrorHandler.ThrowOnFailure(project.GetMkDocument(VSConstants.VSITEMID_ROOT, out projectPath));
                    projectPath = Path.GetDirectoryName(projectPath);
                }

                // Remove and re add the node.
                foreach (ProjectReferenceNode projectReference in projectReferences)
                {
                    ProjectNode         projectMgr   = projectReference.ProjectMgr;
                    IReferenceContainer refContainer = projectMgr.GetReferenceContainer();
                    projectReference.Remove(false);

                    VSCOMPONENTSELECTORDATA selectorData = new VSCOMPONENTSELECTORDATA();
                    selectorData.type        = VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project;
                    selectorData.bstrTitle   = projectName;
                    selectorData.bstrFile    = projectPath;
                    selectorData.bstrProjRef = projectRef;
                    refContainer.AddReferenceFromSelectorData(selectorData);
                }
            }
            catch (COMException e)
            {
                XSettings.LogException(e, "OnAfterRenameProject");
                return(e.ErrorCode);
            }

            return(VSConstants.S_OK);
        }
Пример #23
0
        int IVsLanguageDebugInfo.GetProximityExpressions(IVsTextBuffer pBuffer, int iLine, int iCol, int cLines, out IVsEnumBSTR ppEnum)
        {
            ppEnum = null;
            var           file = getFile(pBuffer);
            var           list = new List <String>();
            XSourceEntity member;

            // We use our original syntax here (so SELF and ":"). The expression compiler
            // in the debugger takes care of translating SELF to this and ':' to '.'
            if (file != null)
            {
                member = file.FindMemberAtRow(iLine);
                if (member.Kind.IsClassMember(file.Project.ParseOptions.Dialect))
                {
                    if (!member.Modifiers.HasFlag(Modifiers.Static))
                    {
                        list.Add(XSettings.FormatKeyword("SELF"));
                    }
                }

                var buffer = _editorAdaptersFactoryService.GetDataBuffer(pBuffer);
                Dictionary <string, IXVariableSymbol> locals = null;
                if (member != null)
                {
                    if (member is XSourceMemberSymbol tm)
                    {
                        locals = new Dictionary <string, IXVariableSymbol>(StringComparer.OrdinalIgnoreCase);
                        var location = new XSharpSearchLocation(tm.File, tm, buffer.CurrentSnapshot, iLine);
                        var vars     = tm.GetLocals(location);
                        foreach (var v in vars)
                        {
                            if (!locals.ContainsKey(v.Name))
                            {
                                locals.Add(v.Name, v);
                            }
                        }
                        foreach (var p in tm.Parameters)
                        {
                            if (!locals.ContainsKey(p.Name))
                            {
                                locals.Add(p.Name, p);
                            }
                        }
                    }
                    addtokens(buffer, iLine, list, file, locals);
                }
            }


            ppEnum = new VsEnumBSTR(list);
            return(VSConstants.S_OK);
        }
Пример #24
0
        static public bool GetMemberParameters(IXMember member, XProject project, IList <string> names, IList <string> descriptions)
        {
            if (member == null)
            {
                return(false);
            }

            if (member is XMemberDefinition)
            {
                var xdef  = (XMemberDefinition)member;
                var xml   = xdef.XmlComments;
                var xfile = XSharpXMLDocTools.firstfile;
                if (xfile != null && !string.IsNullOrEmpty(xml))
                {
                    getParameterInfo(xfile, xml, names, descriptions);
                    return(true);
                }
                return(false);
            }
            if (!(member is XMemberReference))
            {
                return(false);
            }

            var xmember             = (XMemberReference)member;
            var declarationAssembly = xmember.Assembly;
            var file = XSharpXMLDocTools.GetXmlDocFile(declarationAssembly, project);

            if (file == null)
            {
                return(false);
            }
            try
            {
                var sig = xmember.XMLSignature;
                if (!string.IsNullOrEmpty(sig))
                {
                    uint   id     = 0;
                    string xml    = "";
                    var    result = file.ParseMemberSignature(sig, out id);
                    result = file.GetMemberXML(id, out xml);
                    getParameterInfo(file, xml, names, descriptions);
                }
            }
            catch (Exception e)
            {
                XSettings.DisplayOutputMessage("Exception in XSharpXMLDocMember.GetDocSummary");
                XSettings.DisplayException(e);
                return(false);
            }
            return(true);
        }
Пример #25
0
        /// <summary>
        /// This method is used to move dependant items from the main level (1st level below project node) to
        /// and make them children of the modules they belong to.
        /// </summary>
        /// <param name="child"></param>
        /// <returns></returns>
        internal bool AddDependant(HierarchyNode child)
        {
            // If the file is not a XSharpFileNode then drop it and create a new XSharpFileNode
            XSharpFileNode dependant;
            String         fileName = child.Url;

            try
            {
                child.Remove(false);
            }
            catch (Exception e)
            {
                XSettings.LogException(e, "AddDependant failed");
            }
            dependant = (XSharpFileNode)ProjectMgr.CreateDependentFileNode(fileName);

            // Like the C# project system we do not put a path in front of the parent name, even when we are in a subfolder
            // but we do put a path before the parent name when the parent is in a different folder
            // In that case the path is the path from the base project folder
            string parent = this.ItemNode.GetMetadata(ProjectFileConstants.Include);

            parent = Path.GetFileName(parent);
            if (!this.IsNonMemberItem)
            {
                string parentPath = Path.GetDirectoryName(Path.GetFullPath(this.Url));
                string childPath  = Path.GetDirectoryName(Path.GetFullPath(dependant.Url));
                if (String.Equals(parentPath, childPath, StringComparison.OrdinalIgnoreCase))
                {
                    dependant.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parent);
                }
                else
                {
                    string projectPath   = this.ProjectMgr.ProjectFolder;
                    Uri    projectFolder = new Uri(projectPath);
                    Uri    relative      = projectFolder.MakeRelativeUri(new Uri(parentPath));
                    parentPath = relative.ToString() + Path.DirectorySeparatorChar;
                    dependant.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parentPath + parent);
                }
            }
            // Make the item a dependent item
            dependant.HasParentNodeNameRelation = true;
            // Insert in the list of children
            dependant.NextSibling = this.FirstChild;
            this.FirstChild       = dependant;
            ProjectMgr.OnItemsAppended(this);
            this.OnItemAdded(this, dependant);
            // Set parent and inherit the NonMember Status
            dependant.Parent          = this;
            dependant.IsDependent     = true;
            dependant.IsNonMemberItem = this.IsNonMemberItem;
            return(true);
        }
Пример #26
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);
        }
Пример #27
0
        public void AugmentPeekSession(IPeekSession session, IList <IPeekableItem> peekableItems)
        {
            try
            {
                XSharpModel.ModelWalker.Suspend();
                if (!string.Equals(session.RelationshipName, PredefinedPeekRelationships.Definitions.Name, StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }
                //
                var tp = session.GetTriggerPoint(_textBuffer.CurrentSnapshot);
                if (!tp.HasValue)
                {
                    return;
                }
                //
                var    triggerPoint = tp.Value;
                IToken stopToken;
                //
                // Check if we can get the member where we are
                XMemberDefinition member           = XSharpLanguage.XSharpTokenTools.FindMember(triggerPoint.GetContainingLine().LineNumber, _file);
                XTypeDefinition   currentNamespace = XSharpLanguage.XSharpTokenTools.FindNamespace(triggerPoint.Position, _file);

                var           lineNumber = triggerPoint.GetContainingLine().LineNumber;
                var           snapshot   = _textBuffer.CurrentSnapshot;
                List <String> tokenList  = XSharpTokenTools.GetTokenList(triggerPoint.Position, lineNumber, snapshot, out stopToken, true, _file, false, member);
                // LookUp for the BaseType, reading the TokenList (From left to right)
                CompletionElement gotoElement;
                String            currentNS = "";
                if (currentNamespace != null)
                {
                    currentNS = currentNamespace.Name;
                }
                CompletionType cType = XSharpLanguage.XSharpTokenTools.RetrieveType(_file, tokenList, member, currentNS, stopToken, out gotoElement, snapshot, lineNumber, _file.Project.Dialect);
                //
                if ((gotoElement != null) && (gotoElement.IsSourceElement))
                {
                    peekableItems.Add(new XSharpDefinitionPeekItem(gotoElement.SourceElement, _peekResultFactory));
                }
            }
            catch (Exception ex)
            {
                XSettings.DisplayOutputMessage("XSharpPeekItemSource.AugmentPeekSession failed : ");
                XSettings.DisplayException(ex);
            }
            finally
            {
                ModelWalker.Resume();
            }
        }
Пример #28
0
        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);
        }
Пример #29
0
 protected override void GotoSource(VSOBJGOTOSRCTYPE gotoType)
 {
     // We do not support the "Goto Reference"
     if (gotoType == VSOBJGOTOSRCTYPE.GS_REFERENCE)
     {
         return;
     }
     //
     if (this.CanGoToSource && this.editorInfo != null)
     {
         // Need to retrieve the Project, then the File...
         var file = XSolution.FindFile(editorInfo.FileName);
         XSettings.OpenDocument(file.FullPath, editorInfo.Line, editorInfo.Column, true);
     }
 }
Пример #30
0
        /// <summary>
        /// Creates an assembly reference node from a project element.
        /// </summary>
        protected virtual AssemblyReferenceNode CreateAssemblyReferenceNode(ProjectElement element)
        {
            AssemblyReferenceNode node = null;

            try
            {
                node = new AssemblyReferenceNode(this.ProjectMgr, element);
            }
            catch (Exception e)
            {
                XSettings.LogException(e, "CreateAssemblyReferenceNode");
            }

            return(node);
        }