Ejemplo n.º 1
0
        private static void CheckPropertyML(
            Action <Diagnostic> reportDiagnostic,
            PropertyValueSyntax propValue,
            string name,
            string kindName)
        {
            // ISSUE: variable of a compiler-generated type
            CommaSeparatedIdentifierEqualsStringListSyntax stringListSyntax = ((MultilanguagePropertyValueSyntax)propValue).Value;

            if (stringListSyntax.Values.Count <= 0)
            {
                return;
            }
            foreach (IdentifierEqualsStringSyntax equalsStringSyntax in stringListSyntax.Values)
            {
                Action <Diagnostic> reportDiagnostic1 = reportDiagnostic;
                // ISSUE: variable of a compiler-generated type
                StringLiteralValueSyntax stringLiteral = equalsStringSyntax.StringLiteral;
                string input = stringLiteral != null?SyntaxNodeExtensions.GetLiteralValue(stringLiteral).ToString() : (string)null;

                Location location  = propValue.GetLocation();
                string   kindName1 = kindName;
                string   name1     = name;
                EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(reportDiagnostic1, input, location, kindName1, name1);
            }
        }
        public override SyntaxNode VisitField(FieldSyntax node)
        {
            PropertyValueSyntax fieldClass = node.GetPropertyValue("FieldClass");

            if ((fieldClass == null) || (fieldClass.ToString().Equals("Normal", StringComparison.CurrentCultureIgnoreCase)))
            {
                PropertySyntax propertySyntax = node.GetProperty("DataClassification");
                if (propertySyntax == null)
                {
                    NoOfChanges++;
                    return(node.AddPropertyListProperties(
                               this.CreateDataClassificationProperty(node)));
                }
                else
                {
                    string valueText = propertySyntax.Value.ToString();
                    if ((String.IsNullOrWhiteSpace(valueText)) ||
                        (valueText.Equals("ToBeClassified", StringComparison.CurrentCultureIgnoreCase)))
                    {
                        NoOfChanges++;
                        return(node.ReplaceNode(propertySyntax, this.CreateDataClassificationProperty(node)));
                    }
                }
            }
            return(base.VisitField(node));
        }
Ejemplo n.º 3
0
 private static void CheckProperty(
     Action <Diagnostic> reportDiagnostic,
     PropertyValueSyntax propValue,
     string name,
     string kindName)
 {
     EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(reportDiagnostic, propValue.ToString(), propValue.GetLocation(), kindName, name);
 }
Ejemplo n.º 4
0
        protected PropertySyntax CreateToolTipProperty(SyntaxNode node, string caption = null)
        {
            SyntaxTriviaList leadingTriviaList  = node.CreateChildNodeIdentTrivia();
            SyntaxTriviaList trailingTriviaList = SyntaxFactory.ParseTrailingTrivia("\r\n", 0);

            //get caption from control
            PropertyValueSyntax captionProperty = node.GetPropertyValue("Caption");

            if (captionProperty != null)
            {
                string value = ALSyntaxHelper.DecodeString(captionProperty.ToString());
                if (!String.IsNullOrWhiteSpace(value))
                {
                    caption = value;
                }
            }
            else if (String.IsNullOrWhiteSpace(caption))
            {
                caption = node.GetNameStringValue();
            }


            string toolTipValue = "";

            switch (node.Kind.ConvertToLocalType())
            {
            case ConvertedSyntaxKind.PageField:
                toolTipValue = PageFieldTooltip;
                break;

            case ConvertedSyntaxKind.PageAction:
                toolTipValue = PageActionTooltip;
                break;
            }

            if (toolTipValue.Contains("%1"))
            {
                toolTipValue = toolTipValue.Replace("%1", caption);
            }

            //try to convert from string to avoid issues with enum ids changed between AL compiler versions
            PropertyKind propertyKind;

            try
            {
                propertyKind = (PropertyKind)Enum.Parse(typeof(PropertyKind), "ToolTip", true);
            }
            catch (Exception)
            {
                propertyKind = PropertyKind.ToolTip;
            }

            return(SyntaxFactory.PropertyLiteral(propertyKind, toolTipValue)
                   .WithLeadingTrivia(leadingTriviaList)
                   .WithTrailingTrivia(trailingTriviaList));
        }
        public TableFieldTypeInformation(FieldSyntax fieldSyntax) : this(fieldSyntax.GetNameStringValue())
        {
            PropertyValueSyntax propValue = fieldSyntax.GetPropertyValue("Caption");

            if (propValue != null)
            {
                this.Caption = ALSyntaxHelper.DecodeString(propValue.ToString());
            }
            this.DataType = fieldSyntax.Type.ToString();
        }
Ejemplo n.º 6
0
        private void CheckSourceTableProperty(SyntaxNode node)
        {
            //try to find current table
            this.CurrentTable = null;
            PropertyValueSyntax sourceTablePropertyValue = node.GetPropertyValue("SourceTable");

            if (sourceTablePropertyValue != null)
            {
                string sourceTable = ALSyntaxHelper.DecodeName(sourceTablePropertyValue.ToString());
                this.CurrentTable = this.TypeInformationCollector.ProjectTypesInformation.GetTable(sourceTable);
            }
        }
Ejemplo n.º 7
0
        private static void CheckCaptionsTooltips(
            Action <Diagnostic> reportDiagnostic,
            PropertyValueSyntax propValue,
            PropertyKind propKind,
            string name)
        {
            if (propValue == null)
            {
                return;
            }
            switch (propValue.Kind)
            {
            case SyntaxKind.MultilanguagePropertyValue:
                EmailAndPhoneNoMustNotBePresentInTheSource.CheckPropertyML(reportDiagnostic, propValue, name, propKind.ToString());
                break;

            case SyntaxKind.LabelPropertyValue:
                EmailAndPhoneNoMustNotBePresentInTheSource.CheckProperty(reportDiagnostic, propValue, name, propKind.ToString());
                break;
            }
        }