Skip to content

Commit 0bf3f55

Browse files
authored
Merge branch 'next' into CE_Context_Menu
2 parents 1c815d3 + 912f682 commit 0bf3f55

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

Rubberduck.Parsing/Symbols/DeclarationSymbolsListener.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,22 @@ private IEnumerable<IAnnotation> FindAnnotations(int line)
133133
private void DeclareControlsAsMembers(IVBComponent form)
134134
{
135135
if (form.Controls == null) { return; }
136-
var msFormsLib = _state.DeclarationFinder.FindProject("MSForms");
137136

137+
var libraryQualifier = string.Empty;
138+
if (_qualifiedModuleName.ComponentType == ComponentType.UserForm)
139+
{
140+
var msFormsLib = _state.DeclarationFinder.FindProject("MSForms");
141+
//Debug.Assert(msFormsLib != null);
142+
if (msFormsLib != null)
143+
{
144+
// given a UserForm component, MSForms reference is in use and cannot be removed.
145+
libraryQualifier = "MSForms.";
146+
}
147+
}
148+
138149
foreach (var control in form.Controls)
139150
{
140-
var typeName = control.TypeName();
151+
var typeName = $"{libraryQualifier}{control.TypeName()}";
141152
// The as type declaration should be TextBox, CheckBox, etc. depending on the type.
142153
var declaration = new Declaration(
143154
_qualifiedModuleName.QualifyMemberName(control.Name),
@@ -155,11 +166,6 @@ private void DeclareControlsAsMembers(IVBComponent form)
155166
null,
156167
true);
157168

158-
if (msFormsLib != null)
159-
{
160-
declaration.AsTypeDeclaration = _state.DeclarationFinder.FindClassModule(typeName, msFormsLib, true);
161-
}
162-
163169
AddDeclaration(declaration);
164170
}
165171
}

Rubberduck.Parsing/Symbols/TypeAnnotationPass.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ public void Execute(IReadOnlyCollection<QualifiedModuleName> modules)
4545

4646
private void AnnotateType(Declaration declaration)
4747
{
48-
if (declaration.AsTypeDeclaration != null)
49-
{
50-
return;
51-
}
52-
5348
if (declaration.DeclarationType == DeclarationType.ClassModule ||
5449
declaration.DeclarationType == DeclarationType.UserDefinedType ||
5550
declaration.DeclarationType == DeclarationType.ComAlias)

0 commit comments

Comments
 (0)