public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("schema", "http://www.w3.org/2001/XMLSchema"));
			
			schemaChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
			//schemaAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
			
			// Get include elements attributes.
			path.Elements.Add(new QualifiedName("include", "http://www.w3.org/2001/XMLSchema"));
			includeAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
		
			// Get annotation element info.
			path.Elements.RemoveLast();
			path.Elements.Add(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema"));
			
			annotationChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
			annotationAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
		
			// Get app info attributes.
			path.Elements.Add(new QualifiedName("appinfo", "http://www.w3.org/2001/XMLSchema"));
			appInfoAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
			
			// Get foo attributes.
			path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foo", "http://www.w3.org/2001/XMLSchema"));
			fooAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
		}
		public override void FixtureInit()
		{			
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
			
			noteChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
		}
		async Task Init ()
		{
			if (schemaChildElements != null)
				return;
			
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("schema", "http://www.w3.org/2001/XMLSchema"));
			
			schemaChildElements = await SchemaCompletionData.GetChildElementCompletionData(path, CancellationToken.None);
			//schemaAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
			
			// Get include elements attributes.
			path.Elements.Add(new QualifiedName("include", "http://www.w3.org/2001/XMLSchema"));
			includeAttributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		
			// Get annotation element info.
			path.Elements.RemoveAt(path.Elements.Count - 1);
			path.Elements.Add(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema"));
			
			annotationChildElements = await SchemaCompletionData.GetChildElementCompletionData(path, CancellationToken.None);
			annotationAttributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		
			// Get app info attributes.
			path.Elements.Add(new QualifiedName("appinfo", "http://www.w3.org/2001/XMLSchema"));
			appInfoAttributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
			
			// Get foo attributes.
			path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foo", "http://www.w3.org/2001/XMLSchema"));
			fooAttributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		}
		public override void GetAttributeCompletions (CompletionDataList list, IAttributedXObject attributedOb, Dictionary<string, string> existingAtts)
		{
			var required = new NodeCompletionCategory ("Required", 0);
			var optional = new NodeCompletionCategory ("Optional", 1);

			foreach (NodeTypeAttribute att in info.Attributes) {
				if (!existingAtts.ContainsKey (att.Name)) {
					var data = new NodeTypeAttributeCompletionData (att) {
						CompletionCategory = att.Required ? required : optional
					};
					list.Add (data);
				}
			}

			var ordering = new NodeCompletionCategory ("Ordering", 2);
			if (!existingAtts.ContainsKey ("id")) {
				list.Add (new CompletionData ("id", null, "ID for the extension, unique in this extension point.") { CompletionCategory = ordering });
			}
			if (!existingAtts.ContainsKey ("insertbefore")) {
				list.Add (new CompletionData ("insertbefore", null, "ID of an existing extension before which to insert this.") { CompletionCategory = ordering });
			}
			if (!existingAtts.ContainsKey ("insertafter")) {
				list.Add (new CompletionData ("insertafter", null, "ID of an existing extension after which to insert this.") { CompletionCategory = ordering });
			}
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("root", "http://foo"));
			path.Elements.Add(new QualifiedName("bar", "http://foo"));
			barElementAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("html", "http://foo/xhtml"));
		
			htmlChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
		}		
Beispiel #7
0
		//
		// NOTE: MS' documentation for directives is at http://msdn.microsoft.com/en-us/library/t8syafc7.aspx
		//
		// FIXME: gettextise this
		public static CompletionDataList GetDirectives (WebSubtype type)
		{
			CompletionDataList list = new CompletionDataList ();
			
			if (type == WebSubtype.WebForm) {
				list.Add ("Implements", null, "Declare that this page implements an interface.");
				list.Add ("Page", null, "Define properties of this page.");
				list.Add ("PreviousPageType", null, "Strongly type the page's PreviousPage property.");
				list.Add ("MasterType", null, "Strongly type the page's Master property.");
			} else if (type == WebSubtype.MasterPage) {
				list.Add ("Implements", null, "Declare that this master page implements an interface.");
				list.Add ("Master", null, "Define properties of this master page.");
				list.Add ("MasterType", null, "Strongly type the page's Master property.");
			} else if (type == WebSubtype.WebControl) {
				list.Add ("Control", null, "Define properties of this user control.");
				list.Add ("Implements", null, "Declare that this control implements an interface.");
			} else {
				return null;
			}
			
			list.Add ("Assembly", null, "Reference an assembly.");
			list.Add ("Import", null, "Import a namespace.");
			
			if (type != WebSubtype.MasterPage) {
				list.Add ("OutputCache", null, "Set output caching behaviour.");
			}
			
			list.Add ("Reference", null, "Reference a page or user control.");
			list.Add ("Register", null, "Register a user control or custom web controls.");
			
			return list.Count > 0? list : null;
		}
        public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char triggerChar, ref int triggerWordLength)
        {
            var l = new CompletionDataList();

            if (!(triggerChar==' ' ||
                char.IsLetter(triggerChar) ||
                triggerChar == '@' ||
                triggerChar == '(' ||
                triggerChar == '_' ||
                triggerChar == '.' ||
                triggerChar == '\0'))
                return l;

            triggerWordLength = (char.IsLetter(triggerChar) || triggerChar=='_' || triggerChar=='@') ? 1 : 0;

            // Require a parsed D source

            var dom = base.Document.ParsedDocument as ParsedDModule;
            if (dom != null && dom.DDom!=null)
                lock(dom.DDom)
                DCodeCompletionSupport.BuildCompletionData(
                    Document,
                    dom.DDom,
                    completionContext,
                    l,
                    triggerChar);

            return l;
        }
		public static void AddRazorBeginExpressions (CompletionDataList list)
		{
			string icon = "md-literal";
			list.Add ("{", icon, GettextCatalog.GetString ("Razor code block"));
			list.Add ("*", icon, GettextCatalog.GetString ("Razor comment"));
			list.Add ("(", icon, GettextCatalog.GetString ("Razor explicit expression"));
		}
		protected override  Task<CompletionDataList> GetElementCompletions (CancellationToken token)
		{
			var list = new CompletionDataList ();

			AddMiscBeginTags (list);

			var path = GetCurrentPath ();

			if (path.Count == 0) {
				list.Add (new XmlCompletionData ("Project", XmlCompletionData.DataType.XmlElement));
				return Task.FromResult (list);
			}

			var rr = ResolveElement (path);
			if (rr == null)
				return Task.FromResult (list);

			foreach (var c in rr.BuiltinChildren)
				list.Add (new XmlCompletionData (c, XmlCompletionData.DataType.XmlElement));

			var inferredChildren = GetInferredChildren (rr);
			if (inferredChildren != null)
				foreach (var c in inferredChildren)
					list.Add (new XmlCompletionData (c, XmlCompletionData.DataType.XmlElement));
			return Task.FromResult (list);
		}
		CompletionDataList GetPathCompletion (string subPath)
		{
			CompletionContext ctx = GetCompletionContext (1);
			if (!(ctx is ExtensionCompletionContext))
				return null;
			ModuleCompletionContext mc = (ModuleCompletionContext) ctx.GetParentContext (typeof(ModuleCompletionContext));
			
			Set<string> paths = new Set<string> ();
			CompletionDataList cp = new CompletionDataList ();
			foreach (AddinDependency adep in mc.Module.Dependencies) {
				Addin addin = registry.GetAddin (adep.FullAddinId);
				if (addin != null && addin.Description != null) {
					foreach (ExtensionPoint ep in addin.Description.ExtensionPoints) {
						if (ep.Path.StartsWith (subPath)) {
							string spath = ep.Path.Substring (subPath.Length);
							int i = spath.IndexOf ('/');
							if (i != -1)
								spath = spath.Substring (0, i);
							if (paths.Add (spath)) {
								if (i == -1) // Full match. Add the documentation
									cp.Add (spath, "md-extension-point", ep.Name + "\n" + ep.Description);
								else
									cp.Add (spath, "md-literal");
							}
						}
					}
				}
			}
			return cp;
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
						
			attributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path);
			attributeName = attributeCompletionData[0].DisplayText;
		}
		async Task Init ()
		{
			if (barAttributeValuesCompletionData != null)
				return;
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foo", "http://foo.com"));
			barAttributeValuesCompletionData = await SchemaCompletionData.GetAttributeValueCompletionData(path, "bar", CancellationToken.None);
		}
		async Task Init ()
		{
			if (attributes != null)
				return;
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("html", "http://foo/xhtml"));
			attributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		}
		public static void AddAllRazorSymbols (CompletionDataList list)
		{
			if (list == null)
				return;
			AddRazorBeginExpressions (list);
			AddRazorDirectives (list);
			AddRazorTemplates (list);
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("project", "http://nant.sf.net//nant-0.84.xsd"));
			path.Elements.Add(new QualifiedName("attrib", "http://nant.sf.net//nant-0.84.xsd"));
			
			attributes = SchemaCompletionData.GetAttributeCompletionData(path);
		}
		async Task Init ()
		{
			if (attributeCompletionData != null)
				return;
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
			attributeCompletionData = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		}
		public override void FixtureInit()
		{
			rootElementCompletionData = SchemaCompletionData.GetElementCompletionData();
			
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foo", "http://foo.com"));
			
			fooChildElementCompletionData = SchemaCompletionData.GetChildElementCompletionData(path);
		}
		private static void AddRazorTemplates (CompletionDataList list)
		{
			string icon = "md-template";
			list.Add ("inherits", icon, "Template for inherits directive");
			list.Add ("model", icon, "Template for model directive");
			list.Add ("helper", icon, "Template for helper directive");
			list.Add ("section", icon, "Template for section directive");
			list.Add ("functions", icon, "Template for functions directive");
			list.Add ("using", icon, "Template for using statement");
		}
		async Task Init ()
		{
			if (elementData != null)
				return;
			
			noteElementPath = new XmlElementPath();
			noteElementPath.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));

			elementData = await SchemaCompletionData.GetChildElementCompletionData(noteElementPath, CancellationToken.None); 
		}
Beispiel #21
0
        public virtual ICompletionDataList ShowCodeTemplatesCommand()
        {
            CompletionDataList list = new CompletionDataList();

            list.CompletionSelectionMode = CompletionSelectionMode.OwnTextField;

            foreach (CodeTemplate template in CodeTemplateService.Templates) //GetCodeTemplates("text/moscrif"))
                list.Add(new CodeTemplateCompletionData(template,this.editor));
            return list;
        }
		public virtual void GetElementCompletions (CompletionDataList list, XElement element)
		{
			if (children == null) {
				return;
			}

			foreach (var c in children) {
				list.Add (c.Key, null, c.Value.Description);
			}
		}
		async Task Init ()
		{
			if (fooChildElementCompletionData != null)
				return;
			
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foo", "http://foo.com"));
			
			fooChildElementCompletionData = await SchemaCompletionData.GetChildElementCompletionData(path, CancellationToken.None);
		}
