Пример #1
0
        public void Populate(IEditorData data)
        {
            m_data = data;

            if (data == null)
            {
                m_value = null;
                return;
            }

            m_populating = true;
            PopulateList();

            object attr = data.GetAttribute(m_definition.Attribute);
            IEditableObjectReference value = attr as IEditableObjectReference;

            if (value == null)
            {
                lstDropdown.Text = string.Empty;
                lstDropdown.IsEnabled = (attr == null);
            }
            else
            {
                lstDropdown.SelectedItem = value.Reference;
                lstDropdown.IsEnabled = !data.ReadOnly;
            }

            m_value = value;

            m_populating = false;
        }
Пример #2
0
		/// <summary>
		/// Generates the completion data.
		/// </summary>
		/// <param name="alreadyCheckedCompletionContext">Set to <c>false</c> if you already ensured that completion can occur in the current editing context.</param>
		public static bool GenerateCompletionData(IEditorData editor, 
			ICompletionDataGenerator completionDataGen, char triggerChar, bool alreadyCheckedCompletionContext = false)
		{
			if(!alreadyCheckedCompletionContext && !IsCompletionAllowed(editor, triggerChar))
				return false;

			IBlockNode _b = null;
			bool inNonCode;

			var sr = FindCurrentCaretContext(editor, ref _b, out inNonCode);

			if (inNonCode)
				return false;

			if (_b == null || editor.CaretLocation > _b.EndLocation) {
				_b = editor.SyntaxTree;
			}

			var complVis = new CompletionProviderVisitor (completionDataGen, editor, triggerChar) { scopedBlock = _b };
			if (sr is INode)
				(sr as INode).Accept (complVis);
			else if (sr is IStatement)
				(sr as IStatement).Accept (complVis);
			else if (sr is IExpression)
				(sr as IExpression).Accept (complVis);

			if (complVis.GeneratedProvider == null)
				return false;

			complVis.GeneratedProvider.BuildCompletionData(editor, triggerChar);

			return true;
		}
Пример #3
0
        public static AbstractTooltipContent[] BuildToolTip(IEditorData Editor)
        {
            try
            {
                var ctxt = ResolverContextStack.Create(Editor);
                // In the case we've got a method or something, don't return its base type, only the reference to it
                ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.ReturnMethodReferencesOnly;
                var rr = DResolver.ResolveType(Editor, ctxt, DResolver.AstReparseOptions.AlsoParseBeyondCaret);

                if (rr.Length < 1)
                {
                    return(null);
                }

                var l = new List <AbstractTooltipContent>(rr.Length);
                foreach (var res in rr)
                {
                    l.Add(BuildTooltipContent(res));
                }

                return(l.ToArray());
            }
            catch { }
            return(null);
        }
        protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
        {
            if (Editor.ParseCache == null)
            {
                return;
            }

            var module = Editor.ParseCache.LookupModuleName(import.ModuleIdentifier.ToString(true)).FirstOrDefault();

            if (module == null)
            {
                return;
            }

            var ctxt = ResolutionContext.Create(Editor, true);

            /*
             * Show all members of the imported module
             * + public imports
             * + items of anonymous enums
             */

            MemberCompletionEnumeration.EnumChildren(CompletionDataGenerator, ctxt, module, true, MemberFilter.All, true);

            return;
        }
        protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
        {
            var dc = begunNode.Parent as DClassLike;

            if (dc == null || dc.ClassType != DTokens.Class)
                return;

            var classType = DResolver.ResolveClassOrInterface(dc, ResolutionContext.Create(Editor), null) as TemplateIntermediateType;

            if (classType == null)
                return;

            var typesToScan = new List<TemplateIntermediateType>();
            IterateThroughBaseClassesInterfaces(typesToScan, classType);

            foreach (var t in typesToScan)
            {
                foreach (var n in t.Definition)
                {
                    var dm = n as DMethod;
                    if (dm == null ||
                        dm.ContainsAttribute(DTokens.Final, DTokens.Private, DTokens.Static))
                        continue; //TODO: Other attributes?

                    CompletionDataGenerator.AddCodeGeneratingNodeItem(dm, GenerateOverridingMethodStub(dm, begunNode, !(t is InterfaceType)));
                }
            }
        }
Пример #6
0
		static bool IsCompletionAllowed(IEditorData Editor, char enteredChar)
		{/*'debug(', 'version(', 'pragma(' etc. shall trigger, but not 'foo('
			if (enteredChar == '(')
				return false;
			*/
			if (Editor.CaretOffset > 0)
			{
				if (Editor.CaretLocation.Line == 1 && Editor.ModuleCode.Length > 0 && Editor.ModuleCode[0] == '#')
					return false;

				if (enteredChar == '.' || enteredChar == '_')
				{
					// Don't complete on a double/multi-dot
					if (Editor.CaretOffset > 1 && Editor.ModuleCode[Editor.CaretOffset - 2] == enteredChar) 
						// ISSUE: When a dot was typed, off-1 is the dot position, 
						// if a letter was typed, off-1 is the char before the typed letter..
						return false;
				}
				// If typing a begun identifier, return immediately
				else if ((Lexer.IsIdentifierPart(enteredChar) || enteredChar == '\0') &&
					Lexer.IsIdentifierPart(Editor.ModuleCode[Editor.CaretOffset - 1]))
					return false;
			}

			return true;
		}
