public override void WriteKeyword(Role role, string keyword)
        {
            TextLocation    start = locationProvider.Location;
            CSharpTokenNode t     = null;

            if (role is TokenRole)
            {
                t = new CSharpTokenNode(start, (TokenRole)role);
            }
            else if (role == EntityDeclaration.ModifierRole)
            {
                t = new CSharpModifierToken(start, CSharpModifierToken.GetModifierValue(keyword));
            }
            else if (keyword == "this")
            {
                ThisReferenceExpression node = nodes.Peek().LastOrDefault() as ThisReferenceExpression;
                if (node != null)
                {
                    node.Location = start;
                }
            }
            else if (keyword == "base")
            {
                BaseReferenceExpression node = nodes.Peek().LastOrDefault() as BaseReferenceExpression;
                if (node != null)
                {
                    node.Location = start;
                }
            }
            if (t != null)
            {
                currentList.Add(t);
            }
            base.WriteKeyword(role, keyword);
        }
 void PrintModifiers(Modifiers modifiers, IOutputFormatter formatter)
 {
     foreach (var m in CSharpModifierToken.AllModifiers)
     {
         if ((modifiers & m) == m)
         {
             formatter.WriteKeyword(CSharpModifierToken.GetModifierName(m));
             formatter.Space();
         }
     }
 }
Example #3
0
 void PrintModifiers(Modifiers modifiers, TokenWriter writer)
 {
     foreach (var m in CSharpModifierToken.AllModifiers)
     {
         if ((modifiers & m) == m)
         {
             writer.WriteKeyword(EntityDeclaration.ModifierRole, CSharpModifierToken.GetModifierName(m));
             writer.Space();
         }
     }
 }
Example #4
0
 void PrintModifiers(Modifiers modifiers, TextWriterTokenWriter formatter)
 {
     foreach (var m in CSharpModifierToken.AllModifiers)
     {
         if ((modifiers & m) == m)
         {
             formatter.WriteToken(TypeDeclaration.ModifierRole, CSharpModifierToken.GetModifierName(m));
             formatter.Space();
         }
     }
 }
        public override void VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode)
        {
            CSharpModifierToken mod = cSharpTokenNode as CSharpModifierToken;

            if (mod != null)
            {
                StartNode(mod);
                WriteKeyword(CPlusPlusCLIModifierToken.GetModifierName(mod.Modifier));
                EndNode(mod);
            }
            else
            {
                throw new NotSupportedException("Should never visit individual tokens");
            }
        }
Example #6
0
        public override void VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode)
        {
            CSharpModifierToken mod = cSharpTokenNode as CSharpModifierToken;

            if (mod != null)
            {
                // In context of FieldDefinition, the modifier is outputted using "<type> :" (type followed by colon).
                StartNode(mod);
                WriteKeyword(CPlusPlusCLIFieldModifierToken.GetModifierName(mod.Modifier));
                EndNode(mod);
            }
            else
            {
                throw new NotSupportedException("Should never visit individual tokens");
            }
        }
 CodeAction GetFixAction(TypeDeclaration typeDeclaration, CSharpModifierToken partialModifierToken)
 {
     return(new CodeAction(ctx.TranslateString("Remove 'partial'"), script => {
         script.ChangeModifier(typeDeclaration, typeDeclaration.Modifiers & ~Modifiers.Partial);
     }, partialModifierToken));
 }