Beispiel #24
0
        public void InsertTemplate(object obj, EventArgs args)
        {
            ICompletionDataList completionList = new CompletionDataList();

            completionList = ShowCodeTemplatesCommand();
            currentCompletionContext = widget.CreateCodeCompletionContext();//this.editor.Caret.Offset
            CompletionWindowManager.IsTemplateModes = true;
            CompletionWindowManager.ShowWindow((char)0, completionList, widget, currentCompletionContext, OnCompletionWindowClosed);
            editor.GrabFocus();
        }
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("person", "http://foo"));
			personElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
			
			path.Elements.Add(new QualifiedName("firstname", "http://foo"));
			firstNameAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
			firstNameElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
		}
		async Task Init ()
		{
			if (attributes != null)
				return;
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("project", "http://nant.sf.net//nant-0.84.xsd"));
			path.Elements.Add(new QualifiedName("attrib", "http://nant.sf.net//nant-0.84.xsd"));
			
			attributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		}
		protected override void GetElementCompletions (CompletionDataList list)
		{
			AddMiscBeginTags (list);

			XElement el;
			var item = GetSchemaItem (out el);
			if (item != null) {
				item.GetElementCompletions (list, el);
			}
		}
        public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char triggerChar, ref int triggerWordLength)
        {
            var isLetter = char.IsLetter (triggerChar) || triggerChar == '_';

            if (char.IsDigit(triggerChar) || !EnableAutoCodeCompletion && isLetter)
                return null;

            if (isLetter)
            {
                if (completionContext.TriggerOffset > 1){
                    var prevChar = document.Editor.GetCharAt(completionContext.TriggerOffset - 2);
                    if(char.IsLetterOrDigit(prevChar) || prevChar =='_' || prevChar == '"' || prevChar == '#') // Don't trigger if we're already typing an identifier or if we're typing a string suffix (kinda hacky though)
                        return null;
                }
            }
            else if (!(triggerChar==' ' ||
                triggerChar == '@' ||
                triggerChar == '(' ||
                triggerChar == '.' ||
                triggerChar == '\0'))
                return null;

            triggerWordLength = isLetter ? 1 : 0;

            // Require a parsed D source

            var dom = base.Document.ParsedDocument as ParsedDModule;
            if (dom == null || dom.DDom == null)
                return null;

            updater.FinishUpdate();
            lastTriggerOffset = completionContext.TriggerOffset;
            var l = new CompletionDataList();

            if (D_Parser.Misc.CompletionOptions.Instance.EnableSuggestionMode)
            {
                l.AddKeyHandler(new SuggestionKeyHandler());
                l.AutoCompleteUniqueMatch = false;
                l.AutoCompleteEmptyMatch = false;
                l.AutoSelect = true;
            }
            else
                l.AddKeyHandler(new DoubleUnderScoreWorkaroundHandler(this));

            lock(dom.DDom)
                DCodeCompletionSupport.BuildCompletionData(
                    Document,
                    dom.DDom,
                    completionContext,
                    l,
                    triggerChar);

            return l.Count != 0 ? l : null;
        }
		public static void AddRazorDirectives (CompletionDataList list)
		{
			string icon = "md-keyword";
			list.Add ("inherits", icon, "Defines a base class of the view");
			list.Add ("layout", icon, "Defines a layout file to use in this view");
			list.Add ("model", icon, "References a strongly-typed model");
			list.Add ("sessionstate", icon, "Defines a sessionstate mode");
			list.Add ("helper", icon, "Defines a helper");
			list.Add ("section", icon, "Defines a section");
			list.Add ("functions", icon, "Enables to define functions in this view");
		}
 public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char completionChar, ref int triggerWordLength)
 {
     var completionDataList = new CompletionDataList();
     sectionCompletion.FillCompletionList(completionDataList, completionContext, completionChar, ref triggerWordLength);
     directives.FillCompletionList(completionDataList, completionContext, completionChar, ref triggerWordLength);
     if(completionDataList.Count == 0)
     {
         return null;
     }
     return completionDataList;
 }
Beispiel #31
0
        //recreating the list is over 2x as fast as using remove operations, saves typically 10ms
        static CompletionDataList FilterCSharpTemplates(CompletionDataList list)
        {
            var newList = new CompletionDataList()
            {
                AutoCompleteEmptyMatch  = list.AutoCompleteEmptyMatch,
                AutoCompleteUniqueMatch = list.AutoCompleteUniqueMatch,
                AutoSelect              = list.AutoSelect,
                CloseOnSquareBrackets   = list.CloseOnSquareBrackets,
                CompletionSelectionMode = list.CompletionSelectionMode,
                DefaultCompletionString = list.DefaultCompletionString,
                IsSorted          = list.IsSorted,
                TriggerWordLength = list.TriggerWordLength
            };

            foreach (var l in list)
            {
                var c = l as CompletionData;
                if (c == null || (c.Icon.Name != "md-template" && c.Icon.Name != "md-template-surroundwith"))
                {
                    newList.Add(c);
                }
            }
            return(newList);
        }
Beispiel #32
0
        ICompletionDataList InternalHandleCodeCompletion(CodeCompletionContext completionContext, char completionChar, bool ctrlSpace, ref int triggerWordLength)
        {
            if (TextEditorData.CurrentMode is TextLinkEditMode)
            {
                if (((TextLinkEditMode)TextEditorData.CurrentMode).TextLinkMode == TextLinkMode.EditIdentifier)
                {
                    return(null);
                }
            }
            if (Unit == null || CSharpUnresolvedFile == null)
            {
                return(null);
            }
            var list   = new CompletionDataList();
            var engine = new CSharpCompletionEngine(
                TextEditorData.Document,
                typeSystemSegmentTree,
                this,
                Document.GetProjectContext(),
                CSharpUnresolvedFile.GetTypeResolveContext(Document.Compilation, document.Editor.Caret.Location) as CSharpTypeResolveContext
                );

            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);
        }
Beispiel #33
0
        public virtual ICompletionDataList ShowCodeSurroundingsCommand(CodeCompletionContext completionContext)
        {
            CompletionDataList list = new CompletionDataList();

            list.CompletionSelectionMode = CompletionSelectionMode.OwnTextField;
            var templateWidget      = Document.GetContent <ICodeTemplateContextProvider> ();
            CodeTemplateContext ctx = CodeTemplateContext.Standard;

            if (templateWidget != null)
            {
                ctx = templateWidget.GetCodeTemplateContext();
            }
            foreach (CodeTemplate template in CodeTemplateService.GetCodeTemplatesForFile(Document.FileName))
            {
                if ((template.CodeTemplateType & CodeTemplateType.SurroundsWith) == CodeTemplateType.SurroundsWith)
                {
                    if (ctx == template.CodeTemplateContext)
                    {
                        list.Add(new CodeTemplateCompletionData(Document, template));
                    }
                }
            }
            return(list);
        }
Beispiel #34
0
        void AddControlMembers(CompletionDataList list, INamedTypeSymbol controlClass, Dictionary <string, string> existingAtts)
        {
            //add atts only if they're not already in the tag
            foreach (var prop in GetUniqueMembers <IPropertySymbol> (GetAllMembers <IPropertySymbol> (controlClass)))
            {
                if (prop.DeclaredAccessibility == Accessibility.Public && (existingAtts == null || !existingAtts.ContainsKey(prop.Name)))
                {
                    if (GetPersistenceMode(prop) == System.Web.UI.PersistenceMode.Attribute)
                    {
                        list.Add(new AspAttributeCompletionData(prop));
                    }
                }
            }

            //similarly add events
            foreach (var eve in GetUniqueMembers <IEventSymbol> (GetAllMembers <IEventSymbol> (controlClass)))
            {
                string eveName = "On" + eve.Name;
                if (eve.DeclaredAccessibility == Accessibility.Public && (existingAtts == null || !existingAtts.ContainsKey(eveName)))
                {
                    list.Add(new AspAttributeCompletionData(eve, eveName));
                }
            }
        }
        protected override Task <CompletionDataList> GetAttributeCompletions(IAttributedXObject attributedOb,
                                                                             Dictionary <string, string> existingAtts, CancellationToken token)
        {
            var list = new CompletionDataList();
            var path = GetCurrentPath();

            var rr = ResolveElement(path);

            if (rr == null)
            {
                return(Task.FromResult(list));
            }

            foreach (var a in rr.BuiltinAttributes)
            {
                if (!existingAtts.ContainsKey(a))
                {
                    list.Add(new XmlCompletionData(a, XmlCompletionData.DataType.XmlAttribute));
                }
            }

            var inferredAttributes = GetInferredAttributes(rr);

            if (inferredAttributes != null)
            {
                foreach (var a in inferredAttributes)
                {
                    if (!existingAtts.ContainsKey(a))
                    {
                        list.Add(new XmlCompletionData(a, XmlCompletionData.DataType.XmlAttribute));
                    }
                }
            }

            return(Task.FromResult(list));
        }
