Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions RetailCoder.VBE/API/Declaration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ namespace Rubberduck.API
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IDeclaration
{
[ComVisible(true)]
string Name { get; }
[ComVisible(true)]
Accessibility Accessibility { get; }
[ComVisible(true)]
DeclarationType DeclarationType { get; }
string TypeName { get; }
[ComVisible(true)]
bool IsArray { get; }

[ComVisible(true)]
Declaration ParentDeclaration { get; }

[ComVisible(true)]
IdentifierReference[] References { get; }
}

Expand Down
14 changes: 10 additions & 4 deletions RetailCoder.VBE/API/ParserState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
using System.Linq;
using System.Runtime.InteropServices;
using Rubberduck.Common;
using Rubberduck.Parsing.Symbols.DeclarationLoaders;
using Rubberduck.Parsing.VBA;
using Rubberduck.UI.Command.MenuItems;
using Rubberduck.Parsing.Preprocessing;
using System.Globalization;
using Rubberduck.Parsing.Symbols;
using Rubberduck.VBEditor.SafeComWrappers;
using Rubberduck.VBEditor.SafeComWrappers.VBA;

namespace Rubberduck.API
Expand Down Expand Up @@ -72,7 +71,14 @@ public void Initialize(Microsoft.Vbe.Interop.VBE vbe)
Func<IVBAPreprocessor> preprocessorFactory = () => new VBAPreprocessor(double.Parse(_vbe.Version, CultureInfo.InvariantCulture));
_attributeParser = new AttributeParser(new ModuleExporter(), preprocessorFactory);
_parser = new ParseCoordinator(_vbe, _state, _attributeParser, preprocessorFactory,
new List<ICustomDeclarationLoader> { new DebugDeclarations(_state), new SpecialFormDeclarations(_state), new FormEventDeclarations(_state), new AliasDeclarations(_state) });
new List<ICustomDeclarationLoader>
{
new DebugDeclarations(_state),
new SpecialFormDeclarations(_state),
new FormEventDeclarations(_state),
new AliasDeclarations(_state),
//new RubberduckApiDeclarations(_state)
});
}

/// <summary>
Expand All @@ -97,7 +103,7 @@ public void BeginParse()
public event Action OnReady;
public event Action OnError;