Пример #7
0
        public static AbstractType[] ResolveType(IEditorData editor, AstReparseOptions Options = AstReparseOptions.AlsoParseBeyondCaret, ResolutionContext ctxt = null)
        {
            if (ctxt == null)
            {
                ctxt = ResolutionContext.Create(editor);
            }

            var o = GetScopedCodeObject(editor, Options, ctxt);

            var optionBackup = ctxt.CurrentContext.ContextDependentOptions;

            ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.ReturnMethodReferencesOnly;

            AbstractType[] ret;

            if (o is IExpression)
            {
                ret = Evaluation.EvaluateTypes((IExpression)o, ctxt);
            }
            else if (o is ITypeDeclaration)
            {
                ret = TypeDeclarationResolver.Resolve((ITypeDeclaration)o, ctxt);
            }
            else
            {
                ret = null;
            }

            ctxt.CurrentContext.ContextDependentOptions = optionBackup;

            return(ret);
        }
Пример #8
0
		public static bool IsCompletionAllowed(IEditorData Editor, char enteredChar)
		{
			if (Editor.CaretOffset > 0)
			{
				if (Editor.CaretLocation.Line == 1 && Editor.ModuleCode.Length > 0 && Editor.ModuleCode[0] == '#')
					return false;

				if (enteredChar == '.' || enteredChar == '_')
				{
					// Don't complete on a double/multi-dot
					if (Editor.CaretOffset > 1 && Editor.ModuleCode[Editor.CaretOffset - 2] == enteredChar) 
						// ISSUE: When a dot was typed, off-1 is the dot position, 
						// if a letter was typed, off-1 is the char before the typed letter..
						return false;
				}
				// If typing a begun identifier, return immediately
				else if ((DTokens.IsIdentifierChar(enteredChar) || enteredChar == '\0') &&
					DTokens.IsIdentifierChar(Editor.ModuleCode[Editor.CaretOffset - 1]))
					return false;

				return !CaretContextAnalyzer.IsInCommentAreaOrString(Editor.ModuleCode, Editor.CaretOffset);
			}

			return true;
		}
        public void Populate(IEditorData data)
        {
            m_data = data;

            if (data == null)
            {
                m_value = null;
                return;
            }

            m_populating = true;
            PopulateList();

            object attr = data.GetAttribute(m_definition.Attribute);
            IEditableObjectReference value = attr as IEditableObjectReference;

            if (value == null)
            {
                lstDropdown.Text      = string.Empty;
                lstDropdown.IsEnabled = (attr == null);
            }
            else
            {
                lstDropdown.SelectedItem = value.Reference;
                lstDropdown.IsEnabled    = !data.ReadOnly;
            }

            m_value = value;

            m_populating = false;
        }
Пример #10
0
        public void Populate(IEditorData data)
        {
            m_data = data;

            IEnumerable<string> elements = null;
            if (m_elementType == "object")
            {
                string parent = m_data == null ? null : m_data.Name;
                if (parent == "game") parent = null;
                elements = Controller.GetObjectNames(m_objectType, false, parent, true);
            }
            else
            {
                elements = Controller.GetElementNames(m_elementType, false);
            }

            Dictionary<string, string> listItems = new Dictionary<string, string>();

            foreach (var element in elements.Where(e => Filter(e)))
            {
                listItems.Add(element, Controller.GetDisplayName(element));
            }

            ctlListEditor.UpdateList(listItems);
        }
Пример #11
0
        static string GetSelectedSymbolRoot(IEditorData edData)
        {
            var o = DResolver.GetScopedCodeObject(edData,null, DResolver.AstReparseOptions.AlsoParseBeyondCaret);

            if (o is ITypeDeclaration)
            {
                var rootType = ((ITypeDeclaration)o).InnerMost;

                if (rootType is IdentifierDeclaration)
                    return ((IdentifierDeclaration)rootType).Id;
                else if (rootType is TemplateInstanceExpression)
                    return ((TemplateInstanceExpression)rootType).TemplateIdentifier.Id;
            }
            else if (o is IExpression)
            {
                var curEx = (IExpression)o;

                while (curEx is PostfixExpression)
                    curEx = ((PostfixExpression)curEx).PostfixForeExpression;

                if (curEx is IdentifierExpression)
                    return ((IdentifierExpression)curEx).Value as string;
                else if (curEx is TemplateInstanceExpression)
                    return ((TemplateInstanceExpression)curEx).TemplateIdentifier.Id;
            }
            return null;
        }
Пример #12
0
 public void Populate(IEditorData data)
 {
     if (data == null) return;
     m_helper.StartPopulating();
     textBox.Text = m_helper.Populate(data);
     m_helper.FinishedPopulating();
 }
		protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
		{
			if(Editor.ParseCache == null)
				return;

			string pack = null;

			if (imp.ModuleIdentifier != null && imp.ModuleIdentifier.InnerDeclaration != null)
			{
				pack = imp.ModuleIdentifier.InnerDeclaration.ToString();

				// Will occur after an initial dot  
				if (string.IsNullOrEmpty(pack))
					return;
			}

			foreach (var p in Editor.ParseCache.LookupPackage(Editor.SyntaxTree, pack))
			{
				if (p == null)
					continue;

				foreach (var kv_pack in p.Packages)
					CompletionDataGenerator.AddPackage(kv_pack.Value.Name);

				foreach (var kv_mod in p.Modules)
					CompletionDataGenerator.AddModule(kv_mod.Value);
			}
		}