Beispiel #36
0
        static CompletionListWindow CreateListWindow(CompletionListWindowTests.SimulationSettings settings)
        {
            CompletionDataList dataList = new CompletionDataList();

            dataList.AutoSelect = settings.AutoSelect;
            dataList.AddRange(settings.CompletionData);
            dataList.DefaultCompletionString = settings.DefaultCompletionString;
            ListWindow.ClearHistory();
            CompletionListWindow listWindow = new CompletionListWindow()
            {
                CompletionDataList             = dataList,
                CompletionWidget               = new TestCompletionWidget(),
                AutoSelect                     = settings.AutoSelect,
                CodeCompletionContext          = new CodeCompletionContext(),
                CompleteWithSpaceOrPunctuation = settings.CompleteWithSpaceOrPunctuation,
                AutoCompleteEmptyMatch         = settings.AutoCompleteEmptyMatch,
                DefaultCompletionString        = settings.DefaultCompletionString
            };

            listWindow.List.FilterWords();
            listWindow.UpdateWordSelection();
            listWindow.ResetSizes();
            return(listWindow);
        }
        async Task <ICompletionDataList> InternalHandleCodeCompletion(CodeCompletionContext completionContext, CompletionTriggerInfo triggerInfo, int triggerWordLength, CancellationToken token, bool forceSymbolCompletion = false)
        {
            var analysisDocument = DocumentContext.AnalysisDocument;

            if (analysisDocument == null)
            {
                return(EmptyCompletionDataList);
            }


            var        cs = DocumentContext.RoslynWorkspace.Services.GetLanguageServices(LanguageNames.CSharp).GetService <CompletionService> ();
            SourceText sourceText;

            if (!analysisDocument.TryGetText(out sourceText))
            {
                return(EmptyCompletionDataList);
            }

            CompletionTriggerKind kind;

            switch (triggerInfo.CompletionTriggerReason)
            {
            case CompletionTriggerReason.CharTyped:
                kind = CompletionTriggerKind.Insertion;
                if (triggerInfo.TriggerCharacter == '{')
                {
                    return(EmptyCompletionDataList);
                }
                break;

            case CompletionTriggerReason.CompletionCommand:
                kind = CompletionTriggerKind.InvokeAndCommitIfUnique;
                break;

            case CompletionTriggerReason.BackspaceOrDeleteCommand:
                kind = CompletionTriggerKind.Deletion;
                break;

            case CompletionTriggerReason.RetriggerCommand:
                kind = CompletionTriggerKind.InvokeAndCommitIfUnique;
                break;

            default:
                kind = CompletionTriggerKind.Insertion;
                break;
            }
            var triggerSnapshot = Editor.GetPlatformTextBuffer().CurrentSnapshot;
            var trigger         = new CompletionTrigger(kind, triggerInfo.TriggerCharacter.HasValue ? triggerInfo.TriggerCharacter.Value : '\0');

            if (triggerInfo.CompletionTriggerReason == CompletionTriggerReason.CharTyped)
            {
                if (!cs.ShouldTriggerCompletion(sourceText, completionContext.TriggerOffset, trigger, null))
                {
                    return(EmptyCompletionDataList);
                }
            }

            completionContext.Trace("C#: Getting completions");
            var customOptions = DocumentContext.RoslynWorkspace.Options
                                .WithChangedOption(CompletionOptions.TriggerOnDeletion, LanguageNames.CSharp, true)
                                .WithChangedOption(CompletionOptions.HideAdvancedMembers, LanguageNames.CSharp, IdeApp.Preferences.CompletionOptionsHideAdvancedMembers)
                                // Roslyn's implementation of this feature doesn't work correctly in old editor
                                .WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, false);
            var completionList = await Task.Run(() => cs.GetCompletionsAsync(analysisDocument, Editor.CaretOffset, trigger, options: customOptions, cancellationToken: token)).ConfigureAwait(false);

            completionContext.Trace("C#: Got completions");

            if (completionList == null)
            {
                return(EmptyCompletionDataList);
            }

            var result = new CompletionDataList();

            result.TriggerWordLength = triggerWordLength;
            CSharpCompletionData defaultCompletionData = null;
            bool first = true, addProtocolCompletion = false;

            foreach (var item in completionList.Items)
            {
                if (string.IsNullOrEmpty(item.DisplayText))
                {
                    continue;
                }
                var data = new CSharpCompletionData(analysisDocument, triggerSnapshot, cs, item);
                if (first)
                {
                    first = false;
                    addProtocolCompletion = data.Provider is OverrideCompletionProvider;
                }
                result.Add(data);
                if (item.Rules.MatchPriority > 0)
                {
                    if (defaultCompletionData == null || defaultCompletionData.Rules.MatchPriority < item.Rules.MatchPriority)
                    {
                        defaultCompletionData = data;
                    }
                }
            }

            result.AutoCompleteUniqueMatch = (triggerInfo.CompletionTriggerReason == CompletionTriggerReason.CompletionCommand);

            var partialDoc = analysisDocument.WithFrozenPartialSemantics(token);
            var semanticModel = await partialDoc.GetSemanticModelAsync(token).ConfigureAwait(false);

            var syntaxContext = CSharpSyntaxContext.CreateContext(DocumentContext.RoslynWorkspace, semanticModel, completionContext.TriggerOffset, token);

            if (forceSymbolCompletion || IdeApp.Preferences.AddImportedItemsToCompletionList)
            {
                completionContext.Trace("C#: Adding import completion data");
                AddImportCompletionData(syntaxContext, result, semanticModel, completionContext.TriggerOffset, token);
                completionContext.Trace("C#: Added import completion data");
            }
            if (defaultCompletionData != null)
            {
                result.DefaultCompletionString = defaultCompletionData.DisplayText;
            }

            if (completionList.SuggestionModeItem != null)
            {
                if (completionList.Items.Contains(completionList.SuggestionModeItem))
                {
                    result.DefaultCompletionString = completionList.SuggestionModeItem.DisplayText;
                }
                // if a suggestion mode item is present autoselection is disabled
                // for example in the lambda case the suggestion mode item is '<lambda expression>' which is not part of the completion item list but taggs the completion list as auto select == false.
                result.AutoSelect = false;
            }
            if (triggerInfo.TriggerCharacter == '_' && triggerWordLength == 1)
            {
                result.AutoSelect = false;
            }
            if (triggerInfo.TriggerCharacter == ' ')
            {
                result.AutoCompleteEmptyMatch = true;
            }

            return(result);
        }
        internal void AddImportCompletionData(CSharpSyntaxContext ctx, CompletionDataList result, SemanticModel semanticModel, int position, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (ctx == null)
            {
                throw new ArgumentNullException(nameof(ctx));
            }
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }
            if (semanticModel == null)
            {
                throw new ArgumentNullException(nameof(semanticModel));
            }
            try {
                if (result.Count == 0 || position < 0)
                {
                    return;
                }
                var syntaxTree = semanticModel.SyntaxTree;
                var root       = syntaxTree.GetRoot();

                if (syntaxTree.IsInNonUserCode(position, cancellationToken) ||
                    syntaxTree.GetContainingTypeOrEnumDeclaration(position, cancellationToken) is EnumDeclarationSyntax ||
                    syntaxTree.IsPreProcessorDirectiveContext(position, cancellationToken))
                {
                    return;
                }

                var extensionMethodImport = syntaxTree.IsRightOfDotOrArrowOrColonColon(
                    position,
                    syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken).GetPreviousTokenIfTouchingWord(position),
                    cancellationToken);
                ITypeSymbol extensionMethodReceiverType = null;

                if (extensionMethodImport)
                {
                    if (ctx.TargetToken.Parent is MemberAccessExpressionSyntax memberAccess)
                    {
                        var symbol = ctx.SemanticModel.GetSymbolInfo(memberAccess.Expression).Symbol;
                        if (symbol != null && symbol.Kind == SymbolKind.NamedType)
                        {
                            return;
                        }
                        extensionMethodReceiverType = ctx.SemanticModel.GetTypeInfo(memberAccess.Expression).Type;
                        if (extensionMethodReceiverType == null)
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }

                var tokenLeftOfPosition = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);

                if (extensionMethodImport ||
                    syntaxTree.IsGlobalStatementContext(position, cancellationToken) ||
                    syntaxTree.IsExpressionContext(position, tokenLeftOfPosition, true, cancellationToken) ||
                    syntaxTree.IsStatementContext(position, tokenLeftOfPosition, cancellationToken) ||
                    syntaxTree.IsTypeContext(position, cancellationToken) ||
                    syntaxTree.IsTypeDeclarationContext(position, tokenLeftOfPosition, cancellationToken) ||
                    syntaxTree.IsMemberDeclarationContext(position, tokenLeftOfPosition, cancellationToken) ||
                    syntaxTree.IsLabelContext(position, cancellationToken))
                {
                    var usedNamespaces = new HashSet <string> ();
                    var node           = root.FindNode(TextSpan.FromBounds(position, position));
                    if (node != null)
                    {
                        foreach (var un in semanticModel.GetUsingNamespacesInScope(node))
                        {
                            usedNamespaces.Add(un.GetFullName());
                        }
                    }
                    var enclosingNamespaceName = semanticModel.GetEnclosingNamespace(position, cancellationToken)?.GetFullName() ?? "";

                    var stack = new Stack <INamespaceOrTypeSymbol> ();
                    foreach (var member in semanticModel.Compilation.GlobalNamespace.GetNamespaceMembers())
                    {
                        stack.Push(member);
                    }
                    var extMethodDict = extensionMethodImport ? new Dictionary <INamespaceSymbol, List <ImportSymbolCompletionData> > () : null;
                    var typeDict      = new Dictionary <INamespaceSymbol, HashSet <string> > ();
                    while (stack.Count > 0)
                    {
                        if (cancellationToken.IsCancellationRequested)
                        {
                            break;
                        }
                        var current = stack.Pop();
                        if (current is INamespaceSymbol currentNs)
                        {
                            var currentNsName = currentNs.GetFullName();
                            if (usedNamespaces.Contains(currentNsName) ||
                                enclosingNamespaceName == currentNsName ||
                                (enclosingNamespaceName.StartsWith(currentNsName, StringComparison.Ordinal) &&
                                 enclosingNamespaceName [currentNsName.Length] == '.'))
                            {
                                foreach (var member in currentNs.GetNamespaceMembers())
                                {
                                    stack.Push(member);
                                }
                            }
                            else
                            {
                                foreach (var member in currentNs.GetMembers())
                                {
                                    stack.Push(member);
                                }
                            }
                            continue;
                        }
                        if (current is INamedTypeSymbol type)
                        {
                            if (type.IsImplicitClass || type.IsScriptClass)
                            {
                                continue;
                            }
                            if (type.DeclaredAccessibility != Accessibility.Public)
                            {
                                if (type.DeclaredAccessibility != Accessibility.Internal)
                                {
                                    continue;
                                }
                                if (!type.IsAccessibleWithin(semanticModel.Compilation.Assembly))
                                {
                                    continue;
                                }
                            }
                            if (extensionMethodImport)
                            {
                                if (type.MightContainExtensionMethods)
                                {
                                    AddImportExtensionMethodCompletionData(result, ctx, type, extensionMethodReceiverType, extMethodDict);
                                }
                            }
                            else
                            {
                                if (!typeDict.TryGetValue(type.ContainingNamespace, out var existingTypeHashSet))
                                {
                                    typeDict.Add(type.ContainingNamespace, existingTypeHashSet = new HashSet <string> ());
                                }
                                if (!existingTypeHashSet.Contains(type.Name))
                                {
                                    result.Add(new ImportSymbolCompletionData(this, ctx, type, false));
                                    existingTypeHashSet.Add(type.Name);
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                LoggingService.LogError("Exception while AddImportCompletionData", e);
            }
        }
Beispiel #39
0
        internal void AddImportCompletionData(CSharpSyntaxContext ctx, CompletionDataList result, SemanticModel semanticModel, int position, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (result.Count == 0)
            {
                return;
            }
            var root       = semanticModel.SyntaxTree.GetRoot();
            var node       = root.FindNode(TextSpan.FromBounds(position, position));
            var syntaxTree = root.SyntaxTree;

            if (syntaxTree.IsInNonUserCode(position, cancellationToken) ||
                syntaxTree.GetContainingTypeOrEnumDeclaration(position, cancellationToken) is EnumDeclarationSyntax ||
                syntaxTree.IsPreProcessorDirectiveContext(position, cancellationToken))
            {
                return;
            }

            var         extensionMethodImport = syntaxTree.IsRightOfDotOrArrowOrColonColon(position, cancellationToken);
            ITypeSymbol extensionType         = null;

            if (extensionMethodImport)
            {
                var memberAccess = ctx.TargetToken.Parent as MemberAccessExpressionSyntax;
                if (memberAccess != null)
                {
                    var symbolInfo = ctx.SemanticModel.GetSymbolInfo(memberAccess.Expression);
                    if (symbolInfo.Symbol.Kind == SymbolKind.NamedType)
                    {
                        return;
                    }
                    extensionType = ctx.SemanticModel.GetTypeInfo(memberAccess.Expression).Type;
                    if (extensionType == null)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            var tokenLeftOfPosition = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);

            if (extensionMethodImport ||
                syntaxTree.IsGlobalStatementContext(position, cancellationToken) ||
                syntaxTree.IsExpressionContext(position, tokenLeftOfPosition, true, cancellationToken) ||
                syntaxTree.IsStatementContext(position, tokenLeftOfPosition, cancellationToken) ||
                syntaxTree.IsTypeContext(position, cancellationToken) ||
                syntaxTree.IsTypeDeclarationContext(position, tokenLeftOfPosition, cancellationToken) ||
                syntaxTree.IsMemberDeclarationContext(position, tokenLeftOfPosition, cancellationToken) ||
                syntaxTree.IsLabelContext(position, cancellationToken))
            {
                var usedNamespaces = new HashSet <string> ();
                foreach (var un in semanticModel.GetUsingNamespacesInScope(node))
                {
                    usedNamespaces.Add(un.GetFullName());
                }
                var enclosingNamespaceName = semanticModel.GetEnclosingNamespace(position, cancellationToken).GetFullName();

                var stack = new Stack <INamespaceOrTypeSymbol> ();
                foreach (var member in semanticModel.Compilation.GlobalNamespace.GetNamespaceMembers())
                {
                    stack.Push(member);
                }
                var extMethodDict = extensionMethodImport ? new Dictionary <INamespaceSymbol, List <ImportSymbolCompletionData> > () : null;
                var typeDict      = new Dictionary <INamespaceSymbol, HashSet <string> > ();
                while (stack.Count > 0)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        break;
                    }
                    var current   = stack.Pop();
                    var currentNs = current as INamespaceSymbol;
                    if (currentNs != null)
                    {
                        var currentNsName = currentNs.GetFullName();
                        if (usedNamespaces.Contains(currentNsName) ||
                            enclosingNamespaceName == currentNsName ||
                            (enclosingNamespaceName.StartsWith(currentNsName, StringComparison.Ordinal) &&
                             enclosingNamespaceName [currentNsName.Length] == '.'))
                        {
                            foreach (var member in currentNs.GetNamespaceMembers())
                            {
                                stack.Push(member);
                            }
                        }
                        else
                        {
                            foreach (var member in currentNs.GetMembers())
                            {
                                stack.Push(member);
                            }
                        }
                    }
                    else
                    {
                        var type = (INamedTypeSymbol)current;
                        if (type.IsImplicitClass || type.IsScriptClass)
                        {
                            continue;
                        }
                        if (type.DeclaredAccessibility != Accessibility.Public)
                        {
                            if (type.DeclaredAccessibility != Accessibility.Internal)
                            {
                                continue;
                            }
                            if (!type.IsAccessibleWithin(semanticModel.Compilation.Assembly))
                            {
                                continue;
                            }
                        }
                        if (extensionMethodImport)
                        {
                            if (!type.MightContainExtensionMethods)
                            {
                                continue;
                            }
                            foreach (var extMethod in type.GetMembers().OfType <IMethodSymbol> ().Where(method => method.IsExtensionMethod))
                            {
                                var reducedMethod = extMethod.ReduceExtensionMethod(extensionType);
                                if (reducedMethod != null)
                                {
                                    List <ImportSymbolCompletionData> importSymbolList;
                                    if (!extMethodDict.TryGetValue(type.ContainingNamespace, out importSymbolList))
                                    {
                                        extMethodDict.Add(type.ContainingNamespace, importSymbolList = new List <ImportSymbolCompletionData> ());
                                    }
                                    var newData      = new ImportSymbolCompletionData(this, reducedMethod, false);
                                    var existingItem = importSymbolList.FirstOrDefault(data => data.Symbol.Name == extMethod.Name);
                                    if (existingItem != null)
                                    {
                                        existingItem.AddOverload(newData);
                                    }
                                    else
                                    {
                                        result.Add(newData);
                                        importSymbolList.Add(newData);
                                    }
                                }
                            }
                        }
                        else
                        {
                            HashSet <string> existingTypeHashSet;
                            if (!typeDict.TryGetValue(type.ContainingNamespace, out existingTypeHashSet))
                            {
                                typeDict.Add(type.ContainingNamespace, existingTypeHashSet = new HashSet <string> ());
                            }
                            if (!existingTypeHashSet.Contains(type.Name))
                            {
                                result.Add(new ImportSymbolCompletionData(this, type, false));
                                existingTypeHashSet.Add(type.Name);
                            }
                        }
                    }
                }
            }
        }
Beispiel #40
0
        public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char triggerChar, ref int triggerWordLength)
        {
            updater.FinishUpdate();

            if (!EnableAutoCodeCompletion && char.IsLetter(triggerChar))
            {
                return(null);
            }

            if (char.IsLetterOrDigit(triggerChar) || triggerChar == '_')
            {
                if (completionContext.TriggerOffset > 1)
                {
                    var prevChar = document.Editor.GetCharAt(completionContext.TriggerOffset - 2);
                    if (char.IsLetterOrDigit(prevChar) || prevChar == '"' || prevChar == '#')                    // Don't trigger if we're already typing an identifier or if we're typing a string suffix (kinda hacky though)
                    {
                        return(null);
                    }
                }
            }
            else if (!(triggerChar == ' ' ||
                       triggerChar == '@' ||
                       triggerChar == '(' ||
                       triggerChar == '.' ||
                       triggerChar == '\0'))
            {
                return(null);
            }

            triggerWordLength = (char.IsLetter(triggerChar) || triggerChar == '_' || triggerChar == '@') ? 1 : 0;

            // Require a parsed D source

            var dom = base.Document.ParsedDocument as ParsedDModule;

            if (dom == null || dom.DDom == null)
            {
                return(null);
            }

            var l = new CompletionDataList();

            if (D_Parser.Misc.CompletionOptions.Instance.EnableSuggestionMode)
            {
                l.AddKeyHandler(new SuggestionKeyHandler());
                l.AutoCompleteUniqueMatch = false;
                l.AutoCompleteEmptyMatch  = false;
                l.AutoSelect = true;
            }
            else
            {
                l.AddKeyHandler(new DoubleUnderScoreWorkaroundHandler(this));
            }

            lock (dom.DDom)
                DCodeCompletionSupport.BuildCompletionData(
                    Document,
                    dom.DDom,
                    completionContext,
                    l,
                    triggerChar);

            return(l.Count != 0 ? l : null);
        }
Beispiel #41
0
        private CompletionDataList GetMembersOfItem(string itemFullName)
        {
            CProject project = Document.Project as CProject;

            if (project == null)
            {
                return(null);
            }

            ProjectInformation info = ProjectInformationManager.Instance.Get(project);
            CompletionDataList list = new CompletionDataList();

            list.AutoSelect = false;

            LanguageItem container = null;

            string currentFileName = Document.FileName;
            bool   in_project      = false;

            foreach (LanguageItem li in info.Containers())
            {
                if (itemFullName == li.FullName)
                {
                    container  = li;
                    in_project = true;
                }
            }

            if (!in_project && info.IncludedFiles.ContainsKey(currentFileName))
            {
                foreach (CBinding.Parser.FileInformation fi in info.IncludedFiles[currentFileName])
                {
                    foreach (LanguageItem li in fi.Containers())
                    {
                        if (itemFullName == li.FullName)
                        {
                            container = li;
                        }
                    }
                }
            }

            if (container == null)
            {
                return(null);
            }

            if (in_project)
            {
                AddItemsWithParent(list, info.AllItems(), container);
            }
            else
            {
                foreach (CBinding.Parser.FileInformation fi in info.IncludedFiles[currentFileName])
                {
                    AddItemsWithParent(list, fi.AllItems(), container);
                }
            }

            return(list);
        }
 protected virtual void GetEntityCompletions(CompletionDataList list)
 {
 }
        protected virtual ICompletionDataList HandleCodeCompletion(
            CodeCompletionContext completionContext, bool forced, ref int triggerWordLength)
        {
            IEditableTextBuffer buf = this.EditableBuffer;

            // completionChar may be a space even if the current char isn't, when ctrl-space is fired t
            TextLocation currentLocation = new TextLocation(completionContext.TriggerLine, completionContext.TriggerLineOffset);
            char         currentChar     = completionContext.TriggerOffset < 1? ' ' : buf.GetCharAt(completionContext.TriggerOffset - 1);
            char         previousChar    = completionContext.TriggerOffset < 2? ' ' : buf.GetCharAt(completionContext.TriggerOffset - 2);

            LoggingService.LogDebug("Attempting completion for state '{0}'x{1}, previousChar='{2}',"
                                    + " currentChar='{3}', forced='{4}'", tracker.Engine.CurrentState,
                                    tracker.Engine.CurrentStateLength, previousChar, currentChar, forced);

            //closing tag completion
            if (tracker.Engine.CurrentState is XmlFreeState && currentChar == '>')
            {
                return(ClosingTagCompletion(buf, currentLocation));
            }

            // Auto insert '>' when '/' is typed inside tag state (for quick tag closing)
            //FIXME: avoid doing this when the next non-whitespace char is ">" or ignore the next ">" typed
            if (XmlEditorOptions.AutoInsertFragments && tracker.Engine.CurrentState is XmlTagState && currentChar == '/')
            {
                buf.InsertText(buf.CursorPosition, ">");
                return(null);
            }

            //element completion
            if (currentChar == '<' && tracker.Engine.CurrentState is XmlFreeState)
            {
                CompletionDataList list = new CompletionDataList();
                GetElementCompletions(list);
                AddCloseTag(list, Tracker.Engine.Nodes);
                return(list.Count > 0? list : null);
            }

            //entity completion
            if (currentChar == '&' && (tracker.Engine.CurrentState is XmlFreeState ||
                                       tracker.Engine.CurrentState is XmlAttributeValueState))
            {
                CompletionDataList list = new CompletionDataList();

                //TODO: need to tweak semicolon insertion
                list.Add("apos").Description = "'";
                list.Add("quot").Description = "\"";
                list.Add("lt").Description   = "<";
                list.Add("gt").Description   = ">";
                list.Add("amp").Description  = "&";

                //not sure about these "completions". they're more like
                //shortcuts than completions but they're pretty useful
                list.Add("'").CompletionText  = "apos;";
                list.Add("\"").CompletionText = "quot;";
                list.Add("<").CompletionText  = "lt;";
                list.Add(">").CompletionText  = "gt;";
                list.Add("&").CompletionText  = "amp;";

                GetEntityCompletions(list);
                return(list);
            }

            //doctype completion
            if (tracker.Engine.CurrentState is XmlDocTypeState)
            {
                if (tracker.Engine.CurrentStateLength == 1)
                {
                    CompletionDataList list = GetDocTypeCompletions();
                    if (list != null && list.Count > 0)
                    {
                        return(list);
                    }
                }
                return(null);
            }

            //attribute name completion
            if ((forced && Tracker.Engine.Nodes.Peek() is IAttributedXObject && !tracker.Engine.Nodes.Peek().IsEnded) ||
                (Tracker.Engine.CurrentState is XmlNameState &&
                 Tracker.Engine.CurrentState.Parent is XmlAttributeState &&
                 Tracker.Engine.CurrentStateLength == 1)
                )
            {
                IAttributedXObject attributedOb = (Tracker.Engine.Nodes.Peek() as IAttributedXObject) ??
                                                  Tracker.Engine.Nodes.Peek(1) as IAttributedXObject;
                if (attributedOb == null)
                {
                    return(null);
                }

                //attributes
                if (attributedOb.Name.IsValid && (forced ||
                                                  (char.IsWhiteSpace(previousChar) && char.IsLetter(currentChar))))
                {
                    if (!forced)
                    {
                        triggerWordLength = 1;
                    }

                    var existingAtts = new Dictionary <string, string> (StringComparer.OrdinalIgnoreCase);

                    foreach (XAttribute att in attributedOb.Attributes)
                    {
                        existingAtts [att.Name.FullName] = att.Value ?? string.Empty;
                    }

                    return(GetAttributeCompletions(attributedOb, existingAtts));
                }
            }

            //attribute value completion
            //determine whether to trigger completion within attribute values quotes
            if ((Tracker.Engine.CurrentState is XmlAttributeValueState)
                //trigger on the opening quote
                && ((Tracker.Engine.CurrentStateLength == 1 && (currentChar == '\'' || currentChar == '"'))
                    //or trigger on first letter of value, if unforced
                    || (!forced && Tracker.Engine.CurrentStateLength == 1))
                )
            {
                var att = (XAttribute)Tracker.Engine.Nodes.Peek();

                if (att.IsNamed)
                {
                    var attributedOb = Tracker.Engine.Nodes.Peek(1) as IAttributedXObject;
                    if (attributedOb == null)
                    {
                        return(null);
                    }

                    char next = ' ';
                    if (completionContext.TriggerOffset < buf.Length)
                    {
                        next = buf.GetCharAt(completionContext.TriggerOffset);
                    }

                    char compareChar = (Tracker.Engine.CurrentStateLength == 1)? currentChar : previousChar;

                    if ((compareChar == '"' || compareChar == '\'') &&
                        (next == compareChar || char.IsWhiteSpace(next))
                        )
                    {
                        //if triggered by first letter of value, grab that letter
                        if (Tracker.Engine.CurrentStateLength == 2)
                        {
                            triggerWordLength = 1;
                        }

                        return(GetAttributeValueCompletions(attributedOb, att));
                    }
                }
            }

//			if (Tracker.Engine.CurrentState is XmlFreeState) {
//				if (line < 3) {
//				cp.Add ("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
//			}

            if (forced && Tracker.Engine.CurrentState is XmlFreeState)
            {
                CompletionDataList list = new CompletionDataList();
                MonoDevelop.Ide.CodeTemplates.CodeTemplateService.AddCompletionDataForFileName(Document.Name, list);
                return(list.Count > 0? list : null);
            }

            return(null);
        }
        void AddAspAttributeValueCompletionData(CompletionDataList list, XName tagName, XName attName, string id)
        {
            Debug.Assert(tagName.IsValid && tagName.HasPrefix);
            Debug.Assert(attName.IsValid && !attName.HasPrefix);

            INamedTypeSymbol controlClass = refman.GetControlType(tagName.Prefix, tagName.Name);

            if (controlClass == null)
            {
                return;
            }

            //find the codebehind class
            INamedTypeSymbol codeBehindClass;

            GetCodeBehind(out codeBehindClass);

            //if it's an event, suggest compatible methods
            if (codeBehindClass != null && attName.Name.StartsWith("On", StringComparison.Ordinal))
            {
                string eventName = attName.Name.Substring(2);

                foreach (IEventSymbol ev in controlClass.GetAccessibleMembersInThisAndBaseTypes <IEventSymbol> (controlClass))
                {
                    if (ev.Name == eventName)
                    {
                        var domMethod = BindingService.MDDomToCodeDomMethod(ev);
                        if (domMethod == null)
                        {
                            return;
                        }

                        foreach (IMethodSymbol meth
                                 in BindingService.GetCompatibleMethodsInClass(codeBehindClass, ev))
                        {
                            list.Add(meth.Name, "md-method",
                                     GettextCatalog.GetString("A compatible method in the CodeBehind class"));
                        }

                        string suggestedIdentifier = ev.Name;
                        if (id != null)
                        {
                            suggestedIdentifier = id + "_" + suggestedIdentifier;
                        }
                        else
                        {
                            suggestedIdentifier = tagName.Name + "_" + suggestedIdentifier;
                        }

                        domMethod.Name = BindingService.GenerateIdentifierUniqueInClass
                                             (codeBehindClass, suggestedIdentifier);
                        domMethod.Attributes = (domMethod.Attributes & ~System.CodeDom.MemberAttributes.AccessMask)
                                               | System.CodeDom.MemberAttributes.Family;

                        list.Add(
                            new SuggestedHandlerCompletionData(project, domMethod, codeBehindClass,
                                                               CodeBehind.GetNonDesignerClassLocation(codeBehindClass))
                            );
                        return;
                    }
                }
            }

            //if it's a property and is an enum or bool, suggest valid values
            foreach (IPropertySymbol prop in GetAllMembers <IPropertySymbol> (controlClass))
            {
                if (prop.Name != attName.Name)
                {
                    continue;
                }

                //boolean completion
                if (prop.GetReturnType().Equals(refman.Compilation.GetTypeByMetadataName("System.Boolean")))
                {
                    AddBooleanCompletionData(list);
                    return;
                }
                //color completion
                if (prop.GetReturnType().Equals(refman.Compilation.GetTypeByMetadataName("System.Drawing.Color")))
                {
                    var conv = new System.Drawing.ColorConverter();
                    foreach (System.Drawing.Color c in conv.GetStandardValues(null))
                    {
                        if (c.IsSystemColor)
                        {
                            continue;
                        }
                        string hexcol = string.Format("#{0:x2}{1:x2}{2:x2}", c.R, c.G, c.B);
                        list.Add(c.Name, hexcol);
                    }
                    return;
                }

                //enum completion
                var retCls = prop.GetReturnType() as INamedTypeSymbol;
                if (retCls != null && retCls.TypeKind == TypeKind.Enum)
                {
                    foreach (var enumVal in GetAllMembers <IFieldSymbol> (retCls))
                    {
                        if (enumVal.DeclaredAccessibility == Accessibility.Public && enumVal.IsStatic)
                        {
                            list.Add(enumVal.Name, "md-literal", Ambience.GetSummaryMarkup(enumVal));
                        }
                    }
                    return;
                }
            }
        }
        protected override Task <ICompletionDataList> HandleCodeCompletion(
            CodeCompletionContext completionContext, bool forced, CancellationToken token)
        {
            // completionChar may be a space even if the current char isn't, when ctrl-space is fired t
            char currentChar = completionContext.TriggerOffset < 1? ' ' : Editor.GetCharAt(completionContext.TriggerOffset - 1);

            //char previousChar = completionContext.TriggerOffset < 2? ' ' : buf.GetCharAt (completionContext.TriggerOffset - 2);

            //directive names
            if (Tracker.Engine.CurrentState is WebFormsDirectiveState)
            {
                var directive = Tracker.Engine.Nodes.Peek() as WebFormsDirective;
                if (HasDoc && directive != null && directive.Region.BeginLine == completionContext.TriggerLine &&
                    directive.Region.BeginColumn + 3 == completionContext.TriggerLineOffset)
                {
                    return(Task.FromResult((ICompletionDataList)WebFormsDirectiveCompletion.GetDirectives(aspDoc.Type)));
                }
                return(null);
            }
            if (Tracker.Engine.CurrentState is XmlNameState && Tracker.Engine.CurrentState.Parent is WebFormsDirectiveState)
            {
                var directive = Tracker.Engine.Nodes.Peek() as WebFormsDirective;
                if (HasDoc && directive != null && directive.Region.BeginLine == completionContext.TriggerLine &&
                    directive.Region.BeginColumn + 4 == completionContext.TriggerLineOffset && char.IsLetter(currentChar))
                {
                    completionContext.TriggerWordLength = 1;
                    completionContext.TriggerOffset    -= 1;
                    return(Task.FromResult((ICompletionDataList)WebFormsDirectiveCompletion.GetDirectives(aspDoc.Type)));
                }
                return(null);
            }

            bool isAspExprState = Tracker.Engine.CurrentState is WebFormsExpressionState;

            //non-xml tag completion
            if (currentChar == '<' && !(isAspExprState || Tracker.Engine.CurrentState is XmlRootState))
            {
                var list = new CompletionDataList();
                AddAspBeginExpressions(list);
                return(Task.FromResult((ICompletionDataList)list));
            }

            if (!HasDoc || aspDoc.Info.DocType == null)
            {
                //FIXME: get doctype from master page
                DocType = null;
            }
            else
            {
                DocType = new XDocType(DocumentLocation.Empty);
                var matches = DocTypeRegex.Match(aspDoc.Info.DocType);
                DocType.PublicFpi = matches.Groups["fpi"].Value;
                DocType.Uri       = matches.Groups["uri"].Value;
            }

            if (Tracker.Engine.CurrentState is HtmlScriptBodyState)
            {
                var el = Tracker.Engine.Nodes.Peek() as XElement;
                if (el != null)
                {
                    if (el.IsRunatServer())
                    {
                        if (documentBuilder != null)
                        {
                            // TODO: C# completion
                        }
                    }

                    /*
                     * else {
                     *      att = GetHtmlAtt (el, "language");
                     *      if (att == null || "javascript".Equals (att.Value, StringComparison.OrdinalIgnoreCase)) {
                     *          att = GetHtmlAtt (el, "type");
                     *              if (att == null || "text/javascript".Equals (att.Value, StringComparison.OrdinalIgnoreCase)) {
                     *                      // TODO: JS completion
                     *              }
                     *      }
                     * }*/
                }
            }

            return(base.HandleCodeCompletion(completionContext, forced, token));
        }
Beispiel #46
0
        Task <ICompletionDataList> HandleExpressionCompletion(MSBuildResolveResult rr, CancellationToken token)
        {
            var doc = GetDocument();

            if (!ExpressionCompletion.IsPossibleExpressionCompletionContext(Tracker.Engine))
            {
                return(null);
            }

            string expression = GetAttributeOrElementTextToCaret();

            var triggerState = ExpressionCompletion.GetTriggerState(
                expression,
                rr.IsCondition(),
                out int triggerLength,
                out ExpressionNode triggerExpression,
                out IReadOnlyList <ExpressionNode> comparandVariables
                );

            if (triggerState == ExpressionCompletion.TriggerState.None)
            {
                return(null);
            }

            var info = rr.GetElementOrAttributeValueInfo(doc);

            if (info == null)
            {
                return(null);
            }

            var kind = MSBuildCompletionExtensions.InferValueKindIfUnknown(info);

            if (!ExpressionCompletion.ValidateListPermitted(ref triggerState, kind))
            {
                return(null);
            }

            bool allowExpressions = kind.AllowExpressions();

            kind = kind.GetScalarType();

            if (kind == MSBuildValueKind.Data || kind == MSBuildValueKind.Nothing)
            {
                return(null);
            }

            var list = new CompletionDataList {
                TriggerWordLength = triggerLength, AutoSelect = false
            };

            if (comparandVariables != null && triggerState == ExpressionCompletion.TriggerState.Value)
            {
                foreach (var ci in ExpressionCompletion.GetComparandCompletions(doc, comparandVariables))
                {
                    list.Add(new MSBuildCompletionData(ci, doc, rr, XmlCompletionData.DataType.XmlAttributeValue));
                }
            }

            if (triggerState == ExpressionCompletion.TriggerState.Value)
            {
                switch (kind)
                {
                case MSBuildValueKind.NuGetID:
                    return(GetPackageNameCompletions(doc, Editor.CaretOffset - triggerLength, triggerLength));

                case MSBuildValueKind.NuGetVersion:
                    return(GetPackageVersionCompletions(doc, rr, Editor.CaretOffset - triggerLength, triggerLength));

                case MSBuildValueKind.Sdk:
                case MSBuildValueKind.SdkWithVersion:
                    return(GetSdkCompletions(triggerLength, token));

                case MSBuildValueKind.Guid:
                    list.Add(new GenerateGuidCompletionData());
                    break;

                case MSBuildValueKind.Lcid:
                    foreach (var culture in System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.AllCultures))
                    {
                        string name    = culture.Name;
                        string id      = culture.LCID.ToString();
                        string display = culture.DisplayName;
                        //insert multiple versions for matching on both the name and the number
                        list.Add(new CompletionData(id, null, display));
                        list.Add(new CompletionData(display, null, id, id));
                    }
                    break;
                }
            }

            //TODO: better metadata support

            IEnumerable <BaseInfo> cinfos;

            if (info.Values != null && info.Values.Count > 0 && triggerState == ExpressionCompletion.TriggerState.Value)
            {
                cinfos = info.Values;
            }
            else
            {
                cinfos = ExpressionCompletion.GetCompletionInfos(rr, triggerState, kind, triggerExpression, triggerLength, doc);
            }

            if (cinfos != null)
            {
                foreach (var ci in cinfos)
                {
                    list.Add(new MSBuildCompletionData(ci, doc, rr, XmlCompletionData.DataType.XmlAttributeValue));
                }
            }

            if (allowExpressions && triggerState == ExpressionCompletion.TriggerState.Value)
            {
                list.Add(new CompletionDataWithSkipCharAndRetrigger("$(", "md-variable", "Property value reference", "$(|)", ')'));
                list.Add(new CompletionDataWithSkipCharAndRetrigger("@(", "md-variable", "Item list reference", "@(|)", ')'));
            }

            if (list.Count > 0)
            {
                return(Task.FromResult <ICompletionDataList> (list));
            }

            return(null);
        }
