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); }
/// <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); }
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); }
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); }
/// <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); }
/// <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); }
bool StartCompletionSession(uint nCmdId, char typedChar, bool includeKeywords = false, bool autoType = false) { WriteOutputMessage("StartCompletionSession()"); if (_completionSession != null) { if (!_completionSession.IsDismissed) { return(false); } } SnapshotPoint caret = _textView.Caret.Position.BufferPosition; if (cursorIsAfterSLComment(caret)) { return(false); } ITextSnapshot snapshot = caret.Snapshot; if (!_completionBroker.IsCompletionActive(_textView)) { _completionSession = _completionBroker.CreateCompletionSession(_textView, snapshot.CreateTrackingPoint(caret, PointTrackingMode.Positive), true); } else { _completionSession = _completionBroker.GetSessions(_textView)[0]; } _completionSession.Dismissed += OnCompletionSessionDismiss; //_completionSession.Committed += OnCompletionSessionCommitted; _completionSession.SelectedCompletionSetChanged += _completionSession_SelectedCompletionSetChanged; _completionSession.Properties[XsCompletionProperties.Command] = nCmdId; _completionSession.Properties[XsCompletionProperties.Char] = typedChar; _completionSession.Properties[XsCompletionProperties.AutoType] = autoType; _completionSession.Properties[XsCompletionProperties.Type] = null; _completionSession.Properties[XsCompletionProperties.IncludeKeywords] = includeKeywords; try { _completionSession.Start(); } catch (Exception e) { XSettings.LogException(e, "Start Completion failed"); } return(true); }
public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets) { WriteOutputMessage("-->> XAML AugmentCompletionSessions"); try { // Where does the StartSession has been triggered ? ITextSnapshot snapshot = _buffer.CurrentSnapshot; var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot); if (triggerPoint == null) { return; } // What is the character were it starts ? var line = triggerPoint.GetContainingLine(); SnapshotPoint start = triggerPoint; // var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive); // if (_file == null) { // Uhh !??, Something went wrong return; } // The Completion list we are building XCompletionList compList = new XCompletionList(_file); /// /// //compList.Add(new XSCompletion("XSDummy", "XSDummy", "XSDummy Description", null, null, Kind.Class)); /// // Sort in alphabetical order // and put in the SelectionList var values = compList.Values; if (values.Count > 0) { completionSets.Add(new CompletionSet("All", "All", applicableTo, values, Enumerable.Empty <Completion>())); } } catch (Exception ex) { XSettings.LogException(ex, "XAML AugmentCompletionSessions failed"); } finally { } WriteOutputMessage("<<-- XAML AugmentCompletionSessions"); }
public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback) { try { if (relationshipName != PredefinedPeekRelationships.Definitions.Name) { return; } var fileName = Path.GetFileName(this.peekableItem._gotoElement.File.FullPath); if (string.IsNullOrEmpty(fileName)) { return; } var label = this.peekableItem._gotoElement.Name; var title = string.Format("{0} - ({1}, {2})", fileName, this.peekableItem._gotoElement.Range.StartLine, this.peekableItem._gotoElement.Range.StartColumn + 1); using (var displayInfo = new PeekResultDisplayInfo2(label: label, labelTooltip: this.peekableItem._gotoElement.File.FullPath, title: title, titleTooltip: this.peekableItem._gotoElement.File.FullPath, startIndexOfTokenInLabel: 0, lengthOfTokenInLabel: label.Length)) { var result = peekableItem._peekResultFactory.Create ( displayInfo, default(ImageMoniker), this.peekableItem._gotoElement.File.FullPath, this.peekableItem._gotoElement.Range.StartLine, this.peekableItem._gotoElement.Range.StartColumn - 1, this.peekableItem._gotoElement.Range.EndLine, this.peekableItem._gotoElement.Range.EndColumn - 1, this.peekableItem._gotoElement.Range.StartLine, this.peekableItem._gotoElement.Range.StartColumn - 1, this.peekableItem._gotoElement.Range.EndLine, this.peekableItem._gotoElement.Range.EndColumn - 1, false, new Guid(XSharpConstants.EditorFactoryGuidString) ); resultCollection.Add(result); callback.ReportProgress(1); } } catch (Exception ex) { XSettings.LogException(ex, "XSharpResultSource.FindResults failed : "); } }
/// Shows the Object Browser /// </summary> /// <returns></returns> protected virtual int ShowObjectBrowser() { if (String.IsNullOrEmpty(this.Url) || !System.IO.File.Exists(this.Url)) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); } // Request unmanaged code permission in order to be able to creaet the unmanaged memory representing the guid. new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); Guid guid = GetBrowseLibraryGuid(); IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(guid.ToByteArray().Length); System.Runtime.InteropServices.Marshal.StructureToPtr(guid, ptr, false); int returnValue = VSConstants.S_OK; try { VSOBJECTINFO[] objInfo = new VSOBJECTINFO[1]; ThreadHelper.ThrowIfNotOnUIThread(); objInfo[0].pguidLib = ptr; objInfo[0].pszLibName = this.Url; IVsObjBrowser objBrowser = this.ProjectMgr.Site.GetService(typeof(SVsObjBrowser)) as IVsObjBrowser; Assumes.Present(objBrowser); ErrorHandler.ThrowOnFailure(objBrowser.NavigateTo(objInfo, 0)); } catch (COMException e) { XSettings.LogException(e, "ShowObjectBrowser"); returnValue = e.ErrorCode; } finally { if (ptr != IntPtr.Zero) { System.Runtime.InteropServices.Marshal.FreeCoTaskMem(ptr); } } return(returnValue); }
/// <summary> /// Open a file in a document window with a std editor /// </summary> /// <param name="newFile">Open the file as a new file</param> /// <param name="openWith">Use a dialog box to determine which editor to use</param> /// <param name="logicalView">In MultiView case determines view to be activated by IVsMultiViewDocumentView. For a list of logical view GUIDS, see constants starting with LOGVIEWID_ defined in NativeMethods class</param> /// <param name="frame">A reference to the window frame that is mapped to the file</param> /// <param name="windowFrameAction">Determine the UI action on the document window</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns> public int Open(bool newFile, bool openWith, Guid logicalView, out IVsWindowFrame frame, WindowFrameShowAction windowFrameAction) { frame = null; ThreadHelper.ThrowIfNotOnUIThread(); IVsRunningDocumentTable rdt = this.Node.ProjectMgr.Site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; Debug.Assert(rdt != null, " Could not get running document table from the services exposed by this project"); if (rdt == null) { return(VSConstants.E_FAIL); } // First we see if someone else has opened the requested view of the file. _VSRDTFLAGS flags = _VSRDTFLAGS.RDT_NoLock; uint itemid; IntPtr docData = IntPtr.Zero; IVsHierarchy ivsHierarchy; uint docCookie; string path = this.GetFullPathForDocument(); int returnValue = VSConstants.S_OK; try { ThreadHelper.ThrowIfNotOnUIThread(); ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)flags, path, out ivsHierarchy, out itemid, out docData, out docCookie)); ErrorHandler.ThrowOnFailure(this.Open(newFile, openWith, ref logicalView, docData, out frame, windowFrameAction)); } catch (COMException e) { XSettings.LogException(e, "Open"); returnValue = e.ErrorCode; } finally { if (docData != IntPtr.Zero) { Marshal.Release(docData); } } return(returnValue); }
private IList <IToken> getTokens(string text) { IList <IToken> tokens; try { string fileName; fileName = "MissingFile.prg"; var reporter = new ErrorIgnorer(); bool ok = XSharp.Parser.VsParser.Lex(text, fileName, XSharpParseOptions.Default, reporter, out ITokenStream tokenStream); var stream = tokenStream as BufferedTokenStream; tokens = stream.GetTokens(); } catch (Exception e) { XSettings.LogException(e, "getTokens"); tokens = new List <IToken>(); } return(tokens); }
protected override AssemblyReferenceNode CreateAssemblyReferenceNode(ProjectElement element) { AssemblyReferenceNode node = null; try { node = new XSharpAssemblyReferenceNode(this.ProjectMgr, element); } catch (Exception e) { XSettings.LogException(e, "CreateAssemblyReferenceNode"); } ReferenceNode existing = null; if (isDuplicateNode(node, ref existing)) { AssemblyReferenceNode existingNode = existing as AssemblyReferenceNode; } return(node); }
/// <summary> /// Creates an assembly reference node from a file path. /// </summary> protected override AssemblyReferenceNode CreateAssemblyReferenceNode(string fileName) { AssemblyReferenceNode node = null; try { // Ok when file name is a full path or when it doesn't have a DLL extension if (!File.Exists(fileName)) { if (fileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) { fileName = Path.GetFileNameWithoutExtension(fileName); } } node = new XSharpAssemblyReferenceNode(this.ProjectMgr, fileName); } catch (Exception e) { XSettings.LogException(e, "CreateAssemblyReferenceNode"); } return(node); }
private async Task LexAsync() { var success = false; await TaskScheduler.Default; try { IsLexing = true; ClassifyBuffer(); success = true; } catch (Exception ex) { XSettings.LogException(ex, "LexAsync"); } finally { IsLexing = false; if (success) { await ParseAsync(); } } }
public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets) { WriteOutputMessage("-->> AugmentCompletionSessions"); try { if (XSettings.DisableCodeCompletion) { return; } XSharpModel.ModelWalker.Suspend(); if (_disposed) { throw new ObjectDisposedException("XSharpCompletionSource"); } _showTabs = XSettings.EditorCompletionListTabs; _keywordsInAll = XSettings.EditorKeywordsInAll; // Where does the StartSession has been triggered ? ITextSnapshot snapshot = _buffer.CurrentSnapshot; var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot); if (triggerPoint == null) { return; } // What is the character were it starts ? var line = triggerPoint.GetContainingLine(); //var triggerposinline = triggerPoint.Position - 2 - line.Start; //var afterChar = line.GetText()[triggerposinline]; //if (afterChar == ' ' || afterChar == '\t') // return; // The "parameters" coming from CommandFilter uint cmd = 0; char typedChar = '\0'; bool autoType = false; session.Properties.TryGetProperty(XsCompletionProperties.Command, out cmd); VSConstants.VSStd2KCmdID nCmdId = (VSConstants.VSStd2KCmdID)cmd; session.Properties.TryGetProperty(XsCompletionProperties.Char, out typedChar); session.Properties.TryGetProperty(XsCompletionProperties.AutoType, out autoType); bool showInstanceMembers = (typedChar == ':') || ((typedChar == '.') && _file.Project.ParseOptions.AllowDotForInstanceMembers); //////////////////////////////////////////// // SnapshotSpan lineSpan = new SnapshotSpan(line.Start, line.Length); SnapshotPoint caret = triggerPoint; var tagAggregator = aggregator.CreateTagAggregator <IClassificationTag>(_buffer); var tags = tagAggregator.GetTags(lineSpan); IMappingTagSpan <IClassificationTag> lastTag = null; foreach (var tag in tags) { //tagList.Add(tag); SnapshotPoint ptStart = tag.Span.Start.GetPoint(_buffer, PositionAffinity.Successor).Value; SnapshotPoint ptEnd = tag.Span.End.GetPoint(_buffer, PositionAffinity.Successor).Value; if ((ptStart != null) && (ptEnd != null)) { if (caret.Position >= ptEnd) { lastTag = tag; } } } if (lastTag != null) { var name = lastTag.Tag.ClassificationType.Classification.ToLower(); // No Intellisense in Comment if (name == "comment" || name == "xsharp.text") { return; } } //////////////////////////////////////////// SnapshotPoint start = triggerPoint; var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive); // if (_file == null) { // Uhh !??, Something went wrong return; } // The Completion list we are building XCompletionList compList = new XCompletionList(_file); XCompletionList kwdList = new XCompletionList(_file); IXTypeSymbol type = null; if (session.Properties.ContainsProperty(XsCompletionProperties.Type)) { type = (IXTypeSymbol)session.Properties[XsCompletionProperties.Type]; } // Start of Process string filterText = ""; // Check if we can get the member where we are // Standard TokenList Creation (based on colon Selector ) bool includeKeywords; session.Properties.TryGetProperty(XsCompletionProperties.IncludeKeywords, out includeKeywords); CompletionState state; var member = session.TextView.FindMember(triggerPoint); var location = session.TextView.TextBuffer.FindLocation(triggerPoint); if (location == null) { return; } var tokenList = XSharpTokenTools.GetTokenList(location, out state, includeKeywords); // We might be here due to a COMPLETEWORD command, so we have no typedChar // but we "may" have a incomplete word like System.String.To // Try to Guess what TypedChar could be if (typedChar == '\0' && autoType) { if (tokenList.Count > 0) { string extract = tokenList[tokenList.Count - 1].Text; typedChar = extract[extract.Length - 1]; if ((typedChar != '.') && (typedChar != ':')) { if (tokenList.Count == 1) { // filterText = tokenList[0].Text; int dotPos = extract.LastIndexOf("."); if (dotPos > -1) { string startToken = extract.Substring(0, dotPos); filterText = extract.Substring(dotPos + 1); typedChar = '.'; tokenList[0].Text = startToken + "."; } } else { // So, we get the last Token as a Filter filterText = tokenList[tokenList.Count - 1].Text; } // Include the filter as the text to replace start -= filterText.Length; applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive); } } } bool dotSelector = (typedChar == '.'); // TODO: Based on the Project.Settings, we should add the Vulcan.VO namespace int tokenType = XSharpLexer.UNRECOGNIZED; var symbol = XSharpLookup.RetrieveElement(location, tokenList, CompletionState.General, out var notProcessed).FirstOrDefault(); var memberName = ""; // Check for members, locals etc and convert the type of these to IXTypeSymbol if (symbol != null) { if (symbol is IXTypeSymbol xtype) { type = xtype; } else if (symbol is IXMemberSymbol xmember) { var typeName = xmember.TypeName; if (xmember is XSourceMemberSymbol sourcemem) { type = sourcemem.File.FindType(typeName); } else { type = location.FindType(typeName); } memberName = xmember.Name; } else if (symbol is IXVariableSymbol xvar) { var typeName = ""; if (xvar is XSourceUndeclaredVariableSymbol) { type = null; state = CompletionState.General; filterText = xvar.Name; } else if (xvar is XSourceVariableSymbol sourcevar) { typeName = sourcevar.TypeName; if (sourcevar.ResolvedType != null) { type = sourcevar.ResolvedType; typeName = type.FullName; } else { type = sourcevar.File.FindType(typeName); } } else if (xvar is XPEParameterSymbol par) { typeName = par.TypeName; type = location.FindType(typeName); } memberName = xvar.Name; } else if (symbol.Kind == Kind.Keyword) { filterText = symbol.Name; } else if (symbol.Kind == Kind.Namespace) { filterText = symbol.Name + "."; } if (type != null) { switch (type.FullName) { case XSharpTypeNames.XSharpUsual: case XSharpTypeNames.VulcanUsual: type = null; break; } } session.Properties[XsCompletionProperties.Type] = type; } if (type == null) { showInstanceMembers = false; } if ((dotSelector || state != CompletionState.None)) { if (string.IsNullOrEmpty(filterText) && type == null) { filterText = helpers.TokenListAsString(tokenList); if (filterText.Length > 0 && !filterText.EndsWith(".") && state != CompletionState.General) { filterText += "."; } } if (type == null && state.HasFlag(CompletionState.Namespaces)) { helpers.AddNamespaces(compList, location, filterText); } if (type == null && state.HasFlag(CompletionState.Interfaces)) { helpers.AddTypeNames(compList, location, filterText, afterDot: true, onlyInterfaces: true); helpers.AddXSharpKeywordTypeNames(kwdList, filterText); } if (type == null && state.HasFlag(CompletionState.Types)) { helpers.AddTypeNames(compList, location, filterText, afterDot: true, onlyInterfaces: false); helpers.AddXSharpKeywordTypeNames(kwdList, filterText); } if (state.HasFlag(CompletionState.StaticMembers)) { if (type != null && symbol is IXTypeSymbol) { // First we need to keep only the text AFTER the last dot int dotPos = filterText.LastIndexOf('.'); filterText = filterText.Substring(dotPos + 1, filterText.Length - dotPos - 1); helpers.BuildCompletionListMembers(location, compList, type, Modifiers.Public, true, filterText); } } if (type.IsVoStruct() && typedChar == '.') { // vostruct or union in other assembly showInstanceMembers = true; filterText = ""; } if (state.HasFlag(CompletionState.InstanceMembers)) { showInstanceMembers = true; filterText = ""; } } if (showInstanceMembers) { // Member call if (type != null) { Modifiers visibleAs = Modifiers.Public; if (type is XSourceTypeSymbol sourceType && sourceType.File.Project == member.File.Project) { visibleAs = Modifiers.Internal; switch (memberName.ToLower()) { case "self": case "this": visibleAs = Modifiers.Private; break; case "super": visibleAs = Modifiers.Protected; break; default: if (member.ParentName == type.FullName) { visibleAs = Modifiers.Private; } break; } } // Now, Fill the CompletionList with the available members, from there helpers.BuildCompletionListMembers(location, compList, type, visibleAs, false, filterText); } } // if (!dotSelector && !showInstanceMembers) { switch (tokenType) { case XSharpLexer.USING: // It can be a namespace helpers.AddNamespaces(compList, location, filterText); break; case XSharpLexer.AS: case XSharpLexer.IS: case XSharpLexer.REF: case XSharpLexer.INHERIT: // It can be a namespace helpers.AddNamespaces(compList, location, filterText); // It can be Type, FullyQualified // we should also walk all the USINGs, and the current Namespace if any, to search Types helpers.AddTypeNames(compList, location, filterText, onlyInterfaces: false, afterDot: false); // helpers.AddXSharpKeywordTypeNames(kwdList, filterText); break; case XSharpLexer.IMPLEMENTS: // It can be a namespace helpers.AddNamespaces(compList, location, filterText); helpers.AddTypeNames(compList, location, filterText, onlyInterfaces: true, afterDot: false); break; default: //if (state.HasFlag(CompletionState.General)) //{ // filterText = notProcessed; // helpers.AddGenericCompletion(compList, location, filterText); //} break; } } if ((kwdList.Count > 0) && _keywordsInAll /*&& XSettings.CompleteKeywords*/) { foreach (var item in kwdList.Values) { compList.Add(item); } } // Sort in alphabetical order // and put in the SelectionList var values = compList.Values; // Create the All Tab completionSets.Add(new CompletionSet("All", "All", applicableTo, values, Enumerable.Empty <Completion>())); if (_showTabs) { helpers.BuildTabs(compList, completionSets, applicableTo); } // Keywords are ALWAYS in a separate Tab anyway if (kwdList.Count > 0) { completionSets.Add(new CompletionSet("Keywords", "Keywords", applicableTo, kwdList.Values, Enumerable.Empty <Completion>())); } } catch (Exception ex) { XSettings.LogException(ex, "AugmentCompletionSessions failed"); } finally { XSharpModel.ModelWalker.Resume(); } WriteOutputMessage("<<-- AugmentCompletionSessions"); }
public override int DebugLaunch(uint grfLaunch) { CCITracing.TraceCall(); try { if (grfLaunch == 0) { grfLaunch = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_Silent; } VsDebugTargetInfo info = new VsDebugTargetInfo(); info.cbSize = (uint)Marshal.SizeOf(info); info.dlo = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; // On first call, reset the cache, following calls will use the cached values string property = GetConfigurationProperty(XSharpProjectFileConstants.DebuggerCommand, true); if (string.IsNullOrEmpty(property)) { property = this._project.GetOutputAssembly(this.ConfigCanonicalName); } info.bstrExe = property; property = GetConfigurationProperty(XSharpProjectFileConstants.DebuggerWorkingDirectory, false); if (string.IsNullOrEmpty(property)) { property = Path.GetDirectoryName(info.bstrExe); } if (!Path.IsPathRooted(property)) { property = Path.Combine(this.ProjectMgr.ProjectFolder, property); } info.bstrCurDir = property; property = GetConfigurationProperty(XSharpProjectFileConstants.DebuggerCommandArguments, false); if (!string.IsNullOrEmpty(property)) { info.bstrArg = property; } property = GetConfigurationProperty("RemoteDebugMachine", false); if (property != null && property.Length > 0) { info.bstrRemoteMachine = property; } property = GetConfigurationProperty("RedirectToOutputWindow", false); if (property != null && string.Compare(property, "true", StringComparison.OrdinalIgnoreCase) == 0) { info.fSendStdoutToOutputWindow = 1; } else { info.fSendStdoutToOutputWindow = 0; } property = GetConfigurationProperty(XSharpProjectFileConstants.EnableUnmanagedDebugging, false); if (property != null && string.Compare(property, "true", StringComparison.OrdinalIgnoreCase) == 0) { info.clsidCustom = VSConstants.DebugEnginesGuids.ManagedAndNative_guid; // {92EF0900-2251-11D2-B72E-0000F87572EF} } else { info.clsidCustom = VSConstants.DebugEnginesGuids.ManagedOnly_guid; // {449EC4CC-30D2-4032-9256-EE18EB41B62B} } if (!string.IsNullOrEmpty(this.ProjectMgr.BuildProject.Xml.Sdk)) { // Sdk style project info.clsidCustom = VSConstants.DebugEnginesGuids.CoreSystemClr_guid; } info.grfLaunch = grfLaunch; VsShellUtilities.LaunchDebugger(this._project.Site, info); } catch (Exception e) { XSettings.LogException(e, "DebugLaunch"); return(Marshal.GetHRForException(e)); } return(VSConstants.S_OK); }
public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList <ISignature> signatures) { try { Debug("XSharpSignatureHelpSource.AugmentSignatureHelpSession()"); m_session = session; XSharpModel.ModelWalker.Suspend(); ITextSnapshot snapshot = m_textBuffer.CurrentSnapshot; XSharpSignatureProperties props; int position = session.GetTriggerPoint(m_textBuffer).GetPosition(snapshot); session.Properties.TryGetProperty(typeof(XSharpSignatureProperties), out props); m_applicableToSpan = m_textBuffer.CurrentSnapshot.CreateTrackingSpan(new Span(props.Start, props.Length), SpanTrackingMode.EdgeInclusive, 0); object elt = props.Element; if (elt is IXSymbol) { IXMemberSymbol element = elt as IXMemberSymbol; // if (elt is IXMemberSymbol xMember) { var names = new List <string>(); var proto = getProto(xMember, props); names.Add(proto); signatures.Add(CreateSignature(m_textBuffer, xMember, proto, ApplicableToSpan, xMember.Kind == XSharpModel.Kind.Constructor, m_file)); var overloads = xMember.GetOverloads(); foreach (var member in overloads) { if (member.Visibility < props.Visibility) { continue; } // prevent duplicate prototypes in the list (when a child has overriden a method) proto = getProto(member, props); if (!names.Contains(proto)) { signatures.Add(CreateSignature(m_textBuffer, member, proto, ApplicableToSpan, member.Kind == XSharpModel.Kind.Constructor, m_file)); names.Add(proto); } } } else if (element != null) { // Type ?? signatures.Add(CreateSignature(m_textBuffer, null, element.Prototype, ApplicableToSpan, false, m_file)); } // why not ? int paramCount = int.MaxValue; foreach (ISignature sig in signatures) { if (sig.Parameters.Count < paramCount) { paramCount = sig.Parameters.Count; } } // m_textBuffer.Changed += new EventHandler <TextContentChangedEventArgs>(OnSubjectBufferChanged); } session.Dismissed += OnSignatureHelpSessionDismiss; } catch (Exception ex) { XSettings.LogException(ex, "XSharpSignatureHelpSource.AugmentSignatureHelpSession Exception failed "); } finally { XSharpModel.ModelWalker.Resume(); } }
internal static void GotoDefn(ITextView TextView) { try { if (XSettings.DisableGotoDefinition) { return; } var file = TextView.TextBuffer.GetFile(); if (file == null || file.XFileType != XFileType.SourceCode) { return; } WriteOutputMessage("CommandFilter.GotoDefn()"); ModelWalker.Suspend(); var snapshot = TextView.TextBuffer.CurrentSnapshot; // We don't want to lex the buffer. So get the tokens from the last lex run // and when these are too old, then simply bail out var tokens = TextView.TextBuffer.GetDocument(); if (tokens != null) { if (tokens.SnapShot.Version != snapshot.Version) { return; } } string currentNS = TextView.FindNamespace(); var location = TextView.FindLocation(); var state = CompletionState.General | CompletionState.Types | CompletionState.Namespaces; var tokenList = XSharpTokenTools.GetTokensUnderCursor(location, out state); // LookUp for the BaseType, reading the TokenList (From left to right) var result = new List <IXSymbol>(); result.AddRange(XSharpLookup.RetrieveElement(location, tokenList, state, out var notProcessed)); // Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); if (result.Count > 0) { var element = result[0]; if (element is XSourceEntity source) { source.OpenEditor(); } else if (element is XPETypeSymbol petype) { GotoSystemType(TextView, petype, petype); } else if (element is XPEMemberSymbol pemember) { var petype2 = pemember.Parent as XPETypeSymbol; GotoSystemType(TextView, petype2, pemember); } return; } // if (tokenList.Count > 1) { // try again with just the last element in the list var token = tokenList[tokenList.Count - 1]; tokenList.Clear(); tokenList.Add(token); location = location.With(currentNS); result.AddRange(XSharpLookup.RetrieveElement(location, tokenList, state, out notProcessed)); } if (result.Count > 0) { var element = result[0]; if (element is XSourceEntity source) { source.OpenEditor(); } //else //{ // openInObjectBrowser(element.FullName); //} //return; } } catch (Exception ex) { XSettings.LogException(ex, "Goto failed"); } finally { ModelWalker.Resume(); } }
public IEnumerable <ITagSpan <TextMarkerTag> > GetTags(NormalizedSnapshotSpanCollection spans) { // Todo: the classifier is now marking open and close keywords with (invisible) classification // on another location the classifier is building regions based on Open/Close keywords. // During this process of building regions we can also 'remember' the open/close pairs // so we do not have to look for these in this code. DateTime oStart, oEnd; TimeSpan timeSpan; oStart = DateTime.Now; if (spans.Count == 0 || _currentChar == null) //there is no content in the buffer { yield break; } WriteOutputMessage($"GetTags() Spans: {spans.Count}"); //don't do anything if the current SnapshotPoint is not initialized or at the end of the buffer if (!_currentChar.HasValue || _currentChar.Value.Position >= _currentChar.Value.Snapshot.Length) { yield break; } //hold on to a snapshot of the current character SnapshotPoint currentChar = _currentChar.Value; //if the requested snapshot isn't the same as the one the brace is on, translate our spans to the expected snapshot if (spans[0].Snapshot != currentChar.Snapshot) { currentChar = currentChar.TranslateTo(spans[0].Snapshot, PointTrackingMode.Positive); } //get the current char and the previous char SnapshotSpan pairSpan = new SnapshotSpan(); // check to see if we are on a closing or opening keyword if (!cursorOnKwOpenClose(currentChar)) { yield break; } // Try to Match Keywords // Try to retrieve an already parsed list of Tags XSharpClassifier xsClassifier = _buffer.GetClassifier(); if (xsClassifier == null) { yield break; } else { ITagSpan <TextMarkerTag> result1 = null; ITagSpan <TextMarkerTag> result2 = null; ITagSpan <TextMarkerTag> result3 = null; ITagSpan <TextMarkerTag> result4 = null; try { WriteOutputMessage("Match Open/Close keywords : " + oStart.ToString("hh:mm:ss.fff")); ITextSnapshot snapshot = xsClassifier.Snapshot; if (snapshot.Version != currentChar.Snapshot.Version) { yield break; } SnapshotSpan Span = new SnapshotSpan(snapshot, 0, snapshot.Length); var classifications = xsClassifier.GetTags(); // We cannot use SortedList, because we may have several Classification that start at the same position List <ClassificationSpan> sortedTags = new List <ClassificationSpan>(); foreach (var tag in classifications) { // Only keep the Brace matching Tags if ((tag.ClassificationType.IsOfType(ColorizerConstants.XSharpKwOpenFormat)) || (tag.ClassificationType.IsOfType(ColorizerConstants.XSharpKwCloseFormat))) { sortedTags.Add(tag); } } sortedTags.Sort((a, b) => a.Span.Start.Position.CompareTo(b.Span.Start.Position) * 1000 + string.Compare(a.ClassificationType.Classification, b.ClassificationType.Classification)); // var tags = sortedTags.Where(x => currentChar.Position >= x.Span.Start.Position && currentChar.Position <= x.Span.End.Position); foreach (var currentTag in tags) { var index = sortedTags.IndexOf(currentTag); if (currentTag.ClassificationType.IsOfType(ColorizerConstants.XSharpKwOpenFormat) && result1 == null) { if (FindMatchingCloseTag(sortedTags, index, snapshot, out pairSpan)) { var span = currentTag.Span; result1 = new TagSpan <TextMarkerTag>(span, _tag); result2 = new TagSpan <TextMarkerTag>(pairSpan, _tag); } } else if (result3 == null) { if (FindMatchingOpenTag(sortedTags, index, snapshot, out pairSpan)) { var span = currentTag.Span; result3 = new TagSpan <TextMarkerTag>(pairSpan, _tag); result4 = new TagSpan <TextMarkerTag>(span, _tag); } } } } catch (Exception e) { XSettings.LogException(e, "KeywordMatchingTagger.GetTags failed"); } finally { oEnd = DateTime.Now; timeSpan = oEnd - oStart; WriteOutputMessage("Finished Match Open/Close keywords: " + oEnd.ToString("hh:mm:ss.fff")); WriteOutputMessage("Finished Match Open/Close keywords - total ms: " + timeSpan.TotalMilliseconds.ToString()); } if (result1 != null) { yield return(result1); } if (result2 != null) { yield return(result2); } if (result3 != null) { yield return(result3); } if (result4 != null) { yield return(result4); } } }
internal bool StartSignatureSession(bool comma, IXTypeSymbol type = null, string methodName = null, char triggerchar = '\0') { WriteOutputMessage("StartSignatureSession()"); if (_signatureSession != null) { return(false); } IXMemberSymbol currentElement = null; SnapshotPoint ssp = this._textView.Caret.Position.BufferPosition; if (triggerchar == '(' && ssp.Position < ssp.Snapshot.Length && ssp.GetChar() == ')') { ssp -= 1; } var location = _textView.FindLocation(ssp); if (location == null || location.Member == null) { return(false); } if (location.Member.Range.StartLine == location.LineNumber) { return(false); } var props = new XSharpSignatureProperties(location); props.triggerChar = triggerchar; props.triggerPosition = this._textView.Caret.Position.BufferPosition.Position; if (type != null && methodName != null) { var findStatic = triggerchar == '.'; currentElement = XSharpLookup.SearchMethod(location, type, methodName, Modifiers.Private, findStatic).FirstOrDefault(); } else { currentElement = findElementAt(comma, ssp, props); } if (currentElement == null) { return(false); } SnapshotPoint caret = _textView.Caret.Position.BufferPosition; ITextSnapshot caretsnapshot = caret.Snapshot; // if (_signatureBroker.IsSignatureHelpActive(_textView)) { _signatureSession = _signatureBroker.GetSessions(_textView)[0]; } else { _signatureSession = _signatureBroker.CreateSignatureHelpSession(_textView, caretsnapshot.CreateTrackingPoint(caret, PointTrackingMode.Positive), true); } _signatureSession.Properties[typeof(XSharpSignatureProperties)] = props; if (location.Member.Kind.IsGlobalTypeMember()) { props.Visibility = Modifiers.Public; } else { props.Visibility = Modifiers.Protected; } _signatureSession.Dismissed += OnSignatureSessionDismiss; props.Element = currentElement; if (comma) { var tokenList = XSharpTokenTools.GetTokenListBeforeCaret(location, out var state); bool done = false; int nested = 0; for (int i = tokenList.Count - 1; i >= 0 && !done; i--) { var token = tokenList[i]; switch (token.Type) { case XSharpLexer.LPAREN: case XSharpLexer.LCURLY: case XSharpLexer.LBRKT: done = nested == 0; if (done) { props.Start = token.Position; props.Length = _textView.Caret.Position.BufferPosition.Position - token.Position; } nested -= 1; break; case XSharpLexer.RPAREN: case XSharpLexer.RCURLY: case XSharpLexer.RBRKT: nested += 1; break; } } } else { props.Start = ssp.Position; props.Length = _textView.Caret.Position.BufferPosition.Position - ssp.Position; } try { _signatureSession.Start(); } catch (Exception e) { XSettings.LogException(e, "Start Signature session failed:"); } // return(true); }
//static bool skipFirst = true; public async Task <QuickInfoItem> GetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken) { if (XSettings.DebuggerIsRunning || XSettings.DisableQuickInfo) { await session.DismissAsync(); return(null); } var triggerPoint = session.GetTriggerPoint(_textBuffer.CurrentSnapshot); if (triggerPoint == null) { await session.DismissAsync(); return(null); } try { ModelWalker.Suspend(); var ssp = triggerPoint.Value; // Map the trigger point down to our buffer. ITextSnapshot currentSnapshot = ssp.Snapshot; bool abort = false; var tokens = _textBuffer.GetDocument(); if (tokens == null) { return(null); } if (cancellationToken.IsCancellationRequested) { return(null); } if (!abort) { WriteOutputMessage($"Triggerpoint: {triggerPoint.Value.Position}"); // We don't want to lex the buffer. So get the tokens from the last lex run // and when these are too old, then simply bail out abort = tokens == null || tokens.SnapShot.Version != currentSnapshot.Version; } if (abort) { await session.DismissAsync(); return(null); } if (cancellationToken.IsCancellationRequested) { return(null); } var location = _textBuffer.FindLocation(ssp); CompletionState state; var tokenList = XSharpTokenTools.GetTokensUnderCursor(location, out state); // LookUp for the BaseType, reading the TokenList (From left to right) if (cancellationToken.IsCancellationRequested) { return(null); } var lookupresult = new List <IXSymbol>(); lookupresult.AddRange(XSharpLookup.RetrieveElement(location, tokenList, state, out var notProcessed, true)); var lastToken = tokenList.LastOrDefault(); // if (lookupresult.Count > 0) { var element = lookupresult[0]; var qiContent = new List <object>(); if (element.Kind == Kind.Constructor && lastToken?.Type != XSharpLexer.CONSTRUCTOR && lastToken?.Type != XSharpLexer.LPAREN) { if (element.Parent != null) { var xtype = element.Parent as IXTypeSymbol; var qitm = new XTypeAnalysis(xtype); AddImage(qiContent, qitm.Image); var description = new ClassifiedTextElement(qitm.WPFDescription); qiContent.Add(description); } } else if (element is IXMemberSymbol mem) { QuickInfoTypeMember qitm = new QuickInfoTypeMember(mem); AddImage(qiContent, qitm.Image); var description = new ClassifiedTextElement(qitm.WPFDescription); qiContent.Add(description); } else if (element is IXVariableSymbol var) { QuickInfoVariable qitm = new QuickInfoVariable(var); AddImage(qiContent, qitm.Image); var description = new ClassifiedTextElement(qitm.WPFDescription); qiContent.Add(description); } else if (element is IXTypeSymbol xtype) { var qitm = new XTypeAnalysis(xtype); AddImage(qiContent, qitm.Image); var description = new ClassifiedTextElement(qitm.WPFDescription); qiContent.Add(description); } else { var qitm = new XAnalysis(element); AddImage(qiContent, qitm.Image); var description = new ClassifiedTextElement(qitm.WPFDescription); qiContent.Add(description); } if (cancellationToken.IsCancellationRequested) { return(null); } var result = new ContainerElement(ContainerElementStyle.Wrapped, qiContent); var line = ssp.GetContainingLine(); var lineSpan = _textBuffer.CurrentSnapshot.CreateTrackingSpan(line.Extent, SpanTrackingMode.EdgeInclusive); return(new QuickInfoItem(lineSpan, result)); } } catch (Exception ex) { XSettings.LogException(ex, "XSharpQuickInfo.AugmentQuickInfoSession failed : "); } finally { ModelWalker.Resume(); } await session.DismissAsync(); return(null); }
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; // LookUp for the BaseType, reading the TokenList (From left to right) var location = _textBuffer.FindLocation(triggerPoint); if (location == null) { return; } CompletionState state; var tokenList = XSharpTokenTools.GetTokensUnderCursor(location, out state); var result = new List <IXSymbol>(); result.AddRange(XSharpLookup.RetrieveElement(location, tokenList, state, out var notProcessed, true)); // if (result.Count > 0) { if (result[0] is XSourceSymbol symbol) { peekableItems.Add(new XSharpDefinitionPeekItem(symbol, _peekResultFactory)); } else if (result[0] is XPESymbol pesymbol) { XPETypeSymbol petype; if (pesymbol is XPETypeSymbol) { petype = (XPETypeSymbol)pesymbol; } else if (pesymbol is XPEMemberSymbol member) { petype = (XPETypeSymbol)member.Parent; } else { return; } var file = XSharpGotoDefinition.CreateFileForSystemType(petype, pesymbol); var entity = XSharpGotoDefinition.FindElementInFile(file, petype, pesymbol); if (entity != null) { peekableItems.Add(new XSharpDefinitionPeekItem(entity, _peekResultFactory)); } } } } catch (Exception ex) { XSettings.LogException(ex, "XSharpPeekItemSource.AugmentPeekSession failed : "); } finally { ModelWalker.Resume(); } }
public virtual VsResolvedAssemblyPath[] Resolve(IEnumerable <string> assemblies) { if (assemblies == null) { throw new ArgumentNullException("assemblies"); } //// Resolve references WITHOUT invoking MSBuild to avoid re-entrancy problems. //const bool projectDtar = true; //var rar = new Microsoft.Build.Tasks.ResolveAssemblyReference(); //var engine = new MockEngine(EnableLogging); //rar.BuildEngine = engine; //// first set common properties/items then if projectDtar then set additional projectDtar properties //ITaskItem[] assemblyItems = assemblies.Select(assembly => new TaskItem(assembly)).ToArray(); //rar.Assemblies = assemblyItems; //rar.SearchPaths = rarInputs.PdtarSearchPaths; //rar.TargetFrameworkDirectories = rarInputs.TargetFrameworkDirectories; //rar.AllowedAssemblyExtensions = rarInputs.AllowedAssemblyExtensions; //rar.TargetProcessorArchitecture = rarInputs.TargetProcessorArchitecture; //rar.TargetFrameworkVersion = rarInputs.TargetFrameworkVersion; //rar.TargetFrameworkMoniker = rarInputs.TargetFrameworkMoniker; //rar.TargetFrameworkMonikerDisplayName = rarInputs.TargetFrameworkMonikerDisplayName; //rar.TargetedRuntimeVersion = rarInputs.TargetedRuntimeVersion; //rar.FullFrameworkFolders = rarInputs.FullFrameworkFolders; //rar.LatestTargetFrameworkDirectories = rarInputs.LatestTargetFrameworkDirectories; //rar.FullTargetFrameworkSubsetNames = rarInputs.FullTargetFrameworkSubsetNames; //rar.FullFrameworkAssemblyTables = rarInputs.FullFrameworkAssemblyTables; //rar.IgnoreDefaultInstalledAssemblySubsetTables = rarInputs.IgnoreDefaultInstalledAssemblySubsetTables; //rar.ProfileName = rarInputs.ProfileName; //rar.Silent = !this.EnableLogging; //rar.FindDependencies = true; //rar.AutoUnify = false; //rar.FindSatellites = false; //rar.FindSerializationAssemblies = false; //rar.FindRelatedFiles = false; //// This set needs to be kept in sync with the set of project instance data that //// is populated into RarInputs //if (projectDtar) //{ // // set project dtar specific properties // rar.CandidateAssemblyFiles = rarInputs.CandidateAssemblyFiles; // rar.StateFile = rarInputs.StateFile; // rar.InstalledAssemblySubsetTables = rarInputs.InstalledAssemblySubsetTables; // rar.TargetFrameworkSubsets = rarInputs.TargetFrameworkSubsets; //} IEnumerable <VsResolvedAssemblyPath> results; try { //rar.Execute(); //results = FilterResults(rar.ResolvedFiles).Select(pair => new VsResolvedAssemblyPath //{ // bstrOrigAssemblySpec = pair.Key, // bstrResolvedAssemblyPath = pair.Value, //}); } catch (Exception ex) { XSettings.LogException(ex, ""); } finally { if (this.EnableLogging) { //WriteLogFile(engine, projectDtar, assemblies); } } results = Enumerable.Empty <VsResolvedAssemblyPath>(); return(results.ToArray()); }
protected int Open(bool newFile, bool openWith, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction, bool reopen = false) { windowFrame = null; if (this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed) { return(VSConstants.E_FAIL); } Debug.Assert(this.Node != null, "No node has been initialized for the document manager"); Debug.Assert(this.Node.ProjectMgr != null, "No project manager has been initialized for the document manager"); Debug.Assert(this.Node is FileNode, "Node is not FileNode object"); ThreadHelper.ThrowIfNotOnUIThread(); int returnValue = VSConstants.S_OK; string caption = this.GetOwnerCaption(); string fullPath = this.GetFullPathForDocument(); IVsUIShellOpenDocument uiShellOpenDocument = this.Node.ProjectMgr.Site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument; Assumes.Present(uiShellOpenDocument); IOleServiceProvider serviceProvider = this.Node.ProjectMgr.Site.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider; Assumes.Present(serviceProvider); var openState = uiShellOpenDocument as IVsUIShellOpenDocument3; bool showDialog = !reopen && (openState == null || !((__VSNEWDOCUMENTSTATE)openState.NewDocumentState).HasFlag(__VSNEWDOCUMENTSTATE.NDS_Provisional)); // Make sure that the file is on disk before we open the editor and display message if not found if (!((FileNode)this.Node).IsFileOnDisk(showDialog)) { // Bail since we are not able to open the item // Do not return an error code otherwise an internal error message is shown. The scenario for this operation // normally is already a reaction to a dialog box telling that the item has been removed. return(VSConstants.S_FALSE); } try { this.Node.ProjectMgr.OnOpenItem(fullPath); int result = VSConstants.E_FAIL; if (openWith) { result = uiShellOpenDocument.OpenStandardEditor((uint)__VSOSEFLAGS.OSE_UseOpenWithDialog, fullPath, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } else { __VSOSEFLAGS openFlags = 0; if (newFile) { openFlags |= __VSOSEFLAGS.OSE_OpenAsNewFile; } //NOTE: we MUST pass the IVsProject in pVsUIHierarchy and the itemid // of the node being opened, otherwise the debugger doesn't work. if (editorType != Guid.Empty) { result = uiShellOpenDocument.OpenSpecificEditor(editorFlags, fullPath, ref editorType, physicalView, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } else { openFlags |= __VSOSEFLAGS.OSE_ChooseBestStdEditor; result = uiShellOpenDocument.OpenStandardEditor((uint)openFlags, fullPath, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } } if (result != VSConstants.S_OK && result != VSConstants.S_FALSE && result != VSConstants.OLE_E_PROMPTSAVECANCELLED) { // Note that the error MUST be thrown. Without this the file will not be opened in the debugger when it is not already opened ErrorHandler.ThrowOnFailure(result); } if (windowFrame != null) { object var; if (newFile) { ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var)); IVsPersistDocData persistDocData = (IVsPersistDocData)var; ErrorHandler.ThrowOnFailure(persistDocData.SetUntitledDocPath(fullPath)); } var = null; ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocCookie, out var)); this.Node.DocCookie = (uint)(int)var; if (windowFrameAction == WindowFrameShowAction.Show) { ErrorHandler.ThrowOnFailure(windowFrame.Show()); } else if (windowFrameAction == WindowFrameShowAction.ShowNoActivate) { ErrorHandler.ThrowOnFailure(windowFrame.ShowNoActivate()); } else if (windowFrameAction == WindowFrameShowAction.Hide) { ErrorHandler.ThrowOnFailure(windowFrame.Hide()); } } } catch (COMException e) { XSettings.LogException(e, ""); returnValue = e.ErrorCode; CloseWindowFrame(ref windowFrame); } return(returnValue); }
static public void Trace(System.Exception e) { CCITracing.InternalTraceCall(2); XSettings.LogException(e, ""); }