示例#1
0
		public CodeType(CodeModelContext context, ITypeDefinition typeDefinition, params IType[] typeArguments)
			: base(context, typeDefinition)
		{
			this.typeDefinition = typeDefinition;
			this.typeArguments = typeArguments;
			this.InfoLocation = GetInfoLocation();
		}
 public CodeNamespace(CodeModelContext context, INamespace ns)
     : base(context)
 {
     this.ns           = ns;
     this.InfoLocation = global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationExternal;
     this.Language     = context.CurrentProject.GetCodeModelLanguage();
 }
示例#3
0
 public CodeNamespace(CodeModelContext context, INamespace ns)
     : base(context)
 {
     this.ns = ns;
     this.InfoLocation = global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationExternal;
     this.Language = context.CurrentProject.GetCodeModelLanguage();
 }
示例#4
0
 public CodeType(CodeModelContext context, ITypeDefinition typeDefinition, params IType[] typeArguments)
     : base(context, typeDefinition)
 {
     this.typeDefinition = typeDefinition;
     this.typeArguments  = typeArguments;
     this.InfoLocation   = GetInfoLocation();
 }
 FileCodeModelCodeNamespace(CodeModelContext context, NamespaceName namespaceName)
 {
     this.context = context;
     this.namespaceName = namespaceName;
     this.InfoLocation = global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationExternal;
     this.Language = context.CurrentProject.GetCodeModelLanguage();
 }
示例#6
0
		public CodeElement(CodeModelContext context, ISymbolModel symbolModel)
		{
			this.context = context;
			this.symbolModel = symbolModel;
			if (symbolModel.ParentProject != null)
				this.Language = symbolModel.ParentProject.GetCodeModelLanguage();
		}
示例#7
0
 FileCodeModelCodeNamespace(CodeModelContext context, NamespaceName namespaceName)
 {
     this.context       = context;
     this.namespaceName = namespaceName;
     this.InfoLocation  = global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationExternal;
     this.Language      = context.CurrentProject.GetCodeModelLanguage();
 }
示例#8
0
		internal static CodeType Create(CodeModelContext context, IType type)
		{
			ITypeDefinition typeDefinition = type.GetDefinition();
			if (typeDefinition != null) {
				return Create(context.WithFilteredFileName(null), typeDefinition, type.TypeArguments.ToArray());
			}
			return null;
		}
示例#9
0
        public FileCodeModel2(CodeModelContext context, Project project)
        {
            if (context == null || context.FilteredFileName == null) {
                throw new ArgumentException("context must be restricted to a file");
            }

            this.context = context;
            this.project = project;
        }
示例#10
0
		public static CodeType Create(CodeModelContext context, IType type)
		{
			var typeDef = type.GetDefinition();
			if (typeDef != null) {
				var typeModel = typeDef.GetModel();
				if (typeModel != null)
					return Create(context.WithFilteredFileName(null), typeModel);
			}
			return null;
		}
示例#11
0
        internal static CodeType Create(CodeModelContext context, IType type)
        {
            ITypeDefinition typeDefinition = type.GetDefinition();

            if (typeDefinition != null)
            {
                return(Create(context.WithFilteredFileName(null), typeDefinition, type.TypeArguments.ToArray()));
            }
            return(null);
        }
        public FileCodeModel2(CodeModelContext context, Project project)
        {
            if (context == null || context.FilteredFileName == null)
            {
                throw new ArgumentException("context must be restricted to a file");
            }

            this.context = context;
            this.project = project;
        }
示例#13
0
		public override void SetUp()
		{
			base.SetUp();
			project.Stub(p => p.Language).Return(null).WhenCalled(mi => mi.ReturnValue = projectLanguage);
			codeGenerator = MockRepository.GenerateStrictMock<CodeGenerator>();
			codeModelContext = new CodeModelContext {
				CodeGenerator = codeGenerator,
				CurrentProject = project
			};
		}
        public override void SetUp()
        {
            base.SetUp();
            project.Stub(p => p.Language).Return(null).WhenCalled(mi => mi.ReturnValue = projectLanguage);

            codeGenerator = MockRepository.GenerateMock<CodeGenerator>();
            languageBinding = MockRepository.GenerateMock<ILanguageBinding>();
            languageBinding.Stub(binding => binding.CodeGenerator).Return(codeGenerator);
            project.Stub(p => p.LanguageBinding).Return(languageBinding);

            codeModelContext = new CodeModelContext {
                CurrentProject = project
            };
        }