// TODO: Roslyn port
//		public override ParameterHintingResult HandleParameterCompletionAsync (CodeCompletionContext completionContext, char completionChar)
//		{
///*			if (Tracker.Engine.CurrentState is AspNetExpressionState && documentBuilder != null && localDocumentInfo != null) {
//				return documentBuilder.HandleParameterCompletion (defaultDocument, completionContext, documentInfo, localDocumentInfo, completionChar);
//			}*/
//
//			return base.HandleParameterCompletionAsync (completionContext, completionChar);
//		}

        /*public override void RunParameterCompletionCommand ()
         * {
         *      if (localDocumentInfo == null) {
         *              base.RunParameterCompletionCommand ();
         *              return;
         *      }
         *      var doc = document;
         *      document = localDocumentInfo.HiddenDocument;
         *      var cw = CompletionWidget;
         *      CompletionWidget = documentBuilder.CreateCompletionWidget (localDocumentInfo);
         *      try {
         *              base.RunParameterCompletionCommand ();
         *      } finally {
         *              document = doc;
         *              CompletionWidget = cw;
         *      }
         * }*/

        protected override async Task <CompletionDataList> GetElementCompletions(CancellationToken token)
        {
            var   list       = new CompletionDataList();
            XName parentName = GetParentElementName(0);

            INamedTypeSymbol controlClass = null;

            if (parentName.HasPrefix)
            {
                controlClass = refman.GetControlType(parentName.Prefix, parentName.Name);
            }
            else
            {
                XName grandparentName = GetParentElementName(1);
                if (grandparentName.IsValid && grandparentName.HasPrefix)
                {
                    controlClass = refman.GetControlType(grandparentName.Prefix, grandparentName.Name);
                }
            }

            //we're just in HTML
            if (controlClass == null)
            {
                //root element?
                if (!parentName.IsValid)
                {
                    if (aspDoc.Info.Subtype == WebSubtype.WebControl)
                    {
                        await AddHtmlTagCompletionData(list, Schema, new XName ("div"), token);

                        AddAspBeginExpressions(list);
                        list.AddRange(refman.GetControlCompletionData());
                        AddMiscBeginTags(list);
                    }
                    else if (!string.IsNullOrEmpty(aspDoc.Info.MasterPageFile))
                    {
                        //FIXME: add the actual region names
                        list.Add(new CompletionData("asp:Content"));
                    }
                }
                else
                {
                    AddAspBeginExpressions(list);
                    list.AddRange(refman.GetControlCompletionData());
                    list.AddRange(await base.GetElementCompletions(token));
                }
                return(list);
            }

            string defaultProp;
            bool   childrenAsProperties = AreChildrenAsProperties(controlClass, out defaultProp);

            if (defaultProp != null && defaultProp.Length == 0)
            {
                defaultProp = null;
            }

            //parent permits child controls directly
            if (!childrenAsProperties)
            {
                AddAspBeginExpressions(list);
                list.AddRange(refman.GetControlCompletionData());
                AddMiscBeginTags(list);
                //TODO: get correct parent for Content tags
                await AddHtmlTagCompletionData(list, Schema, new XName ("body"), token);

                return(list);
            }

            //children of properties
            if (childrenAsProperties && (!parentName.HasPrefix || defaultProp != null))
            {
                string          propName = defaultProp ?? parentName.Name;
                IPropertySymbol property =
                    controlClass.GetMembers().OfType <IPropertySymbol> ()
                    .FirstOrDefault(x => string.Equals(propName, x.Name, StringComparison.OrdinalIgnoreCase));

                if (property == null)
                {
                    return(list);
                }

                //sanity checks on attributes
                switch (GetPersistenceMode(property))
                {
                case System.Web.UI.PersistenceMode.Attribute:
                case System.Web.UI.PersistenceMode.EncodedInnerDefaultProperty:
                    return(list);

                case System.Web.UI.PersistenceMode.InnerDefaultProperty:
                    if (!parentName.HasPrefix)
                    {
                        return(list);
                    }
                    break;

                case System.Web.UI.PersistenceMode.InnerProperty:
                    if (parentName.HasPrefix)
                    {
                        return(list);
                    }
                    break;
                }

                //check if allows freeform ASP/HTML content
                if (property.GetReturnType().GetFullName() == "System.Web.UI.ITemplate")
                {
                    AddAspBeginExpressions(list);
                    AddMiscBeginTags(list);
                    await AddHtmlTagCompletionData(list, Schema, new XName ("body"), token);

                    list.AddRange(refman.GetControlCompletionData());
                    return(list);
                }

                //FIXME:unfortunately ASP.NET doesn't seem to have enough type information / attributes
                //to be able to resolve the correct child types here
                //so we assume it's a list and have a quick hack to find arguments of strongly typed ILists

                ITypeSymbol collectionType = property.GetReturnType();
                if (collectionType == null)
                {
                    list.AddRange(refman.GetControlCompletionData());
                    return(list);
                }

                string        addStr = "Add";
                IMethodSymbol meth   = collectionType.GetMembers().OfType <IMethodSymbol> ().FirstOrDefault(m => m.Parameters.Length == 1 && m.Name == addStr);

                if (meth != null)
                {
                    var argType           = meth.Parameters [0].Type as INamedTypeSymbol;
                    INamedTypeSymbol type = refman.Compilation.GetTypeByMetadataName("System.Web.UI.Control");
                    if (argType != null && type != null && argType.IsDerivedFromClass(type))
                    {
                        list.AddRange(refman.GetControlCompletionData(argType));
                        return(list);
                    }
                }

                list.AddRange(refman.GetControlCompletionData());
                return(list);
            }

            //properties as children of controls
            if (parentName.HasPrefix && childrenAsProperties)
            {
                foreach (IPropertySymbol prop in GetUniqueMembers <IPropertySymbol> (controlClass.GetMembers().OfType <IPropertySymbol> ()))
                {
                    if (GetPersistenceMode(prop) != System.Web.UI.PersistenceMode.Attribute)
                    {
                        list.Add(prop.Name, prop.GetStockIcon(), Ambience.GetSummaryMarkup(prop));
                    }
                }
            }
            return(list);
        }
