// CompletionDataList result = new ProjectDomCompletionDataList (); // // "var o = new " needs special treatment. // if (returnType == null && returnTypeUnresolved != null && returnTypeUnresolved.FullName == "var") // returnType = returnTypeUnresolved = DomReturnType.Object; // // // ExpressionContext.TypeExpressionContext tce = context as ExpressionContext.TypeExpressionContext; // // CompletionDataCollector col = new CompletionDataCollector (this, dom, result, Document.CompilationUnit, callingType, location); // IType type = null; // if (returnType != null) // type = dom.GetType (returnType); // if (type == null) // type = dom.SearchType (Document.CompilationUnit, callingType, location, returnTypeUnresolved); // // // special handling for nullable types: Bug 674516 - new completion for nullables should not include "Nullable" // if (type is InstantiatedType && ((InstantiatedType)type).UninstantiatedType.FullName == "System.Nullable" && ((InstantiatedType)type).GenericParameters.Count == 1) { // var genericParameter = ((InstantiatedType)type).GenericParameters [0]; // returnType = returnTypeUnresolved = Document.CompilationUnit.ShortenTypeName (genericParameter, location); // type = dom.SearchType (Document.CompilationUnit, callingType, location, genericParameter); // } // // if (type == null || !(type.IsAbstract || type.ClassType == ClassType.Interface)) { // if (type == null || type.ConstructorCount == 0 || type.Methods.Any (c => c.IsConstructor && c.IsAccessibleFrom (dom, callingType, type, callingType != null && dom.GetInheritanceTree (callingType).Any (x => x.FullName == type.FullName)))) { // if (returnTypeUnresolved != null) { // col.FullyQualify = true; // CompletionData unresovedCompletionData = col.Add (returnTypeUnresolved); // col.FullyQualify = false; // // don't set default completion string for arrays, since it interferes with: // // string[] arr = new string[] vs new { "a"} // if (returnTypeUnresolved.ArrayDimensions == 0) // result.DefaultCompletionString = StripGenerics (unresovedCompletionData.CompletionText); // } else { // CompletionData unresovedCompletionData = col.Add (returnType); // if (returnType.ArrayDimensions == 0) // result.DefaultCompletionString = StripGenerics (unresovedCompletionData.CompletionText); // } // } // } // // // if (tce != null && tce.Type != null) { // // result.DefaultCompletionString = StripGenerics (col.AddCompletionData (result, tce.Type).CompletionString); // // } // // else { // // } // if (type == null) // return result; // HashSet<string > usedNamespaces = new HashSet<string> (GetUsedNamespaces ()); // if (type.FullName == DomReturnType.Object.FullName) // AddPrimitiveTypes (col); // // foreach (IType curType in dom.GetSubclasses (type)) { // if (context != null && context.FilterEntry (curType)) // continue; // if ((curType.TypeModifier & TypeModifier.HasOnlyHiddenConstructors) == TypeModifier.HasOnlyHiddenConstructors) // continue; // if (usedNamespaces.Contains (curType.Namespace)) { // if (curType.ConstructorCount > 0) { // if (!(curType.Methods.Any (c => c.IsConstructor && c.IsAccessibleFrom (dom, curType, callingType, callingType != null && dom.GetInheritanceTree (callingType).Any (x => x.FullName == curType.FullName))))) // continue; // } // col.Add (curType); // } else { // string nsName = curType.Namespace; // int idx = nsName.IndexOf ('.'); // if (idx >= 0) // nsName = nsName.Substring (0, idx); // col.Add (new Namespace (nsName)); // } // } // // // add aliases // if (returnType != null) { // foreach (IUsing u in Document.CompilationUnit.Usings) { // foreach (KeyValuePair<string, IReturnType> alias in u.Aliases) { // if (alias.Value.ToInvariantString () == returnType.ToInvariantString ()) // result.Add (alias.Key, "md-class"); // } // } // } // // return result; // } // IEnumerable<ICompletionData> GetDefineCompletionData () // { // if (Document.Project == null) // yield break; // // var symbols = new Dictionary<string, string> (); // var cp = new ProjectDomCompletionDataList (); // foreach (DotNetProjectConfiguration conf in Document.Project.Configurations) { // var cparams = conf.CompilationParameters as CSharpCompilerParameters; // if (cparams != null) { // string[] syms = cparams.DefineSymbols.Split (';'); // foreach (string s in syms) { // string ss = s.Trim (); // if (ss.Length > 0 && !symbols.ContainsKey (ss)) { // symbols [ss] = ss; // yield return factory.CreateLiteralCompletionData (ss); // } // } // } // } // } public override IParameterDataProvider HandleParameterCompletion(CodeCompletionContext completionContext, char completionChar) { if (!EnableCodeCompletion) { return(null); } if (Unit == null || CSharpParsedFile == null) { return(null); } try { var engine = new CSharpParameterCompletionEngine( textEditorData.Document, this, Document.GetProjectContext(), CSharpParsedFile.GetTypeResolveContext(Document.Compilation, document.Editor.Caret.Location) as CSharpTypeResolveContext, Unit, CSharpParsedFile ); engine.MemberProvider = typeSystemSegmentTree; return(engine.GetParameterDataProvider(completionContext.TriggerOffset, completionChar)); } catch (Exception e) { LoggingService.LogError("Unexpected parameter completion exception." + Environment.NewLine + "FileName: " + Document.FileName + Environment.NewLine + "Position: line=" + completionContext.TriggerLine + " col=" + completionContext.TriggerLineOffset + Environment.NewLine + "Line text: " + Document.Editor.GetLineText(completionContext.TriggerLine), e); return(null); } finally { // if (timer != null) // timer.Dispose (); } }
ICompletionData ICompletionDataFactory.CreateEntityCompletionData(IUnresolvedEntity entity, string text) { var context = CSharpParsedFile.GetTypeResolveContext(Document.Compilation, document.Editor.Caret.Location); var resolvedEntity = ((IUnresolvedMember)entity).CreateResolved(context); return(new MemberCompletionData(this, resolvedEntity, OutputFlags.IncludeGenerics | OutputFlags.HideArrayBrackets | OutputFlags.IncludeParameterName) { HideExtensionParameter = true }); }
public override int GetCurrentParameterIndex(int startOffset) { var engine = new CSharpParameterCompletionEngine( textEditorData.Document, this, Document.GetProjectContext(), CSharpParsedFile.GetTypeResolveContext(Document.Compilation, document.Editor.Caret.Location) as CSharpTypeResolveContext, Unit, CSharpParsedFile ); engine.MemberProvider = typeSystemSegmentTree; return(engine.GetCurrentParameterIndex(startOffset, document.Editor.Caret.Offset)); }
public override bool GetParameterCompletionCommandOffset(out int cpos) { var engine = new CSharpParameterCompletionEngine( textEditorData.Document, this, Document.GetProjectContext(), CSharpParsedFile.GetTypeResolveContext(Document.Compilation, document.Editor.Caret.Location) as CSharpTypeResolveContext, Unit, CSharpParsedFile ); engine.MemberProvider = typeSystemSegmentTree; engine.SetOffset(document.Editor.Caret.Offset); return(engine.GetParameterCompletionCommandOffset(out cpos)); }
ICompletionDataList InternalHandleCodeCompletion(CodeCompletionContext completionContext, char completionChar, bool ctrlSpace, ref int triggerWordLength) { /* * if (textEditorData.CurrentMode is CompletionTextLinkMode) { * if (!((CompletionTextLinkMode)textEditorData.CurrentMode).TriggerCodeCompletion) * return null; * } else if (textEditorData.CurrentMode is Mono.TextEditor.TextLinkEditMode) { * return null; * }*/ if (Unit == null || CSharpParsedFile == null) { return(null); } var list = new CompletionDataList(); var engine = new CSharpCompletionEngine( textEditorData.Document, this, Document.GetProjectContext(), CSharpParsedFile.GetTypeResolveContext(Document.Compilation, document.Editor.Caret.Location) as CSharpTypeResolveContext, Unit, CSharpParsedFile ); engine.MemberProvider = typeSystemSegmentTree; engine.FormattingPolicy = FormattingPolicy.CreateOptions(); engine.EolMarker = textEditorData.EolMarker; engine.IndentString = textEditorData.Options.IndentationString; list.AddRange(engine.GetCompletionData(completionContext.TriggerOffset, ctrlSpace)); list.AutoCompleteEmptyMatch = engine.AutoCompleteEmptyMatch; list.AutoSelect = engine.AutoSelect; list.DefaultCompletionString = engine.DefaultCompletionString; list.CloseOnSquareBrackets = engine.CloseOnSquareBrackets; if (ctrlSpace) { list.AutoCompleteUniqueMatch = true; } return(list.Count > 0 ? list : null); }
ICompletionData ICompletionDataFactory.CreateNewPartialCompletionData(int declarationBegin, IUnresolvedTypeDefinition type, IUnresolvedMember m) { var ctx = CSharpParsedFile.GetTypeResolveContext(Compilation, document.Editor.Caret.Location); return(new NewOverrideCompletionData(this, declarationBegin, type, m.CreateResolved(ctx))); }