Пример #1
0
 public ConstructorSuggestedActionsSource(ConstructorSuggestedActionsSourceProvider ctorSuggestedActionsSourceProvider, ITextView textView, ITextBuffer textBuffer) : base(textView, textBuffer)
 {
     this.m_factory = ctorSuggestedActionsSourceProvider;
     //
     _classEntity  = null;
     _existingCtor = new List <string>();
 }
Пример #2
0
        bool isHiddenTypeSymbol(IXTypeSymbol type, out string displayName)
        {
            string fullName = type.FullName;

            displayName = fullName;
            if (IsHiddenTypeName(fullName))
            {
                return(true);
            }
            if (fullName.Contains("+"))
            {
                fullName = fullName.Replace('+', '.');
            }
            displayName = fullName;
            // Do we have another part file
            var dotPos = fullName.LastIndexOf('.');

            // Then remove it
            if (dotPos > 0)
            {
                displayName = displayName.Substring(dotPos + 1);
            }
            if (IsHiddenTypeName(displayName))
            {
                return(true);
            }
            return(false);
        }
Пример #3
0
 public ConstructorSuggestedAction(ITextView textView, ITextBuffer textBuffer, IXTypeSymbol classEntity, int insertionLine, List <IXMemberSymbol> members) : base(textView.TextSnapshot)
 {
     this._textBuffer    = textBuffer;
     this._classEntity   = classEntity;
     this._insertionLine = insertionLine;
     this._fieldsNProps  = members;
 }
Пример #4
0
 public ImplementInterfaceSuggestedActionsSource(ImplementInterfaceSuggestedActionsSourceProvider ImplementInterfaceSuggestedActionsSourceProvider, ITextView textView, ITextBuffer textBuffer)
     : base(textView, textBuffer)
 {
     this.m_factory = ImplementInterfaceSuggestedActionsSourceProvider;
     //
     _classEntity = null;
 }
Пример #5
0
 internal XMemberType(string name, MemberTypes memberType, bool inherited, IXTypeSymbol type, string typeName)
 {
     Name       = name;
     MemberType = memberType;
     Inherited  = inherited;
     Type       = type;
     TypeName   = typeName;
 }
 public ImplementInterfaceSuggestedAction(ITextView textView, ITextBuffer m_textBuffer, string intface, IXTypeSymbol entity, List <IXMemberSymbol> memberstoAdd, XSharpModel.TextRange range, bool fqn)
     : base(textView)
 {
     m_interface  = intface;
     _classEntity = entity;
     _members     = memberstoAdd;
     _range       = range;
     _explicitly  = fqn;
 }
