ConvertEntity() private method

private ConvertEntity ( IEntity entity ) : string
entity IEntity
return string
Esempio n. 1
0
        public TypeLookupResponse GetTypeLookupResponse(TypeLookupRequest request)
        {
            var res = _bufferParser.ParsedContent(request.Buffer, request.FileName);
            var loc = new TextLocation(request.Line, request.Column);
            var resolveResult = ResolveAtLocation.Resolve(res.Compilation, res.UnresolvedFile, res.SyntaxTree, loc);
            var response = new TypeLookupResponse();
            var ambience = new CSharpAmbience()
                {
                    ConversionFlags = AmbienceFlags,
                };


            if (resolveResult == null || resolveResult is NamespaceResolveResult)
                response.Type = "";
            else
            {
                response.Type = resolveResult.Type.ToString();
                IEntity entity = null;
                if (resolveResult is CSharpInvocationResolveResult)
                {
                    var result = resolveResult as CSharpInvocationResolveResult;
                    entity = result.Member;
                    response.Type = ambience.ConvertEntity(result.Member);
                }
                else if (resolveResult is LocalResolveResult)
                {
                    var result = resolveResult as LocalResolveResult;
                    response.Type = ambience.ConvertVariable(result.Variable);
                }
                else if (resolveResult is MemberResolveResult)
                {
                    var result = resolveResult as MemberResolveResult;
                    entity = result.Member;
                    response.Type = ambience.ConvertEntity(result.Member);
                }
                else if (resolveResult is TypeResolveResult)
                {
                    ambience.ConversionFlags |= ConversionFlags.UseFullyQualifiedTypeNames;
                    response.Type = ambience.ConvertType(resolveResult.Type);
                }

                if (resolveResult.Type is UnknownType)
                    response.Type = "Unknown Type: " + resolveResult.Type.Name;
                if (resolveResult.Type == SpecialType.UnknownType)
                    response.Type = "Unknown Type";

                if (request.IncludeDocumentation && entity != null)
                {
                    var project = _solution.ProjectContainingFile(request.FileName);
                    response.Documentation = new DocumentationFetcher().GetDocumentation(project, entity);
                }
            }

            return response;
        }
 public OverrideCompletionData(int declarationBegin, IMember m, CSharpTypeResolveContext contextAtCaret)
     : base(m)
 {
     this.declarationBegin = declarationBegin;
     this.contextAtCaret = contextAtCaret;
     var ambience = new CSharpAmbience();
     ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames;
     this.CompletionText = ambience.ConvertEntity(m);
 }
Esempio n. 3
0
 void GenerateHeader()
 {
     CSharpAmbience ambience = new CSharpAmbience();
     ambience.ConversionFlags = ConversionFlags.StandardConversionFlags;
     var stringBuilder = new StringBuilder();
     var formatter = new ParameterHighlightingOutputFormatter(stringBuilder, highlightedParameterIndex);
     ambience.ConvertEntity(Method, formatter, FormattingOptionsFactory.CreateSharpDevelop());
     var inlineBuilder = new HighlightedInlineBuilder(stringBuilder.ToString());
     inlineBuilder.SetFontWeight(formatter.parameterStartOffset, formatter.parameterLength, FontWeights.Bold);
     header.Inlines.Clear();
     header.Inlines.AddRange(inlineBuilder.CreateRuns());
 }
 public EntityCompletionData(IEntity entity)
 {
     if (entity == null) throw new ArgumentNullException("entity");
     this.entity = entity;
     IAmbience ambience = new CSharpAmbience();
     ambience.ConversionFlags = entity is ITypeDefinition ? ConversionFlags.ShowTypeParameterList : ConversionFlags.None;
     DisplayText = entity.Name;
     this.CompletionText = ambience.ConvertEntity(entity);
     ambience.ConversionFlags = ConversionFlags.StandardConversionFlags;
     if (entity is ITypeDefinition)
     {
         // Show fully qualified Type name
         ambience.ConversionFlags |= ConversionFlags.UseFullyQualifiedTypeNames;
     }
     this.Image = ICSharpCode.AvalonEdit.CodeCompletion.CompletionImage.GetImage(entity);
 }
