Skip to content
Permalink
Browse files

Merge branch 'next' into ResolveParameterlessDefaultMemberAccesses

  • Loading branch information
MDoerner committed Aug 24, 2019
2 parents 617b27f + 4164774 commit 6aa489bb67a11767e821c3c177d2f0040ed01f26
@@ -189,3 +189,4 @@ Rubberduck.CodeAnalysis.xml

#Gradle
/.gradle/
/Rubberduck.CodeAnalysis/Rubberduck.CodeAnalysis.xml

Large diffs are not rendered by default.

@@ -18,6 +18,7 @@
<CodeInspection Name="MissingAttributeInspection" Severity="Warning" InspectionType="RubberduckOpportunities" />
<CodeInspection Name="AttributeOutOfSyncInspection" Severity="Warning" InspectionType="RubberduckOpportunities" />
<CodeInspection Name="MissingAnnotationArgumentInspection" Severity="Error" InspectionType="CodeQualityIssues" />
<CodeInspection Name="MissingMemberAnnotationInspection" Severity="Error" InspectionType="RubberduckOpportunities" />
<CodeInspection Name="ModuleScopeDimKeywordInspection" Severity="Suggestion" InspectionType="LanguageOpportunities" />
<CodeInspection Name="MultilineParameterInspection" Severity="Suggestion" InspectionType="MaintainabilityAndReadabilityIssues" />
<CodeInspection Name="MultipleDeclarationsInspection" Severity="Warning" InspectionType="MaintainabilityAndReadabilityIssues" />

This file was deleted.

@@ -72,7 +72,9 @@ public enum AnnotationType
ModuleAttribute = 1 << 20 | Attribute | ModuleAnnotation,
MemberAttribute = 1 << 21 | Attribute | MemberAnnotation | VariableAnnotation,
[FlexibleAttributeValueAnnotation("VB_VarDescription", 1)]
VariableDescription = 1 << 13 | Attribute | VariableAnnotation
VariableDescription = 1 << 13 | Attribute | VariableAnnotation,
[FlexibleAttributeValueAnnotation("VB_ProcData.VB_Invoke_Func", 1)]
ExcelHotKey = 1 << 16 | Attribute | MemberAnnotation
}

[AttributeUsage(AttributeTargets.Field)]
@@ -33,6 +33,11 @@ public class AttributeAnnotationProvider : IAttributeAnnotationProvider
var flexibleValueAttributeAnnotation = FirstMatchingFlexibleAttributeValueAnnotation(annotationTypes, attributeName, attributeValues.Count);
if (flexibleValueAttributeAnnotation != default)
{
// FIXME special cased bodge for ExcelHotKeyAnnotation to deal with the value transformation:
if (flexibleValueAttributeAnnotation == AnnotationType.ExcelHotKey)
{
return (flexibleValueAttributeAnnotation, attributeValues.Select(keySpec => '"' + keySpec.Substring(1, 1) + '"').ToList());
}
return (flexibleValueAttributeAnnotation, attributeValues);
}

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Rubberduck.Parsing.Grammar;
using Rubberduck.VBEditor;

