static CompletionDataList CreateCompletionList(SimpleExpansion simpleExpansion)
        {
            var list = new CompletionDataList {
                AutoSelect = false
            };

            foreach (string expansion in simpleExpansion.Expansions)
            {
                list.Add(new CompletionData(expansion));
            }

            list.AddKeyHandler(new PackageConsoleCompletionKeyHandler());

            return(list);
        }
		/// <summary>
		/// Adds CDATA and comment begin tags.
		/// </summary>
		protected static void AddMiscBeginTags (CompletionDataList list)
		{
			list.Add ("!--",  "md-literal", GettextCatalog.GetString ("Comment"));
			list.AddKeyHandler (new IgnoreDashKeyHandler ());
			list.Add ("![CDATA[", "md-literal", GettextCatalog.GetString ("Character data"));
		}
			public CompletionDataCollector (ProjectDom dom, CompletionDataList completionList, ICompilationUnit unit, IType declaringType, DomLocation location)
			{
				this.CompletionList = completionList;
				this.unit = unit;
				this.dom = dom;
				this.FullyQualify = false;
//				this.location = location;
				this.declaringType = declaringType;
				completionList.AddKeyHandler (new NegateKeyHandler ());
				// Get a list of all namespaces in scope
				if (unit != null) {
					foreach (IUsing u in unit.Usings) {
						if (!u.IsFromNamespace || u.Region.Contains (location)) {
							foreach (string ns in u.Namespaces)
								namespacesInScope.Add (ns);
						}
					}
				}
			}
Beispiel #4
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 #5
0
 /// <summary>
 /// Adds CDATA and comment begin tags.
 /// </summary>
 protected static void AddMiscBeginTags(CompletionDataList list)
 {
     list.Add(new BaseXmlCompletionData("!--", "md-literal", GettextCatalog.GetString("Comment")));
     list.AddKeyHandler(new IgnoreDashKeyHandler());
     list.Add(new BaseXmlCompletionData("![CDATA[", "md-literal", GettextCatalog.GetString("Character data")));
 }
        public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char triggerChar, ref int triggerWordLength)
        {
            if (!EnableCodeCompletion)
                return null;
            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 == '"') // 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.AutoSelect = l.AutoCompleteEmptyMatch = false;
            }
            else
                l.AddKeyHandler(new DoubleUnderScoreWorkaroundHandler());

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

            return l.Count != 0 ? l : null;
        }
        public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char triggerChar, ref int triggerWordLength)
        {
            if (!currentWrapperNullfied && workaround_currentWrapper != null)
            {
                workaround_currentWrapper.SetValue(document, null);
                currentWrapperNullfied = true;
            }

            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 ast = Document.GetDAst();

            if (ast == 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));
            }

            try{
                lock (ast)
                    DCodeCompletionSupport.BuildCompletionData(
                        Document,
                        ast,
                        completionContext,
                        l,
                        triggerChar);
            }catch (System.Exception ex) {
                LoggingService.LogWarning("Error during completion", ex);
            }

            return(l.Count != 0 ? l : null);
        }
		public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char triggerChar, ref int triggerWordLength)
		{
			if (!currentWrapperNullfied && workaround_currentWrapper != null)
			{
				workaround_currentWrapper.SetValue(document, null);
				currentWrapperNullfied = true;
			}

			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 ast = Document.GetDAst();
			if (ast == 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));

			try{
			lock(ast)
				DCodeCompletionSupport.BuildCompletionData(
					Document,
					ast,
					completionContext,
					l,
					triggerChar);
			}catch(System.Exception ex) {
				LoggingService.LogWarning ("Error during completion", ex);
			}

			return l.Count != 0 ? l : null;
		}