Skip to content

Commit 6811bdc

Browse files
committed
Merge branch 'next' into bugfi
2 parents 9448424 + 8d26793 commit 6811bdc

File tree

162 files changed

+3690
-47537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+3690
-47537
lines changed
Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
using System.Reflection;
2-
using System.Runtime.CompilerServices;
1+
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43
using Rubberduck.Resources.Registration;
54

6-
// General Information about an assembly is controlled through the following
7-
// set of attributes. Change these attribute values to modify the information
8-
// associated with an assembly.
9-
[assembly: AssemblyTitle("Rubberduck.API")]
10-
[assembly: AssemblyDescription("Rubberduck Reflection API")]
11-
[assembly: AssemblyConfiguration("")]
12-
[assembly: AssemblyCompany("Rubberduck-VBA")]
13-
[assembly: AssemblyProduct("Rubberduck.API")]
14-
[assembly: AssemblyCopyright("Copyright © 2018")]
15-
[assembly: AssemblyCulture("en")]
16-
[assembly: AssemblyTrademark("")]
175
[assembly: InternalsVisibleTo("RubberduckTests")]
186

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

2412
// The following GUID is for the ID of the typelib if this project is exposed to COM
2513
[assembly: Guid(RubberduckGuid.RubberduckApiTypeLibGuid)]
26-
27-
// Version information for an assembly consists of the following four values:
28-
//
29-
// Major Version
30-
// Minor Version
31-
// Build Number
32-
// Revision
33-
//
34-
// You can specify all the values or you can default the Build and Revision Numbers
35-
// by using the '*' as shown below:
36-
// [assembly: AssemblyVersion("1.0.*")]
37-
[assembly: AssemblyVersion("2.1.*")]

Rubberduck.API/Rubberduck.API.csproj