namespace Rubberduck.Parsing.Annotations
{
public sealed class ExcelHotKeyAnnotation : FlexibleAttributeValueAnnotationBase
{
public ExcelHotKeyAnnotation(QualifiedSelection qualifiedSelection, VBAParser.AnnotationContext context, IEnumerable<string> annotationParameterValues) :
base(AnnotationType.ExcelHotKey, qualifiedSelection, context, GetHotKeyAttributeValue(annotationParameterValues))
{ }

private static IEnumerable<string> GetHotKeyAttributeValue(IEnumerable<string> parameters) =>
parameters.Take(1).Select(StripStringLiteralQuotes).Select(v => @"""" + v[0] + @"\n14""").ToList();

private static string StripStringLiteralQuotes(string value) =>
value.StartsWith("\"") && value.EndsWith("\"") && value.Length > 2
? value.Substring(1, value.Length - 2)
: value;
}
}
@@ -8,26 +8,19 @@ namespace Rubberduck.Parsing.Annotations
{
public abstract class FlexibleAttributeValueAnnotationBase : AnnotationBase, IAttributeAnnotation
{
protected FlexibleAttributeValueAnnotationBase(AnnotationType annotationType, QualifiedSelection qualifiedSelection, VBAParser.AnnotationContext context, IEnumerable<string> parameters)
public string Attribute { get; }
public IReadOnlyList<string> AttributeValues { get; }

protected FlexibleAttributeValueAnnotationBase(AnnotationType annotationType, QualifiedSelection qualifiedSelection, VBAParser.AnnotationContext context, IEnumerable<string> attributeValues)
:base(annotationType, qualifiedSelection, context)
{
var flexibleAttributeValueInfo = FlexibleAttributeValueInfo(annotationType);

if (flexibleAttributeValueInfo == null)
{
Attribute = string.Empty;
AttributeValues = new List<string>();
return;
}

Attribute = flexibleAttributeValueInfo.Value.attribute;
AttributeValues = parameters?.Take(flexibleAttributeValueInfo.Value.numberOfValues).ToList() ?? new List<string>();
Attribute = flexibleAttributeValueInfo.attribute;
AttributeValues = attributeValues?.Take(flexibleAttributeValueInfo.numberOfValues).ToList() ?? new List<string>();
}

public string Attribute { get; }
public IReadOnlyList<string> AttributeValues { get; }

private static (string attribute, int numberOfValues)? FlexibleAttributeValueInfo(AnnotationType annotationType)
private static (string attribute, int numberOfValues) FlexibleAttributeValueInfo(AnnotationType annotationType)
{
var type = annotationType.GetType();
var name = Enum.GetName(type, annotationType);
@@ -38,7 +31,7 @@ private static (string attribute, int numberOfValues)? FlexibleAttributeValueInf

if (attribute == null)
{
return null;
return ("", 0);
}

return (attribute.AttributeName, attribute.NumberOfParameters);
@@ -33,6 +33,7 @@ public VBAParserAnnotationFactory()
_creators.Add(AnnotationType.ModuleAttribute.ToString().ToUpperInvariant(), typeof(ModuleAttributeAnnotation));
_creators.Add(AnnotationType.MemberAttribute.ToString().ToUpperInvariant(), typeof(MemberAttributeAnnotation));
_creators.Add(AnnotationType.ModuleDescription.ToString().ToUpperInvariant(), typeof(ModuleDescriptionAnnotation));
_creators.Add(AnnotationType.ExcelHotKey.ToString().ToUpperInvariant(), typeof(ExcelHotKeyAnnotation));
}

public IAnnotation Create(VBAParser.AnnotationContext context, QualifiedSelection qualifiedSelection)
@@ -5,6 +5,7 @@
namespace RubberduckTests.Annotations
{
[TestFixture]
[Category("Annotations")]
public class AttributeAnnotationProviderTests
{
[Test]
@@ -56,13 +57,14 @@ public void ModuleAttributeAnnotationReturnsSpecializedAnnotationsWhereApplicabl
AssertEqual(expectedValues, actualValues);
}

[TestCase("VB_ProcData.VB_Invoke_Func", "\"A\n14\"", AnnotationType.ExcelHotKey, "\"A\"")]
[TestCase("VB_Description", "\"SomeDescription\"", AnnotationType.Description, "\"SomeDescription\"")]
[TestCase("VB_VarDescription", "\"SomeDescription\"", AnnotationType.VariableDescription, "\"SomeDescription\"")]
[TestCase("VB_UserMemId", "0", AnnotationType.DefaultMember)]
[TestCase("VB_UserMemId", "-4", AnnotationType.Enumerator)]
public void MemberAttributeAnnotationReturnsSpecializedAnnotationsWhereApplicable(string attributeName, string annotationValue, AnnotationType expectedAnnotationType, string expectedValue = null)
public void MemberAttributeAnnotationReturnsSpecializedAnnotationsWhereApplicable(string attributeName, string attributeValue, AnnotationType expectedAnnotationType, string expectedValue = null)
{
var attributeValues = new List<string> { annotationValue };
var attributeValues = new List<string> { attributeValue };
var expectedValues = expectedValue != null
? new List<string> { expectedValue }
: new List<string>();
@@ -4,21 +4,17 @@

### [ANTLR](http://www.antlr.org/)

As of v1.2, Rubberduck is empowered by the awesomeness of ANTLR.

> **What is ANTLR?**
Since v1.2, tokenizing and parsing the VBA code is left to the parsing masters behind Antlr. We write the language's grammatical/syntactical rules into a file that Antlr processes to generate a lexer that can turn a string into a stream of tokens, a parser that turns that stream into a tree structure Rubberduck can work with. Everything starts with Antlr.

> *ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It's widely used to build languages, tools, and frameworks. From a grammar, ANTLR generates a parser that can build and walk parse trees.*
We're not doing half of what we could be doing with this amazing tool. Try it, see for yourself!

### [AvalonEdit](http://avalonedit.net)

Source code looks a lot better with syntax highlighting, and AvalonEdit excels at it.

> AvalonEdit is a WPF-based text editor component. It was written by [Daniel Grunwald](https://github.com/dgrunwald) for the [SharpDevelop](http://www.icsharpcode.net/OpenSource/SD/) IDE. Starting with version 5.0, AvalonEdit is released under the [MIT license](http://opensource.org/licenses/MIT).
We're currently only using a tiny bit of this code editor's functionality (more to come!).


### [EasyHook](http://easyhook.github.io/index.html)

@@ -34,6 +30,16 @@ This library makes localizing WPF applications at runtime using resx files a bre

> Licensed under [The Code Project Open License](http://www.codeproject.com/info/cpol10.aspx) with the [author's permission](http://www.codeproject.com/Messages/5272045/Re-License.aspx) to re-release under the GPLv3.
### [Moq](https://github.com/moq)

Moq has always been powering Rubberduck's own unit test mocks, but as of v2.5 our VBA unit testing API includes a wrapper that basically lets you use Moq for your VBA unit tests, to configure a mock implementation of any class or interface your VBA code might depend on.

> **What is ANTLR?**
> *ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It's widely used to build languages, tools, and frameworks. From a grammar, ANTLR generates a parser that can build and walk parse trees.*
We're not doing half of what we could be doing with this amazing tool. Try it, see for yourself!

## Icons

We didn't come up with these icons ourselves! Here's who did what:

0 comments on commit 6aa489b

Please sign in to comment.
You can’t perform that action at this time.