|
1 |
| -using System; |
2 |
| -using System.Collections.Generic; |
3 |
| -using System.Diagnostics; |
4 |
| -using System.IO; |
5 |
| -using System.Linq; |
6 |
| -using System.Reflection; |
7 |
| -using System.Runtime.InteropServices; |
8 |
| -using Rubberduck.Parsing.Annotations; |
9 |
| -using Rubberduck.Parsing.ComReflection; |
10 |
| -using Rubberduck.Parsing.VBA; |
11 |
| -using Rubberduck.VBEditor; |
| 1 | +//using System; |
| 2 | +//using System.Collections.Generic; |
| 3 | +//using System.Diagnostics; |
| 4 | +//using System.IO; |
| 5 | +//using System.Linq; |
| 6 | +//using System.Reflection; |
| 7 | +//using System.Runtime.InteropServices; |
| 8 | +//using Rubberduck.Parsing.Annotations; |
| 9 | +//using Rubberduck.Parsing.ComReflection; |
| 10 | +//using Rubberduck.Parsing.VBA; |
| 11 | +//using Rubberduck.VBEditor; |
12 | 12 |
|
13 |
| -namespace Rubberduck.Parsing.Symbols.DeclarationLoaders |
14 |
| -{ |
15 |
| - public class RubberduckApiDeclarations : ICustomDeclarationLoader |
16 |
| - { |
17 |
| - private readonly RubberduckParserState _state; |
18 |
| - private readonly List<Declaration> _declarations = new List<Declaration>(); |
| 13 | +//namespace Rubberduck.Parsing.Symbols.DeclarationLoaders |
| 14 | +//{ |
| 15 | +// public class RubberduckApiDeclarations : ICustomDeclarationLoader |
| 16 | +// { |
| 17 | +// private readonly RubberduckParserState _state; |
| 18 | +// private readonly List<Declaration> _declarations = new List<Declaration>(); |
19 | 19 |
|
20 |
| - public RubberduckApiDeclarations(RubberduckParserState state) |
21 |
| - { |
22 |
| - _state = state; |
23 |
| - } |
| 20 | +// public RubberduckApiDeclarations(RubberduckParserState state) |
| 21 | +// { |
| 22 | +// _state = state; |
| 23 | +// } |
24 | 24 |
|
25 |
| - public IReadOnlyList<Declaration> Load() |
26 |
| - { |
27 |
| - var assembly = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(a => a.GetName().Name.Equals("Rubberduck")); |
28 |
| - if (assembly == null) |
29 |
| - { |
30 |
| - return _declarations; |
31 |
| - } |
| 25 | +// public IReadOnlyList<Declaration> Load() |
| 26 | +// { |
| 27 | +// var assembly = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(a => a.GetName().Name.Equals("Rubberduck")); |
| 28 | +// if (assembly == null) |
| 29 | +// { |
| 30 | +// return _declarations; |
| 31 | +// } |
32 | 32 |
|
33 |
| - var name = assembly.GetName(); |
34 |
| - var path = Path.ChangeExtension(assembly.Location, "tlb"); |
| 33 | +// var name = assembly.GetName(); |
| 34 | +// var path = Path.ChangeExtension(assembly.Location, "tlb"); |
35 | 35 |
|
36 |
| - var projectName = new QualifiedModuleName("Rubberduck", path, "Rubberduck"); |
37 |
| - var project = new ProjectDeclaration(projectName.QualifyMemberName("Rubberduck"), "Rubberduck", true, null) |
38 |
| - { |
39 |
| - MajorVersion = name.Version.Major, |
40 |
| - MinorVersion = name.Version.Minor |
41 |
| - }; |
42 |
| - _declarations.Add(project); |
| 36 | +// var projectName = new QualifiedModuleName("Rubberduck", path, "Rubberduck"); |
| 37 | +// var project = new ProjectDeclaration(projectName.QualifyMemberName("Rubberduck"), "Rubberduck", true, null) |
| 38 | +// { |
| 39 | +// MajorVersion = name.Version.Major, |
| 40 | +// MinorVersion = name.Version.Minor |
| 41 | +// }; |
| 42 | +// _declarations.Add(project); |
43 | 43 |
|
44 |
| - var types = assembly.DefinedTypes.WhereIsComVisible(); |
| 44 | +// var types = assembly.DefinedTypes.WhereIsComVisible(); |
45 | 45 |
|
46 |
| - foreach (var type in types) |
47 |
| - { |
48 |
| - var module = type.ToModuleDeclaration(project, projectName, type.IsEnum); |
49 |
| - _declarations.Add(module); |
| 46 | +// foreach (var type in types) |
| 47 | +// { |
| 48 | +// var module = type.ToModuleDeclaration(project, projectName, type.IsEnum); |
| 49 | +// _declarations.Add(module); |
50 | 50 |
|
51 |
| - var properties = type.GetProperties().WhereIsComVisible().ToList(); |
| 51 | +// var properties = type.GetProperties().WhereIsComVisible().ToList(); |
52 | 52 |
|
53 |
| - foreach (var property in properties) |
54 |
| - { |
55 |
| - if (property.CanWrite && property.GetSetMethod().IsPublic) |
56 |
| - { |
57 |
| - var declaration = property.ToMemberDeclaration(module, false); |
58 |
| - _declarations.Add(declaration); |
59 |
| - } |
60 |
| - if (property.CanRead && property.GetGetMethod().IsPublic) |
61 |
| - { |
62 |
| - var declaration = property.ToMemberDeclaration(module, true); |
63 |
| - _declarations.Add(declaration); |
64 |
| - } |
65 |
| - } |
| 53 | +// foreach (var property in properties) |
| 54 | +// { |
| 55 | +// if (property.CanWrite && property.GetSetMethod().IsPublic) |
| 56 | +// { |
| 57 | +// var declaration = property.ToMemberDeclaration(module, false); |
| 58 | +// _declarations.Add(declaration); |
| 59 | +// } |
| 60 | +// if (property.CanRead && property.GetGetMethod().IsPublic) |
| 61 | +// { |
| 62 | +// var declaration = property.ToMemberDeclaration(module, true); |
| 63 | +// _declarations.Add(declaration); |
| 64 | +// } |
| 65 | +// } |
66 | 66 |
|
67 |
| - var members = type.GetMembers().WhereIsComVisible(); |
| 67 | +// var members = type.GetMembers().WhereIsComVisible(); |
68 | 68 |
|
69 |
| - foreach (var member in members) |
70 |
| - { |
71 |
| - if (member.MemberType == MemberTypes.Property) |
72 |
| - { |
| 69 | +// foreach (var member in members) |
| 70 | +// { |
| 71 | +// if (member.MemberType == MemberTypes.Property) |
| 72 | +// { |
73 | 73 |
|
74 |
| - } |
75 |
| - //var declaration = member.ToMemberDeclaration(project); |
76 |
| - } |
77 |
| - }; |
78 |
| - return _declarations; |
79 |
| - } |
80 |
| - } |
| 74 | +// } |
| 75 | +// //var declaration = member.ToMemberDeclaration(project); |
| 76 | +// } |
| 77 | +// }; |
| 78 | +// return _declarations; |
| 79 | +// } |
| 80 | +// } |
81 | 81 |
|
82 |
| - internal static class RubberduckApiDeclarationStatics |
83 |
| - { |
84 |
| - public static IEnumerable<T> WhereIsComVisible<T>(this IEnumerable<T> source) where T : MemberInfo |
85 |
| - { |
86 |
| - return source.Where(member => |
87 |
| - { |
88 |
| - var attr = member.GetCustomAttributes(typeof(ComVisibleAttribute), true).FirstOrDefault(); |
89 |
| - return attr != null && ((ComVisibleAttribute)attr).Value; |
90 |
| - }); |
91 |
| - } |
| 82 | +// internal static class RubberduckApiDeclarationStatics |
| 83 | +// { |
| 84 | +// public static IEnumerable<T> WhereIsComVisible<T>(this IEnumerable<T> source) where T : MemberInfo |
| 85 | +// { |
| 86 | +// return source.Where(member => |
| 87 | +// { |
| 88 | +// var attr = member.GetCustomAttributes(typeof(ComVisibleAttribute), true).FirstOrDefault(); |
| 89 | +// return attr != null && ((ComVisibleAttribute)attr).Value; |
| 90 | +// }); |
| 91 | +// } |
92 | 92 |
|
93 |
| - public static Declaration ToModuleDeclaration(this TypeInfo type, Declaration project, QualifiedModuleName projectName, bool isEnum = false) |
94 |
| - { |
95 |
| - return isEnum ? new ProceduralModuleDeclaration(projectName.QualifyMemberName(type.Name), project, type.Name, true, null, null) as Declaration : |
96 |
| - new ClassModuleDeclaration(projectName.QualifyMemberName(type.Name), project, type.Name, true, null, null); |
97 |
| - } |
| 93 | +// public static Declaration ToModuleDeclaration(this TypeInfo type, Declaration project, QualifiedModuleName projectName, bool isEnum = false) |
| 94 | +// { |
| 95 | +// return isEnum ? new ProceduralModuleDeclaration(projectName.QualifyMemberName(type.Name), project, type.Name, true, null, null) as Declaration : |
| 96 | +// new ClassModuleDeclaration(projectName.QualifyMemberName(type.Name), project, type.Name, true, null, null); |
| 97 | +// } |
98 | 98 |
|
99 |
| - public static Declaration ToMemberDeclaration(this PropertyInfo member, Declaration parent, bool getter) |
100 |
| - { |
101 |
| - if (getter) |
102 |
| - { |
103 |
| - return new PropertyGetDeclaration(parent.QualifiedName.QualifiedModuleName.QualifyMemberName(member.Name), |
104 |
| - parent, |
105 |
| - parent, |
106 |
| - member.PropertyType.ToVbaTypeName(), |
107 |
| - null, |
108 |
| - string.Empty, |
109 |
| - parent.Accessibility, |
110 |
| - null, |
111 |
| - Selection.Home, |
112 |
| - member.PropertyType.IsArray, |
113 |
| - true, |
114 |
| - null, |
115 |
| - new Attributes()); |
116 |
| - } |
117 |
| - if (member.PropertyType.IsClass) |
118 |
| - { |
119 |
| - return new PropertySetDeclaration(parent.QualifiedName.QualifiedModuleName.QualifyMemberName(member.Name), |
120 |
| - parent, |
121 |
| - parent, |
122 |
| - member.PropertyType.ToVbaTypeName(), |
123 |
| - parent.Accessibility, |
124 |
| - null, |
125 |
| - Selection.Home, |
126 |
| - true, |
127 |
| - null, |
128 |
| - new Attributes()); |
129 |
| - } |
130 |
| - return new PropertyLetDeclaration(parent.QualifiedName.QualifiedModuleName.QualifyMemberName(member.Name), |
131 |
| - parent, |
132 |
| - parent, |
133 |
| - member.PropertyType.ToVbaTypeName(), |
134 |
| - parent.Accessibility, |
135 |
| - null, |
136 |
| - Selection.Home, |
137 |
| - true, |
138 |
| - null, |
139 |
| - new Attributes()); |
140 |
| - } |
| 99 | +// public static Declaration ToMemberDeclaration(this PropertyInfo member, Declaration parent, bool getter) |
| 100 | +// { |
| 101 | +// if (getter) |
| 102 | +// { |
| 103 | +// return new PropertyGetDeclaration(parent.QualifiedName.QualifiedModuleName.QualifyMemberName(member.Name), |
| 104 | +// parent, |
| 105 | +// parent, |
| 106 | +// member.PropertyType.ToVbaTypeName(), |
| 107 | +// null, |
| 108 | +// string.Empty, |
| 109 | +// parent.Accessibility, |
| 110 | +// null, |
| 111 | +// Selection.Home, |
| 112 | +// member.PropertyType.IsArray, |
| 113 | +// true, |
| 114 | +// null, |
| 115 | +// new Attributes()); |
| 116 | +// } |
| 117 | +// if (member.PropertyType.IsClass) |
| 118 | +// { |
| 119 | +// return new PropertySetDeclaration(parent.QualifiedName.QualifiedModuleName.QualifyMemberName(member.Name), |
| 120 | +// parent, |
| 121 | +// parent, |
| 122 | +// member.PropertyType.ToVbaTypeName(), |
| 123 | +// parent.Accessibility, |
| 124 | +// null, |
| 125 | +// Selection.Home, |
| 126 | +// true, |
| 127 | +// null, |
| 128 | +// new Attributes()); |
| 129 | +// } |
| 130 | +// return new PropertyLetDeclaration(parent.QualifiedName.QualifiedModuleName.QualifyMemberName(member.Name), |
| 131 | +// parent, |
| 132 | +// parent, |
| 133 | +// member.PropertyType.ToVbaTypeName(), |
| 134 | +// parent.Accessibility, |
| 135 | +// null, |
| 136 | +// Selection.Home, |
| 137 | +// true, |
| 138 | +// null, |
| 139 | +// new Attributes()); |
| 140 | +// } |
141 | 141 |
|
142 |
| - public static string ToVbaTypeName(this Type type) |
143 |
| - { |
144 |
| - var name = string.Empty; |
145 |
| - if (type.IsClass || type.IsEnum) |
146 |
| - { |
147 |
| - name = type.Name; |
148 |
| - } |
149 |
| - switch (type.Name) |
150 |
| - { |
151 |
| - case "bool": |
152 |
| - name = "Boolean"; |
153 |
| - break; |
154 |
| - case "short": |
155 |
| - name = "Integer"; |
156 |
| - break; |
157 |
| - case "int": |
158 |
| - name = "Long"; |
159 |
| - break; |
160 |
| - } |
161 |
| - return name + (type.IsArray ? "()" : string.Empty); |
162 |
| - } |
163 |
| - } |
164 |
| -} |
| 142 | +// public static string ToVbaTypeName(this Type type) |
| 143 | +// { |
| 144 | +// var name = string.Empty; |
| 145 | +// if (type.IsClass || type.IsEnum) |
| 146 | +// { |
| 147 | +// name = type.Name; |
| 148 | +// } |
| 149 | +// switch (type.Name) |
| 150 | +// { |
| 151 | +// case "bool": |
| 152 | +// name = "Boolean"; |
| 153 | +// break; |
| 154 | +// case "short": |
| 155 | +// name = "Integer"; |
| 156 | +// break; |
| 157 | +// case "int": |
| 158 | +// name = "Long"; |
| 159 | +// break; |
| 160 | +// } |
| 161 | +// return name + (type.IsArray ? "()" : string.Empty); |
| 162 | +// } |
| 163 | +// } |
| 164 | +//} |
0 commit comments