Beispiel #48
0
        public static CompletionDataList GetAttributes(AspNetAppProject project, string directiveName,
                                                       Dictionary <string, string> existingAtts)
        {
            var  list  = new CompletionDataList();
            bool net20 = project == null || project.TargetFramework.ClrVersion != ClrVersion.Net_1_1;

            //FIXME: detect whether the page is VB
            bool vb = false;

            switch (directiveName.ToLowerInvariant())
            {
            case "page":
                ExclusiveAdd(list, existingAtts, page11Attributes);
                if (net20)
                {
                    ExclusiveAdd(list, existingAtts, page20Attributes);
                }
                if (vb)
                {
                    ExclusiveAdd(list, existingAtts, pageVBAttributes);
                }
                MutexAdd(list, existingAtts, page11MutexAttributes);
                break;

            case "control":
                ExclusiveAdd(list, existingAtts, userControlAttributes);
                if (vb)
                {
                    ExclusiveAdd(list, existingAtts, pageVBAttributes);
                }
                break;

            case "master":
                ExclusiveAdd(list, existingAtts, userControlAttributes);
                ExclusiveAdd(list, existingAtts, masterControlAttributes);
                if (vb)
                {
                    ExclusiveAdd(list, existingAtts, pageVBAttributes);
                }
                break;

            case "mastertype":
                MutexAdd(list, existingAtts, mastertypeAttributes);
                break;

            case "assembly":
                //the two assembly directive attributes are mutually exclusive
                MutexAdd(list, existingAtts, assemblyAttributes);
                break;

            case "import":
                ExclusiveAdd(list, existingAtts, importAttributes);
                break;

            case "reference":
                MutexAdd(list, existingAtts, referenceAttributes);
                break;

            case "register":
                ExclusiveAdd(list, existingAtts, registerAttributes);
                if (existingAtts.Keys.Intersect(registerAssemblyAttributes, StringComparer.OrdinalIgnoreCase).Any())
                {
                    ExclusiveAdd(list, existingAtts, registerAssemblyAttributes);
                }
                else if (existingAtts.Keys.Intersect(registerUserControlAttributes, StringComparer.OrdinalIgnoreCase).Any())
                {
                    ExclusiveAdd(list, existingAtts, registerUserControlAttributes);
                }
                else
                {
                    list.AddRange(registerAssemblyAttributes);
                    list.AddRange(registerUserControlAttributes);
                }
                break;

            case "outputcache":
                ExclusiveAdd(list, existingAtts, outputcacheAttributes);
                break;

            case "previouspagetype":
                MutexAdd(list, existingAtts, previousPageTypeAttributes);
                break;

            case "implements":
                ExclusiveAdd(list, existingAtts, implementsAttributes);
                break;
            }
            return(list.Count > 0? list : null);
        }
 static void AddBooleanCompletionData(CompletionDataList list)
 {
     list.Add("true", "md-literal");
     list.Add("false", "md-literal");
 }