Пример #7
0
        /// <summary>
        /// Retrieve the Entity, and check if it has an Interface and if some members are missing
        /// </summary>
        /// <returns></returns>
        public bool SearchMissingMembers()
        {
            // Reset
            _classEntity = null;
            _members     = null;
            if (!GetFile())
            {
                return(false);
            }
            //
            int caretLine = SearchRealStartLine();

            if (caretLine < 0)
            {
                return(false);
            }
            //
            foreach (var entity in _xfile.EntityList)
            {
                if (entity is XSourceTypeSymbol typeEntity)
                {
                    if (typeEntity.Range.StartLine == caretLine)
                    {
                        // Got it !
                        _classEntity = _xfile.FindType(typeEntity.FullName);
                        if (_classEntity != null)
                        {
                            _range = typeEntity.Range;
                            break;
                        }
                    }
                }
            }
            // Ok, we know the class, now does it have an Interface..and does it need it ?
            if (_classEntity != null)
            {
                _members = BuildMissingMembers();
                if (_members != null)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #8
0
        /// <summary>
        /// Retrieve the Entity, and check if it has an Interface and if some members are missing
        /// </summary>
        /// <returns></returns>
        public bool SearchCtor()
        {
            // Reset
            _classEntity  = null;
            _fieldNProps  = null;
            _existingCtor = new List <string>();
            // Sorry, we are lost...
            if (!GetFile())
            {
                return(false);
            }
            //
            int caretLine = SearchRealStartLine();

            if (caretLine < 0)
            {
                return(false);
            }
            //
            foreach (var entity in _xfile.EntityList)
            {
                if (entity is XSourceTypeSymbol typeEntity)
                {
                    if ((typeEntity.Range.StartLine <= caretLine) && (typeEntity.Range.EndLine >= caretLine) && (typeEntity.Kind == Kind.Class))
                    {
                        // Got it !
                        _classEntity = _xfile.FindType(typeEntity.FullName);
                        if (_classEntity != null)
                        {
                            _insertionLine = this.SearchInsertionPoint(typeEntity);
                            break;
                        }
                    }
                }
            }
            // Ok, we know the class, now does it have an empty Constructor ? does the class have fields ? or Properties ?
            if (_classEntity != null)
            {
                _fieldNProps = BuildMissingCtor();
                //
                return((!_hasDefault) || (_fieldNProps != null));
            }
            return(false);
        }
        private void TriggerSignatureHelp(IXTypeSymbol type, string method, char triggerChar)
        {
            // it MUST be the case....
            WriteOutputMessage("OnCompletionSessionCommitted()");

            if (triggerChar == '{' || triggerChar == '}')
            {
                if (method.EndsWith("{}"))
                {
                    method = method.Substring(0, method.Length - 2);
                }
                else if (method.EndsWith("{"))
                {
                    method = method.Substring(0, method.Length - 1);
                }
                //triggerChar = '{';
            }
            else
            {
                if (method.EndsWith("()"))
                {
                    method = method.Substring(0, method.Length - 2);
                }
                else if (method.EndsWith("("))
                {
                    method = method.Substring(0, method.Length - 1);
                }
                //triggerChar = '(';
            }

            // send command to editor to Signature Helper
            if (_signatureCommandHandler == null)
            {
                _signatureCommandHandler = _textView.Properties.GetProperty <XSharpSignatureHelpCommandHandler>(typeof(XSharpSignatureHelpCommandHandler));
            }
            if (_signatureCommandHandler != null)
            {
                _signatureCommandHandler.StartSignatureSession(true, type, method, triggerChar);
            }

            //
            //
        }
Пример #10
0
 internal XTypeAnalysis(IXTypeSymbol typeInfo) : base(typeInfo)
 {
     //
     if (typeInfo == null)
     {
         return;
     }
     Type = typeInfo;
     Name = typeInfo.FullName;
     //
     if (typeInfo.IsGeneric)
     {
         // convert syntax with `2 to real type parameter names
         string genName = typeInfo.FullName;
         if (typeInfo is XPETypeSymbol petype)
         {
             genName = petype.OriginalTypeName;
         }
         int index = genName.IndexOf('`');
         if (index != -1)
         {
             genName = genName.Substring(0, index);
         }
         if (genName.IndexOf('<') == -1)
         {
             genName += "<";
             int count = 0;
             int max   = typeInfo.TypeParameters.Count;
             foreach (var genType in typeInfo.TypeParameters)
             {
                 genName += genType;
                 count++;
                 if ((count < max))
                 {
                     genName += ", ";
                 }
             }
             genName += ">";
         }
         Name = genName;
     }
 }
Пример #11
0
        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);
        }
Пример #12
0
 internal void FillExtensions(XSharpSearchLocation location, XCompletionList compList, IXTypeSymbol type, string startWith)
 {
     WriteOutputMessage($"FillExtensions for type {type?.FullName}");
     if (type != null)
     {
         var extensions = _file.Project.GetExtensions(type.FullName);
         IEnumerable <IXMemberSymbol> selection = extensions;
         if (!string.IsNullOrEmpty(startWith))
         {
             selection = extensions.Where(x => nameStartsWith(x.Name, startWith));
         }
         if (selection.Count() > 0)
         {
             FillMembers(location, compList, null, selection, Modifiers.Public, true);
         }
         foreach (var ifname in type.Interfaces)
         {
             var lifname       = ifname;
             var lookupproject = _file.Project;
             if (type is XSourceTypeSymbol sourceType)
             {
                 var typedef  = sourceType;
                 var origfile = XSolution.FindFullPath(typedef.File.FullPath);
                 lookupproject = origfile.Project;
                 var reftype = SystemTypeController.FindType(lifname, typedef.FileUsings, lookupproject.AssemblyReferences);
                 if (reftype != null)
                 {
                     lifname = reftype.FullName;
                 }
             }
             extensions = lookupproject.GetExtensions(lifname);
             selection  = extensions;
             if (!string.IsNullOrEmpty(startWith))
             {
                 selection = extensions.Where(x => nameStartsWith(x.Name, startWith));
             }
             if (selection.Count() > 0)
             {
                 FillMembers(location, compList, null, selection, Modifiers.Public, true);
             }
         }
     }
     //WriteOutputMessage($"FillExtensions complete for type {sType.FullName}");
 }
Пример #13
0
 /// <summary>
 /// Add Members for our Types to the completionlist
 /// </summary>
 /// <param name="compList"></param>
 /// <param name="xType"></param>
 /// <param name="minVisibility"></param>
 internal void FillMembers(XSharpSearchLocation location, XCompletionList compList, IXTypeSymbol xType, Modifiers minVisibility, bool staticOnly, string startWith)
 {
     FillMembers(location, compList, xType, xType.GetMembers(startWith), minVisibility, staticOnly);
 }