Пример #14
0
 protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
 {
     foreach (var kv in new Dictionary<string, string>{
         {"isArithmetic","If the arguments are all either types that are arithmetic types, or expressions that are typed as arithmetic types, then true is returned. Otherwise, false is returned. If there are no arguments, false is returned."},
         {"isFloating","Works like isArithmetic, except it's for floating point types (including imaginary and complex types)."},
         {"isIntegral","Works like isArithmetic, except it's for integral types (including character types)."},
         {"isScalar","Works like isArithmetic, except it's for scalar types."},
         {"isUnsigned","Works like isArithmetic, except it's for unsigned types."},
         {"isStaticArray","Works like isArithmetic, except it's for static array types."},
         {"isAssociativeArray","Works like isArithmetic, except it's for associative array types."},
         {"isAbstractClass","If the arguments are all either types that are abstract classes, or expressions that are typed as abstract classes, then true is returned. Otherwise, false is returned. If there are no arguments, false is returned."},
         {"isFinalClass","Works like isAbstractClass, except it's for final classes."},
         {"isVirtualFunction","The same as isVirtualMethod, except that final functions that don't override anything return true."},
         {"isVirtualMethod","Takes one argument. If that argument is a virtual function, true is returned, otherwise false. Final functions that don't override anything return false."},
         {"isAbstractFunction","Takes one argument. If that argument is an abstract function, true is returned, otherwise false."},
         {"isFinalFunction","Takes one argument. If that argument is a final function, true is returned, otherwise false."},
         {"isStaticFunction","Takes one argument. If that argument is a static function, meaning it has no context pointer, true is returned, otherwise false."},
         {"isRef","Takes one argument. If that argument is a declaration, true is returned if it is ref, otherwise false."},
         {"isOut","Takes one argument. If that argument is a declaration, true is returned if it is out, otherwise false."},
         {"isLazy","Takes one argument. If that argument is a declaration, true is returned if it is lazy, otherwise false."},
         {"hasMember","The first argument is a type that has members, or is an expression of a type that has members. The second argument is a string. If the string is a valid property of the type, true is returned, otherwise false."},
         {"identifier","Takes one argument, a symbol. Returns the identifier for that symbol as a string literal."},
         {"getMember","Takes two arguments, the second must be a string. The result is an expression formed from the first argument, followed by a ‘.’, followed by the second argument as an identifier."},
         {"getOverloads","The first argument is a class type or an expression of class type. The second argument is a string that matches the name of one of the functions of that class. The result is a tuple of all the overloads of that function."},
         {"getVirtualFunctions","The same as getVirtualMethods, except that final functions that do not override anything are included."},
         {"getVirtualMethods","The first argument is a class type or an expression of class type. The second argument is a string that matches the name of one of the functions of that class. The result is a tuple of the virtual overloads of that function. It does not include final functions that do not override anything."},
         {"parent","Takes a single argument which must evaluate to a symbol. The result is the symbol that is the parent of it."},
         {"classInstanceSize","Takes a single argument, which must evaluate to either a class type or an expression of class type. The result is of type size_t, and the value is the number of bytes in the runtime instance of the class type. It is based on the static type of a class, not the polymorphic type."},
         {"allMembers","Takes a single argument, which must evaluate to either a type or an expression of type. A tuple of string literals is returned, each of which is the name of a member of that type combined with all of the members of the base classes (if the type is a class). No name is repeated. Builtin properties are not included."},
         {"derivedMembers","Takes a single argument, which must evaluate to either a type or an expression of type. A tuple of string literals is returned, each of which is the name of a member of that type. No name is repeated. Base class member names are not included. Builtin properties are not included."},
         {"isSame","Takes two arguments and returns bool true if they are the same symbol, false if not."},
         {"compiles",@"Returns a bool true if all of the arguments compile (are semantically correct). The arguments can be symbols, types, or expressions that are syntactically correct. The arguments cannot be statements or declarations. If there are no arguments, the result is false."},
     })
         CompletionDataGenerator.AddTextItem(kv.Key, kv.Value);
 }
Пример #15
0
        public string GetDefaultFilterName(string filterGroupName, IEditorData data)
        {
            FilterGroup   filterGroup = m_filterGroups[filterGroupName];
            List <Filter> candidates  = new List <Filter>();

            foreach (Filter filter in filterGroup.Filters.Values)
            {
                foreach (string attribute in filter.Attributes)
                {
                    if (data.GetAttribute(attribute) != null)
                    {
                        candidates.Add(filter);
                        break;
                    }
                }
            }

            // If there is only one candidate then we have our result
            if (candidates.Count == 1)
            {
                return(candidates[0].Name);
            }

            // Otherwise just default to the first filter
            return(filterGroup.Filters.First().Value.Name);
        }
Пример #16
0
 public void Populate(IEditorData data)
 {
     if (data == null)
     {
         return;
     }
     m_helper.StartPopulating();
     if (m_dictionary != null)
     {
         string value = m_helper.Populate(data) ?? string.Empty;
         string dropdownValue;
         if (m_dictionary.TryGetValue(value, out dropdownValue))
         {
             lstDropdown.Text = dropdownValue;
         }
         else
         {
             if (lstDropdown.IsEditable)
             {
                 lstDropdown.Text = value;
             }
             else
             {
                 lstDropdown.Text = string.Empty;
             }
         }
     }
     else
     {
         lstDropdown.Text = m_helper.Populate(data);
     }
     lstDropdown.IsEnabled = m_helper.CanEdit(data) && !data.ReadOnly;
     m_helper.FinishedPopulating();
 }