Beispiel #50
0
        static CompletionDataList GetPageAttributeValues(AspNetAppProject project, FilePath fromFile, string attribute)
        {
            var list = new CompletionDataList();

            switch (attribute.ToLowerInvariant())
            {
            //
            //boolean, default to false
            //
            case "async":
            case "aspcompat":
            case "explicit":           // useful for VB only. set to true in machine.config
            case "maintainscrollpositiononpostback":
            case "linepragmas":        //actually not sure if this defaults true or false
            case "smartnavigation":
            case "strict":             //VB ONLY
            case "trace":
                SimpleList.AddBoolean(list, false);
                break;

            //
            //boolean, default to true
            //
            case "autoeventwireup":
            case "buffer":
            case "enableeventvalidation":
            case "enablesessionstate":
            case "enabletheming":
            case "enableviewstate":
            case "enableviewstatemac":
            case "validaterequest":             //enabled in machine.config
            case "debug":
                SimpleList.AddBoolean(list, true);
                break;

            //
            //specialised hard value list completions
            //
            case "codepage":
                list.AddRange(from e in Encoding.GetEncodings() select e.CodePage.ToString());
                list.DefaultCompletionString = Encoding.UTF8.CodePage.ToString();
                break;

            case "compilationmode":
                SimpleList.AddEnum(list, System.Web.UI.CompilationMode.Always);
                break;

            case "culture":
                list.AddRange(from c in CultureInfo.GetCultures(CultureTypes.AllCultures) select c.Name);
                list.DefaultCompletionString = CultureInfo.CurrentCulture.Name;
                break;

            case "lcid":
                //  locale ID, MUTUALLY EXCLUSIVE with Culture
                list.AddRange(from c in CultureInfo.GetCultures(CultureTypes.AllCultures)
                              select c.LCID.ToString());
                list.DefaultCompletionString = CultureInfo.CurrentCulture.LCID.ToString();
                break;

            case "responseencoding":
                list.AddRange(from e in Encoding.GetEncodings() select e.Name);
                list.DefaultCompletionString = Encoding.UTF8.EncodingName;
                break;

            case "tracemode":
                list.Add("SortByTime");
                list.Add("SortByCategory");
                list.DefaultCompletionString = "SortByTime";
                break;

            case "transaction":
                list.Add("Disabled");
                list.Add("NotSupported");
                list.Add("Required");
                list.Add("RequiresNew");
                list.DefaultCompletionString = "Disabled";
                break;

            case "viewstateencryptionmode":
                SimpleList.AddEnum(list, ViewStateEncryptionMode.Auto);
                break;

            case "warninglevel":
                list.AddRange(new string[] { "0", "1", "2", "3", "4" });
                list.DefaultCompletionString = "0";
                break;

            case "masterpagefile":
                return(project != null
                                        ? MonoDevelop.Html.PathCompletion.GetPathCompletion(project, "*.master", fromFile,
                                                                                            x => "~/" + x.ProjectVirtualPath.ToString().Replace(System.IO.Path.PathSeparator, '/'))
                                        : null);

            //
            //we can probably complete these using info from the project, but not yet
            //

            /*
             * case "CodeFile":
             *      //source file to compile for codebehind on server
             * case "ContentType":
             *      //string, HTTP MIME content-type
             * case "CodeFileBaseClass":
             *      // known base class for the partial classes, so code generator knows not
             *      //to redefine fields to ignore members in partial class
             * case "ErrorPage":
             *      // string, URL
             * case "Inherits":
             *      //  IType : Page. defaults to namespace from ClassName
             * case "Language":
             *      //  string, any available .NET language
             * case "Src":
             *      //  string, extra source code for page
             * case "StyleSheetTheme":
             *      //  theme ID, can be overridden by controls
             * case "Theme":
             *      //  theme identifier, overrides controls' themes
             * case "UICulture":
             *      //  string, valid UI culture
             */

            //
            //we're not likely to suggest anything for these:
            //

            /*
             * case "AsyncTimeOut":
             *      // int in seconds, default 45
             * case "ClassName":
             *      //string, .NET name, default namespace ASP
             * case "ClientTarget":
             *      //string, user agent
             * case "CodeBehind":
             *      //valid but IGNORE. VS-only
             * case "CompilerOptions":
             *      //string, list of compiler switches
             * case "Description":
             *      // string, pointless
             * case "TargetSchema":
             *      //  schema to validate page content. IGNORED, so rather pointless
             * case "Title":
             *      //  string for <title>
             */
            default:
                return(null);
            }

            return(list.Count > 0? list : null);
        }
 protected virtual void GetElementCompletions(CompletionDataList list)
 {
 }
 public CompletionDataGenerator(CompletionDataList l, INode scopedBlock)
 {
     CompletionDataList = l;
     this.scopedBlock   = scopedBlock;
 }
 /// <summary>
 /// Adds CDATA and comment begin tags.
 /// </summary>
 protected static void AddMiscBeginTags(CompletionDataList list)
 {
     list.Add("!--", "md-literal", GettextCatalog.GetString("Comment"));
     list.Add("![CDATA[", "md-literal", GettextCatalog.GetString("Character data"));
 }
