public PropertySuggestedActionsSource(PropertySuggestedActionsSourceProvider propertySuggestedActionsSourceProvider, ITextView textView, ITextBuffer textBuffer) : base(textView, textBuffer) { this.m_factory = propertySuggestedActionsSourceProvider; // _memberEntity = null; }
/// <summary> /// Search the item under the caret. /// If a Field, it is stored in _memberentity /// </summary> /// <returns>True if the caret is placed on a Field</returns> private bool SearchField() { _memberEntity = null; if (m_textBuffer.Properties == null) { return(false); } // SnapshotPoint caret = this.m_textView.Caret.Position.BufferPosition; var location = this.m_textBuffer.FindLocation(caret); CompletionState state; var tokenList = XSharpTokenTools.GetTokensUnderCursor(location, out state); // LookUp for the BaseType, reading the TokenList (From left to right) var lookupresult = new List <IXSymbol>(); lookupresult.AddRange(XSharpLookup.RetrieveElement(location, tokenList, state, out var notProcessed, true)); // if (lookupresult.Count > 0) { var element = lookupresult[0]; if (element is XSourceMemberSymbol mem && mem.Kind == Kind.Field) { _memberEntity = mem; return(true); } } return(false); }
public PropertySuggestedAction(ITextView textView, ITextBuffer m_textBuffer, XSourceMemberSymbol fieldToPropertize, XSharpModel.TextRange range, bool fullProperty, string genName, bool renField) : base(textView) { _fieldEntity = fieldToPropertize; _range = range; _full = fullProperty; _renameField = renField; _generateName = genName; }
internal XSharpSearchLocation With(XSourceMemberSymbol member) { var clone = (XSharpSearchLocation)this.MemberwiseClone(); clone.Member = member; clone.Usings = clone.GetUsings(); return(clone); }
internal XSharpSearchLocation(XFile file, XSourceMemberSymbol member, ITextSnapshot snapshot, int lineNumber = 0, int position = 0, string currentNs = "") { Member = member; Snapshot = snapshot; if (member != null) { File = Member.File; } else { File = file; } LineNumber = lineNumber; Position = position; CurrentNamespace = currentNs; Usings = GetUsings(); }
/// <summary> /// Retrieve the locals for a particular member /// </summary> /// <param name="member"></param> /// <param name="snapshot"></param> /// <param name="iCurrentLine"></param> /// <returns></returns> internal static IList <XSourceVariableSymbol> GetLocals(this XSourceMemberSymbol member, XSharpSearchLocation location) { var iCurrentLine = Math.Min(location.Snapshot.LineCount - 1, location.LineNumber); // create a walker with just the contents of the current member // use a new file object so we will not destroy the types in the existing object var walker = new SourceWalker(new XFile(member.File.FullPath, member.File.Project), false); var start = member.Interval.Start; var end = member.Interval.Width; if (start + end > location.Snapshot.Length) { end = location.Snapshot.Length - start; } var memberSource = location.Snapshot.GetText(start, end); var locals = walker.ParseLocals(memberSource, member); // Add the normal locals for class members foreach (var local in locals) { // assign the current member so we will have the proper Parent as well local.Parent = member; local.File = member.File; } if (member.Kind.IsClassMember(location.Dialect) && !member.Modifiers.HasFlag(Modifiers.Static)) { var XVar = new XSourceVariableSymbol(member, "SELF", member.Range, member.Interval, member.ParentName); XVar.File = walker.File; locals.Add(XVar); if (!String.IsNullOrEmpty(member.ParentType.BaseTypeName)) { XVar = new XSourceVariableSymbol(member, "SUPER", member.Range, member.Interval, member.ParentType.BaseTypeName); XVar.File = walker.File; locals.Add(XVar); } } return(locals); }