Пример #17
0
        public static ISyntaxRegion FindCurrentCaretContext(IEditorData editor, 
			ref IBlockNode currentScope, 
			out IStatement currentStatement,
			out bool isInsideNonCodeSegment)
        {
            isInsideNonCodeSegment = false;
            currentStatement = null;

            if(currentScope == null)
                currentScope = DResolver.SearchBlockAt (editor.SyntaxTree, editor.CaretLocation, out currentStatement);

            if (currentScope == null)
                return null;

            BlockStatement blockStmt;
            // Always skip lambdas as they're too quirky for accurate scope calculation // ISSUE: May be other anon symbols too?
            var dm = currentScope as DMethod;
            if (dm != null && (dm.SpecialType & DMethod.MethodType.Lambda) != 0)
                currentScope = dm.Parent as IBlockNode;

            if (currentScope is DMethod &&
                (blockStmt = (currentScope as DMethod).GetSubBlockAt (editor.CaretLocation)) != null) {
                blockStmt.UpdateBlockPartly (editor, out isInsideNonCodeSegment);
                currentScope = DResolver.SearchBlockAt (currentScope, editor.CaretLocation, out currentStatement);
            }else {
                while (currentScope is DMethod)
                    currentScope = currentScope.Parent as IBlockNode;
                if (currentScope == null)
                    return null;

                (currentScope as DBlockNode).UpdateBlockPartly (editor, out isInsideNonCodeSegment);
                currentScope = DResolver.SearchBlockAt (currentScope, editor.CaretLocation, out currentStatement);
            }
            return currentScope;
        }
		protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
		{
			var visibleMembers = MemberFilter.All;

			if(!GetVisibleMemberFilter(Editor, enteredChar, ref visibleMembers, ref curStmt))
				return;

			MemberCompletionEnumeration.EnumAllAvailableMembers(
					CompletionDataGenerator,
					curBlock,
					curStmt,
					Editor.CaretLocation,
					Editor.ParseCache,
					visibleMembers,
					new ConditionalCompilationFlags(Editor));

			//TODO: Split the keywords into such that are allowed within block statements and non-block statements
			// Insert typable keywords
			if (visibleMembers.HasFlag(MemberFilter.Keywords))
				foreach (var kv in DTokens.Keywords)
					CompletionDataGenerator.Add(kv.Key);

			else if (visibleMembers.HasFlag(MemberFilter.StructsAndUnions))
				foreach (var kv in DTokens.BasicTypes_Array)
					CompletionDataGenerator.Add(kv);
		}
Пример #19
0
 public void Populate(IEditorData data)
 {
     if (data == null) return;
     m_helper.StartPopulating();
     if (m_dictionary != null)
     {
         string value = m_helper.Populate(data) ?? string.Empty;
         string dropdownValue;
         if (m_dictionary.TryGetValue(value, out dropdownValue))
         {
             lstDropdown.Text = dropdownValue;
         }
         else
         {
             if (lstDropdown.IsEditable)
             {
                 lstDropdown.Text = value;
             }
             else
             {
                 lstDropdown.Text = string.Empty;
             }
         }
     }
     else
     {
         lstDropdown.Text = m_helper.Populate(data);
     }
     lstDropdown.IsEnabled = m_helper.CanEdit(data) && !data.ReadOnly;
     m_helper.FinishedPopulating();
 }
Пример #20
0
        protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
        {
            ed   = Editor;
            ctxt = ResolutionContext.Create(Editor, false);

            AbstractType t = null;

            CodeCompletion.DoTimeoutableCompletionTask(CompletionDataGenerator, ctxt, () =>
            {
                ctxt.Push(Editor);
                if (AccessExpression is IExpression)
                {
                    t = ExpressionTypeEvaluation.EvaluateType(AccessExpression as IExpression, ctxt);
                }
                else if (AccessExpression is ITypeDeclaration)
                {
                    t = TypeDeclarationResolver.ResolveSingle(AccessExpression as ITypeDeclaration, ctxt);
                }
            });

            if (t == null)             //TODO: Add after-space list creation when an unbound . (Dot) was entered which means to access the global scope
            {
                return;
            }

            t.Accept(this);
        }
		protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
		{
			ed = Editor;
			ctxt = ResolutionContext.Create(Editor, false);

			AbstractType t = null;
			CodeCompletion.DoTimeoutableCompletionTask(CompletionDataGenerator,ctxt,() =>
			{
				try
				{
					ctxt.Push(Editor);
					if (AccessExpression is IExpression)
						t = ExpressionTypeEvaluation.EvaluateType(AccessExpression as IExpression, ctxt);
					else if (AccessExpression is ITypeDeclaration)
						t = TypeDeclarationResolver.ResolveSingle(AccessExpression as ITypeDeclaration, ctxt);
				}catch(Exception ex)
				{
					Logger.LogWarn("Error during member completion", ex);
				}
			});

			if (t == null) //TODO: Add after-space list creation when an unbound . (Dot) was entered which means to access the global scope
				return;

			t.Accept(this);
		}
Пример #22
0
 protected override void BuildCompletionDataInternal(IEditorData ed, char enteredChar)
 {
     foreach (var v in completionItemData)
     {
         CompletionDataGenerator.AddIconItem(v.IconID, v.DisplayName, v.Description);
     }
 }
		public CompletionProviderVisitor(ICompletionDataGenerator cdg, IEditorData ed, char enteredChar = '\0')
		{
			this.ed = ed;
			this.cdgen = cdg;
			this.triggerChar = enteredChar;
			this.shownKeywords.Push(BlockMemberFilter);
		}
