コード例 #1
0
        public EncapsulateFieldCandidate(Declaration declaration, IValidateVBAIdentifiers identifierValidator)
        {
            _target       = declaration;
            NameValidator = identifierValidator;
            _rhsParameterIdentifierName = Resources.Refactorings.Refactorings.CodeBuilder_DefaultPropertyRHSParam;

            _fieldAndProperty  = new EncapsulationIdentifiers(declaration.IdentifierName, identifierValidator);
            IdentifierName     = declaration.IdentifierName;
            PropertyAsTypeName = declaration.AsTypeName;
            _qmn = declaration.QualifiedModuleName;

            CanBeReadWrite = true;

            _uniqueID = $"{_qmn.Name}.{declaration.IdentifierName}";
            _hashCode = _uniqueID.GetHashCode();

            ImplementLet = true;
            ImplementSet = false;
            if (_target.IsEnumField() && _target.AsTypeDeclaration.HasPrivateAccessibility())
            {
                //5.3.1 The declared type of a function declaration
                //may not be a private enum name.
                PropertyAsTypeName = Tokens.Long;
            }
            else if (_target.AsTypeName.Equals(Tokens.Variant) &&
                     !_target.IsArray)
            {
                ImplementSet = true;
            }
            else if (Declaration.IsObject)
            {
                ImplementLet = false;
                ImplementSet = true;
            }
        }
コード例 #2
0
        public EncapsulateFieldCandidate(Declaration declaration)
        {
            Declaration = declaration;
            AsTypeName  = declaration.AsTypeName;

            _fieldAndProperty        = new EncapsulationIdentifiers(declaration.IdentifierName);
            BackingIdentifierMutator = (value) => _fieldAndProperty.Field = value;

            IdentifierName = declaration.IdentifierName;

            TargetID = IdentifierName;

            QualifiedModuleName = declaration.QualifiedModuleName;

            //5.3.1 The declared type of a function declaration may not be a private enum.
            PropertyAsTypeName = declaration.IsEnumField() && declaration.AsTypeDeclaration.HasPrivateAccessibility()
                ? Tokens.Long
                : declaration.AsTypeName;

            CanBeReadWrite = !Declaration.IsArray;

            _hashCode = $"{QualifiedModuleName.Name}.{declaration.IdentifierName}".GetHashCode();
        }