Skip to content

Commit

Permalink
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck i…
Browse files Browse the repository at this point in the history
…nto ExtractMethod

Amended the RubberduckTests.csproj to exclude broken tests to allow building and aid in testing the test modules being worked upon. The section in the csproj should be removed once all tests are updated.

# Conflicts:
#	Rubberduck.Core/Rubberduck.Core.csproj
#	Rubberduck.Main/Rubberduck.Main.csproj
#	Rubberduck.Refactorings/Rubberduck.Refactorings.csproj
#	RubberduckTests/Properties/AssemblyInfo.cs
#	RubberduckTests/RubberduckTests.csproj
  • Loading branch information
bclothier committed Oct 18, 2018
2 parents e7cbfe5 + 8d26793 commit 9250fde
Show file tree
Hide file tree
Showing 164 changed files with 3,705 additions and 47,528 deletions.
26 changes: 1 addition & 25 deletions Rubberduck.API/Properties/AssemblyInfo.cs
@@ -1,19 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Rubberduck.Resources.Registration;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Rubberduck.API")]
[assembly: AssemblyDescription("Rubberduck Reflection API")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Rubberduck-VBA")]
[assembly: AssemblyProduct("Rubberduck.API")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyCulture("en")]
[assembly: AssemblyTrademark("")]
[assembly: InternalsVisibleTo("RubberduckTests")]

// Setting ComVisible to false makes the types in this assembly not visible
Expand All @@ -23,15 +11,3 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid(RubberduckGuid.RubberduckApiTypeLibGuid)]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.*")]
86 changes: 14 additions & 72 deletions Rubberduck.API/Rubberduck.API.csproj
@@ -1,82 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Product>Rubberduck.API</Product>
<Description>Rubberduck Reflection API</Description>
<Copyright>Copyright © 2018</Copyright>
<ProjectGuid>{AC1B4A57-364A-4F90-A0CD-6EE818349CE5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Rubberduck.API</RootNamespace>
<AssemblyName>Rubberduck.API</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<!--
TODO: affix AssemblyVersion and/or FileVersion for COM-Registration?!
-->
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="VBA\ApiProvider.cs" />
<Compile Include="VBA\Accessibility.cs" />
<Compile Include="VBA\Declaration.cs" />
<Compile Include="VBA\Declarations.cs" />
<Compile Include="VBA\DeclarationType.cs" />
<Compile Include="VBA\IdentifierReference.cs" />
<Compile Include="VBA\IdentifierReferences.cs" />
<Compile Include="VBA\Parser.cs" />
<Compile Include="VBA\ParserState.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rubberduck.Core\Rubberduck.Core.csproj">
<Project>{a1587eac-7b54-407e-853f-4c7493d0323e}</Project>
<Name>Rubberduck.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Rubberduck.Main\Rubberduck.Main.csproj">
<Project>{E8AB5D93-2D0F-423D-BC15-5EE118673E48}</Project>
<Name>Rubberduck.Main</Name>
</ProjectReference>
<ProjectReference Include="..\Rubberduck.Parsing\Rubberduck.Parsing.csproj">
<Project>{a4a618e1-cbca-435f-9c6c-5181e030adfc}</Project>
<Name>Rubberduck.Parsing</Name>
</ProjectReference>
<ProjectReference Include="..\Rubberduck.Resources\Rubberduck.Resources.csproj">
<Project>{1b84b387-f7c4-4876-9bdf-c644c365359a}</Project>
<Name>Rubberduck.Resources</Name>
</ProjectReference>
<ProjectReference Include="..\Rubberduck.VBEEditor\Rubberduck.VBEditor.csproj">
<Project>{8ce35eb3-8852-4ba1-84dd-df3f5d2967b0}</Project>
<Name>Rubberduck.VBEditor</Name>
</ProjectReference>
</ItemGroup>
<Import Project="..\RubberduckBaseProject.csproj" />

<ItemGroup>
<Folder Include="Plugin\" />
<ProjectReference Include="..\Rubberduck.Core\Rubberduck.Core.csproj" />
<ProjectReference Include="..\Rubberduck.Main\Rubberduck.Main.csproj" />
<ProjectReference Include="..\Rubberduck.Parsing\Rubberduck.Parsing.csproj" />
<ProjectReference Include="..\Rubberduck.Resources\Rubberduck.Resources.csproj" />
<ProjectReference Include="..\Rubberduck.VBEEditor\Rubberduck.VBEditor.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\RubberduckCodeAnalysis\bin\Release\RubberduckCodeAnalysis.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,61 @@
using System.Collections.Generic;
using System.Linq;
using Antlr4.Runtime;
using NLog;
using Rubberduck.Inspections.Abstract;
using Rubberduck.Parsing;
using Rubberduck.Parsing.Grammar;
using Rubberduck.Parsing.Symbols;
using Rubberduck.Parsing.VBA;

namespace Rubberduck.Inspections.Inspections.Abstract
{
public abstract class IsMissingInspectionBase : InspectionBase
{
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();

protected IsMissingInspectionBase(RubberduckParserState state)
: base(state) { }

private static readonly List<string> IsMissingQualifiedNames = new List<string>
{
"VBE7.DLL;VBA.Information.IsMissing",
"VBA6.DLL;VBA.Information.IsMissing"
};

protected IReadOnlyList<Declaration> IsMissingDeclarations
{
get
{
var isMissing = BuiltInDeclarations.Where(decl => IsMissingQualifiedNames.Contains(decl.QualifiedName.ToString())).ToList();

if (isMissing.Count == 0)
{
_logger.Trace("No 'IsMissing' Declarations were not found in IsMissingInspectionBase.");
}

return isMissing;
}
}

protected ParameterDeclaration GetParameterForReference(IdentifierReference reference)
{
// First case is for unqualified use: IsMissing(foo)
// Second case if for use as a member access: VBA.IsMissing(foo)
var argument = ((ParserRuleContext)reference.Context.Parent).GetDescendent<VBAParser.ArgumentExpressionContext>() ??
((ParserRuleContext)reference.Context.Parent.Parent).GetDescendent<VBAParser.ArgumentExpressionContext>();

var name = argument?.GetDescendent<VBAParser.SimpleNameExprContext>();
if (name == null || name.Parent.Parent != argument)
{
return null;
}

var procedure = reference.Context.GetAncestor<VBAParser.ModuleBodyElementContext>();
return UserDeclarations.Where(decl => decl is ModuleBodyElementDeclaration)
.Cast<ModuleBodyElementDeclaration>()
.FirstOrDefault(decl => decl.Context.Parent == procedure)?
.Parameters.FirstOrDefault(param => param.IdentifierName.Equals(name.GetText()));
}
}
}
4 changes: 2 additions & 2 deletions Rubberduck.CodeAnalysis/Inspections/Abstract/QuickFixBase.cs
Expand Up @@ -10,7 +10,7 @@ namespace Rubberduck.Inspections.Abstract
{
public abstract class QuickFixBase : IQuickFix
{
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
protected readonly ILogger Logger = LogManager.GetCurrentClassLogger();
private HashSet<Type> _supportedInspections;
public IReadOnlyCollection<Type> SupportedInspections => _supportedInspections.ToList();

Expand All @@ -27,7 +27,7 @@ public void RegisterInspections(params Type[] inspections)
throw new ArgumentException($"Parameters must implement {nameof(IInspection)}", nameof(inspections));
#else
inspections.Where(s => s.GetInterfaces().All(i => i != typeof(IInspection))).ToList()
.ForEach(i => _logger.Error($"Type {i.Name} does not implement {nameof(IInspection)}"));
.ForEach(i => Logger.Error($"Type {i.Name} does not implement {nameof(IInspection)}"));
#endif
}

Expand Down

This file was deleted.

@@ -0,0 +1,40 @@
using System.Collections.Generic;
using System.Linq;
using Rubberduck.Inspections.Inspections.Abstract;
using Rubberduck.Inspections.Results;
using Rubberduck.Parsing.Grammar;
using Rubberduck.Parsing.Inspections.Abstract;
using Rubberduck.Parsing.VBA;
using Rubberduck.Resources.Inspections;

namespace Rubberduck.Inspections.Concrete
{
public class IsMissingOnInappropriateArgumentInspection : IsMissingInspectionBase
{
public IsMissingOnInappropriateArgumentInspection(RubberduckParserState state)
: base(state) { }

protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
{
var results = new List<IInspectionResult>();

foreach (var reference in IsMissingDeclarations.SelectMany(decl => decl.References.Where(candidate => !IsIgnoringInspectionResultFor(candidate, AnnotationName))))
{
var parameter = GetParameterForReference(reference);

if (parameter == null ||
parameter.IsOptional
&& parameter.AsTypeName.Equals(Tokens.Variant)
&& string.IsNullOrEmpty(parameter.DefaultValue)
&& !parameter.IsArray)
{
continue;
}

results.Add(new IdentifierReferenceInspectionResult(this, InspectionResults.IsMissingOnInappropriateArgumentInspection, State, reference, parameter));
}

return results;
}
}
}
@@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Linq;
using Rubberduck.Inspections.Inspections.Abstract;
using Rubberduck.Inspections.Results;
using Rubberduck.Parsing.Inspections.Abstract;
using Rubberduck.Parsing.VBA;
using Rubberduck.Resources.Inspections;

namespace Rubberduck.Inspections.Inspections.Concrete
{
public class IsMissingWithNonArgumentParameterInspection : IsMissingInspectionBase
{
public IsMissingWithNonArgumentParameterInspection(RubberduckParserState state)
: base(state) { }

protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
{
var results = new List<IInspectionResult>();

foreach (var reference in IsMissingDeclarations.SelectMany(decl => decl.References.Where(candidate => !IsIgnoringInspectionResultFor(candidate, AnnotationName))))
{
var parameter = GetParameterForReference(reference);

if (parameter != null)
{
continue;
}

results.Add(new IdentifierReferenceInspectionResult(this, InspectionResults.IsMissingWithNonArgumentParameterInspection, State, reference));
}

return results;
}
}
}

0 comments on commit 9250fde

Please sign in to comment.