Пример #14
0
        /// <summary>
        /// Add members to the completionlist
        /// </summary>
        /// <param name="compList"></param>
        /// <param name="members"></param>
        /// <param name="minVisibility"></param>
        /// <param name="staticOnly"></param>
        internal void FillMembers(XSharpSearchLocation location, XCompletionList compList, IXTypeSymbol type, IEnumerable <IXMemberSymbol> members, Modifiers minVisibility, bool staticOnly)
        {
            if (members.Count() == 0)
            {
                return;
            }
            WriteOutputMessage($"FillMembers {type?.FullName}: {members.Count()} members");
            foreach (var elt in members)
            {
                bool add = true;
                if (IsHiddenMemberName(elt.Name))
                {
                    continue;
                }
                switch (elt.Kind)
                {
                case Kind.EnumMember:
                    add = true;
                    break;

                case Kind.Constructor:
                case Kind.Destructor:
                case Kind.Operator:
                    add = false;
                    break;

                default:
                    if (!elt.Kind.IsGlobalTypeMember() && elt.IsStatic != staticOnly)
                    {
                        add = false;
                    }
                    if (add)
                    {
                        add = elt.IsVisible(minVisibility);
                    }
                    if (staticOnly && elt.IsStatic && type != null)
                    {
                        if (elt.Parent.FullName == "System.Object" && type.FullName != "System.Object")
                        {
                            add = false;
                        }
                    }
                    break;
                }
                if (type != null && type.Kind == Kind.Enum && elt.DeclaringType != null && elt.DeclaringType != type.FullName && elt.Name != "HasFlag")
                {
                    add = false;
                }
                if (!add)
                {
                    continue;
                }
                //
                ImageSource icon  = _glyphService.GetGlyph(elt.getGlyphGroup(), elt.getGlyphItem());
                string      toAdd = "";
                if (elt.Kind.HasParameters() && elt.Kind != Kind.Constructor && !elt.Kind.IsProperty() && elt.Kind != Kind.Event)
                {
                    toAdd = "(";
                }
                if (!compList.Add(new XSCompletion(elt.Name, elt.Name + toAdd, elt.Prototype, icon, null, elt.Kind, elt.Value)))
                {
                    break;
                }
            }
        }
Пример #15
0
 internal XCodeTypeReference(IXTypeSymbol type) : base(type.FullName)
 {
 }
Пример #16
0
 public ConstructorSuggestedAction(ITextView textView, ITextBuffer textBuffer, IXTypeSymbol classEntity, int insertionLine, List <IXMemberSymbol> members, List <string> existingCtor) :
     this(textView, textBuffer, classEntity, insertionLine, members)
 {
     this._existingCtor = existingCtor;
 }
Пример #17
0
        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");
        }
Пример #18
0
 internal void BuildCompletionListMembers(XSharpSearchLocation location, XCompletionList compList, IXTypeSymbol type, Modifiers minVisibility, bool staticOnly, string startWith)
 {
     if (type == null)
     {
         return;
     }
     //
     FillMembers(location, compList, type, minVisibility, staticOnly, startWith);
     if (type is XSourceTypeSymbol sourceType)
     {
         sourceType.ForceComplete();
         var baseType = sourceType.BaseTypeName;
         if (string.IsNullOrWhiteSpace(baseType))
         {
             if (type.Kind == Kind.Enum)
             {
                 baseType = "System.Enum";
             }
             else if (type.Kind == Kind.Delegate)
             {
                 baseType = "System.Delegate";
             }
             else
             {
                 baseType = "System.Object";
             }
         }
         var parentType = sourceType.File.FindType(baseType, sourceType.Namespace);
         if (parentType != null && parentType.FullName == sourceType.FullName)
         {
             ; // recursion !
             WriteOutputMessage("*** Recursion detected *** " + sourceType.FullName + " inherits from " + parentType.FullName);
         }
         else if (baseType == "System.Enum" && staticOnly)
         {
             ; // do nothing
         }
         else
         {
             BuildCompletionListMembers(location, compList, parentType, Modifiers.Protected, staticOnly, startWith);
         }
         foreach (var ifname in sourceType.Interfaces)
         {
             var iftype = sourceType.File.FindType(ifname, sourceType.Namespace);
             if (iftype != null)
             {
                 BuildCompletionListMembers(location, compList, iftype, Modifiers.Public, staticOnly, startWith);
             }
         }
     }
     if (type is XPETypeSymbol && type.Children.Count > 0)
     {
         AddTypeNames(compList, location, type.FullName, false);
     }
     if (type is XSourceTypeSymbol)
     {
         var usings = location.Usings.ToList();
         usings.Add(type.FullName);
         AddXSharpTypeNames(compList, location, type.FullName, usings, type.FullName);
     }
     if (!staticOnly)
     {
         FillExtensions(location, compList, type, startWith);
     }
 }