Lines changed: 14 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
2+
<Project Sdk="Microsoft.NET.Sdk">
43
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
4+
<Product>Rubberduck.API</Product>
5+
<Description>Rubberduck Reflection API</Description>
6+
<Copyright>Copyright © 2018</Copyright>
77
<ProjectGuid>{AC1B4A57-364A-4F90-A0CD-6EE818349CE5}</ProjectGuid>
8-
<OutputType>Library</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>Rubberduck.API</RootNamespace>
11-
<AssemblyName>Rubberduck.API</AssemblyName>
12-
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
<TargetFrameworkProfile />
8+
<!--
9+
TODO: affix AssemblyVersion and/or FileVersion for COM-Registration?!
10+
-->
1511
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17-
<DebugSymbols>true</DebugSymbols>
18-
<DebugType>full</DebugType>
19-
<Optimize>false</Optimize>
20-
<OutputPath>bin\Debug\</OutputPath>
21-
<DefineConstants>DEBUG;TRACE</DefineConstants>
22-
<ErrorReport>prompt</ErrorReport>
23-
<WarningLevel>4</WarningLevel>
24-
</PropertyGroup>
25-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26-
<DebugType>pdbonly</DebugType>
27-
<Optimize>true</Optimize>
28-
<OutputPath>bin\Release\</OutputPath>
29-
<DefineConstants>TRACE</DefineConstants>
30-
<ErrorReport>prompt</ErrorReport>
31-
<WarningLevel>4</WarningLevel>
32-
</PropertyGroup>
33-
<ItemGroup>
34-
<Reference Include="System" />
35-
<Reference Include="System.Core" />
36-
<Reference Include="Microsoft.CSharp" />
37-
</ItemGroup>
38-
<ItemGroup>
39-
<Compile Include="VBA\ApiProvider.cs" />
40-
<Compile Include="VBA\Accessibility.cs" />
41-
<Compile Include="VBA\Declaration.cs" />
42-
<Compile Include="VBA\Declarations.cs" />
43-
<Compile Include="VBA\DeclarationType.cs" />
44-
<Compile Include="VBA\IdentifierReference.cs" />
45-
<Compile Include="VBA\IdentifierReferences.cs" />
46-
<Compile Include="VBA\Parser.cs" />
47-
<Compile Include="VBA\ParserState.cs" />
48-
<Compile Include="Properties\AssemblyInfo.cs" />
49-
</ItemGroup>
50-
<ItemGroup>
51-
<ProjectReference Include="..\Rubberduck.Core\Rubberduck.Core.csproj">
52-
<Project>{a1587eac-7b54-407e-853f-4c7493d0323e}</Project>
53-
<Name>Rubberduck.Core</Name>
54-
</ProjectReference>
55-
<ProjectReference Include="..\Rubberduck.Main\Rubberduck.Main.csproj">
56-
<Project>{E8AB5D93-2D0F-423D-BC15-5EE118673E48}</Project>
57-
<Name>Rubberduck.Main</Name>
58-
</ProjectReference>
59-
<ProjectReference Include="..\Rubberduck.Parsing\Rubberduck.Parsing.csproj">
60-
<Project>{a4a618e1-cbca-435f-9c6c-5181e030adfc}</Project>
61-
<Name>Rubberduck.Parsing</Name>
62-
</ProjectReference>
63-
<ProjectReference Include="..\Rubberduck.Resources\Rubberduck.Resources.csproj">
64-
<Project>{1b84b387-f7c4-4876-9bdf-c644c365359a}</Project>
65-
<Name>Rubberduck.Resources</Name>
66-
</ProjectReference>
67-
<ProjectReference Include="..\Rubberduck.VBEEditor\Rubberduck.VBEditor.csproj">
68-
<Project>{8ce35eb3-8852-4ba1-84dd-df3f5d2967b0}</Project>
69-
<Name>Rubberduck.VBEditor</Name>
70-
</ProjectReference>
71-
</ItemGroup>
12+
<Import Project="..\RubberduckBaseProject.csproj" />
13+
7214
<ItemGroup>
73-
<Folder Include="Plugin\" />
15+
<ProjectReference Include="..\Rubberduck.Core\Rubberduck.Core.csproj" />
16+
<ProjectReference Include="..\Rubberduck.Main\Rubberduck.Main.csproj" />
17+
<ProjectReference Include="..\Rubberduck.Parsing\Rubberduck.Parsing.csproj" />
18+
<ProjectReference Include="..\Rubberduck.Resources\Rubberduck.Resources.csproj" />
19+
<ProjectReference Include="..\Rubberduck.VBEEditor\Rubberduck.VBEditor.csproj" />
7420
</ItemGroup>
7521
<ItemGroup>
7622
<None Include="app.config" />
7723
</ItemGroup>
78-
<ItemGroup>
79-
<Analyzer Include="..\RubberduckCodeAnalysis\bin\Release\RubberduckCodeAnalysis.dll" />
80-
</ItemGroup>
81-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8224
</Project>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using Antlr4.Runtime;
4+
using NLog;
5+
using Rubberduck.Inspections.Abstract;
6+
using Rubberduck.Parsing;
7+
using Rubberduck.Parsing.Grammar;
8+
using Rubberduck.Parsing.Symbols;
9+
using Rubberduck.Parsing.VBA;
10+
11+
namespace Rubberduck.Inspections.Inspections.Abstract
12+
{
13+
public abstract class IsMissingInspectionBase : InspectionBase
14+
{
15+
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
16+
17+
protected IsMissingInspectionBase(RubberduckParserState state)
18+
: base(state) { }
19+
20+
private static readonly List<string> IsMissingQualifiedNames = new List<string>
21+
{
22+
"VBE7.DLL;VBA.Information.IsMissing",
23+
"VBA6.DLL;VBA.Information.IsMissing"
24+
};
25+
26+
protected IReadOnlyList<Declaration> IsMissingDeclarations
27+
{
28+
get
29+
{
30+
var isMissing = BuiltInDeclarations.Where(decl => IsMissingQualifiedNames.Contains(decl.QualifiedName.ToString())).ToList();
31+
32+
if (isMissing.Count == 0)
33+
{
34+
_logger.Trace("No 'IsMissing' Declarations were not found in IsMissingInspectionBase.");
35+
}
36+
37+
return isMissing;
38+
}
39+
}
40+
41+
protected ParameterDeclaration GetParameterForReference(IdentifierReference reference)
42+
{
43+
// First case is for unqualified use: IsMissing(foo)
44+
// Second case if for use as a member access: VBA.IsMissing(foo)
45+
var argument = ((ParserRuleContext)reference.Context.Parent).GetDescendent<VBAParser.ArgumentExpressionContext>() ??
46+
((ParserRuleContext)reference.Context.Parent.Parent).GetDescendent<VBAParser.ArgumentExpressionContext>();
47+
48+
var name = argument?.GetDescendent<VBAParser.SimpleNameExprContext>();
49+
if (name == null || name.Parent.Parent != argument)
50+
{
51+
return null;
52+
}
53+
54+
var procedure = reference.Context.GetAncestor<VBAParser.ModuleBodyElementContext>();
55+
return UserDeclarations.Where(decl => decl is ModuleBodyElementDeclaration)
56+
.Cast<ModuleBodyElementDeclaration>()
57+
.FirstOrDefault(decl => decl.Context.Parent == procedure)?
58+
.Parameters.FirstOrDefault(param => param.IdentifierName.Equals(name.GetText()));
59+
}
60+
}
61+
}