Пример #24
0
        protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
        {
            var dc = begunNode.Parent as DClassLike;

            if (dc == null || dc.ClassType != DTokens.Class)
            {
                return;
            }

            var classType = DResolver.ResolveClassOrInterface(dc, ResolutionContext.Create(Editor), null) as TemplateIntermediateType;

            if (classType == null)
            {
                return;
            }

            var typesToScan = new List <TemplateIntermediateType>();

            IterateThroughBaseClassesInterfaces(typesToScan, classType);

            foreach (var t in typesToScan)
            {
                foreach (var n in t.Definition)
                {
                    var dm = n as DMethod;
                    if (dm == null ||
                        dm.ContainsAttribute(DTokens.Final, DTokens.Private, DTokens.Static))
                    {
                        continue;                         //TODO: Other attributes?
                    }
                    CompletionDataGenerator.AddCodeGeneratingNodeItem(dm, GenerateOverridingMethodStub(dm, begunNode, !(t is InterfaceType)));
                }
            }
        }
Пример #25
0
        public void Populate(IEditorData data)
        {
            m_readOnly = data != null && data.ReadOnly;
            cmdAdd.Enabled = !m_readOnly;
            cmdAddType.Enabled = !m_readOnly;

            lstAttributes.Items.Clear();
            lstTypes.Items.Clear();
            m_inheritedTypeData.Clear();
            ClearListenedToAttributes();
            cmdDelete.Enabled = false;
            cmdOnChange.Enabled = false;
            cmdDeleteType.Enabled = false;
            ctlMultiControl.Visible = false;
            m_data = (IEditorDataExtendedAttributeInfo)data;

            if (data != null)
            {
                foreach (var type in m_data.GetInheritedTypes())
                {
                    m_inheritedTypeData.Add(type.AttributeName, type);
                    AddListItem(lstTypes, type, GetTypeDisplayString);
                }

                foreach (var attr in m_data.GetAttributeData())
                {
                    if (CanDisplayAttribute(attr.AttributeName, m_data.GetAttribute(attr.AttributeName), attr.Source != m_data.Name))
                    {
                        AddListItem(lstAttributes, attr, GetAttributeDisplayString);
                        ListenToAttribute(attr);
                    }
                }
            }
        }
Пример #26
0
        protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
        {
            var ctxt             = ResolutionContext.Create(Editor, true);
            var resolvedVariable = TypeDeclarationResolver.HandleNodeMatch(initedVar, ctxt) as DSymbol;

            if (resolvedVariable == null)
            {
                return;
            }

            while (resolvedVariable is TemplateParameterSymbol)
            {
                resolvedVariable = resolvedVariable.Base as DSymbol;
            }

            var structType = resolvedVariable.Base as TemplateIntermediateType;

            if (structType == null)
            {
                return;
            }

            var alreadyTakenNames = new List <int>();

            foreach (var m in init.MemberInitializers)
            {
                alreadyTakenNames.Add(m.MemberNameHash);
            }

            new StructVis(structType, alreadyTakenNames, CompletionDataGenerator, ctxt);
        }
Пример #27
0
        protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
        {
            var ctxt = ResolutionContext.Create(Editor, false);

            foreach (var kv in VersionCompletionItems)
            {
                CompletionDataGenerator.AddTextItem(kv.Key, kv.Value);
            }

            CodeCompletion.DoTimeoutableCompletionTask(CompletionDataGenerator, ctxt, () => {
                ctxt.Push(Editor);
                var cs = ctxt.CurrentContext.DeclarationCondititons;
                foreach (var v in cs.GlobalFlags.Versions)
                {
                    if (!VersionCompletionItems.ContainsKey(v))
                    {
                        CompletionDataGenerator.AddTextItem(v, "");
                    }
                }
                foreach (var v in cs.LocalFlags.Versions)
                {
                    if (!VersionCompletionItems.ContainsKey(v))
                    {
                        CompletionDataGenerator.AddTextItem(v, "");
                    }
                }
            });
        }
Пример #28
0
 public CompletionProviderVisitor(ICompletionDataGenerator cdg, IEditorData ed, char enteredChar = '\0')
 {
     this.ed          = ed;
     this.cdgen       = cdg;
     this.triggerChar = enteredChar;
     this.shownKeywords.Push(BlockMemberFilter);
 }
Пример #29
0
 protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
 {
     foreach (var kv in TraitsExpressionCompletionItems)
     {
         CompletionDataGenerator.AddTextItem(kv.Key, kv.Value);
     }
 }
Пример #30
0
        public void Populate(IEditorData data)
        {
            m_data = data;

            IEnumerable <string> elements = null;

            if (m_elementType == "object")
            {
                string parent = m_data == null ? null : m_data.Name;
                if (parent == "game")
                {
                    parent = null;
                }
                elements = Controller.GetObjectNames(m_objectType, false, parent, true);
            }
            else
            {
                elements = Controller.GetElementNames(m_elementType, false);
            }

            Dictionary <string, string> listItems = new Dictionary <string, string>();

            foreach (var element in elements.Where(e => Filter(e)))
            {
                listItems.Add(element, Controller.GetDisplayName(element));
            }

            ctlListEditor.UpdateList(listItems);
        }