private void _state_StateChanged(object sender, System.EventArgs e)
private void _state_StateChanged(object sender, EventArgs e)
{
_allDeclarations = _state.AllDeclarations
.Select(item => new Declaration(item))
Expand Down
1 change: 1 addition & 0 deletions RetailCoder.VBE/Root/RubberduckModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Ninject.Modules;
using Rubberduck.Common;
using Rubberduck.Parsing;
using Rubberduck.Parsing.Symbols.DeclarationLoaders;
using Rubberduck.Parsing.VBA;
using Rubberduck.Settings;
using Rubberduck.SettingsProvider;
Expand Down
12 changes: 2 additions & 10 deletions RetailCoder.VBE/UnitTesting/TestMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Rubberduck.Parsing;
using Rubberduck.Parsing.Symbols;
using Rubberduck.UI;
using Rubberduck.UI.Controls;
Expand Down Expand Up @@ -88,16 +89,7 @@ private AssertCompletedEventArgs EvaluateResults()

public NavigateCodeEventArgs GetNavigationArgs()
{
var moduleName = Declaration.QualifiedName.QualifiedModuleName;
var methodName = Declaration.IdentifierName;
var module = moduleName.Component.CodeModule;

var startLine = module.GetProcBodyStartLine(methodName, ProcKind.Procedure);
var endLine = startLine + module.GetProcCountLines(methodName, ProcKind.Procedure);
var endLineColumns = module.GetLines(endLine, 1).Length;

var selection = new Selection(startLine, 1, endLine, endLineColumns == 0 ? 1 : endLineColumns);
return new NavigateCodeEventArgs(new QualifiedSelection(moduleName, selection));
return new NavigateCodeEventArgs(new QualifiedSelection(Declaration.QualifiedName.QualifiedModuleName, Declaration.Context.GetSelection()));
}

public object[] ToArray()
Expand Down
11 changes: 6 additions & 5 deletions Rubberduck.Parsing/Rubberduck.Parsing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@
<Compile Include="ComReflection\ComMember.cs" />
<Compile Include="ComReflection\ComModule.cs" />
<Compile Include="ComReflection\ComProject.cs" />
<Compile Include="Symbols\SpecialFormDeclarations.cs" />
<Compile Include="Symbols\DeclarationLoaders\SpecialFormDeclarations.cs" />
<Compile Include="Symbols\CommentNode.cs" />
<Compile Include="ComReflection\ComParameter.cs" />
<Compile Include="Symbols\DebugDeclarations.cs" />
<Compile Include="Symbols\AliasDeclarations.cs" />
<Compile Include="Symbols\FormEventDeclarations.cs" />
<Compile Include="Symbols\ICustomDeclarationLoader.cs" />
<Compile Include="Symbols\DeclarationLoaders\DebugDeclarations.cs" />
<Compile Include="Symbols\DeclarationLoaders\AliasDeclarations.cs" />
<Compile Include="Symbols\DeclarationLoaders\FormEventDeclarations.cs" />
<Compile Include="Symbols\DeclarationLoaders\ICustomDeclarationLoader.cs" />
<Compile Include="Symbols\Identifier.cs" />
<Compile Include="Binding\IBindingContext.cs" />
<Compile Include="Binding\IBoundExpression.cs" />
Expand Down Expand Up @@ -257,6 +257,7 @@
<Compile Include="Symbols\PropertySetDeclaration.cs" />
<Compile Include="Symbols\PropertyGetDeclaration.cs" />
<Compile Include="Symbols\FunctionDeclaration.cs" />
<Compile Include="Symbols\DeclarationLoaders\RubberduckApiDeclarations.cs" />
<Compile Include="Symbols\SerializableDeclaration.cs" />
<Compile Include="Symbols\SquareBracketedNameComparer.cs" />
<Compile Include="Symbols\SubroutineDeclaration.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using Rubberduck.Parsing.VBA;
using Rubberduck.VBEditor;
using System.Linq;
using Rubberduck.Parsing.Annotations;
using Rubberduck.Parsing.VBA;
using Rubberduck.VBEditor;

namespace Rubberduck.Parsing.Symbols
namespace Rubberduck.Parsing.Symbols.DeclarationLoaders
{
public class AliasDeclarations : ICustomDeclarationLoader
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using Rubberduck.Parsing.Annotations;
using System.Collections.Generic;
using System.Linq;
using Rubberduck.Parsing.Annotations;
using Rubberduck.Parsing.VBA;
using Rubberduck.VBEditor;
using System.Collections.Generic;
using System.Linq;
using Rubberduck.Parsing.Grammar;

namespace Rubberduck.Parsing.Symbols
namespace Rubberduck.Parsing.Symbols.DeclarationLoaders
{
public class DebugDeclarations : ICustomDeclarationLoader
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using Rubberduck.Parsing.Annotations;
using Rubberduck.Parsing.VBA;
using Rubberduck.VBEditor;
using Rubberduck.Parsing.Annotations;

namespace Rubberduck.Parsing.Symbols
namespace Rubberduck.Parsing.Symbols.DeclarationLoaders
{
public class FormEventDeclarations : ICustomDeclarationLoader
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace Rubberduck.Parsing.Symbols
namespace Rubberduck.Parsing.Symbols.DeclarationLoaders
{
public interface ICustomDeclarationLoader
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
//using System;
//using System.Collections.Generic;
//using System.Diagnostics;
//using System.IO;
//using System.Linq;
//using System.Reflection;
//using System.Runtime.InteropServices;
//using Rubberduck.Parsing.Annotations;
//using Rubberduck.Parsing.ComReflection;
//using Rubberduck.Parsing.VBA;
//using Rubberduck.VBEditor;

//namespace Rubberduck.Parsing.Symbols.DeclarationLoaders
//{
// public class RubberduckApiDeclarations : ICustomDeclarationLoader
// {
// private readonly RubberduckParserState _state;
// private readonly List<Declaration> _declarations = new List<Declaration>();

// public RubberduckApiDeclarations(RubberduckParserState state)
// {
// _state = state;
// }

// public IReadOnlyList<Declaration> Load()
// {
// var assembly = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(a => a.GetName().Name.Equals("Rubberduck"));
// if (assembly == null)
// {
// return _declarations;
// }

// var name = assembly.GetName();
// var path = Path.ChangeExtension(assembly.Location, "tlb");

// var projectName = new QualifiedModuleName("Rubberduck", path, "Rubberduck");
// var project = new ProjectDeclaration(projectName.QualifyMemberName("Rubberduck"), "Rubberduck", true, null)
// {
// MajorVersion = name.Version.Major,
// MinorVersion = name.Version.Minor
// };
// _declarations.Add(project);

// var types = assembly.DefinedTypes.WhereIsComVisible();

// foreach (var type in types)
// {
// var module = type.ToModuleDeclaration(project, projectName, type.IsEnum);
// _declarations.Add(module);

// var properties = type.GetProperties().WhereIsComVisible().ToList();

// foreach (var property in properties)
// {
// if (property.CanWrite && property.GetSetMethod().IsPublic)
// {
// var declaration = property.ToMemberDeclaration(module, false);
// _declarations.Add(declaration);
// }
// if (property.CanRead && property.GetGetMethod().IsPublic)
// {
// var declaration = property.ToMemberDeclaration(module, true);
// _declarations.Add(declaration);
// }
// }

// var members = type.GetMembers().WhereIsComVisible();

// foreach (var member in members)
// {
// if (member.MemberType == MemberTypes.Property)
// {

// }
// //var declaration = member.ToMemberDeclaration(project);
// }
// };
// return _declarations;
// }
// }

// internal static class RubberduckApiDeclarationStatics
// {
// public static IEnumerable<T> WhereIsComVisible<T>(this IEnumerable<T> source) where T : MemberInfo
// {
// return source.Where(member =>
// {
// var attr = member.GetCustomAttributes(typeof(ComVisibleAttribute), true).FirstOrDefault();
// return attr != null && ((ComVisibleAttribute)attr).Value;
// });
// }

// public static Declaration ToModuleDeclaration(this TypeInfo type, Declaration project, QualifiedModuleName projectName, bool isEnum = false)
// {
// return isEnum ? new ProceduralModuleDeclaration(projectName.QualifyMemberName(type.Name), project, type.Name, true, null, null) as Declaration :
// new ClassModuleDeclaration(projectName.QualifyMemberName(type.Name), project, type.Name, true, null, null);
// }

// public static Declaration ToMemberDeclaration(this PropertyInfo member, Declaration parent, bool getter)
// {
// if (getter)
// {
// return new PropertyGetDeclaration(parent.QualifiedName.QualifiedModuleName.QualifyMemberName(member.Name),
// parent,
// parent,
// member.PropertyType.ToVbaTypeName(),
// null,
// string.Empty,
// parent.Accessibility,
// null,
// Selection.Home,
// member.PropertyType.IsArray,
// true,
// null,
// new Attributes());
// }
// if (member.PropertyType.IsClass)
// {
// return new PropertySetDeclaration(parent.QualifiedName.QualifiedModuleName.QualifyMemberName(member.Name),
// parent,
// parent,
// member.PropertyType.ToVbaTypeName(),
// parent.Accessibility,
// null,
// Selection.Home,
// true,
// null,
// new Attributes());
// }
// return new PropertyLetDeclaration(parent.QualifiedName.QualifiedModuleName.QualifyMemberName(member.Name),
// parent,
// parent,
// member.PropertyType.ToVbaTypeName(),
// parent.Accessibility,
// null,
// Selection.Home,
// true,
// null,
// new Attributes());
// }

// public static string ToVbaTypeName(this Type type)
// {
// var name = string.Empty;
// if (type.IsClass || type.IsEnum)
// {
// name = type.Name;
// }
// switch (type.Name)
// {
// case "bool":
// name = "Boolean";
// break;
// case "short":
// name = "Integer";
// break;
// case "int":
// name = "Long";
// break;
// }
// return name + (type.IsArray ? "()" : string.Empty);
// }
// }
//}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Rubberduck.Parsing.Annotations;
using Rubberduck.Parsing.VBA;
using Rubberduck.VBEditor;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Rubberduck.Parsing.Grammar;
using Rubberduck.Parsing.Annotations;
using Rubberduck.Parsing.VBA;
using Rubberduck.VBEditor;

namespace Rubberduck.Parsing.Symbols
namespace Rubberduck.Parsing.Symbols.DeclarationLoaders
{
public class SpecialFormDeclarations : ICustomDeclarationLoader
{
Expand Down
1 change: 1 addition & 0 deletions Rubberduck.Parsing/Symbols/IdentifierReferenceResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Rubberduck.Parsing.Annotations;
using Rubberduck.Parsing.Binding;
using Rubberduck.Parsing.Grammar;
using Rubberduck.Parsing.Symbols.DeclarationLoaders;
using Rubberduck.VBEditor;
using System.Collections.Generic;
using System.Linq;
Expand Down
1 change: 1 addition & 0 deletions Rubberduck.Parsing/VBA/ParseCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Antlr4.Runtime;
using Antlr4.Runtime.Tree;
using Rubberduck.Parsing.Symbols;
using Rubberduck.Parsing.Symbols.DeclarationLoaders;
using Rubberduck.VBEditor;
using Rubberduck.Parsing.Preprocessing;
using System.Diagnostics;
Expand Down
11 changes: 0 additions & 11 deletions Rubberduck.Parsing/VBA/RubberduckParserState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,17 +532,6 @@ public List<CommentNode> AllComments
}
}

public IEnumerable<CommentNode> GetModuleComments(IVBComponent component)
{
ModuleState state;
if (_moduleStates.TryGetValue(new QualifiedModuleName(component), out state))
{
return state.Comments;
}

return new List<CommentNode>();
}

public void SetModuleComments(IVBComponent component, IEnumerable<CommentNode> comments)
{
_moduleStates[new QualifiedModuleName(component)].SetComments(new List<CommentNode>(comments));
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rubberduck", "RetailCoder.VBE\Rubberduck.csproj", "{20589DE8-432E-4359-9232-69EB070B7185}"
ProjectSection(ProjectDependencies) = postProject
Expand Down
Loading