PageRenderTime 66ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/SpecSharp/System.Compiler.Framework/LanguageService/LanguageService.cs

#
C# | 2090 lines | 1924 code | 32 blank | 134 comment | 1262 complexity | e0e7c0d668acdcbb32d8d9094d74657b MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. //-----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  4. //
  5. //-----------------------------------------------------------------------------
  6. using System;
  7. using System.CodeDom.Compiler;
  8. using System.Collections;
  9. using System.ComponentModel;
  10. using System.Diagnostics;
  11. using System.Globalization;
  12. using System.IO;
  13. using System.Runtime.InteropServices;
  14. using System.Text;
  15. using System.Threading;
  16. using System.Xml;
  17. #if CCINamespace
  18. namespace Microsoft.Cci{
  19. #else
  20. namespace System.Compiler{
  21. #endif
  22. public class CommentInfo{
  23. public bool supported;
  24. public string lineStart;
  25. public string blockStart;
  26. public string blockEnd;
  27. public bool useLineComments;
  28. }
  29. public enum ParseReason{
  30. Colorize,
  31. Check,
  32. MemberSelect, // Also means Implicit invocation
  33. CompleteWord,
  34. QuickInfo,
  35. MethodTip,
  36. MatchBraces, // Also means parameter help.
  37. HighlightBraces,
  38. Autos,
  39. CodeSpan,
  40. CollapsibleRegions,
  41. MemberSelectExplicit,
  42. //Compile,
  43. }
  44. public abstract class LanguageService{
  45. /// <summary>Tracks the symbol table (Module) associated with the current editor window</summary>
  46. public Module currentSymbolTable;
  47. public Node currentAst;
  48. public CultureInfo culture;
  49. public ErrorHandler errorHandler;
  50. public Int32List identifierPositions;
  51. public Int32List identifierLengths;
  52. public NodeList identifierInfos;
  53. public Int32List identifierContexts;
  54. public ScopeList identifierScopes;
  55. public ScopeList allScopes;
  56. /// <summary>Set this to True if you want drop downs showing types and members</summary>
  57. public bool EnableDropDownCombos;
  58. public LanguageService(ErrorHandler errorHandler){
  59. this.errorHandler = errorHandler;
  60. this.GetCompilationFor = new LanguageService.GetCompilation(this.GetDummyCompilationFor);
  61. }
  62. public abstract Scanner GetScanner();
  63. public abstract Compilation GetDummyCompilationFor(string fileName);
  64. public abstract void ParseAndAnalyzeCompilationUnit(string fname, string source, int line, int col, ErrorNodeList errors, Compilation compilation, AuthoringSink sink);
  65. public abstract CompilationUnit ParseCompilationUnit(string fname, string source, ErrorNodeList errors, Compilation compilation, AuthoringSink sink);
  66. public abstract void Resolve(Member unresolvedMember, Member resolvedMember);
  67. public abstract void Resolve(CompilationUnit partialCompilationUnit);
  68. public virtual MemberList GetTypesNamespacesAndPrefixes(Scope scope, bool constructorMustBeVisible, bool listAllUnderRootNamespace) {
  69. return null;
  70. }
  71. public virtual MemberList GetVisibleNames(Scope scope){
  72. return null;
  73. }
  74. public virtual MemberList GetNestedNamespacesAndTypes(Identifier name, Scope scope){
  75. return this.GetNestedNamespacesAndTypes(name, scope, null);
  76. }
  77. public virtual MemberList GetNestedNamespacesAndTypes(Identifier name, Scope scope, AssemblyReferenceList assembliesToSearch){
  78. return null;
  79. }
  80. public virtual MemberList GetNestedNamespaces(Identifier name, Scope scope) {
  81. MemberList fullList = this.GetNestedNamespacesAndTypes(name, scope);
  82. MemberList result = new MemberList();
  83. for (int i = 0, n = fullList == null ? 0 : fullList.Count; i < n; i++){
  84. Namespace ns = fullList[i] as Namespace;
  85. if (ns == null) continue;
  86. result.Add(ns);
  87. }
  88. return result;
  89. }
  90. public virtual MemberList GetNamespacesAndAttributeTypes(Scope scope){
  91. return this.GetTypesNamespacesAndPrefixes(scope, true, false);
  92. }
  93. public virtual AuthoringHelper GetAuthoringHelper(){
  94. return new AuthoringHelper(this.errorHandler, this.culture);
  95. }
  96. public virtual AuthoringScope GetAuthoringScope(){
  97. return new AuthoringScope(this, this.GetAuthoringHelper());
  98. }
  99. public virtual void GetCommentFormat(CommentInfo info){
  100. info.supported = true;
  101. info.lineStart = "//";
  102. info.blockStart = "/*";
  103. info.blockEnd = "*/";
  104. info.useLineComments = true;
  105. }
  106. public virtual void GetMethodFormat(out string typeStart, out string typeEnd, out bool typePrefixed){
  107. typeStart = "";
  108. typeEnd = " ";
  109. typePrefixed = true;
  110. }
  111. public AuthoringScope ParseSource(string text, int line, int col, string fname, AuthoringSink asink, ParseReason reason){
  112. this.currentAst = null;
  113. Compilation compilation = this.GetCompilationFor(fname);
  114. Debug.Assert(compilation != null, "no compilation for: "+fname);
  115. this.currentSymbolTable = compilation.TargetModule;
  116. switch (reason){
  117. case ParseReason.CollapsibleRegions:
  118. case ParseReason.CompleteWord:
  119. case ParseReason.MatchBraces:
  120. case ParseReason.HighlightBraces:
  121. case ParseReason.MemberSelect:
  122. case ParseReason.MemberSelectExplicit:
  123. case ParseReason.MethodTip:
  124. case ParseReason.QuickInfo:
  125. case ParseReason.Autos:{
  126. return this.ParsePartialCompilationUnit(fname, text, line, col, asink, reason);
  127. }
  128. case ParseReason.Check:{
  129. ErrorNodeList errors = new ErrorNodeList();
  130. this.ParseAndAnalyzeCompilationUnit(fname, text, line, col, errors, compilation, asink);
  131. this.ReportErrors(fname, errors, asink);
  132. return this.GetAuthoringScope();
  133. }
  134. }
  135. return null;
  136. }
  137. public virtual AuthoringScope GetAuthoringScopeForMethodBody(string text, Compilation/*!*/ compilation, Method/*!*/ method, AuthoringSink asink) {
  138. return null;
  139. }
  140. public virtual AuthoringScope ParsePartialCompilationUnit(string fname, string text, int line, int col, AuthoringSink asink, ParseReason reason){
  141. Compilation compilation = this.GetCompilationFor(fname);
  142. if (line >= 0 && (reason == ParseReason.MemberSelect || reason == ParseReason.MemberSelectExplicit || reason == ParseReason.CompleteWord))
  143. text = this.Truncate(text, line, col);
  144. Module savedSymbolTable = this.currentSymbolTable;
  145. compilation.TargetModule = this.currentSymbolTable = new Module();
  146. this.currentSymbolTable.AssemblyReferences = savedSymbolTable.AssemblyReferences;
  147. CompilationUnit partialCompilationUnit = this.ParseCompilationUnit(fname, text, new ErrorNodeList(), compilation, asink);
  148. compilation.TargetModule = this.currentSymbolTable = savedSymbolTable;
  149. if (reason != ParseReason.HighlightBraces && reason != ParseReason.MatchBraces){
  150. MemberFinder memberFinder = this.GetMemberFinder(line+1, col+1);
  151. memberFinder.Visit(partialCompilationUnit);
  152. Member unresolvedMember = memberFinder.Member;
  153. memberFinder.Member = null;
  154. CompilationUnit cu = this.GetCompilationUnitSnippet(compilation, fname);
  155. if (cu != null){
  156. if (unresolvedMember == null){
  157. //Dealing with a construct that is not part of a type definition, such as a using statement
  158. this.Resolve(partialCompilationUnit);
  159. }else{
  160. memberFinder.Visit(cu);
  161. if (memberFinder.Member != null)
  162. this.Resolve(unresolvedMember, memberFinder.Member);
  163. else
  164. this.Resolve(partialCompilationUnit); //Symbol table is out of date
  165. }
  166. }
  167. }
  168. return this.GetAuthoringScope();
  169. }
  170. public virtual CompilationUnitSnippet GetCompilationUnitSnippet(Compilation compilation, string fname){
  171. if (compilation == null || compilation.CompilationUnits == null) return null;
  172. for (int i = 0, n = compilation.CompilationUnits.Count; i < n; i++){
  173. CompilationUnitSnippet cu = compilation.CompilationUnits[i] as CompilationUnitSnippet;
  174. if (cu == null) continue;
  175. if (string.Compare(cu.Name.ToString(), fname, true, System.Globalization.CultureInfo.InvariantCulture) != 0) continue;
  176. return cu;
  177. }
  178. return null;
  179. }
  180. public virtual MemberFinder GetMemberFinder(int line, int col){
  181. return new MemberFinder(line, col);
  182. }
  183. public virtual string Truncate(string text, int line, int col){
  184. // If we are just parsing for intellisense then there's no point parsing beyond
  185. // the caret position, except that we do need to complete the token so that we
  186. // provide the right intellisense on that token.
  187. int pos = 0;
  188. int length = text.Length;
  189. while ( pos < length && line >= 0 && col >= 0 ){
  190. char ch = text[pos++];
  191. if (line == 0 && col == 0){
  192. // cursor position - finish here
  193. if (!Char.IsLetter(ch)){
  194. pos--;
  195. break;
  196. }
  197. }else{
  198. // handle the standard ret/lf
  199. if (ch == '\r' && pos < length && text[pos] == '\n'){
  200. // reached a new line
  201. pos++;
  202. line --;
  203. continue;
  204. }
  205. // in case of dangling ret and lf we assume each one symbolises a new line
  206. // have not encountered this case, but it is safe to do ...
  207. if (ch == '\n' || ch == '\r'){line --; continue;}
  208. if (line == 0){
  209. // now we are in the correct line, so start counting column position
  210. col--;
  211. continue;
  212. }
  213. }
  214. }
  215. return text.Substring(0,pos);
  216. }
  217. public virtual int GetColorCount(){
  218. return (int)TokenColor.LastColor;
  219. }
  220. protected int lastLine = -1;
  221. protected int lastCol = -1;
  222. protected string lastFileName;
  223. public delegate Compilation GetCompilation(string fileName);
  224. public GetCompilation GetCompilationFor;
  225. public virtual CompilerParameters GetDummyCompilerParameters(){
  226. return new CompilerOptions();
  227. }
  228. public virtual void ReportErrors(string fileName, ErrorNodeList errors, AuthoringSink sink){
  229. if (sink == null) return;
  230. for (int n = errors.Count, i = n-1; i >= 0; i--){ //Scan backwards so that early errors trump later errors
  231. ErrorNode enode = errors[i];
  232. if (enode == null || enode.Severity < 0) continue;
  233. //TODO: suppress warnings of level > set in options
  234. SourceContext context = enode.SourceContext;
  235. if (context.Document == null) continue;
  236. if (context.Document.Name != fileName) continue;
  237. sink.AddError(enode);
  238. }
  239. }
  240. public virtual void SearchAstForNodeAtPosition(int line, int col, out Node node, out Scope scope, out int identContext){
  241. node = null;
  242. scope = null;
  243. identContext = IdentifierContexts.NullContext;
  244. }
  245. public virtual Scope SearchForLeastEnclosingScope(int line, int col) {
  246. if (allScopes == null) return null;
  247. Scope retScope = null;
  248. for (int i = 0; i < allScopes.Count; i++){
  249. SourceContext sc = allScopes[i].LexicalSourceExtent;
  250. if (sc.Encloses(line, col)) {
  251. if (retScope == null) {
  252. retScope = allScopes[i];
  253. }
  254. else {
  255. SourceContext scForRetScope = retScope.LexicalSourceExtent;
  256. if (scForRetScope.Encloses(sc))
  257. retScope = allScopes[i];
  258. }
  259. }
  260. }
  261. return retScope;
  262. }
  263. public virtual void AddReleventKeywords(MemberList memberList, Node node, Scope scope, int identifierContext) {
  264. return;
  265. }
  266. public virtual void SearchForNodeAtPosition(int line, int col, out Node node, out Scope scope, out int identifierContext) {
  267. if (this.currentAst != null) {
  268. this.SearchAstForNodeAtPosition(line, col, out node, out scope, out identifierContext);
  269. identifierContext = IdentifierContexts.NullContext;
  270. return;
  271. }
  272. node = null;
  273. scope = null;
  274. identifierContext = IdentifierContexts.AllContext;
  275. int pos = line*1000+col;
  276. Int32List posList = this.identifierPositions;
  277. Int32List lenList = this.identifierLengths;
  278. NodeList infos = this.identifierInfos;
  279. ScopeList scopes = this.identifierScopes;
  280. Int32List identContexts = this.identifierContexts;
  281. if (posList == null || infos == null) return;
  282. int i = 0, n = posList.Count, j = n-1;
  283. while (i < j){
  284. int k = (i+j) / 2;
  285. int m = posList[k] - pos;
  286. if (m < 0)
  287. i = k+1;
  288. else if (m > 0)
  289. j = k;
  290. else{
  291. // Move ahead to the last index with the same pos.
  292. while (k < n-1 && posList[k+1] == pos)
  293. k++;
  294. int bestMatch = -1;
  295. while (k >= 0 && posList[k] / 1000 == line) {
  296. // Within the tange and smaller in length than best match
  297. if (((posList[k] % 1000) <= col) && ((posList[k] % 1000) + lenList[k] >= col) && (bestMatch == -1 || lenList[k] < lenList[bestMatch]))
  298. bestMatch = k;
  299. k--;
  300. }
  301. node = infos[bestMatch];
  302. identifierContext = identContexts[bestMatch];
  303. scope = scopes[bestMatch];
  304. return;
  305. }
  306. }
  307. if (j >= 0){
  308. if (posList[j] > pos && j > 0) j--;
  309. if (j >= n - 1 && posList[j] / 1000 < line) {
  310. node = infos[j];
  311. identifierContext = identContexts[j];
  312. if (node != null) {
  313. if (node.SourceContext.EndLine == line && node.SourceContext.EndColumn == col) {
  314. scope = scopes[j];
  315. return;
  316. }
  317. node = null;
  318. identifierContext = IdentifierContexts.AllContext;
  319. }
  320. return; //At the last node, but not on the same line. No match.
  321. }
  322. int bestMatch = -1;
  323. while (j >= 0 && posList[j] / 1000 == line){
  324. // Within the tange and smaller in length than best match
  325. if (((posList[j] % 1000) <= col) && ((posList[j] % 1000) + lenList[j] >= col) && (bestMatch == -1 || lenList[j] < lenList[bestMatch]))
  326. bestMatch = j;
  327. j--;
  328. }
  329. if (bestMatch < 0 || posList[bestMatch] / 1000 != line) return;
  330. node = infos[bestMatch];
  331. identifierContext = identContexts[bestMatch];
  332. scope = scopes[bestMatch];
  333. }
  334. return;
  335. }
  336. public virtual MemberList GetConstructibleNestedTypes(TypeNode typeNode, TypeNode referringType){
  337. if (typeNode == null) return null;
  338. MemberList result = new MemberList();
  339. TypeNodeList nestedTypes = typeNode.NestedTypes;
  340. for (int i = 0, n = nestedTypes == null ? 0 : nestedTypes.Count; i < n; i++){
  341. TypeNode nt = nestedTypes[i];
  342. if (this.TypeHasNoVisibleConstructorsOrIsAbstract(nt, referringType)) continue;
  343. result.Add(nt);
  344. }
  345. return result;
  346. }
  347. public virtual bool TypeHasNoVisibleConstructorsOrIsAbstract(TypeNode type, TypeNode referringType){
  348. if (type == null || referringType == null || type.IsAbstract) return true;
  349. if (type is Struct || type is EnumNode) return false;
  350. TypeNode dummy = referringType;
  351. MemberList constructors = type.GetConstructors();
  352. for (int i = 0, n = constructors == null ? 0 : constructors.Count; i < n; i++){
  353. Member constr = constructors[i];
  354. if (constr == null) continue;
  355. if (!Checker.NotAccessible(constr, ref dummy, referringType.DeclaringModule, referringType, null)) return false;
  356. }
  357. return true;
  358. }
  359. }
  360. public class AuthoringScope{
  361. protected LanguageService languageService;
  362. protected AuthoringHelper helper;
  363. protected bool suppressAttributeSuffix;
  364. public AuthoringScope(LanguageService languageService, AuthoringHelper helper){
  365. this.languageService = languageService;
  366. this.helper = helper;
  367. }
  368. public virtual Member GetMember(int line, int col){
  369. Node n;
  370. Scope scope;
  371. int identContext;
  372. this.languageService.SearchForNodeAtPosition(line + 1, col + 1, out n, out scope, out identContext);
  373. if (n == null) return null;
  374. MemberBinding mb = this.GetMemberBinding(n);
  375. if (mb != null) return mb.BoundMember;
  376. TypeNode t = n as TypeNode;
  377. if (t == null && n is Expression)
  378. t = ((Expression)n).Type;
  379. if (t != null) return t;
  380. t = this.GetQueryResultType(n);
  381. if (t != null) return t;
  382. return null;
  383. }
  384. public virtual string GetDataTipText(int line, int col, out SourceContext sourceContext){
  385. Node n;
  386. Scope scope;
  387. int identContext;
  388. this.languageService.SearchForNodeAtPosition(line + 1, col + 1, out n, out scope, out identContext);
  389. if (n == null){
  390. sourceContext = new SourceContext(); return null;
  391. }
  392. sourceContext = n.SourceContext;
  393. string helpText = null;
  394. MemberBinding mb = this.GetMemberBinding(n);
  395. string memberSignature = "";
  396. if (mb != null){
  397. sourceContext = mb.SourceContext;
  398. Member mem = mb.BoundMember;
  399. Method m = mem as Method;
  400. if (m != null && m.IsSpecialName && m.Name.ToString().StartsWith("get_")){
  401. TypeNode[] types = m.GetParameterTypes();
  402. Identifier propId = Identifier.For(m.Name.ToString().Substring(4));
  403. TypeNode ty = m.DeclaringType;
  404. while (ty != null){
  405. Property prop = ty.GetProperty(propId, types);
  406. if (prop != null){
  407. mem = prop;
  408. break;
  409. }
  410. ty = ty.BaseType;
  411. }
  412. }
  413. helpText = mem.HelpText;
  414. if (mb.TargetObject is ImplicitThis){
  415. if (mem.DeclaringType is BlockScope)
  416. memberSignature = this.languageService.errorHandler.GetLocalSignature(mem as Field);
  417. else if (mem is ParameterField)
  418. memberSignature = this.languageService.errorHandler.GetParameterSignature((ParameterField)mem);
  419. else if (mem is Field || mem is Property)
  420. memberSignature = this.languageService.errorHandler.GetInstanceMemberSignature(mb.BoundMember);
  421. else
  422. memberSignature = this.languageService.errorHandler.GetMemberSignature(mb.BoundMember, true);
  423. }else
  424. memberSignature = this.languageService.errorHandler.GetMemberSignature(mb.BoundMember, true);
  425. if (helpText == "" && mb.BoundMember is InstanceInitializer)
  426. helpText = mem.DeclaringType.HelpText;
  427. }else{
  428. TypeNode t = n as TypeNode;
  429. if (t == null && n is Expression)
  430. t = ((Expression)n).Type;
  431. if (t != null){
  432. memberSignature = this.languageService.errorHandler.GetMemberSignature(t, true);
  433. helpText = t.HelpText;
  434. }else{
  435. t = this.GetQueryResultType(n);
  436. if (t != null)
  437. memberSignature = this.languageService.errorHandler.GetMemberSignature(t, false);
  438. }
  439. }
  440. if (helpText != null && helpText != "")
  441. return memberSignature + "\n" + helpText;
  442. else
  443. return memberSignature;
  444. }
  445. public virtual SourceContext GetPositionOfDeclaration(int line, int col){
  446. return this.GetPositionOfDefinition(line, col);
  447. }
  448. public virtual Node GetDefinition(int line, int col) {
  449. Node n;
  450. Scope scope;
  451. int identContext;
  452. this.languageService.SearchForNodeAtPosition(line + 1, col + 1, out n, out scope, out identContext);
  453. if (n is TypeNode)
  454. return n;
  455. MemberBinding mb = this.GetMemberBinding(n);
  456. if (mb != null) {
  457. Member mem = mb.BoundMember;
  458. if (mem != null) {
  459. n = mem;
  460. }
  461. }
  462. return n;
  463. }
  464. public virtual SourceContext GetPositionOfDefinition(Node definition) {
  465. TypeNode type = definition as TypeNode;
  466. Member member = definition as Member;
  467. Identifier name = null;
  468. if (type != null)
  469. name = type.Name;
  470. else if (member != null)
  471. name = member.Name;
  472. SourceContext result = new SourceContext();
  473. if (name != null) result = name.SourceContext;
  474. return result;
  475. }
  476. public virtual SourceContext GetPositionOfDefinition(int line, int col) {
  477. return this.GetPositionOfDefinition(this.GetDefinition(line, col));
  478. }
  479. public virtual SourceContext GetPositionOfReference(int line, int col){
  480. return new SourceContext();
  481. }
  482. protected virtual MemberBinding GetMemberBinding(Node n){
  483. NameBinding nb = n as NameBinding;
  484. QualifiedIdentifier qualId = n as QualifiedIdentifier;
  485. Construct cons = n as Construct;
  486. AttributeNode attr = n as AttributeNode;
  487. MemberBinding mb = null;
  488. if (nb != null)
  489. mb = nb.BoundMember as MemberBinding;
  490. else if (qualId != null)
  491. mb = qualId.BoundMember as MemberBinding;
  492. else if (cons != null)
  493. mb = cons.Constructor as MemberBinding;
  494. else if (attr != null){
  495. Literal lit = attr.Constructor as Literal;
  496. if (lit == null || !(lit.Value is TypeNode)) return null;
  497. mb = new MemberBinding(null, (TypeNode)lit.Value);
  498. }else
  499. mb = n as MemberBinding;
  500. return mb;
  501. }
  502. protected virtual TypeNode GetQueryResultType(Node n){
  503. QualifiedIdentifier qualId = n as QualifiedIdentifier;
  504. if (qualId == null) return null;
  505. QueryAxis qAxis = qualId.Qualifier as QueryAxis;
  506. if (qAxis == null) return null;
  507. return qAxis.Type;
  508. }
  509. /// <summary>
  510. /// Called for completions.
  511. /// </summary>
  512. public virtual Declarations GetDeclarations(int line, int col, ParseReason reason){
  513. Scope scope;
  514. Node node;
  515. MemberList members = this.GetMembers(line, col, reason, out node, out scope);
  516. if (members == null) members = new MemberList(); // return empty list then.
  517. return new Declarations(members, this.helper, node, scope);
  518. }
  519. public virtual MemberList FilterByContext(MemberList originalList, int identContext) {
  520. if (originalList == null || identContext == IdentifierContexts.AllContext) return originalList;
  521. MemberList retMemberList = new MemberList();
  522. for (int i = 0; i < originalList.Count; ++i) {
  523. Member memb = originalList[i];
  524. if (!this.MemberSatisfies(memb, identContext)) continue;
  525. retMemberList.Add(memb);
  526. }
  527. return retMemberList;
  528. }
  529. public virtual bool MemberSatisfies(Member memb, int identContext) {
  530. return true;
  531. }
  532. // MemberSelectExplicit =>
  533. // if node != null then show rele vent stuff only
  534. // else show default list
  535. // MemberSelect =>
  536. // if node != null then show relevent stuff only
  537. // dont show anything
  538. public virtual MemberList GetMembers(int line, int col, ParseReason reason, out Node node, out Scope scope){
  539. int identContext;
  540. this.languageService.SearchForNodeAtPosition(line + 1, col + 1, out node, out scope, out identContext);
  541. if (identContext == IdentifierContexts.NullContext) return null;
  542. bool doingCompletion = reason == ParseReason.MemberSelect || reason == ParseReason.MemberSelectExplicit || reason == ParseReason.CompleteWord;
  543. MemberList retList = null;
  544. QualifiedIdentifier qi = node as QualifiedIdentifier;
  545. if (qi != null && qi.Identifier.UniqueIdKey == StandardIds.Ctor.UniqueIdKey && (qi.Qualifier is This || qi.Qualifier is Base) && reason == ParseReason.CompleteWord) {
  546. node = null;
  547. retList = this.GetMembers(line, col, node, scope);
  548. } else if ((node as Scope) == scope && scope != null) {
  549. retList = this.languageService.GetTypesNamespacesAndPrefixes(scope, false, false);
  550. } else if (node is AttributeNode) {
  551. retList = this.GetMembers(line, col, (AttributeNode)node, scope);
  552. } else if (node is ClassExpression) {
  553. retList = this.GetMembers(line, col, (ClassExpression)node, scope);
  554. } else if (node is InterfaceExpression) {
  555. InterfaceExpression ie = (InterfaceExpression)node;
  556. if (ie.Expression != null && ie.Expression is QualifiedIdentifier)
  557. retList = this.GetMembers(line, col, ie.Expression as QualifiedIdentifier, scope);
  558. else
  559. retList = this.GetMembers(line, col, (InterfaceExpression)node, scope);
  560. } else if (node is Construct) {
  561. retList = this.GetMembers(line, col, (Construct)node, scope, doingCompletion);
  562. } else if (node is UsedNamespace && (node.SourceContext.StartLine == line + 1)) {
  563. retList = this.languageService.GetNestedNamespaces(((UsedNamespace)node).Namespace, scope);
  564. } else if (node is AliasDefinition) {
  565. retList = this.GetMembers(line, col, (AliasDefinition)node, scope);
  566. } else if (node is Namespace) {
  567. Namespace ns = (Namespace)node;
  568. string name = ns.FullName;
  569. if (name != null && (name.Equals("global:") || name.Length == 0)) {
  570. Scope iterScope = scope;
  571. while (iterScope != null && iterScope.OuterScope != null)
  572. iterScope = iterScope.OuterScope;
  573. retList = this.languageService.GetNestedNamespacesAndTypes(Identifier.Empty, iterScope);
  574. goto returnList;
  575. }
  576. if (doingCompletion)
  577. retList = this.FillWithDefaultList(line, col, node, scope);
  578. else
  579. retList = this.GetMembers(line, col, ns, scope);
  580. } else if (node is QualifiedIdentifier) {
  581. retList = this.GetMembers(line, col, qi, scope);
  582. } else if (node is TemplateInstance) {
  583. retList = this.GetMembers(line, col, (TemplateInstance)node, scope);
  584. } else if (node is TypeExpression) {
  585. retList = this.GetMembers(line, col, (TypeExpression)node, scope);
  586. } else if (node is NameBinding) {
  587. retList = this.GetMembers(line, col, (NameBinding)node, scope, doingCompletion);
  588. } else if (node is Event || node is Method || node is Property) {
  589. retList = this.GetMembers(line, col, (Member)node, scope, doingCompletion);
  590. } else if (node is This) {
  591. retList = this.GetMembers(line, col, (This)node, scope, doingCompletion);
  592. } else if (node is Base) {
  593. retList = this.GetMembers(line, col, (Base)node, scope, doingCompletion);
  594. } else if (node is Identifier || node is Class || node is Interface) {
  595. retList = this.FillWithDefaultList(line, col, node, scope);
  596. }
  597. if (node == null && (reason == ParseReason.CompleteWord || reason == ParseReason.MemberSelectExplicit)) {
  598. retList = this.FillWithDefaultList(line, col, node, scope);
  599. } else if (reason == ParseReason.MethodTip) {
  600. Class cl = node as Class;
  601. if (cl != null && cl.IsAssignableTo(SystemTypes.Attribute)) {
  602. this.suppressAttributeSuffix = true;
  603. retList = new MemberList();
  604. MemberList memList = cl.GetConstructors();
  605. bool showInternal = this.MayAccessInternals(this.languageService.currentSymbolTable, cl);
  606. if (memList != null) {
  607. int n = memList.Count;
  608. for (int i = 0; i < n; ++i) {
  609. Member mem = memList[i];
  610. if (mem == null) continue;
  611. if (mem.IsCompilerControlled) continue;
  612. if (mem.IsPrivate) continue;
  613. if (mem.IsFamily || mem.IsFamilyAndAssembly) continue;
  614. if ((mem.IsAssembly || mem.IsFamilyOrAssembly) && !showInternal) continue;
  615. retList.Add(mem);
  616. }
  617. }
  618. }
  619. }
  620. if (retList != null && reason != ParseReason.MethodTip) {
  621. retList = this.FilterByContext(retList, identContext);
  622. this.languageService.AddReleventKeywords(retList, node, scope, identContext);
  623. }
  624. returnList:
  625. return retList;
  626. }
  627. private MemberList FillWithDefaultList(int line, int col, Node node, Scope scope) {
  628. Scope contScope = scope;
  629. if (contScope == null) contScope = this.languageService.SearchForLeastEnclosingScope(line + 1, col + 1);
  630. MemberList retList = this.GetMembers(line, col, node, contScope);
  631. if (retList != null) {
  632. Identifier id = node as Identifier;
  633. if (id != null)
  634. retList.Add(id.Type);
  635. }
  636. return retList;
  637. }
  638. protected virtual MemberList GetMembers(int line, int col, This thisNode, Scope scope, bool doingCompletion) {
  639. if (thisNode == null || scope == null || !(thisNode.Type is Class)) return null;
  640. if (thisNode.IsCtorCall)
  641. return ((Class)thisNode.Type).GetConstructors();
  642. else
  643. return ((Class)thisNode.Type).DefaultMembers;
  644. }
  645. protected virtual MemberList GetMembers(int line, int col, Base baseNode, Scope scope, bool doingCompletion) {
  646. if (baseNode == null || scope == null || !(baseNode.Type is Class)) return null;
  647. if (baseNode.IsCtorCall)
  648. return ((Class)baseNode.Type).GetConstructors();
  649. else
  650. return ((Class)baseNode.Type).DefaultMembers;
  651. }
  652. protected virtual MemberList GetMembers(int line, int col, AttributeNode attrNode, Scope scope) {
  653. if (attrNode == null || scope == null) return null;
  654. Literal lit = attrNode.Constructor as Literal;
  655. if (lit != null && lit.Value is TypeNode) return new MemberList((TypeNode)lit.Value);
  656. return this.languageService.GetNamespacesAndAttributeTypes(scope);
  657. }
  658. protected virtual MemberList GetMembers(int line, int col, AliasDefinition aliasDef, Scope scope){
  659. if (aliasDef == null || scope == null) return null;
  660. //deal with case where the alias is being defined, e.g. "using sys = System."
  661. if (aliasDef.SourceContext.StartLine == line+1)
  662. return this.languageService.GetNestedNamespacesAndTypes(aliasDef.AliasedExpression as Identifier, scope);
  663. //deal with the case where the alias is being used, e.g. "sys::"
  664. MemberList members;
  665. if (aliasDef.AliasedNamespace != null && aliasDef.AliasedNamespace.Name != null)
  666. members = this.GetMembers(line, col, new QualifiedIdentifier(aliasDef.AliasedNamespace, Identifier.Empty, aliasDef.SourceContext), scope);
  667. else
  668. members = this.languageService.GetNestedNamespacesAndTypes(Identifier.Empty, scope, aliasDef.AliasedAssemblies);
  669. if (scope is AttributeScope) return members;
  670. if (aliasDef.RestrictToClassesAndInterfaces)
  671. members = this.GetClassesAndInterfacesAndNamespacesThatContainThem(members, null);
  672. else if (aliasDef.RestrictToInterfaces)
  673. members = this.GetInterfacesAndNamespacesThatContainThem(scope, members);
  674. return members;
  675. }
  676. protected virtual MemberList GetMembers(int line, int col, ClassExpression cExpr, Scope scope){
  677. if (cExpr == null) return null;
  678. MemberList members;
  679. QualifiedIdentifier qual = cExpr.Expression as QualifiedIdentifier;
  680. if (qual != null)
  681. members = this.GetMembers(line, col, qual, scope);
  682. else
  683. members = this.languageService.GetTypesNamespacesAndPrefixes(scope, false, false);
  684. if (members == null) return null;
  685. return this.GetClassesAndInterfacesAndNamespacesThatContainThem(members, cExpr.DeclaringType);
  686. }
  687. protected virtual MemberList GetClassesAndInterfacesAndNamespacesThatContainThem(MemberList members, TypeNode classToExclude){
  688. MemberList result = new MemberList(members.Count);
  689. for (int i = 0, n = members.Count; i < n; i++) {
  690. Member mem = members[i];
  691. if (mem is Class && classToExclude != null && mem.FullName == classToExclude.FullName) continue;
  692. if (mem is Interface || mem is Namespace)
  693. result.Add(mem); //TODO: show namespaces only if they have classes or interfaces or types with nested classes/interfaces.
  694. else{
  695. Class cl = mem as Class;
  696. if (cl == null || cl.IsSealed || cl == SystemTypes.Array || cl == SystemTypes.Delegate || cl == SystemTypes.Enum ||
  697. cl == SystemTypes.MulticastDelegate || cl == SystemTypes.ValueType) continue;
  698. result.Add(mem);
  699. }
  700. }
  701. if (result.Count == 0) return null;
  702. return result;
  703. }
  704. protected virtual MemberList GetConstructibleTypesAndAndNamespacesThatContainThem(MemberList members, TypeNode referringType){
  705. MemberList result = new MemberList(members.Count);
  706. for (int i = 0, n = members.Count; i < n; i++) {
  707. Member mem = members[i];
  708. if (mem is Namespace)
  709. result.Add(mem); //TODO: show namespaces only if they have classes or interfaces or types with nested classes/interfaces.
  710. else{
  711. TypeNode t = mem as TypeNode;
  712. if (t == null || this.languageService.TypeHasNoVisibleConstructorsOrIsAbstract(t, referringType)) continue;
  713. result.Add(mem);
  714. }
  715. }
  716. if (result.Count == 0) return null;
  717. return result;
  718. }
  719. protected virtual MemberList GetMembers(int line, int col, InterfaceExpression iExpr, Scope scope) {
  720. MemberList members = this.languageService.GetTypesNamespacesAndPrefixes(scope, false, false);
  721. if (members == null) return null;
  722. return this.GetInterfacesAndNamespacesThatContainThem(scope, members);
  723. }
  724. protected virtual MemberList GetInterfacesAndNamespacesThatContainThem(Scope scope, MemberList members){
  725. MemberList result = new MemberList(members.Count);
  726. for (int i = 0, n = members.Count; i < n; i++) {
  727. Member mem = members[i];
  728. if (mem is Interface || mem is Namespace || (mem is TypeNode && this.HasNestedInterface((TypeNode)mem, scope)))
  729. result.Add(mem); //TODO: show namespaces only if they have interfaces or types with nested interfaces
  730. }
  731. if (result.Count == 0) return null;
  732. return result;
  733. }
  734. private bool HasNestedInterface(TypeNode typeNode, Scope scope){
  735. if (typeNode == null) return false;
  736. MemberList members = typeNode.Members;
  737. for (int i = 0, n = members == null ? 0 : members.Count; i < n; i++){
  738. TypeNode nt = members[i] as TypeNode;
  739. if (nt == null) continue;
  740. if (nt.IsPrivate) continue; //TODO: check that other visibilities are visible from given scope
  741. if (nt is Interface) return true;
  742. if (this.HasNestedInterface(nt, scope)) return true;
  743. }
  744. return false;
  745. }
  746. protected virtual MemberList GetMembers(int line, int col, Namespace nspace, Scope scope){
  747. if (nspace == null || nspace.Name == null || scope == null) return null;
  748. string nsname = nspace.Name.ToString();
  749. if (nsname == null || nsname.Length == 0) return null;
  750. if (nsname[nsname.Length-1] == ':') nsname = nsname.Substring(0, nsname.Length-1) + ".";
  751. return this.languageService.GetNestedNamespacesAndTypes(Identifier.For(nsname), scope);
  752. }
  753. protected virtual MemberList GetMembers(int line, int col, Construct cons, Scope scope, bool doingCompletion){
  754. if (cons == null) return null;
  755. MemberBinding mb = cons.Constructor as MemberBinding;
  756. if (mb != null && !doingCompletion) {
  757. if (mb.BoundMember is InstanceInitializer && mb.BoundMember.DeclaringType != null)
  758. return new MemberList(mb.BoundMember.DeclaringType);
  759. else if (mb.BoundMember is TypeNode) {
  760. return new MemberList(mb.BoundMember);
  761. }
  762. }
  763. MemberList result = null;
  764. QualifiedIdentifier qual = cons.Constructor as QualifiedIdentifier;
  765. if (qual != null){
  766. if (qual.Qualifier is Literal && ((Literal)qual.Qualifier).Value is TypeNode)
  767. return this.languageService.GetConstructibleNestedTypes((TypeNode)((Literal)qual.Qualifier).Value, this.GetReferringType(scope));
  768. result = this.GetMembers(line, col, qual, scope);
  769. if (result != null)
  770. return this.GetConstructibleTypesAndAndNamespacesThatContainThem(result, this.GetReferringType(scope));
  771. }
  772. if (scope != null) result = this.languageService.GetTypesNamespacesAndPrefixes(scope, true, false);
  773. if (result != null){
  774. if (cons.Type != null && !(cons.Type is Reference)) {
  775. TypeNode type = cons.Type;
  776. while (type != null) {
  777. if (type is ArrayType)
  778. type = ((ArrayType)type).ElementType;
  779. else if (type is Pointer)
  780. type = ((Pointer)type).ElementType;
  781. else
  782. break;
  783. }
  784. if (type != null && (type != cons.Type || !this.languageService.TypeHasNoVisibleConstructorsOrIsAbstract(type, this.GetReferringType(scope))))
  785. result.Add(type);
  786. else
  787. result.Add(null); // Always add something to the end of the list in the case of constructor. We will remove this later when creating declaration.
  788. }
  789. if (result.Count > 0) return result;
  790. }
  791. return null;
  792. }
  793. protected virtual MemberList FilterOutIncassessibleMembers(MemberList members, Scope scope){
  794. if (members == null) return null;
  795. TypeNode referringType = GetReferringType(scope);
  796. MemberList result = new MemberList(members.Count);
  797. for (int i = 0, n = members.Count; i < n; i++){
  798. Member member = members[i];
  799. if (member == null) continue;
  800. if (member.IsPrivate && referringType != member.DeclaringType) continue;
  801. if ((member.IsFamily || member.IsFamilyAndAssembly) && referringType.IsAssignableTo(member.DeclaringType)) continue;
  802. if (member.IsAssembly && !this.MayAccessInternals(referringType, member.DeclaringType)) continue;
  803. if (member.IsFamilyOrAssembly && !referringType.IsAssignableTo(member.DeclaringType) && !this.MayAccessInternals(referringType, member.DeclaringType)) continue;
  804. result.Add(member);
  805. }
  806. return result;
  807. }
  808. protected virtual TypeNode GetReferringType(Scope scope){
  809. TypeNode referringType = null;
  810. while (scope != null) {
  811. TypeScope tScope = scope as TypeScope;
  812. if (tScope != null) {
  813. referringType = tScope.Type;
  814. break;
  815. }
  816. scope = scope.OuterScope;
  817. }
  818. return referringType;
  819. }
  820. protected virtual MemberList GetMembers(int line, int col, Node node, Scope scope){
  821. if (node is MemberBinding) return null;
  822. if (scope != null) return this.languageService.GetVisibleNames(scope);
  823. return null;
  824. }
  825. protected virtual MemberList GetMembers(int line, int col, NameBinding nameBinding, Scope scope, bool doingCompletion) {
  826. if (nameBinding == null) return null;
  827. if (nameBinding.BoundMembers != null && !doingCompletion)
  828. return this.FilterOutIncassessibleMembers(nameBinding.BoundMembers, scope);
  829. if (scope != null) return this.languageService.GetVisibleNames(scope);
  830. return null;
  831. }
  832. protected virtual MemberList GetMembers(int line, int col, Member memberNode, Scope scope, bool doingCompletion) {
  833. if (memberNode == null) return null;
  834. Interface i = null;
  835. TypeNode type = memberNode.DeclaringType;
  836. NodeType toShow = NodeType.Method;
  837. Event e = memberNode as Event;
  838. if (e != null){
  839. if (e.ImplementedTypes == null || e.ImplementedTypes.Count == 0) return null;
  840. i = e.ImplementedTypes[0] as Interface;
  841. toShow = NodeType.Event;
  842. }
  843. Property p = memberNode as Property;
  844. if(p != null){
  845. if (p.ImplementedTypes == null || p.ImplementedTypes.Count == 0) return null;
  846. i = p.ImplementedTypes[0] as Interface;
  847. toShow = NodeType.Method;
  848. }
  849. Method m = memberNode as Method;
  850. if(m != null){
  851. if (m.ImplementedTypes == null || m.ImplementedTypes.Count == 0) return null;
  852. i = m.ImplementedTypes[0] as Interface;
  853. toShow = NodeType.Method;
  854. }
  855. if (i == null) return null;
  856. TypeNode referringType = null;
  857. while (scope != null) {
  858. TypeScope tScope = scope as TypeScope;
  859. if (tScope != null) {
  860. referringType = tScope.Type;
  861. break;
  862. }
  863. scope = scope.OuterScope;
  864. }
  865. bool showInternal = this.MayAccessInternals(referringType, type);
  866. MemberList result = new MemberList();
  867. this.GetMembers(i, result, showInternal, toShow);
  868. return result;
  869. }
  870. protected virtual MemberList GetMembers(int line, int col, QualifiedIdentifier qualId, Scope scope) {
  871. if (qualId == null) return null;
  872. bool staticMembersWanted = true;
  873. bool allMembersWanted = false;
  874. Node n = qualId.Qualifier;
  875. if (n == null || n.IsErroneous) return null;
  876. if (n is ConstructArray) return null;
  877. TypeNode type = null;
  878. MemberBinding mb = this.GetMemberBinding(n);
  879. if (mb != null){
  880. staticMembersWanted = false;
  881. Member mem = mb.BoundMember;
  882. if (mem is Field)
  883. type = ((Field)mem).Type;
  884. else if (mem is Property)
  885. type = ((Property)mem).Type;
  886. else if (mem is InstanceInitializer)
  887. type = mem.DeclaringType;
  888. //TODO: other stuff? Events?
  889. allMembersWanted = (mem != null && type != null && mem.Name != null && type.Name != null && mem.Name.UniqueIdKey == type.Name.UniqueIdKey);
  890. }else{
  891. if (n is Identifier || n is NameBinding || n is QualifiedIdentifier){
  892. NameBinding nb = n as NameBinding;
  893. if (nb != null) n = nb.Identifier;
  894. return this.languageService.GetNestedNamespacesAndTypes(this.ConvertToNamespaceId((Expression)n), scope);
  895. }
  896. type = n as TypeNode;
  897. if (type == null){
  898. if (n is Literal){
  899. if (Literal.IsNullLiteral((Literal)n)) return null;
  900. type = ((Literal)n).Value as TypeNode;
  901. }
  902. Expression expr = n as Expression;
  903. if (type == null && expr != null){
  904. if (n is Base && n.SourceContext.Document == null) return null;
  905. staticMembersWanted = false;
  906. type = expr.Type;
  907. MethodCall mc = expr as MethodCall;
  908. bool useEnum = false;
  909. if (mc != null && mc.Callee is MemberBinding) {
  910. Member mem = ((MemberBinding)mc.Callee).BoundMember;
  911. Method meth = mem as Method;
  912. if (meth != null) {
  913. Property p = meth.DeclaringMember as Property;
  914. useEnum = p == null;
  915. allMembersWanted = p != null && type != null && p.Name != null && type.Name != null && p.Name.UniqueIdKey == type.Name.UniqueIdKey;
  916. }
  917. }
  918. if (type is EnumNode && useEnum) type = SystemTypes.Enum;
  919. }
  920. }
  921. }
  922. TypeAlias ta = type as TypeAlias;
  923. while (ta != null) {
  924. type = ta.AliasedType;
  925. ta = type as TypeAlias;
  926. }
  927. type = TypeNode.StripModifiers(type);
  928. if (type is Reference) type = ((Reference)type).ElementType;
  929. if (type == null || type == SystemTypes.Void) return null;
  930. TypeNode referringType = null;
  931. while (scope != null){
  932. TypeScope tScope = scope as TypeScope;
  933. if (tScope != null){
  934. referringType = tScope.Type;
  935. break;
  936. }
  937. scope = scope.OuterScope;
  938. }
  939. Debug.Assert(referringType != SystemTypes.Object);
  940. MemberList result = new MemberList();
  941. bool showPrivate = referringType == type;
  942. bool showFamily = referringType == null || type.IsAssignableTo(referringType) || n is Base;
  943. bool showInternal = this.MayAccessInternals(referringType, type);
  944. this.GetMembers(type, result, staticMembersWanted, allMembersWanted, showPrivate, showFamily, showInternal);
  945. return result;
  946. }
  947. protected virtual Identifier ConvertToNamespaceId(Expression expression){
  948. Identifier id = expression as Identifier;
  949. if (id != null) return Identifier.For(id.Name+".");
  950. NameBinding nb = expression as NameBinding;
  951. if (nb != null) return Identifier.For(nb.Identifier.Name + ".");
  952. QualifiedIdentifier qualId = expression as QualifiedIdentifier;
  953. if (qualId != null) return Identifier.For(this.ConvertToNamespaceId(qualId.Qualifier)+qualId.Identifier.Name+".");
  954. return Identifier.Empty;
  955. }
  956. protected virtual MemberList GetMembers(int line, int col, TemplateInstance templateInstance, Scope scope){
  957. if (templateInstance == null) return null;
  958. return this.FilterOutIncassessibleMembers(templateInstance.BoundMembers, scope);
  959. }
  960. protected virtual MemberList GetMembers(int line, int col, TypeExpression tExpr, Scope scope) {
  961. if (tExpr == null) return null;
  962. MemberList members;
  963. QualifiedIdentifier qual = tExpr.Expression as QualifiedIdentifier;
  964. if (qual != null)
  965. members = this.GetMembers(line, col, qual, scope);
  966. else
  967. members = this.languageService.GetTypesNamespacesAndPrefixes(scope, true, false);
  968. if (members == null) return null;
  969. return this.GetTypesAndNamespacesThatContainThem(members);
  970. }
  971. protected virtual MemberList GetTypesAndNamespacesThatContainThem(MemberList members) {
  972. MemberList result = new MemberList(members.Count);
  973. for (int i = 0, n = members.Count; i < n; i++) {
  974. Member mem = members[i];
  975. if (mem is TypeNode || mem is Namespace)
  976. result.Add(mem);
  977. }
  978. if (result.Count == 0) return null;
  979. return result;
  980. }
  981. protected virtual bool MayAccessInternals(TypeNode referringType, TypeNode referredToType) {
  982. if (referringType == null || referredToType == null) return false;
  983. Module referringModule = referringType.DeclaringModule;
  984. return this.MayAccessInternals(referringModule, referredToType);
  985. }
  986. protected virtual bool MayAccessInternals(Module referringModule, TypeNode referredToType) {
  987. if (referringModule == null || referredToType == null) return false;
  988. Module referredToModule = referredToType.DeclaringModule;
  989. if (referredToModule == null) return false;
  990. if (referringModule == referredToModule) return true;
  991. AssemblyNode referringAssembly = referringModule.ContainingAssembly;
  992. AssemblyNode referredToAssembly = referredToModule.ContainingAssembly;
  993. if (referringAssembly == null) referringAssembly = referringModule as AssemblyNode;
  994. if (referredToAssembly == null) referredToAssembly = referredToModule as AssemblyNode;
  995. if (referringAssembly == null) return referringModule.ContainsModule(referredToModule);
  996. if (referringAssembly == referredToAssembly) return true;
  997. if (referringAssembly.ContainsModule(referringModule)) return true;
  998. return referringAssembly.MayAccessInternalTypesOf(referredToAssembly);
  999. }
  1000. protected virtual void GetMembers(Interface type, MemberList memberList, bool showInternal, NodeType memberKind) {
  1001. if (type == null) return;
  1002. MemberList typeMembers = type.Members;
  1003. for (int i = 0, k = typeMembers == null ? 0 : typeMembers.Count; i < k; i++) {
  1004. Member mem = typeMembers[i];
  1005. if (mem == null) continue;
  1006. if (mem.IsCompilerControlled) continue;
  1007. if (mem.IsPrivate) continue;
  1008. if ((mem.IsAssembly || mem.IsFamilyOrAssembly) && !showInternal) continue;
  1009. if (mem.IsSpecialName && !(mem is InstanceInitializer)) continue;
  1010. if (this.SuppressBecauseItIsADefaultMember(mem, type.DefaultMembers)) continue;
  1011. if (mem.IsAnonymous || this.MemberIsOverriddenOrHidden(mem, memberList)) continue;
  1012. if ((memberKind == NodeType.Event && mem is Event) || (memberKind == NodeType.Method && (mem is Property || mem is Method)))
  1013. memberList.Add(mem);
  1014. }
  1015. for (int i = 0, k = type.Interfaces == null ? 0 : type.Interfaces.Count; i < k; i++) {
  1016. this.GetMembers(type.Interfaces[i], memberList, showInternal, memberKind);
  1017. }
  1018. }
  1019. protected virtual void GetMembers(TypeNode type, MemberList members, bool onlyStaticMembersWanted, bool allMembersWanted, bool showPrivate, bool showFamily, bool showInternal) {
  1020. if (type == null || members == null) return;
  1021. if (type is ArrayType){
  1022. this.GetMembers(SystemTypes.Array, members, onlyStaticMembersWanted, allMembersWanted, showPrivate, showFamily, showInternal);
  1023. return;
  1024. }
  1025. TypeUnion tu = type as TypeUnion;
  1026. if (tu != null){
  1027. TypeNodeList tlist = tu.Types;
  1028. for (int i = 0, n = (tlist == null ? 0 : tlist.Count); i < n; i++){
  1029. TypeNode t = tlist[i] as TypeNode;
  1030. if (t == null) continue;
  1031. this.GetMembers(t, members, onlyStaticMembersWanted, allMembersWanted, showPrivate, showFamily, showInternal);
  1032. }
  1033. return;
  1034. }
  1035. TypeAlias ta = type as TypeAlias;
  1036. if (ta != null){
  1037. this.GetMembers(ta.AliasedType, members, onlyStaticMembersWanted, allMembersWanted, showPrivate, showFamily, showInternal);
  1038. return;
  1039. }
  1040. MemberList typeMembers = type.Members;
  1041. for (int i = 0, k = typeMembers == null ? 0 : typeMembers.Count; i < k; i++){
  1042. Member mem = typeMembers[i];
  1043. if (mem == null) continue;
  1044. if (onlyStaticMembersWanted != mem.IsStatic && !allMembersWanted) continue;
  1045. if (mem.IsCompilerControlled) continue;
  1046. if (mem.IsPrivate && !showPrivate) continue;
  1047. if ((mem.IsFamily || mem.IsFamilyAndAssembly) && !showFamily) continue;
  1048. if ((m

Large files files are truncated, but you can click here to view the full file