Beispiel #54
0
        private ICompletionDataList GlobalComplete()
        {
            CProject project = Document.Project as CProject;

            if (project == null)
            {
                return(null);
            }

            ProjectInformation info = ProjectInformationManager.Instance.Get(project);

            CompletionDataList list = new CompletionDataList();

            list.AutoSelect = false;

            foreach (LanguageItem li in info.Containers())
            {
                if (li.Parent == null)
                {
                    list.Add(new CompletionData(li));
                }
            }

            foreach (Function f in info.Functions)
            {
                if (f.Parent == null)
                {
                    list.Add(new CompletionData(f));
                }
            }

            foreach (Enumerator e in info.Enumerators)
            {
                list.Add(new CompletionData(e));
            }

            foreach (Macro m in info.Macros)
            {
                list.Add(new CompletionData(m));
            }

            string currentFileName = Document.FileName;

            if (info.IncludedFiles.ContainsKey(currentFileName))
            {
                foreach (CBinding.Parser.FileInformation fi in info.IncludedFiles[currentFileName])
                {
                    foreach (LanguageItem li in fi.Containers())
                    {
                        if (li.Parent == null)
                        {
                            list.Add(new CompletionData(li));
                        }
                    }

                    foreach (Function f in fi.Functions)
                    {
                        if (f.Parent == null)
                        {
                            list.Add(new CompletionData(f));
                        }
                    }

                    foreach (Enumerator e in fi.Enumerators)
                    {
                        list.Add(new CompletionData(e));
                    }

                    foreach (Macro m in fi.Macros)
                    {
                        list.Add(new CompletionData(m));
                    }
                }
            }

            return(list);
        }
Beispiel #55
0
        /// <summary>
        /// Gets completion data for a given instance
        /// </summary>
        /// <param name="instanceName">
        /// The identifier of the instance
        /// <see cref="System.String"/>
        /// </param>
        /// <param name="isPointer">
        /// Whether the instance in question is a pointer
        /// <see cref="System.Boolean"/>
        /// </param>
        /// <returns>
        /// Completion data for the instance
        /// <see cref="CompletionDataList"/>
        /// </returns>
        private CompletionDataList GetMembersOfInstance(string instanceName, bool isPointer)
        {
            CProject project = Document.Project as CProject;

            if (project == null)
            {
                return(null);
            }

            ProjectInformation info = ProjectInformationManager.Instance.Get(project);
            CompletionDataList list = new CompletionDataList();

            list.AutoSelect = false;

            string container = null;

            string currentFileName = Document.FileName;
            bool   in_project      = false;

            // Find the typename of the instance
            foreach (Member li in info.Members)
            {
                if (instanceName == li.Name && li.IsPointer == isPointer)
                {
                    container  = li.InstanceType;
                    in_project = true;
                    break;
                }
            }

            // Search included files
            if (!in_project && info.IncludedFiles.ContainsKey(currentFileName))
            {
                foreach (CBinding.Parser.FileInformation fi in info.IncludedFiles[currentFileName])
                {
                    foreach (Member li in fi.Members)
                    {
                        if (instanceName == li.Name && li.IsPointer == isPointer)
                        {
                            container = li.InstanceType;
                            break;
                        }
                    }
                }
            }

            if (null == container)
            {
                // Search locals
                foreach (Local li in info.Locals)
                {
                    if (instanceName == li.Name && li.IsPointer == isPointer && currentFileName == li.File)
                    {
                        container  = li.InstanceType;
                        in_project = true;
                        break;
                    }
                }
            }

            // Not found
            if (container == null)
            {
                return(null);
            }

            // Get the LanguageItem corresponding to the typename
            // and populate completion data accordingly
            if (in_project)
            {
                AddMembersWithParent(list, info.InstanceMembers(), container);
            }
            else
            {
                foreach (CBinding.Parser.FileInformation fi in info.IncludedFiles[currentFileName])
                {
                    AddMembersWithParent(list, fi.InstanceMembers(), container);
                }
            }

            return(list);
        }
Beispiel #56
0
        protected override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext,
                                                                    bool forced, ref int triggerWordLength)
        {
            ITextBuffer buf = this.Buffer;
            // completionChar may be a space even if the current char isn't, when ctrl-space is fired t
            char currentChar = completionContext.TriggerOffset < 1? ' ' : buf.GetCharAt(completionContext.TriggerOffset - 1);

            //char previousChar = completionContext.TriggerOffset < 2? ' ' : buf.GetCharAt (completionContext.TriggerOffset - 2);


            //directive names
            if (Tracker.Engine.CurrentState is AspNetDirectiveState)
            {
                var directive = Tracker.Engine.Nodes.Peek() as AspNetDirective;
                if (HasDoc && directive != null && directive.Region.BeginLine == completionContext.TriggerLine &&
                    directive.Region.BeginColumn + 3 == completionContext.TriggerLineOffset)
                {
                    return(DirectiveCompletion.GetDirectives(aspDoc.Type));
                }
                return(null);
            }
            else if (Tracker.Engine.CurrentState is S.XmlNameState && Tracker.Engine.CurrentState.Parent is AspNetDirectiveState)
            {
                var directive = Tracker.Engine.Nodes.Peek() as AspNetDirective;
                if (HasDoc && directive != null && directive.Region.BeginLine == completionContext.TriggerLine &&
                    directive.Region.BeginColumn + 4 == completionContext.TriggerLineOffset && char.IsLetter(currentChar))
                {
                    triggerWordLength = 1;
                    return(DirectiveCompletion.GetDirectives(aspDoc.Type));
                }
                return(null);
            }

            bool isAspExprState = Tracker.Engine.CurrentState is AspNetExpressionState;

            //non-xml tag completion
            if (currentChar == '<' && !(isAspExprState || Tracker.Engine.CurrentState is S.XmlFreeState))
            {
                var list = new CompletionDataList();
                AddAspBeginExpressions(list);
                return(list);
            }

            if (!HasDoc || aspDoc.Info.DocType == null)
            {
                //FIXME: get doctype from master page
                DocType = null;
            }
            else
            {
                DocType = new MonoDevelop.Xml.StateEngine.XDocType(TextLocation.Empty);
                var matches = DocTypeRegex.Match(aspDoc.Info.DocType);
                DocType.PublicFpi = matches.Groups["fpi"].Value;
                DocType.Uri       = matches.Groups["uri"].Value;
            }

            if (Tracker.Engine.CurrentState is HtmlScriptBodyState)
            {
                var el = Tracker.Engine.Nodes.Peek() as S.XElement;
                if (el != null)
                {
                    var att = GetHtmlAtt(el, "runat");
                    if (att != null && "server".Equals(att.Value, StringComparison.OrdinalIgnoreCase))
                    {
                        if (documentBuilder != null)
                        {
                            // TODO: C# completion
                        }
                    }

                    /*
                     * else {
                     *      att = GetHtmlAtt (el, "language");
                     *      if (att == null || "javascript".Equals (att.Value, StringComparison.OrdinalIgnoreCase)) {
                     *          att = GetHtmlAtt (el, "type");
                     *              if (att == null || "text/javascript".Equals (att.Value, StringComparison.OrdinalIgnoreCase)) {
                     *                      // TODO: JS completion
                     *              }
                     *      }
                     * }*/
                }
            }

            return(base.HandleCodeCompletion(completionContext, forced, ref triggerWordLength));
        }
Beispiel #57
0
        public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char completionChar, ref int triggerWordLength)
        {
            if (!CanRunCompletionCommand())
            {
                return(null);
            }

            if (completionChar == '(' || completionChar == ')' ||
                completionChar == '[' || completionChar == ']' ||
                completionChar == '{' || completionChar == '}' ||
                completionChar == '"' || completionChar == '\'' ||
                completionChar == ';' || completionChar == '=' ||
                completionChar == ' ' || completionChar == '\t' ||
                completionChar == ',')
            {
                if (completionChar == '(')
                {
                    // TODO: Add function args
                }
                return(null);                // don't show it yet
            }

            CompletionDataList ret         = new CompletionDataList();
            string             fullcontext = "";
            bool has_namespace             = false;

            if (completionContext.TriggerOffset > 1)
            {
                completionContext.TriggerOffset = document.Editor.Caret.Offset;
                int pos = completionContext.TriggerOffset - 1;

                while (pos > 1)
                {
                    char letter = document.Editor.GetCharAt(pos);

                    pos--;
                    if (letter == '.' || letter == ':' || letter == ',' ||
                        !ValidVarnameChar(letter))
                    {
                        has_namespace |= letter == '.' || letter == ':';
                        break;
                    }
                }

                triggerWordLength = completionContext.TriggerOffset - pos - 2;
                completionContext.TriggerWordLength = triggerWordLength;

                // now, work out the context
                bool did_space     = false;
                bool did_namespace = false;

                while (pos > 1 && has_namespace)
                {
                    char letter = document.Editor.GetCharAt(pos);

                    if (char.IsWhiteSpace(letter))
                    {
                        did_space = true;
                    }
                    else if (did_space && !did_namespace && (letter != '.' && letter != ':'))
                    {
                        break;
                    }
                    else if (letter == '.' || letter == ':')
                    {
                        did_namespace = true;
                        fullcontext   = letter + fullcontext;
                    }
                    else if (ValidVarnameChar(letter))
                    {
                        did_namespace = false;
                        did_space     = false;
                        fullcontext   = letter + fullcontext;
                    }
                    else
                    {
                        break;
                    }
                    pos--;
                }
            }

            if (completionChar == '.' && string.IsNullOrWhiteSpace(fullcontext.Trim(".".ToCharArray())))
            {
                return(null);
            }

            if (fullcontext.Trim() == "")
            {
                fullcontext = "_G";
            }
            else
            {
                fullcontext = fullcontext.TrimEnd(".".ToCharArray());
                if (fullcontext.StartsWith("_G.", StringComparison.Ordinal))
                {
                    fullcontext = fullcontext.Substring("_G.".Length);
                }
            }

            CompletionCategory cat         = null;
            Action <string>    handle_line = delegate(string line) {
                if (line.Trim().StartsWith("#", StringComparison.Ordinal))
                {
                    return;
                }
                if (string.IsNullOrWhiteSpace(line))
                {
                    return;
                }

                string[] split = line.Split("\t".ToCharArray());

                string arg0 = split.Length >= 1 ? split[0] : "";                 // namespace
                string arg1 = split.Length >= 2 ? split[1] : "";                 // name
                string arg2 = split.Length >= 3 ? split[2] : "";                 // arguments

                if (arg0 == fullcontext)
                {
                    string icon = MonoDevelop.Ide.Gui.Stock.Method;
                    string arg  = arg2;

                    switch (arg)
                    {
                    case "":
                        icon = "md-keyword";
                        arg  = "";
                        break;

                    case "{}":
                        icon = MonoDevelop.Ide.Gui.Stock.NameSpace;
                        arg  = "";
                        break;

                    case "#":
                        icon = MonoDevelop.Ide.Gui.Stock.Literal;
                        arg  = "";
                        break;
                    }

                    var elm = ret.Add(arg1 + arg, icon, "", arg1);
                    elm.CompletionCategory = cat;
                }
            };

            UpdateProjectGlobals();
            //UpdateEngineGlobals();
            cat = new GlobalCompletionCategory();

            foreach (string glob in Globals)
            {
                handle_line(glob);
            }
            foreach (string glob in ProjectGlobals)
            {
                handle_line(glob);
            }
            foreach (string glob in EngineGlobals)
            {
                handle_line(glob);
            }

            cat             = new LocalCompletionCategory();
            cat.DisplayText = "Locals";

            foreach (string glob in GetDocumentLocals())
            {
                handle_line(glob);
            }

            return(ret);
            //return base.HandleCodeCompletion(completionContext, completionChar, ref triggerWordLength);
        }
