Exemplo n.º 1
0
        public static PropertyDeclarationSyntax GetHalSynchronizedPropertyUsed(
            HalfSynchronizedClassRepresentation halfSynchronizedClass,
            MethodDeclarationSyntax methodWithHalfSynchronizedProperties)
        {
            var identifiersInMethods =
                methodWithHalfSynchronizedProperties.DescendantNodesAndSelf()
                .OfType <IdentifierNameSyntax>()
                .Select(e => e.Identifier.Text);

            var propUsed =
                halfSynchronizedClass.UnsynchronizedPropertiesInSynchronizedMethods.ToList()
                .First(e => identifiersInMethods.Contains(e.Identifier.Text));

            return(propUsed);
        }
Exemplo n.º 2
0
        public static IEnumerable <MethodDeclarationSyntax> GetMethodsWithHalfSynchronizedProperties(HalfSynchronizedClassRepresentation halfSynchronizedClass)
        {
            var methodsWithHalfSynchronizedProperties = new List <MethodDeclarationSyntax>().ToList();

            foreach (var methodDeclarationSyntax in halfSynchronizedClass.UnsynchronizedMethods)
            {
                var identifiersInMethods =
                    methodDeclarationSyntax.DescendantNodesAndSelf()
                    .OfType <IdentifierNameSyntax>()
                    .Select(e => e.Identifier.Text);
                if (
                    halfSynchronizedClass.UnsynchronizedPropertiesInSynchronizedMethods.ToList()
                    .Select(e => e.Identifier.Text)
                    .Any(e => identifiersInMethods.Contains(e)))
                {
                    methodsWithHalfSynchronizedProperties.Add(methodDeclarationSyntax);
                }
            }
            return(methodsWithHalfSynchronizedProperties);
        }
Exemplo n.º 3
0
        public static bool MethodHasHalfSynchronizedProperties(MethodDeclarationSyntax method, HalfSynchronizedClassRepresentation halfSynchronizedClass)
        {
            var methodsWithHalfSynchronizedProperties = GetMethodsWithHalfSynchronizedProperties(halfSynchronizedClass);

            return(methodsWithHalfSynchronizedProperties.Select(e => e.Identifier.Text).Contains(method.Identifier.Text));
        }
Exemplo n.º 4
0
        public static bool PropertyNeedsSynchronization(PropertyDeclarationSyntax propertyDeclaration, HalfSynchronizedClassRepresentation halfSynchronizedClass)
        {
            if (PropertyIsSynchronized(propertyDeclaration))
            {
                return(false);
            }
            var identifiersInLockStatements = halfSynchronizedClass.GetIdentifiersInLockStatements();

            return(identifiersInLockStatements.Contains(propertyDeclaration.Identifier.Text));
        }