Ejemplo n.º 1
0
        public override void FinalizeProject(Variables.Root variables)
        {
            base.FinalizeProject(variables);

            variables.Average(Key + "LinesAvg", Key + "LinesTotal", Key + "CodeFiles");
            variables.Average(Key + "CharsAvg", Key + "CharsTotal", Key + "CodeFiles");
            variables.Average(Key + "CharsPerLineAvg", Key + "CharsTotal", Key + "LinesTotal");

            State state = variables.GetStateObject <State>(stateOwner);

            foreach (FileIntValue fi in state.MaxLines)
            {
                variables.AddToArray(Key + "LinesTop", GetFileObject(fi, variables));
            }

            foreach (FileIntValue fi in state.MinLines.Reverse())
            {
                variables.AddToArray(Key + "LinesBottom", GetFileObject(fi, variables));
            }

            foreach (FileIntValue fi in state.MaxChars)
            {
                variables.AddToArray(Key + "CharsTop", GetFileObject(fi, variables));
            }

            foreach (FileIntValue fi in state.MinChars.Reverse())
            {
                variables.AddToArray(Key + "CharsBottom", GetFileObject(fi, variables));
            }
        }
Ejemplo n.º 2
0
        public override void Process(File file, Variables.Root variables)
        {
            base.Process(file, variables);
            variables.Increment("fileTypeAssets");

            State state = variables.GetStateObject <State>(this);

            if (++state.Count == 1)
            {
                variables.SetArraySorter("assetTypes", AssetRowSorter);
                state.TypeEntry = variables.AddToArray("assetTypes", new { title = GetAssetTypeName(type), value = 0 });

                variables.SetArraySorter("assetSizes", AssetSizeRowSorter);
                state.SizeEntry = variables.AddToArray("assetSizes", new { title = GetAssetTypeName(type), compl = 0, comph = 0, size = 0, units = "" });
            }

            state.Size += file.SizeInBytes;
        }