示例#15
0
        public Project(
			MSBuildBasedProject project,
			IPackageManagementProjectService projectService,
			IPackageManagementFileService fileService)
        {
            this.MSBuildProject = project;
            this.projectService = projectService;
            this.fileService = fileService;

            context = new CodeModelContext {
                CurrentProject = project,
                DteProject = this
            };

            CreateProperties();
            Object = new ProjectObject(this);
            ProjectItems = new ProjectItems(this, this);
        }
示例#16
0
        public Project(
            MSBuildBasedProject project,
            IPackageManagementProjectService projectService,
            IPackageManagementFileService fileService)
        {
            this.MSBuildProject = project;
            this.projectService = projectService;
            this.fileService    = fileService;

            context = new CodeModelContext {
                CurrentProject = project,
                DteProject     = this
            };

            CreateProperties();
            Object       = new ProjectObject(this);
            ProjectItems = new ProjectItems(this, this);
        }
示例#17
0
		internal static CodeType Create(
			CodeModelContext context,
			ITypeDefinition typeDefinition,
			params IType[] typeArguments)
		{
			switch (typeDefinition.Kind) {
				case TypeKind.Class:
					return new CodeClass2(context, typeDefinition);
				case TypeKind.Interface:
					return new CodeInterface(context, typeDefinition, typeArguments);
				case TypeKind.Module:
				case TypeKind.Struct:
				case TypeKind.Void:
				case TypeKind.Delegate:
				case TypeKind.Enum:
				default:
					return new CodeType(context, typeDefinition, typeArguments);
			}
		}
示例#18
0
		public static CodeType Create(CodeModelContext context, ITypeDefinitionModel typeModel)
		{
			switch (typeModel.TypeKind) {
				case TypeKind.Class:
				case TypeKind.Module:
					goto default;
				case TypeKind.Interface:
					goto default;
				case TypeKind.Struct:
				case TypeKind.Void:
					goto default;
				case TypeKind.Delegate:
					goto default;
				case TypeKind.Enum:
					goto default;
				default:
					return new CodeType(context, typeModel);
			}
		}
示例#19
0
		public static CodeElement CreateMember(CodeModelContext context, IMemberModel m)
		{
			switch (m.SymbolKind) {
				case SymbolKind.Field:
					return new CodeVariable(context, (IFieldModel)m);
				case SymbolKind.Property:
				case SymbolKind.Indexer:
//					return new CodeProperty2(m);
					throw new NotImplementedException();
				case SymbolKind.Event:
					return null; // events are not supported in EnvDTE?
				case SymbolKind.Method:
				case SymbolKind.Operator:
				case SymbolKind.Constructor:
				case SymbolKind.Destructor:
					return new CodeFunction2(context, (IMethodModel)m);
				default:
					throw new NotSupportedException("Invalid value for SymbolKind");
			}
		}
示例#20
0
		public FileCodeModel2(CodeModelContext context)
		{
			if (context == null || context.FilteredFileName == null)
				throw new ArgumentException("context must be restricted to a file");
			this.context = context;
			var compilation = SD.ParserService.GetCompilation(context.CurrentProject);
			
			var projectContent = compilation.MainAssembly.UnresolvedAssembly as IProjectContent;
			if (projectContent != null) {
				IUnresolvedFile file = projectContent.GetFile(context.FilteredFileName);
				if (file != null) {
					var csharpFile = file as CSharpUnresolvedFile;
					if (csharpFile != null)
						AddUsings(codeElements, csharpFile.RootUsingScope, compilation);
					
					var resolveContext = new SimpleTypeResolveContext(compilation.MainAssembly);
					AddTypes(file.TopLevelTypeDefinitions
					         .Select(td => td.Resolve(resolveContext) as ITypeDefinition)
					         .Where(td => td != null).Distinct());
				}
			}
		}
