예제 #1
0
        private static HotspotInfo[] CreateHotspots(
            [NotNull] IInvocationExpression invocation,
            ref LocalList <IDeclarationStatement> declarations,
            ref LocalList <IList <string> > variableNameSuggestions)
        {
            bool isTypeInferenceSupported = invocation.IsCSharp3Supported();

            if (isTypeInferenceSupported)
            {
                var hotspots = new HotspotInfo[declarations.Count * 2];

                for (int i = 0; i < declarations.Count - 1; i++)
                {
                    hotspots[2 * i]     = CreateVariableTypeHotspot(declarations[i]);
                    hotspots[2 * i + 1] = CreateVariableNameHotspot(declarations[i], declarations[i + 1], variableNameSuggestions[i]);
                }

                var lastDeclaration = declarations[declarations.Count - 1];
                var lastSuggestions = variableNameSuggestions[variableNameSuggestions.Count - 1];

                hotspots[hotspots.Length - 2] = CreateVariableTypeHotspot(lastDeclaration);
                hotspots[hotspots.Length - 1] = CreateVariableNameHotspot(lastDeclaration, invocation, lastSuggestions);

                return(hotspots);
            }
            else
            {
                var hotspots = new HotspotInfo[declarations.Count];

                for (int i = 0; i < hotspots.Length - 1; i++)
                {
                    hotspots[i] = CreateVariableNameHotspot(declarations[i], declarations[i + 1], variableNameSuggestions[i]);
                }

                var lastDeclaration = declarations[declarations.Count - 1];
                var lastSuggestions = variableNameSuggestions[variableNameSuggestions.Count - 1];

                hotspots[hotspots.Length - 1] = CreateVariableNameHotspot(lastDeclaration, invocation, lastSuggestions);

                return(hotspots);
            }
        }