Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3975 from bclothier/techdebt
Reflection API & COM management/cleanup
- Loading branch information
Showing
112 changed files
with
4,460 additions
and
495 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.ComponentModel; | ||
using Rubberduck.API.VBA; | ||
using System.Runtime.InteropServices; | ||
using Rubberduck.Resources.Registration; | ||
|
||
namespace Rubberduck.API | ||
{ | ||
[ | ||
ComVisible(true), | ||
Guid(RubberduckGuid.IApiProviderGuid), | ||
InterfaceType(ComInterfaceType.InterfaceIsDual) | ||
] | ||
public interface IApiProvider | ||
{ | ||
Parser GetParser(object vbe); | ||
} | ||
|
||
[ | ||
ComVisible(true), | ||
Guid(RubberduckGuid.ApiProviderClassGuid), | ||
ProgId(RubberduckProgId.ApiProviderProgId), | ||
ClassInterface(ClassInterfaceType.None), | ||
ComDefaultInterface(typeof(IApiProvider)), | ||
EditorBrowsable(EditorBrowsableState.Always) | ||
] | ||
public class ApiProvider : IApiProvider | ||
{ | ||
// vbe is the com coclass interface from the interop assembly. | ||
// There is no shared interface between VBA and VB6 types, hence object. | ||
public Parser GetParser(object vbe) | ||
{ | ||
return new Parser(vbe); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Runtime.InteropServices; | ||
using Rubberduck.Resources.Registration; | ||
using Source = Rubberduck.Parsing.Symbols; | ||
|
||
namespace Rubberduck.API.VBA | ||
{ | ||
[ | ||
ComVisible(true), | ||
Guid(RubberduckGuid.AccessibilityGuid) | ||
] | ||
public enum Accessibility | ||
{ | ||
Private = Source.Accessibility.Private, | ||
Friend = Source.Accessibility.Friend, | ||
Global = Source.Accessibility.Global, | ||
Implicit = Source.Accessibility.Implicit, | ||
Public = Source.Accessibility.Public, | ||
Static = Source.Accessibility.Static | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Runtime.InteropServices; | ||
using Rubberduck.Resources.Registration; | ||
using Source = Rubberduck.Parsing.Symbols; | ||
|
||
namespace Rubberduck.API.VBA | ||
{ | ||
[ | ||
ComVisible(true), | ||
Guid(RubberduckGuid.DeclarationTypeGuid) | ||
] | ||
public enum DeclarationType | ||
{ | ||
//TODO: figure out a cleaner way to handle long/int | ||
BracketedExpression = (int)Source.DeclarationType.BracketedExpression, | ||
ClassModule = (int)Source.DeclarationType.ClassModule, | ||
ComAlias = (int)Source.DeclarationType.ComAlias, | ||
Constant = (int)Source.DeclarationType.Constant, | ||
Control = (int)Source.DeclarationType.Control, | ||
Document = (int)Source.DeclarationType.Document, | ||
Enumeration = (int)Source.DeclarationType.Enumeration, | ||
EnumerationMember = (int)Source.DeclarationType.EnumerationMember, | ||
Event = (int)Source.DeclarationType.Event, | ||
Function = (int)Source.DeclarationType.Function, | ||
LibraryFunction = (int)Source.DeclarationType.LibraryFunction, | ||
LibraryProcedure = (int)Source.DeclarationType.LibraryProcedure, | ||
LineLabel = (int)Source.DeclarationType.LineLabel, | ||
Member = (int)Source.DeclarationType.Member, | ||
Module = (int)Source.DeclarationType.Module, | ||
Parameter = (int)Source.DeclarationType.Parameter, | ||
ProceduralModule = (int)Source.DeclarationType.ProceduralModule, | ||
Procedure = (int)Source.DeclarationType.Procedure, | ||
Project = (int)Source.DeclarationType.Project, | ||
Property = (int)Source.DeclarationType.Property, | ||
PropertyGet = (int)Source.DeclarationType.PropertyGet, | ||
PropertyLet = (int)Source.DeclarationType.PropertyLet, | ||
PropertySet = (int)Source.DeclarationType.PropertySet, | ||
UnresolvedMember = (int)Source.DeclarationType.UnresolvedMember, | ||
UserDefinedType = (int)Source.DeclarationType.UserDefinedType, | ||
UserDefinedTypeMember = (int)Source.DeclarationType.UserDefinedTypeMember, | ||
UserForm = (int)Source.DeclarationType.UserForm, | ||
Variable = (int)Source.DeclarationType.Variable | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using Rubberduck.Resources.Registration; | ||
|
||
namespace Rubberduck.API.VBA | ||
{ | ||
[ | ||
ComVisible(true), | ||
Guid(RubberduckGuid.IDeclarationsGuid), | ||
InterfaceType(ComInterfaceType.InterfaceIsDual) | ||
] | ||
public interface IDeclarations : IEnumerable | ||
{ | ||
[DispId(WellKnownDispIds.Value)] | ||
Declaration Item(int Index); | ||
|
||
[DispId(1)] | ||
int Count { get; } | ||
|
||
[DispId(WellKnownDispIds.NewEnum)] | ||
IEnumerator _GetEnumerator(); | ||
} | ||
|
||
[ | ||
ComVisible(true), | ||
Guid(RubberduckGuid.DeclarationsClassGuid), | ||
ProgId(RubberduckProgId.DeclarationsProgId), | ||
ClassInterface(ClassInterfaceType.None), | ||
ComDefaultInterface(typeof(IDeclarations)) | ||
] | ||
public class Declarations : IDeclarations, IEnumerable<Declaration> | ||
{ | ||
private readonly IEnumerable<Declaration> _declarations; | ||
|
||
public int Count => _declarations.Count(); | ||
|
||
internal Declarations(IEnumerable<Declaration> declarations) | ||
{ | ||
_declarations = declarations; | ||
} | ||
|
||
public Declaration Item(int Index) | ||
{ | ||
return _declarations.ElementAt(Index); | ||
} | ||
|
||
public IEnumerator<Declaration> GetEnumerator() | ||
{ | ||
return _declarations.GetEnumerator(); | ||
} | ||
|
||
public IEnumerator _GetEnumerator() | ||
{ | ||
return _declarations.GetEnumerator(); | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() | ||
{ | ||
return _declarations.GetEnumerator(); | ||
} | ||
} | ||
} |
Oops, something went wrong.