public EncapsulateFieldModel Show() { if (_model.TargetDeclaration == null) { return(null); } _view.NewPropertyName = _model.TargetDeclaration.IdentifierName; _view.TargetDeclaration = _model.TargetDeclaration; if (_model.TargetDeclaration.References.Any(r => r.IsAssignment)) { if (PrimitiveTypes.Contains(_model.TargetDeclaration.AsTypeName)) { _view.MustImplementLetSetterType = true; _view.CanImplementSetSetterType = false; } else if (_model.TargetDeclaration.AsTypeName != Tokens.Variant) { _view.MustImplementSetSetterType = true; _view.CanImplementLetSetterType = false; } else { RuleContext node = _model.TargetDeclaration.References.First(r => r.IsAssignment).Context; while (!(node is VBAParser.LetStmtContext) && !(node is VBAParser.SetStmtContext)) { node = node.Parent; } if (node is VBAParser.LetStmtContext) { _view.MustImplementLetSetterType = true; _view.CanImplementSetSetterType = false; } else { _view.MustImplementSetSetterType = true; _view.CanImplementLetSetterType = false; } } } else { if (PrimitiveTypes.Contains(_model.TargetDeclaration.AsTypeName)) { _view.CanImplementSetSetterType = false; } else if (_model.TargetDeclaration.AsTypeName != Tokens.Variant) { _view.CanImplementLetSetterType = false; } } if (_view.ShowDialog() != DialogResult.OK) { return(null); } _model.PropertyName = _view.NewPropertyName; _model.ImplementLetSetterType = _view.MustImplementLetSetterType; _model.ImplementSetSetterType = _view.MustImplementSetSetterType; _model.ParameterName = _view.ParameterName; return(_model); }
public EncapsulateFieldModel Show() { if (_model.TargetDeclaration == null) { return(null); } _view.TargetDeclaration = _model.TargetDeclaration; _view.NewPropertyName = _model.TargetDeclaration.IdentifierName; var isVariant = _model.TargetDeclaration.AsTypeName.Equals(Tokens.Variant); var isValueType = !isVariant && (SymbolList.ValueTypes.Contains(_model.TargetDeclaration.AsTypeName) || _model.TargetDeclaration.DeclarationType == DeclarationType.Enumeration); if (_model.TargetDeclaration.References.Any(r => r.IsAssignment)) { if (isVariant) { RuleContext node = _model.TargetDeclaration.References.First(r => r.IsAssignment).Context; while (!(node is VBAParser.LetStmtContext) && !(node is VBAParser.SetStmtContext)) { node = node.Parent; } if (node is VBAParser.LetStmtContext) { _view.CanImplementLetSetterType = true; } else { _view.CanImplementSetSetterType = true; } } else if (isValueType) { _view.CanImplementLetSetterType = true; } else { _view.CanImplementSetSetterType = true; } } else { if (isValueType) { _view.CanImplementLetSetterType = true; } else if (!isVariant) { _view.CanImplementSetSetterType = true; } else { _view.CanImplementLetSetterType = true; _view.CanImplementSetSetterType = true; } } if (_view.ShowDialog() != DialogResult.OK) { return(null); } _model.PropertyName = _view.NewPropertyName; _model.ImplementLetSetterType = _view.CanImplementLetSetterType; _model.ImplementSetSetterType = _view.CanImplementSetSetterType; _model.CanImplementLet = !_view.MustImplementSetSetterType; _model.ParameterName = _view.ParameterName; return(_model); }