Rubberduck.CodeAnalysis/Inspections/Abstract/QuickFixBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Rubberduck.Inspections.Abstract
1010
{
1111
public abstract class QuickFixBase : IQuickFix
1212
{
13-
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
13+
protected readonly ILogger Logger = LogManager.GetCurrentClassLogger();
1414
private HashSet<Type> _supportedInspections;
1515
public IReadOnlyCollection<Type> SupportedInspections => _supportedInspections.ToList();
1616

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

Rubberduck.CodeAnalysis/Inspections/Concrete/EmptyConditionBlockInspection.cs

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using Rubberduck.Inspections.Inspections.Abstract;
4+
using Rubberduck.Inspections.Results;
5+
using Rubberduck.Parsing.Grammar;
6+
using Rubberduck.Parsing.Inspections.Abstract;
7+
using Rubberduck.Parsing.VBA;
8+
using Rubberduck.Resources.Inspections;
9+
10+
namespace Rubberduck.Inspections.Concrete
11+
{
12+
public class IsMissingOnInappropriateArgumentInspection : IsMissingInspectionBase
13+
{
14+
public IsMissingOnInappropriateArgumentInspection(RubberduckParserState state)
15+
: base(state) { }
16+
17+
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
18+
{
19+
var results = new List<IInspectionResult>();
20+
21+
foreach (var reference in IsMissingDeclarations.SelectMany(decl => decl.References.Where(candidate => !IsIgnoringInspectionResultFor(candidate, AnnotationName))))
22+
{
23+
var parameter = GetParameterForReference(reference);
24+
25+
if (parameter == null ||
26+
parameter.IsOptional
27+
&& parameter.AsTypeName.Equals(Tokens.Variant)
28+
&& string.IsNullOrEmpty(parameter.DefaultValue)
29+
&& !parameter.IsArray)
30+
{
31+
continue;
32+
}
33+
34+
results.Add(new IdentifierReferenceInspectionResult(this, InspectionResults.IsMissingOnInappropriateArgumentInspection, State, reference, parameter));
35+
}
36+
37+
return results;
38+
}
39+
}
40+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using Rubberduck.Inspections.Inspections.Abstract;
4+
using Rubberduck.Inspections.Results;
5+
using Rubberduck.Parsing.Inspections.Abstract;
6+
using Rubberduck.Parsing.VBA;
7+
using Rubberduck.Resources.Inspections;
8+
9+
namespace Rubberduck.Inspections.Inspections.Concrete
10+
{
11+
public class IsMissingWithNonArgumentParameterInspection : IsMissingInspectionBase
12+
{
13+
public IsMissingWithNonArgumentParameterInspection(RubberduckParserState state)
14+
: base(state) { }
15+
16+
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
17+
{
18+
var results = new List<IInspectionResult>();
19+
20+
foreach (var reference in IsMissingDeclarations.SelectMany(decl => decl.References.Where(candidate => !IsIgnoringInspectionResultFor(candidate, AnnotationName))))
21+
{
22+
var parameter = GetParameterForReference(reference);
23+
24+
if (parameter != null)
25+
{
26+
continue;
27+
}
28+
29+
results.Add(new IdentifierReferenceInspectionResult(this, InspectionResults.IsMissingWithNonArgumentParameterInspection, State, reference));
30+
}
31+
32+
return results;
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)