Пример #31
0
        static bool IsCompletionAllowed(IEditorData Editor, char enteredChar)
        {
            if (enteredChar == '(')
            {
                return(false);
            }

            if (Editor.CaretOffset > 0)
            {
                if (Editor.CaretLocation.Line == 1 && Editor.ModuleCode.Length > 0 && Editor.ModuleCode[0] == '#')
                {
                    return(false);
                }

                if (enteredChar == '.' || enteredChar == '_')
                {
                    // Don't complete on a double/multi-dot
                    if (Editor.CaretOffset > 1 && Editor.ModuleCode[Editor.CaretOffset - 2] == enteredChar)
                    {
                        // ISSUE: When a dot was typed, off-1 is the dot position,
                        // if a letter was typed, off-1 is the char before the typed letter..
                        return(false);
                    }
                }
                // If typing a begun identifier, return immediately
                else if ((Lexer.IsIdentifierPart(enteredChar) || enteredChar == '\0') &&
                         Lexer.IsIdentifierPart(Editor.ModuleCode[Editor.CaretOffset - 1]))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #32
0
 private ParameterInsightResolution(IEditorData ed, ResolutionContext c, ArgumentsResolutionResult r, IBlockNode cs)
 {
     Editor   = ed;
     ctxt     = c;
     res      = r;
     curScope = cs;
 }
Пример #33
0
        public void Populate(IEditorData data)
        {
            m_readOnly         = data != null && data.ReadOnly;
            cmdAdd.Enabled     = !m_readOnly;
            cmdAddType.Enabled = !m_readOnly;

            lstAttributes.Items.Clear();
            lstTypes.Items.Clear();
            m_inheritedTypeData.Clear();
            ClearListenedToAttributes();
            cmdDelete.Enabled       = false;
            cmdOnChange.Enabled     = false;
            cmdDeleteType.Enabled   = false;
            ctlMultiControl.Visible = false;
            m_data = (IEditorDataExtendedAttributeInfo)data;

            if (data != null)
            {
                foreach (var type in m_data.GetInheritedTypes())
                {
                    m_inheritedTypeData.Add(type.AttributeName, type);
                    AddListItem(lstTypes, type, GetTypeDisplayString);
                }

                foreach (var attr in m_data.GetAttributeData())
                {
                    if (CanDisplayAttribute(attr.AttributeName, m_data.GetAttribute(attr.AttributeName), attr.Source != m_data.Name))
                    {
                        AddListItem(lstAttributes, attr, GetAttributeDisplayString);
                        ListenToAttribute(attr);
                    }
                }
            }
        }
Пример #34
0
 protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
 {
     if (Attribute is VersionCondition)
     {
         foreach (var kv in VersionCompletionItems)
         {
             CompletionDataGenerator.AddTextItem(kv.Key, kv.Value);
         }
     }
     else if (Attribute is PragmaAttribute)
     {
         var p = Attribute as PragmaAttribute;
         if (string.IsNullOrEmpty(p.Identifier))
         {
             foreach (var kv in PragmaAttributeCompletionItems)
             {
                 CompletionDataGenerator.AddTextItem(kv.Key, kv.Value);
             }
         }
     }
     else if (Attribute is Modifier && ((Modifier)Attribute).Token == DTokens.Extern)
     {
         foreach (var kv in ExternAttributeCompletionItems)
         {
             CompletionDataGenerator.AddTextItem(kv.Key, kv.Value);
         }
     }
 }
Пример #35
0
        public static TestCompletionDataGen TestCompletionListContents(IEditorData ed, INode[] itemWhiteList = null, INode[] itemBlackList = null, char trigger = '\0')
        {
            var gen = new TestCompletionDataGen (itemWhiteList, itemBlackList);
            Assert.That (CodeCompletion.GenerateCompletionData (ed, gen, trigger), Is.True);

            Assert.That (gen.HasRemainingItems, Is.False, "Some items were not enlisted!");
            return gen;
        }
Пример #36
0
 protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
 {
     foreach (var kv in new Dictionary<string, string>{
         {"exit","Executes on leaving current scope"},
         {"success", "Executes if no error occurred in current scope"},
         {"failure","Executes if error occurred in current scope"}})
         CompletionDataGenerator.AddTextItem(kv.Key, kv.Value);
 }
Пример #37
0
        public static ResolutionContext Create(IEditorData editor, ConditionalCompilationFlags globalConditions = null)
        {
            IStatement stmt;

            return(new ResolutionContext(editor.ParseCache, globalConditions ?? new ConditionalCompilationFlags(editor),
                                         DResolver.SearchBlockAt(editor.SyntaxTree, editor.CaretLocation, out stmt) ?? editor.SyntaxTree,
                                         stmt));
        }
Пример #38
0
 public void Uninitialise()
 {
     m_controller.ElementsUpdated -= m_controller_ElementsUpdated;
     m_controller.ElementMoved -= m_controller_ElementMoved;
     m_controller = null;
     m_controlData = null;
     m_data = null;
 }
Пример #39
0
 public void ApplyFrom(IEditorData data)
 {
     ModuleCode    = data.ModuleCode;
     CaretLocation = data.CaretLocation;
     CaretOffset   = data.CaretOffset;
     SyntaxTree    = data.SyntaxTree;
     ParseCache    = data.ParseCache;
 }
Пример #40
0
 public void Populate(IEditorData data)
 {
     if (data == null) return;
     m_helper.StartPopulating();
     checkBox.IsChecked = m_helper.Populate(data);
     checkBox.IsEnabled = !data.ReadOnly && m_helper.CanEdit(data);
     m_helper.FinishedPopulating();
 }
Пример #41
0
 public void Uninitialise()
 {
     m_controller.ElementsUpdated -= m_controller_ElementsUpdated;
     m_controller.ElementMoved    -= m_controller_ElementMoved;
     m_controller  = null;
     m_controlData = null;
     m_data        = null;
 }
Пример #42
0
 public void ApplyFrom(IEditorData data)
 {
     ModuleCode = data.ModuleCode;
     CaretLocation = data.CaretLocation;
     CaretOffset = data.CaretOffset;
     SyntaxTree = data.SyntaxTree;
     ParseCache = data.ParseCache;
 }
Пример #43
0
        private static SelectionRange FindIdealSelectionRange(IEditorData editor)
        {
            var vis = new IdealSelectionVisitor(editor.CaretLocation);

            editor.SyntaxTree.Accept(vis);

            return(vis.narrowestSelectionRange);
        }
Пример #44
0
        public static AbstractType[] ResolveTypeLoosely(IEditorData editor, out NodeResolutionAttempt resolutionAttempt, ResolutionContext ctxt = null)
        {
            if (ctxt == null)
            {
                ctxt = ResolutionContext.Create(editor);
            }

            var o = GetScopedCodeObject(editor, ctxt: ctxt);

            var optionBackup = ctxt.CurrentContext.ContextDependentOptions;

            ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.ReturnMethodReferencesOnly;
            resolutionAttempt = NodeResolutionAttempt.Normal;

            AbstractType[] ret;

            if (o is IExpression)
            {
                ret = Evaluation.EvaluateTypes((IExpression)o, ctxt);
            }
            else if (o is ITypeDeclaration)
            {
                ret = TypeDeclarationResolver.Resolve((ITypeDeclaration)o, ctxt);
            }
            else
            {
                ret = null;
            }

            if (ret == null)
            {
                resolutionAttempt = NodeResolutionAttempt.NoParameterOrTemplateDeduction;

                if (o is PostfixExpression_MethodCall)
                {
                    o = (o as PostfixExpression_MethodCall).PostfixForeExpression;
                }

                if (o is IdentifierExpression)
                {
                    ret = Evaluation.GetOverloads(o as IdentifierExpression, ctxt, false);
                }
                else if (o is ITypeDeclaration)
                {
                    ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.NoTemplateParameterDeduction;
                    ret = TypeDeclarationResolver.Resolve(o as ITypeDeclaration, ctxt);
                }
            }

            if (ret == null)
            {
                resolutionAttempt = NodeResolutionAttempt.RawSymbolLookup;
                ret = TypeDeclarationResolver.HandleNodeMatches(LookupIdRawly(editor, o as ISyntaxRegion), ctxt);
            }

            ctxt.CurrentContext.ContextDependentOptions = optionBackup;
            return(ret);
        }
Пример #45
0
 public void Populate(IEditorData data)
 {
     if (data == null)
     {
         Populate((EditableIfScript)null);
         return;
     }
     throw new NotImplementedException();
 }
Пример #46
0
 public void Populate(IEditorData data)
 {
     if (data == null) return;
     m_helper.StartPopulating();
     textBox.Text = m_helper.Populate(data);
     textBox.IsEnabled = m_helper.CanEdit(data);
     textBox.IsReadOnly = data.ReadOnly;
     m_helper.FinishedPopulating();
 }
Пример #47
0
 public void Populate(IEditorData data)
 {
     if (data == null)
     {
         Populate((EditableIfScript)null);
         return;
     }
     throw new NotImplementedException();
 }
        public static AbstractCompletionProvider BuildCompletionData(ICompletionDataGenerator dataGen, IEditorData editor, string EnteredText)
        {
            var provider = Create(dataGen, editor, EnteredText);

            if (provider != null)
                provider.BuildCompletionData(editor, EnteredText);

            return provider;
        }
Пример #49
0
        public static TestCompletionDataGen TestCompletionListContents(IEditorData ed, INode[] itemWhiteList = null, INode[] itemBlackList = null, char trigger = '\0')
        {
            var gen = new TestCompletionDataGen(itemWhiteList, itemBlackList);

            Assert.That(CodeCompletion.GenerateCompletionData(ed, gen, trigger), Is.True);

            Assert.That(gen.HasRemainingItems, Is.False, "Some items were not enlisted!");
            return(gen);
        }
Пример #50
0
        public static ISyntaxRegion FindCurrentCaretContext(IEditorData editor,
                                                            ref IBlockNode currentScope,
                                                            out bool isInsideNonCodeSegment)
        {
            isInsideNonCodeSegment = false;

            if (currentScope == null)
            {
                currentScope = DResolver.SearchBlockAt(editor.SyntaxTree, editor.CaretLocation);
            }

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

            // class asd : |
            if (currentScope is IBlockNode && (currentScope as IBlockNode).BlockStartLocation > editor.CaretLocation)
            {
                currentScope = currentScope.Parent as IBlockNode;
            }

            BlockStatement blockStmt;
            // Always skip lambdas as they're too quirky for accurate scope calculation // ISSUE: May be other anon symbols too?
            var dm = currentScope as DMethod;

            if (dm != null && (dm.SpecialType & DMethod.MethodType.Lambda) != 0)
            {
                currentScope = dm.Parent as IBlockNode;
            }

            if (currentScope is DMethod &&
                (blockStmt = (currentScope as DMethod).GetSubBlockAt(editor.CaretLocation)) != null)
            {
                var tempBlock = blockStmt.UpdateBlockPartly(editor, out isInsideNonCodeSegment);
                if (tempBlock == null)
                {
                    return(null);
                }
                currentScope = DResolver.SearchBlockAt(tempBlock, editor.CaretLocation);
            }
            else
            {
                while (currentScope is DMethod)
                {
                    currentScope = currentScope.Parent as IBlockNode;
                }
                if (currentScope == null)
                {
                    return(null);
                }

                var tempBlock = (currentScope as DBlockNode).UpdateBlockPartly(editor, out isInsideNonCodeSegment);
                currentScope = DResolver.SearchBlockAt(tempBlock, editor.CaretLocation);
            }
            return(currentScope);
        }
Пример #51
0
 public void Populate(IEditorData data)
 {
     m_data = data;
     if (data == null) return;
     m_helper.StartPopulating();
     ctlNumber.Value = m_helper.Populate(data);
     ctlNumber.IsEnabled = m_helper.CanEdit(data) && !data.ReadOnly;
     m_helper.FinishedPopulating();
 }
Пример #52
0
 protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
 {
     if (Attribute is Modifier && ((Modifier)Attribute).Token == DTokens.Extern)
     {
         foreach (var kv in ExternAttributeCompletionItems)
         {
             CompletionDataGenerator.AddTextItem(kv.Key, kv.Value);
         }
     }
 }
Пример #53
0
 protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
 {
     if (string.IsNullOrEmpty(Attribute.Identifier))
     {
         foreach (var kv in PragmaAttributeCompletionItems)
         {
             CompletionDataGenerator.AddTextItem(kv.Key, kv.Value);
         }
     }
 }
Пример #54
0
 public void Populate(IEditorData data)
 {
     m_data = data;
     if (data == null) return;
     m_helper.StartPopulating();
     fileDropDown.RefreshFileList();
     fileDropDown.Filename = m_helper.Populate(data);
     fileDropDown.Enabled = m_helper.CanEdit(data) && !data.ReadOnly;
     m_helper.FinishedPopulating();
 }
Пример #55
0
        public static ResolverContextStack Create(IEditorData editor)
        {
            IStatement stmt = null;

            return(new ResolverContextStack(editor.ParseCache, new ResolverContext
            {
                ScopedBlock = DResolver.SearchBlockAt(editor.SyntaxTree, editor.CaretLocation, out stmt),
                ScopedStatement = stmt
            }));
        }
Пример #56
0
 public void Populate(IEditorData data)
 {
     m_data = data;
     if (data == null) return;
     m_helper.StartPopulating();
     RefreshFileList();
     lstFiles.Text = m_helper.Populate(data);
     lstFiles.IsEnabled = m_helper.CanEdit(data) && !data.ReadOnly;
     m_helper.FinishedPopulating();
 }
Пример #57
0
 public void Populate(IEditorData data)
 {
     if (data == null)
     {
         return;
     }
     m_helper.StartPopulating();
     textBox.Text = m_helper.Populate(data);
     m_helper.FinishedPopulating();
 }
		protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar)
		{
			if(Editor.ParseCache == null)
				return;

			if (impBind != null)
			{
				DModule mod = null;

				var modName = imp.ModuleIdentifier.ToString (true);
				foreach (var pc in Editor.ParseCache)
					if ((mod = pc.GetModule (modName)) != null)
						break;

				if (mod == null)
					return;

				var ctxt = ResolutionContext.Create (Editor);

				/*
				 * Show all members of the imported module
				 * + public imports 
				 * + items of anonymous enums
				 */

				MemberCompletionEnumeration.EnumChildren(CompletionDataGenerator, ctxt, mod, true, MemberFilter.All);

				return;
			}


			string pack = null;

			if (imp.ModuleIdentifier != null && imp.ModuleIdentifier.InnerDeclaration != null)
			{
				pack = imp.ModuleIdentifier.InnerDeclaration.ToString();

				// Will occur after an initial dot  
				if (string.IsNullOrEmpty(pack))
					return;
			}

			foreach (var p in Editor.ParseCache.LookupPackage(pack))
			{
				if (p == null)
					continue;

				foreach (var kv_pack in p.Packages)
					CompletionDataGenerator.AddPackage(kv_pack.Value.Name);

				foreach (var kv_mod in p.Modules)
					CompletionDataGenerator.AddModule(kv_mod.Value);
			}
		}
Пример #59
0
        public ExpressionTemplateEditorData(string expression, EditorDefinition definition, IEditorData parentData)
        {
            // We get passed in an expression like "Got(myobject)"
            // The definition has pattern like "Got(#object#)" (as a regex)
            // We create the parameter dictionary in the same way as the command parser, so
            // we end up with a dictionary like "object=myobject".

            m_parameters = Utility.Populate(definition.Pattern, expression);
            m_originalPattern = definition.OriginalPattern;
            m_parentData = parentData;
        }
 protected override void BuildCompletionDataInternal(IEditorData Editor, string EnteredText)
 {
     foreach (var propAttr in new[] {
             "disable",
             "property",
             "safe",
             "system",
             "trusted"
         })
         CompletionDataGenerator.AddPropertyAttribute(propAttr);
 }