Beispiel #58
0
        /*public override void RunParameterCompletionCommand ()
         * {
         *      if (localDocumentInfo == null) {
         *              base.RunParameterCompletionCommand ();
         *              return;
         *      }
         *      var doc = document;
         *      document = localDocumentInfo.HiddenDocument;
         *      var cw = CompletionWidget;
         *      CompletionWidget = documentBuilder.CreateCompletionWidget (localDocumentInfo);
         *      try {
         *              base.RunParameterCompletionCommand ();
         *      } finally {
         *              document = doc;
         *              CompletionWidget = cw;
         *      }
         * }*/

        protected override void GetElementCompletions(CompletionDataList list)
        {
            S.XName parentName = GetParentElementName(0);

            //fallback
            if (!HasDoc)
            {
                AddAspBeginExpressions(list);
                string aspPrefix = "asp:";
                var    type      = ReflectionHelper.ParseReflectionName("System.Web.UI.Control").Resolve(TypeSystemService.GetCompilation(project));
                foreach (var cls in WebTypeContext.ListSystemControlClasses(type, project))
                {
                    list.Add(new AspTagCompletionData(aspPrefix, cls));
                }

                base.GetElementCompletions(list);
                return;
            }

            IType controlClass = null;

            if (parentName.HasPrefix)
            {
                controlClass = refman.GetControlType(parentName.Prefix, parentName.Name);
            }
            else
            {
                S.XName grandparentName = GetParentElementName(1);
                if (grandparentName.IsValid && grandparentName.HasPrefix)
                {
                    controlClass = refman.GetControlType(grandparentName.Prefix, grandparentName.Name);
                }
            }

            //we're just in HTML
            if (controlClass == null)
            {
                //root element?
                if (!parentName.IsValid)
                {
                    if (aspDoc.Info.Subtype == WebSubtype.WebControl)
                    {
                        AddHtmlTagCompletionData(list, Schema, new S.XName("div"));
                        AddAspBeginExpressions(list);
                        list.AddRange(refman.GetControlCompletionData());
                        AddMiscBeginTags(list);
                    }
                    else if (!string.IsNullOrEmpty(aspDoc.Info.MasterPageFile))
                    {
                        //FIXME: add the actual region names
                        list.Add(new CompletionData("asp:Content"));
                    }
                }
                else
                {
                    AddAspBeginExpressions(list);
                    list.AddRange(refman.GetControlCompletionData());
                    base.GetElementCompletions(list);
                }
                return;
            }

            string defaultProp;
            bool   childrenAsProperties = AreChildrenAsProperties(controlClass, out defaultProp);

            if (defaultProp != null && defaultProp.Length == 0)
            {
                defaultProp = null;
            }

            //parent permits child controls directly
            if (!childrenAsProperties)
            {
                AddAspBeginExpressions(list);
                list.AddRange(refman.GetControlCompletionData());
                AddMiscBeginTags(list);
                //TODO: get correct parent for Content tags
                AddHtmlTagCompletionData(list, Schema, new S.XName("body"));
                return;
            }

            //children of properties
            if (childrenAsProperties && (!parentName.HasPrefix || defaultProp != null))
            {
                if (controlClass.GetProjectContent() == null)
                {
                    LoggingService.LogWarning("IType {0} does not have a SourceProjectDom", controlClass);
                    return;
                }

                string    propName = defaultProp ?? parentName.Name;
                IProperty property =
                    controlClass.GetProperties()
                    .Where(x => string.Compare(propName, x.Name, StringComparison.OrdinalIgnoreCase) == 0)
                    .FirstOrDefault();

                if (property == null)
                {
                    return;
                }

                //sanity checks on attributes
                switch (GetPersistenceMode(property))
                {
                case System.Web.UI.PersistenceMode.Attribute:
                case System.Web.UI.PersistenceMode.EncodedInnerDefaultProperty:
                    return;

                case System.Web.UI.PersistenceMode.InnerDefaultProperty:
                    if (!parentName.HasPrefix)
                    {
                        return;
                    }
                    break;

                case System.Web.UI.PersistenceMode.InnerProperty:
                    if (parentName.HasPrefix)
                    {
                        return;
                    }
                    break;
                }

                //check if allows freeform ASP/HTML content
                if (property.ReturnType.ToString() == "System.Web.UI.ITemplate")
                {
                    AddAspBeginExpressions(list);
                    AddMiscBeginTags(list);
                    AddHtmlTagCompletionData(list, Schema, new S.XName("body"));
                    list.AddRange(refman.GetControlCompletionData());
                    return;
                }

                //FIXME:unfortunately ASP.NET doesn't seem to have enough type information / attributes
                //to be able to resolve the correct child types here
                //so we assume it's a list and have a quick hack to find arguments of strongly typed ILists

                IType collectionType = property.ReturnType;
                if (collectionType == null)
                {
                    list.AddRange(refman.GetControlCompletionData());
                    return;
                }

                string  addStr = "Add";
                IMethod meth   = collectionType.GetMethods()
                                 .Where(m => m.Parameters.Count == 1 && m.Name == addStr).FirstOrDefault();

                if (meth != null)
                {
                    IType argType = meth.Parameters [0].Type;
                    var   type    = ReflectionHelper.ParseReflectionName("System.Web.UI.Control").Resolve(argType.GetDefinition().Compilation);
                    if (argType != null && argType.IsBaseType(type))
                    {
                        list.AddRange(refman.GetControlCompletionData(argType));
                        return;
                    }
                }

                list.AddRange(refman.GetControlCompletionData());
                return;
            }

            //properties as children of controls
            if (parentName.HasPrefix && childrenAsProperties)
            {
                if (controlClass.GetProjectContent() == null)
                {
                    LoggingService.LogWarning("IType {0} does not have a SourceProjectDom", controlClass);
                }

                foreach (IProperty prop in GetUniqueMembers <IProperty> (controlClass.GetProperties()))
                {
                    if (GetPersistenceMode(prop) != System.Web.UI.PersistenceMode.Attribute)
                    {
                        list.Add(prop.Name, prop.GetStockIcon(), AmbienceService.GetSummaryMarkup(prop));
                    }
                }
                return;
            }
        }
Beispiel #59
0
        private CompletionDataList GetCompletionList(CodeCompletionContext completionContext)
        {
            FetchCompletionData(completionContext);

            if (mCacheXML != null && mCacheXMLCurrent && mCacheIsObject)
            {
                try
                {
                    XmlDocument        xml  = mCacheXML;
                    CompletionDataList list = new CompletionDataList();

                    if (xml.HasChildNodes && xml.FirstChild.HasChildNodes)
                    {
                        string   documentation;
                        string[] lines;
                        string   name;
                        string   type;
                        string   icon;

                        switch (xml.FirstChild.Name)
                        {
                        case "list":

                            foreach (XmlElement node in xml.FirstChild.ChildNodes)
                            {
                                name = node.GetAttribute("n");
                                icon = "md-property";

                                lines = node.InnerText.Replace("\r", "").Split('\n');

                                type          = "";
                                documentation = "";

                                for (var i = 0; i < lines.Length; i++)
                                {
                                    if (i == 0)
                                    {
                                        type = lines[0];
                                    }
                                    else
                                    {
                                        documentation += "\n" + lines[i];
                                    }
                                }

                                //MonoDevelop.Ide.MessageService.ShowMessage (documentation);

                                if (type.IndexOf(":") > -1)
                                {
                                    icon = "md-method";
                                    //md-literal
                                }

                                if (documentation.IndexOf("@private") == -1)
                                {
                                    list.Add(new CompletionData(name, icon, FormatType(name, type) + FormatDocumentation(documentation)));
                                }
                            }

                            break;
                        }
                    }

                    return(list);
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }
            }

            return(null);
        }
Beispiel #60
0
        void AddAspAttributeValueCompletionData(CompletionDataList list, S.XName tagName, S.XName attName, string id)
        {
            Debug.Assert(tagName.IsValid && tagName.HasPrefix);
            Debug.Assert(attName.IsValid && !attName.HasPrefix);

            IType controlClass = HasDoc ? refman.GetControlType(tagName.Prefix, tagName.Name) : null;

            if (controlClass == null)
            {
                LoggingService.LogWarning("Could not obtain IType for {0}", tagName.FullName);

                var database = WebTypeContext.GetSystemWebDom(project);
                controlClass = ReflectionHelper.ParseReflectionName("System.Web.UI.WebControls.WebControl").Resolve(database);

                if (controlClass == null)
                {
                    LoggingService.LogWarning("Could not obtain IType for System.Web.UI.WebControls.WebControl");
                    return;
                }
            }

            //find the codebehind class
            IType        codeBehindClass;
            ICompilation projectDatabase;

            GetCodeBehind(out codeBehindClass, out projectDatabase);

            //if it's an event, suggest compatible methods
            if (codeBehindClass != null && attName.Name.StartsWith("On"))
            {
                string eventName = attName.Name.Substring(2);

                foreach (IEvent ev in controlClass.GetEvents())
                {
                    if (ev.Name == eventName)
                    {
                        var domMethod = BindingService.MDDomToCodeDomMethod(ev);
                        if (domMethod == null)
                        {
                            return;
                        }

                        foreach (IMethod meth
                                 in BindingService.GetCompatibleMethodsInClass(codeBehindClass, ev))
                        {
                            list.Add(meth.Name, "md-method",
                                     GettextCatalog.GetString("A compatible method in the CodeBehind class"));
                        }

                        string suggestedIdentifier = ev.Name;
                        if (id != null)
                        {
                            suggestedIdentifier = id + "_" + suggestedIdentifier;
                        }
                        else
                        {
                            suggestedIdentifier = tagName.Name + "_" + suggestedIdentifier;
                        }

                        domMethod.Name = BindingService.GenerateIdentifierUniqueInClass
                                             (codeBehindClass, suggestedIdentifier);
                        domMethod.Attributes = (domMethod.Attributes & ~System.CodeDom.MemberAttributes.AccessMask)
                                               | System.CodeDom.MemberAttributes.Family;

                        list.Add(
                            new SuggestedHandlerCompletionData(project, domMethod, codeBehindClass,
                                                               MonoDevelop.DesignerSupport.CodeBehind.GetNonDesignerClass(codeBehindClass))
                            );
                        return;
                    }
                }
            }

            if (projectDatabase == null)
            {
                projectDatabase = WebTypeContext.GetSystemWebDom(project);

                if (projectDatabase == null)
                {
                    LoggingService.LogWarning("Could not obtain type database in AddAspAttributeCompletionData");
                    return;
                }
            }

            //if it's a property and is an enum or bool, suggest valid values
            foreach (IProperty prop in controlClass.GetProperties())
            {
                if (prop.Name != attName.Name)
                {
                    continue;
                }

                //boolean completion
                if (prop.ReturnType.Equals(projectDatabase.FindType(KnownTypeCode.Boolean)))
                {
                    AddBooleanCompletionData(list);
                    return;
                }
                //color completion
                if (prop.ReturnType.Equals(projectDatabase.FindType(typeof(System.Drawing.Color))))
                {
                    System.Drawing.ColorConverter conv = new System.Drawing.ColorConverter();
                    foreach (System.Drawing.Color c in conv.GetStandardValues(null))
                    {
                        if (c.IsSystemColor)
                        {
                            continue;
                        }
                        string hexcol = string.Format("#{0:x2}{1:x2}{2:x2}", c.R, c.G, c.B);
                        list.Add(c.Name, hexcol);
                    }
                    return;
                }

                //enum completion
                IType retCls = prop.ReturnType;
                if (retCls != null && retCls.Kind == TypeKind.Enum)
                {
                    foreach (var enumVal in retCls.GetFields())
                    {
                        if (enumVal.IsPublic && enumVal.IsStatic)
                        {
                            list.Add(enumVal.Name, "md-literal", AmbienceService.GetSummaryMarkup(enumVal));
                        }
                    }
                    return;
                }
            }
        }