Esempio n. 5
0
		FlowDocumentScrollViewer GenerateHeader()
		{
			CSharpAmbience ambience = new CSharpAmbience();
			ambience.ConversionFlags = ConversionFlags.StandardConversionFlags;
			var stringBuilder = new StringBuilder();
			var formatter = new ParameterHighlightingOutputFormatter(stringBuilder, highlightedParameterIndex);
			ambience.ConvertEntity(Method, formatter, FormattingOptionsFactory.CreateSharpDevelop());
			
			var documentation = XmlDocumentationElement.Get(Method);
			ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList;
			
			DocumentationUIBuilder b = new DocumentationUIBuilder(ambience);
			string parameterName = null;
			if (Method.Parameters.Count > highlightedParameterIndex)
				parameterName = Method.Parameters[highlightedParameterIndex].Name;
			b.AddSignatureBlock(stringBuilder.ToString(), formatter.parameterStartOffset, formatter.parameterLength, parameterName);
			
			DocumentationUIBuilder b2 = new DocumentationUIBuilder(ambience);
			b2.ParameterName = parameterName;
			b2.ShowAllParameters = false;
			
			if (documentation != null) {
				foreach (var child in documentation.Children) {
					b2.AddDocumentationElement(child);
				}
			}
			
			content = new FlowDocumentScrollViewer {
				Document = b2.CreateFlowDocument(),
				VerticalScrollBarVisibility = ScrollBarVisibility.Auto
			};
			
			var flowDocument = b.CreateFlowDocument();
			flowDocument.PagePadding = new Thickness(0); // default is NOT Thickness(0), but Thickness(Auto), which adds unnecessary space
			
			return new FlowDocumentScrollViewer {
				Document = flowDocument,
				VerticalScrollBarVisibility = ScrollBarVisibility.Auto
			};
		}
Esempio n. 6
0
        private ICompletionData CompletionData(IEntity entity)
        {

            ICompletionData completionData = null;
            if (entity.Documentation != null)
            {
                completionData = new CompletionData(_signature, _completionText,
                                                    _signature + Environment.NewLine +
                                                    DocumentationConverter.ConvertDocumentation(entity.Documentation));
            }
            else
            {

                var ambience = new CSharpAmbience
                {
                    ConversionFlags = ConversionFlags.ShowParameterList |
                                      ConversionFlags.ShowParameterNames |
                                      ConversionFlags.ShowReturnType |
                                      ConversionFlags.ShowBody |
                                      ConversionFlags.ShowTypeParameterList
                };

                var documentationSignature = ambience.ConvertEntity(entity);
                if (_wantDocumentation)
                {
                    string documentation = new DocumentationFetcher().GetDocumentation(_project, entity);
                    var documentationAndSignature =
                        documentationSignature + Environment.NewLine + documentation;
                    completionData = new CompletionData(_signature, _completionText, documentationAndSignature);
                }
                else
                {
                    completionData = new CompletionData(_signature, _completionText, documentationSignature);
                }
            }
            return completionData;
        }
Esempio n. 7
0
        private ICompletionData CompletionData(IEntity entity)
        {
            ICompletionData completionData = null;
            if (entity.Documentation != null)
            {
                completionData = new CompletionData(_signature, _completionText,
                                                    _signature + Environment.NewLine +
                                                    DocumentationConverter.ConvertDocumentation(entity.Documentation));
            }
            else
            {
                IDocumentationProvider docProvider = null;
                if (entity.ParentAssembly.AssemblyName != null)
                {
                    docProvider =
                        XmlDocumentationProviderFactory.Get(entity.ParentAssembly.AssemblyName);
                }
                var ambience = new CSharpAmbience
                {
                    ConversionFlags = ConversionFlags.ShowParameterList |
                                      ConversionFlags.ShowParameterNames |
                                      ConversionFlags.ShowReturnType |
                                      ConversionFlags.ShowBody |
                                      ConversionFlags.ShowTypeParameterList
                };

                var documentationSignature = ambience.ConvertEntity(entity);
                if (docProvider != null)
                {
                    DocumentationComment documentationComment = docProvider.GetDocumentation(entity);
                    if (documentationComment != null)
                    {
                        var documentation = documentationSignature + Environment.NewLine +
                                            DocumentationConverter.ConvertDocumentation(
                                                documentationComment.Xml.Text);
                        completionData = new CompletionData(_signature, _completionText, documentation);
                    }
                    else
                    {
                        completionData = new CompletionData(_signature, _completionText, documentationSignature);
                    }
                }
                else
                {
                    completionData = new CompletionData(_signature, _completionText, documentationSignature);
                }
            }
            return completionData;
        }