示例#21
0
        internal static CodeType Create(
            CodeModelContext context,
            ITypeDefinition typeDefinition,
            params IType[] typeArguments)
        {
            switch (typeDefinition.Kind)
            {
            case TypeKind.Class:
                return(new CodeClass2(context, typeDefinition));

            case TypeKind.Interface:
                return(new CodeInterface(context, typeDefinition, typeArguments));

            case TypeKind.Module:
            case TypeKind.Struct:
            case TypeKind.Void:
            case TypeKind.Delegate:
            case TypeKind.Enum:
            default:
                return(new CodeType(context, typeDefinition, typeArguments));
            }
        }
        internal static CodeElement CreateMember(CodeModelContext context, IMember member)
        {
            switch (member.SymbolKind)
            {
            case SymbolKind.Field:
                return(new CodeVariable(context, (IField)member));

            case SymbolKind.Property:
            case SymbolKind.Indexer:
                return(new CodeProperty2(context, (IProperty)member));

            case SymbolKind.Event:
                return(null);

            case SymbolKind.Method:
            case SymbolKind.Operator:
            case SymbolKind.Constructor:
            case SymbolKind.Destructor:
                return(new CodeFunction2(context, (IMethod)member));

            default:
                throw new NotSupportedException("Invalid value for SymbolKind");
            }
        }
示例#23
0
 public CodeClass2(CodeModelContext context, ITypeDefinition typeDefinition)
     : base(context, typeDefinition)
 {
 }
 public CodeDelegate(CodeModelContext context, ITypeDefinition typeDefinition)
     : base(context, typeDefinition)
 {
 }
示例#25
0
 public CodeParameter2(CodeModelContext context, IParameter parameter)
     : base(context, parameter)
 {
 }
示例#26
0
 public CodeProperty2(CodeModelContext context, IProperty property)
     : base(context, property)
 {
 }
示例#27
0
 public CodeAttribute2(CodeModelContext context, IAttribute attribute)
     : base(context, attribute)
 {
 }
 public FileCodeModelCodeNamespace(CodeModelContext context, string namespaceName)
     : this(context, new NamespaceName(namespaceName))
 {
 }
示例#29
0
 public CodeVariable(CodeModelContext context, IField field)
     : base(context, field)
 {
     this.field = field;
 }
示例#30
0
 public CodeInterface(CodeModelContext context, ITypeDefinition typeDefinition, params IType[] typeArguments)
     : base(context, typeDefinition, typeArguments)
 {
 }
 public CodeElement(CodeModelContext context, IEntity entity)
 {
     this.context  = context;
     this.entity   = entity;
     this.Language = context.CurrentProject.GetCodeModelLanguage();
 }
示例#32
0
 public CodeVariable(CodeModelContext context, IField field)
     : base(context, field)
 {
     this.field = field;
 }
示例#33
0
 public CodeElement(CodeModelContext context)
 {
     this.context = context;
 }
示例#34
0
 public CodeFunction2(CodeModelContext context, IMethod method)
     : base(context, method)
 {
 }
 public CodeClass2(CodeModelContext context, ITypeDefinition typeDefinition)
     : base(context, typeDefinition)
 {
 }
示例#36
0
 public CodeProperty(CodeModelContext context, IProperty property)
     : base(context, property)
 {
     this.property = property;
 }
 public CodeStruct(CodeModelContext context, ITypeDefinition typeDefinition)
     : base(context, typeDefinition)
 {
 }
示例#38
0
 public CodeClass(CodeModelContext context, ITypeDefinition typeDefinition)
     : base(context, typeDefinition, typeDefinition.TypeArguments.ToArray())
 {
 }
示例#39
0
 public CodeTypeRef2(CodeModelContext context, CodeElement parent, IType type)
     : base(context, parent, type)
 {
 }
