Пример #1
0
		public ParameterDataProvider (Document document, ProjectInformation info, string functionName)
		{
			this.document = document;
			this.functionName = functionName;

			functions = new List<Symbol> ();
			Symbol function = info.GetFunction (functionName, document.FileName, document.Editor.Caret.Line + 1, document.Editor.Caret.Column + 1);
			if (null != function){ functions.Add (function); }
		}// member function constructor
		public ParameterDataProvider (Document document, ProjectInformation info, string functionName)
		{
			this.editor = document.TextEditor;
			this.functionName = functionName;
			this.info = info;

			functions = new List<Symbol> ();
			Symbol function = info.GetFunction (functionName, document.FileName, editor.CursorLine, editor.CursorColumn);
			if (null != function){ functions.Add (function); }
		}// member function constructor
		/// <summary>
		/// Gets or creates the ProjectInformation for a given project
		/// </summary>
		public ProjectInformation Get (Project project)
		{
			foreach (ProjectInformation p in projects) {
				if (project == p.Project || (null != project && project.Equals (p.Project))) {
					return p;
				}
			}
			
			ProjectInformation newinfo = new ProjectInformation (project);
			projects.Add (newinfo);
			
			return newinfo;
		}
        /// <summary>
        /// Gets or creates the ProjectInformation for a given project
        /// </summary>
        public ProjectInformation Get(Project project)
        {
            foreach (ProjectInformation p in projects)
            {
                if (project == p.Project || (null != project && project.Equals(p.Project)))
                {
                    return(p);
                }
            }

            ProjectInformation newinfo = new ProjectInformation(project);

            projects.Add(newinfo);

            return(newinfo);
        }
Пример #5
0
		}// member function constructor
		
		/// <summary>
		/// Create a ParameterDataProvider for a constructor
		/// </summary>
		/// <param name="constructorOverload">
		/// A <see cref="System.String"/>: The named of the pertinent constructor overload
		/// </param>
		public ParameterDataProvider (Document document, ProjectInformation info, string typename, string constructorOverload)
		{
			this.functionName = constructorOverload;
			this.document = document;
			
			List<Symbol> myfunctions = info.GetConstructorsForType (typename, document.FileName, document.Editor.Caret.Line + 1, document.Editor.Caret.Column + 1, null); // bottleneck
			if (1 < myfunctions.Count) {
				foreach (Symbol function in myfunctions) {
					if (functionName.Equals (function.Name, StringComparison.Ordinal)) {
						functions = new List<Symbol> () {function};
						return;
					}
				}
			}
			
			functions = myfunctions;
		}// constructor constructor
        public override ParsedDocument Parse(ProjectDom dom, string fileName, string content)
        {
            ParsedDocument     doc = new ParsedDocument(fileName);
            ProjectInformation pi  = ProjectInformationManager.Instance.Get((null == dom)? null: dom.Project);

            if (null == doc.CompilationUnit)
            {
                doc.CompilationUnit = new CompilationUnit(fileName);
            }
            CompilationUnit      cu       = (CompilationUnit)doc.CompilationUnit;
            int                  lastLine = 0;
            ICollection <Symbol> classes  = pi.GetClassesForFile(fileName);

            if (null == classes || 0 == classes.Count)
            {
                return(lastGood);
            }

            foreach (Symbol node in classes)
            {
                if (null == node)
                {
                    continue;
                }
                List <IMember> members = new List <IMember> ();
                lastLine = node.SourceReferences[0].LastLine;

                foreach (Symbol child in node.Children)
                {
                    if (1 > child.SourceReferences.Count ||
                        child.SourceReferences[0].File != node.SourceReferences[0].File)
                    {
                        continue;
                    }
                    lastLine = Math.Max(lastLine, child.SourceReferences[0].LastLine + 1);

                    switch (child.MemberType.ToLower())
                    {
                    case "class":
                        members.Add(new DomType(new CompilationUnit(fileName), ClassType.Class, child.Name, new DomLocation(child.SourceReferences[0].FirstLine, 1), string.Empty, new DomRegion(child.SourceReferences[0].FirstLine, int.MaxValue, child.SourceReferences[0].LastLine, int.MaxValue), new List <IMember> ()));
                        break;

                    case "interface":
                        members.Add(new DomType(new CompilationUnit(fileName), ClassType.Interface, child.Name, new DomLocation(child.SourceReferences[0].FirstLine, 1), string.Empty, new DomRegion(child.SourceReferences[0].FirstLine, int.MaxValue, child.SourceReferences[0].LastLine, int.MaxValue), new List <IMember> ()));
                        break;

                    case "delegate":
                        members.Add(new DomType(new CompilationUnit(fileName), ClassType.Delegate, child.Name, new DomLocation(child.SourceReferences[0].FirstLine, 1), string.Empty, new DomRegion(child.SourceReferences[0].FirstLine, int.MaxValue, child.SourceReferences[0].LastLine, int.MaxValue), new List <IMember> ()));
                        break;

                    case "struct":
                        members.Add(new DomType(new CompilationUnit(fileName), ClassType.Struct, child.Name, new DomLocation(child.SourceReferences[0].FirstLine, 1), string.Empty, new DomRegion(child.SourceReferences[0].FirstLine, int.MaxValue, child.SourceReferences[0].LastLine, int.MaxValue), new List <IMember> ()));
                        break;

                    case "enum":
                        members.Add(new DomType(new CompilationUnit(fileName), ClassType.Enum, child.Name, new DomLocation(child.SourceReferences[0].FirstLine, 1), string.Empty, new DomRegion(child.SourceReferences[0].FirstLine, int.MaxValue, child.SourceReferences[0].LastLine, int.MaxValue), new List <IMember> ()));
                        break;

                    case "method":
                    case "creationmethod":
                    case "constructor":
                        DomMethod method = new DomMethod(child.Name, Modifiers.None, MethodModifier.None, new DomLocation(child.SourceReferences[0].FirstLine, 1), new DomRegion(child.SourceReferences[0].FirstLine, int.MaxValue, child.SourceReferences[0].LastLine, int.MaxValue), new DomReturnType(child.ReturnType.TypeName));
                        foreach (DataType param in child.Parameters)
                        {
                            method.Add(new DomParameter(method, param.Name, new DomReturnType(param.TypeName)));
                        }
                        members.Add(method);
                        break;

                    case "property":
                        members.Add(new DomProperty(child.Name, Modifiers.None, new DomLocation(child.SourceReferences[0].FirstLine, 1), new DomRegion(child.SourceReferences[0].FirstLine, int.MaxValue, child.SourceReferences[0].LastLine, int.MaxValue), new DomReturnType()));
                        break;

                    case "field":
                    case "constant":
                    case "errorcode":
                        members.Add(new DomField(child.Name, Modifiers.None, new DomLocation(child.SourceReferences[0].FirstLine, 1), new DomReturnType()));
                        break;

                    case "signal":
                        members.Add(new DomEvent(child.Name, Modifiers.None, new DomLocation(child.SourceReferences[0].FirstLine, 1), new DomReturnType()));
                        break;

                    default:
                        MonoDevelop.Core.LoggingService.LogDebug("ValaDocumentParser: Unsupported member type: {0}", child.MemberType);
                        break;
                    }            // Switch on node type
                }                // Collect members

                cu.Add(new DomType(new CompilationUnit(fileName), ClassType.Class, node.Name, new DomLocation(node.SourceReferences[0].FirstLine, 1), string.Empty, new DomRegion(node.SourceReferences[0].FirstLine, int.MaxValue, lastLine, int.MaxValue), members));
            }            // Add each class in file

            return(lastGood = doc);
        } // Parse