Ejemplo n.º 3
0
        public override void FinalizeProject(Variables.Root variables)
        {
            base.FinalizeProject(variables);

            JavaState      state  = variables.GetStateObject <JavaState>(this);
            JavaGlobalInfo global = state.GlobalInfo;

            // general
            variables.SetVariable("javaPackages", state.PackageCount);

            // imports
            variables.Average("javaImportsAvg", "javaImportsTotal", "javaCodeFiles");
            variables.Average("javaNamesSimpleAvg", "javaNamesSimpleTotal", "javaTypesTotal");
            variables.Average("javaNamesFullAvg", "javaNamesFullTotal", "javaTypesTotal");

            // identifiers
            foreach (TypeIdentifier identifier in global.IdentifiersSimpleTop)
            {
                variables.AddToArray("javaNamesSimpleTop", new { package = identifier.Prefix, name = identifier.Name });
            }

            foreach (TypeIdentifier identifier in global.IdentifiersSimpleBottom.Reverse())
            {
                variables.AddToArray("javaNamesSimpleBottom", new { package = identifier.Prefix, name = identifier.Name });
            }

            foreach (TypeIdentifier identifier in global.IdentifiersFullTop)
            {
                variables.AddToArray("javaNamesFullTop", new { package = identifier.Prefix, name = identifier.Name });
            }

            foreach (TypeIdentifier identifier in global.IdentifiersFullBottom.Reverse())
            {
                variables.AddToArray("javaNamesFullBottom", new { package = identifier.Prefix, name = identifier.Name });
            }

            // fields and methods
            variables.Average("javaClassesFieldsAvg", "javaClassesFieldsTotal", "javaClasses");
            variables.Average("javaClassesConstructorsAvg", "javaClassesConstructorsTotal", "javaClasses");
            variables.Average("javaClassesMethodsAvg", "javaClassesMethodsTotal", "javaClasses");

            variables.Average("javaInterfacesFieldsAvg", "javaInterfacesFieldsTotal", "javaInterfaces");
            variables.Average("javaInterfacesMethodsAvg", "javaInterfacesMethodsTotal", "javaInterfaces");

            variables.Average("javaAnnotationsElementsAvg", "javaAnnotationsElementsTotal", "javaAnnotations");

            variables.Average("javaMethodParametersAvg", "javaMethodParametersTotal", "javaMethodsTotal");

            variables.SetVariable("javaMethodsReturnsTotal", state.GlobalInfo.Statements[FlowStatement.Return]);

            foreach (KeyValuePair <string, int> fieldType in global.FieldTypes.ListFromTop())
            {
                variables.AddToArray("javaFieldTypes", new { type = fieldType.Key, amount = fieldType.Value });
            }

            foreach (KeyValuePair <string, int> methodReturnType in global.MethodReturnTypes.ListFromTop())
            {
                variables.AddToArray("javaMethodReturnTypes", new { type = methodReturnType.Key, amount = methodReturnType.Value });
            }

            foreach (KeyValuePair <string, int> methodParameterType in global.MethodParameterTypes.ListFromTop())
            {
                variables.AddToArray("javaMethodParameterTypes", new { type = methodParameterType.Key, amount = methodParameterType.Value });
            }

            // enums
            variables.Average("javaEnumsValuesAvg", "javaEnumsValuesTotal", "javaEnums");

            // annotations
            List <KeyValuePair <string, int> > annotationUses = global.AnnotationUses.ListFromTop();
            int totalAnnotationsUsed = annotationUses.Sum(kvp => kvp.Value);

            for (int annotationIndex = 0; annotationIndex < Math.Min(annotationUses.Count, 10); annotationIndex++)
            {
                variables.AddToArray("javaAnnotationsUsedTop", new { name = annotationUses[annotationIndex].Key, amount = annotationUses[annotationIndex].Value });
            }

            variables.SetVariable("javaAnnotationsUsedTotal", totalAnnotationsUsed);
            variables.SetVariable("javaAnnotationsUsedOther", totalAnnotationsUsed - variables.GetVariable("javaAnnotationsUsedClasses", 0) - variables.GetVariable("javaAnnotationsUsedFields", 0) - variables.GetVariable("javaAnnotationsUsedMethods", 0));

            // control flow
            variables.SetVariable("javaControlFlowIf", state.GlobalInfo.Statements[FlowStatement.If] + state.GlobalInfo.Statements[FlowStatement.Else]);

            variables.SetVariable("javaControlFlowFor", state.GlobalInfo.Statements[FlowStatement.For]);
            variables.SetVariable("javaControlFlowEnhFor", state.GlobalInfo.Statements[FlowStatement.EnhancedFor]);
            variables.SetVariable("javaControlFlowWhile", state.GlobalInfo.Statements[FlowStatement.While]);
            variables.SetVariable("javaControlFlowDoWhile", state.GlobalInfo.Statements[FlowStatement.DoWhile]);

            variables.SetVariable("javaControlFlowSwitch", state.GlobalInfo.Statements[FlowStatement.Switch]);
            variables.SetVariable("javaControlFlowCaseTotal", state.GlobalInfo.Statements[FlowStatement.SwitchCase]);
            variables.SetVariable("javaControlFlowCaseDefaultTotal", state.GlobalInfo.Statements[FlowStatement.SwitchDefault]);

            variables.SetVariable("javaControlFlowCaseMin", state.GlobalInfo.MinSwitchCases);
            variables.SetVariable("javaControlFlowCaseMax", state.GlobalInfo.MaxSwitchCases);
            variables.Average("javaControlFlowCaseAvg", "javaControlFlowCaseTotal", "javaControlFlowSwitch");
            variables.Percent("javaControlFlowCaseDefaultPerc", "javaControlFlowCaseDefaultTotal", "javaControlFlowSwitch");

            variables.SetVariable("javaControlFlowTry", state.GlobalInfo.Statements[FlowStatement.Try]);
            variables.SetVariable("javaControlFlowTryCatch", state.GlobalInfo.Statements[FlowStatement.TryCatch]);
            variables.SetVariable("javaControlFlowTryWithResources", state.GlobalInfo.Statements[FlowStatement.TryWithResources]);
            variables.SetVariable("javaControlFlowTryCatchFinally", state.GlobalInfo.TryCatchWithFinally);
            variables.SetVariable("javaControlFlowTryWithResourcesFinally", state.GlobalInfo.TryWithResourcesWithFinally);
            variables.Percent("javaControlFlowTryCatchFinallyPerc", "javaControlFlowTryCatchFinally", "javaControlFlowTry");
            variables.Percent("javaControlFlowTryWithResourcesFinallyPerc", "javaControlFlowTryWithResourcesFinally", "javaControlFlowTry");

            variables.SetVariable("javaControlFlowCatchTotal", state.GlobalInfo.Statements[FlowStatement.Catch]);
            variables.SetVariable("javaControlFlowCatchMin", state.GlobalInfo.MinCatchBlocks);
            variables.SetVariable("javaControlFlowCatchMax", state.GlobalInfo.MaxCatchBlocks);
            variables.Average("javaControlFlowCatchAvg", "javaControlFlowCatchTotal", "javaControlFlowTry");
        }