示例#40
0
 internal static TextPoint CreateStartPoint(CodeModelContext context, DomRegion region)
 {
     return new TextPoint(region.FileName, region.Begin, context.DocumentLoader);
 }
示例#41
0
 public CodeProperty2(CodeModelContext context, IProperty property)
     : base(context, property)
 {
 }
示例#42
0
 public CodeModel(CodeModelContext context, Project project)
 {
     this.context = context;
     this.project = project;
 }
示例#43
0
 public CodeParameter(CodeModelContext context, IParameter parameter)
     : base(context)
 {
     this.parameter = parameter;
 }
示例#44
0
 public CodeElementsInNamespace(CodeModelContext context, INamespace ns)
 {
     this.context = context;
     this.ns      = ns;
     GetCodeElements();
 }
 public CodeTypeRef(CodeModelContext context, CodeElement parent, IType type)
 {
     this.context = context;
     this.parent  = parent;
     this.type    = type;
 }
示例#46
0
		public CodeFunction2(CodeModelContext context, IMethodModel methodModel)
			: base(context, methodModel)
		{
		}
示例#47
0
 public CodeFunction(CodeModelContext context, IMethod method)
     : base(context, method)
 {
     this.method = method;
 }
示例#48
0
		public CodeAttribute(CodeModelContext context, IAttribute attribute)
			: base(context)
		{
			this.attribute = attribute;
		}
示例#49
0
		/// <summary>
		/// Note that projectContent may be different to the IClass.ProjectContent since the class
		/// is retrieved from the namespace contents and could belong to a separate project or
		/// referenced assembly.
		/// </summary>
		public CodeType(CodeModelContext context, ITypeDefinitionModel typeModel)
			: base(context, typeModel)
		{
			this.typeModel = typeModel;
		}
示例#50
0
 public CodeModel(CodeModelContext context, Project project)
 {
     this.context = context;
     this.project = project;
 }
示例#51
0
 public CodeAttribute(CodeModelContext context, IAttribute attribute)
     : base(context)
 {
     this.attribute = attribute;
 }
示例#52
0
 public CodeInterface(CodeModelContext context, ITypeDefinition typeDefinition, params IType[] typeArguments)
     : base(context, typeDefinition, typeArguments)
 {
 }
示例#53
0
 public CodeTypeRef2(CodeModelContext context, CodeElement parent, IType type)
     : base(context, parent, type)
 {
 }
示例#54
0
 public CodeElementsInNamespace(CodeModelContext context)
     : this(context, context.DteProject.GetCompilationUnit().RootNamespace)
 {
 }
示例#55
0
 internal static CodeElement CreateMember(CodeModelContext context, IMember member)
 {
     switch (member.SymbolKind) {
         case SymbolKind.Field:
             return new CodeVariable(context, (IField)member);
         case SymbolKind.Property:
         case SymbolKind.Indexer:
             return new CodeProperty2(context, (IProperty)member);
         case SymbolKind.Event:
             return null;
         case SymbolKind.Method:
         case SymbolKind.Operator:
         case SymbolKind.Constructor:
         case SymbolKind.Destructor:
             return new CodeFunction2(context, (IMethod)member);
         default:
             throw new NotSupportedException("Invalid value for SymbolKind");
     }
 }
示例#56
0
 public FileCodeModelCodeNamespace(CodeModelContext context, string namespaceName)
     : this(context, new NamespaceName(namespaceName))
 {
 }
示例#57
0
 public CodeElement(CodeModelContext context, IEntity entity)
 {
     this.context = context;
     this.entity = entity;
     this.Language = context.CurrentProject.GetCodeModelLanguage();
 }
示例#58
0
		public CodeClass(CodeModelContext context, ITypeDefinitionModel typeModel)
			: base(context, typeModel)
		{
		}
示例#59
0
 public CodeDelegate(CodeModelContext context, ITypeDefinition typeDefinition)
     : base(context, typeDefinition)
 {
 }
 public CodeElement(CodeModelContext context)
 {
     this.context = context;
 }