Esempio n. 1
0
        protected virtual void WriteMultiLineComment(string text, bool newline, bool wrap = true)
        {
            bool needRemoveIndent  = false;
            var  methodDeclaration = this.Comment.GetParent <MethodDeclaration>();
            int  mode = 0;

            if (methodDeclaration != null)
            {
                foreach (var attrSection in methodDeclaration.Attributes)
                {
                    foreach (var attr in attrSection.Attributes)
                    {
                        var rr = this.Emitter.Resolver.ResolveNode(attr.Type, this.Emitter);

                        if (rr.Type.FullName == "Bridge.InitAttribute")
                        {
                            if (attr.HasArgumentList && attr.Arguments.Count > 0)
                            {
                                var argExpr = attr.Arguments.First();
                                var argrr   = this.Emitter.Resolver.ResolveNode(argExpr, this.Emitter);

                                if (argrr.ConstantValue is int && (int)argrr.ConstantValue > 0)
                                {
                                    mode             = (int)argrr.ConstantValue;
                                    needRemoveIndent = true;
                                }
                            }
                        }
                    }
                }
            }

            if (!newline && this.RemovePenultimateEmptyLines(true))
            {
                this.Emitter.IsNewLine = false;
                this.WriteSpace();
            }

            if (needRemoveIndent)
            {
                text = AbstractEmitterBlock.RemoveIndentFromString(text, this.Comment.StartLocation.Column - (mode == 1 ? 5 : 1));
            }

            if (wrap)
            {
                this.Write("/* " + text + "*/");
                this.WriteNewLine();
            }
            else
            {
                this.Write(text);
            }
        }