public void IsDirectiveCompletableToken_ReturnsTrueForCSharpMarkerTokens()
        {
            // Arrange
            var csharpToken = new CSharpToken(string.Empty, CSharpTokenType.Unknown);

            // Act
            var result = DefaultRazorCompletionFactsService.IsDirectiveCompletableToken(csharpToken);

            // Assert
            Assert.True(result);
        }
        public void IsDirectiveCompletableToken_ReturnsFalseForInvalidCSharpTokens()
        {
            // Arrange
            var csharpToken = new CSharpToken("~", CSharpTokenType.Tilde);

            // Act
            var result = DefaultRazorCompletionFactsService.IsDirectiveCompletableToken(csharpToken);

            // Assert
            Assert.False(result);
        }
        public void IsDirectiveCompletableToken_ReturnsTrueForCSharpIdentifiers()
        {
            // Arrange
            var csharpToken = new CSharpToken("model", CSharpTokenType.Identifier);

            // Act
            var result = DefaultRazorCompletionFactsService.IsDirectiveCompletableToken(csharpToken);

            // Assert
            Assert.True(result);
        }
Exemplo n.º 4
0
    public virtual bool PrintToken(CSharpToken token) {
      switch (token) {
        case CSharpToken.Assign:
          sourceEmitterOutput.Write("=");
          break;
        case CSharpToken.NewLine:
          sourceEmitterOutput.WriteLine("");
          break;
        case CSharpToken.Indent:
          sourceEmitterOutput.Write("", true);
          break;
        case CSharpToken.Space:
          sourceEmitterOutput.Write(" ");
          break;
        case CSharpToken.Dot:
          sourceEmitterOutput.Write(".");
          break;
        case CSharpToken.LeftCurly:
          if (this.LeftCurlyOnNewLine) {
            if (!this.sourceEmitterOutput.CurrentLineEmpty)
              PrintToken(CSharpToken.NewLine);
          } else {
            PrintToken(CSharpToken.Space);
          }
          sourceEmitterOutput.WriteLine("{", this.LeftCurlyOnNewLine);
          sourceEmitterOutput.IncreaseIndent();
          break;
        case CSharpToken.RightCurly:
          sourceEmitterOutput.DecreaseIndent();
          sourceEmitterOutput.WriteLine("}", true);
          break;
        case CSharpToken.LeftParenthesis:
          sourceEmitterOutput.Write("(");
          break;
        case CSharpToken.RightParenthesis:
          sourceEmitterOutput.Write(")");
          break;
        case CSharpToken.LeftAngleBracket:
          sourceEmitterOutput.Write("<");
          break;
        case CSharpToken.RightAngleBracket:
          sourceEmitterOutput.Write(">");
          break;
        case CSharpToken.LeftSquareBracket:
          sourceEmitterOutput.Write("[");
          break;
        case CSharpToken.RightSquareBracket:
          sourceEmitterOutput.Write("]");
          break;
        case CSharpToken.Semicolon:
          sourceEmitterOutput.WriteLine(";");
          break;
        case CSharpToken.Colon:
          sourceEmitterOutput.Write(":");
          break;
        case CSharpToken.Comma:
          sourceEmitterOutput.Write(",");
          break;
        case CSharpToken.Tilde:
          sourceEmitterOutput.Write("~");
          break;
        case CSharpToken.Public:
          sourceEmitterOutput.Write("public ");
          break;
        case CSharpToken.Private:
          sourceEmitterOutput.Write("private ");
          break;
        case CSharpToken.Internal:
          sourceEmitterOutput.Write("internal ");
          break;
        case CSharpToken.Protected:
          sourceEmitterOutput.Write("protected ");
          break;
        case CSharpToken.Static:
          sourceEmitterOutput.Write("static ");
          break;
        case CSharpToken.Abstract:
          sourceEmitterOutput.Write("abstract ");
          break;
        case CSharpToken.Extern:
          sourceEmitterOutput.Write("extern ");
          break;
        case CSharpToken.Unsafe:
          sourceEmitterOutput.Write("unsafe ");
          break;
        case CSharpToken.ReadOnly:
          sourceEmitterOutput.Write("readonly ");
          break;
        case CSharpToken.Fixed:
          sourceEmitterOutput.Write("fixed ");
          break;
        case CSharpToken.New:
          sourceEmitterOutput.Write("new ");
          break;
        case CSharpToken.Sealed:
          sourceEmitterOutput.Write("sealed ");
          break;
        case CSharpToken.Virtual:
          sourceEmitterOutput.Write("virtual ");
          break;
        case CSharpToken.Override:
          sourceEmitterOutput.Write("override ");
          break;
        case CSharpToken.Class:
          sourceEmitterOutput.Write("class ");
          break;
        case CSharpToken.Interface:
          sourceEmitterOutput.Write("interface ");
          break;
        case CSharpToken.Struct:
          sourceEmitterOutput.Write("struct ");
          break;
        case CSharpToken.Enum:
          sourceEmitterOutput.Write("enum ");
          break;
        case CSharpToken.Delegate:
          sourceEmitterOutput.Write("delegate ");
          break;
        case CSharpToken.Event:
          sourceEmitterOutput.Write("event ");
          break;
        case CSharpToken.Namespace:
          sourceEmitterOutput.Write("namespace ");
          break;
        case CSharpToken.Null:
          sourceEmitterOutput.Write("null");
          break;
        case CSharpToken.In:
          sourceEmitterOutput.Write("in ");
          break;
        case CSharpToken.Out:
          sourceEmitterOutput.Write("out ");
          break;
        case CSharpToken.Ref:
          sourceEmitterOutput.Write("ref ");
          break;
        case CSharpToken.Boolean:
          sourceEmitterOutput.Write("boolean ");
          break;
        case CSharpToken.Byte:
          sourceEmitterOutput.Write("byte ");
          break;
        case CSharpToken.Char:
          sourceEmitterOutput.Write("char ");
          break;
        case CSharpToken.Double:
          sourceEmitterOutput.Write("double ");
          break;
        case CSharpToken.Short:
          sourceEmitterOutput.Write("short ");
          break;
        case CSharpToken.Int:
          sourceEmitterOutput.Write("int ");
          break;
        case CSharpToken.Long:
          sourceEmitterOutput.Write("long ");
          break;
        case CSharpToken.Object:
          sourceEmitterOutput.Write("object ");
          break;
        case CSharpToken.String:
          sourceEmitterOutput.Write("string ");
          break;
        case CSharpToken.UShort:
          sourceEmitterOutput.Write("ushort ");
          break;
        case CSharpToken.UInt:
          sourceEmitterOutput.Write("uint ");
          break;
        case CSharpToken.ULong:
          sourceEmitterOutput.Write("ulong ");
          break;
        case CSharpToken.Get:
          sourceEmitterOutput.Write("get");
          break;
        case CSharpToken.Set:
          sourceEmitterOutput.Write("set");
          break;
        case CSharpToken.Add:
          sourceEmitterOutput.Write("add");
          break;
        case CSharpToken.Remove:
          sourceEmitterOutput.Write("remove");
          break;
        case CSharpToken.Return:
          sourceEmitterOutput.Write("return");
          break;
        case CSharpToken.This:
          sourceEmitterOutput.Write("this");
          break;
        case CSharpToken.Throw:
          sourceEmitterOutput.Write("throw");
          break;
        case CSharpToken.Try:
          sourceEmitterOutput.Write("try");
          break;
        case CSharpToken.YieldReturn:
          sourceEmitterOutput.Write("yield return");
          break;
        case CSharpToken.YieldBreak:
          sourceEmitterOutput.Write("yield break");
          break;
        case CSharpToken.True:
          sourceEmitterOutput.Write("true");
          break;
        case CSharpToken.False:
          sourceEmitterOutput.Write("false");
          break;
        case CSharpToken.TypeOf:
          sourceEmitterOutput.Write("typeof");
          break;
        default:
          sourceEmitterOutput.Write("Unknown-token");
          break;
      }

      return true;
    }
Exemplo n.º 5
0
        public virtual bool PrintToken(CSharpToken token)
        {
            switch (token)
            {
            case CSharpToken.Assign:
                sourceEmitterOutput.Write("=");
                break;

            case CSharpToken.NewLine:
                sourceEmitterOutput.WriteLine("");
                break;

            case CSharpToken.Indent:
                sourceEmitterOutput.Write("", true);
                break;

            case CSharpToken.Space:
                sourceEmitterOutput.Write(" ");
                break;

            case CSharpToken.Dot:
                sourceEmitterOutput.Write(".");
                break;

            case CSharpToken.LeftCurly:
                if (this.LeftCurlyOnNewLine)
                {
                    if (!this.sourceEmitterOutput.CurrentLineEmpty)
                    {
                        PrintToken(CSharpToken.NewLine);
                    }
                }
                else
                {
                    PrintToken(CSharpToken.Space);
                }
                sourceEmitterOutput.WriteLine("{", this.LeftCurlyOnNewLine);
                sourceEmitterOutput.IncreaseIndent();
                break;

            case CSharpToken.RightCurly:
                sourceEmitterOutput.DecreaseIndent();
                sourceEmitterOutput.WriteLine("}", true);
                break;

            case CSharpToken.LeftParenthesis:
                sourceEmitterOutput.Write("(");
                break;

            case CSharpToken.RightParenthesis:
                sourceEmitterOutput.Write(")");
                break;

            case CSharpToken.LeftAngleBracket:
                sourceEmitterOutput.Write("<");
                break;

            case CSharpToken.RightAngleBracket:
                sourceEmitterOutput.Write(">");
                break;

            case CSharpToken.LeftSquareBracket:
                sourceEmitterOutput.Write("[");
                break;

            case CSharpToken.RightSquareBracket:
                sourceEmitterOutput.Write("]");
                break;

            case CSharpToken.Semicolon:
                sourceEmitterOutput.WriteLine(";");
                break;

            case CSharpToken.Colon:
                sourceEmitterOutput.Write(":");
                break;

            case CSharpToken.Comma:
                sourceEmitterOutput.Write(",");
                break;

            case CSharpToken.Tilde:
                sourceEmitterOutput.Write("~");
                break;

            case CSharpToken.Public:
                sourceEmitterOutput.Write("public ");
                break;

            case CSharpToken.Private:
                sourceEmitterOutput.Write("private ");
                break;

            case CSharpToken.Internal:
                sourceEmitterOutput.Write("internal ");
                break;

            case CSharpToken.Protected:
                sourceEmitterOutput.Write("protected ");
                break;

            case CSharpToken.Static:
                sourceEmitterOutput.Write("static ");
                break;

            case CSharpToken.Abstract:
                sourceEmitterOutput.Write("abstract ");
                break;

            case CSharpToken.Extern:
                sourceEmitterOutput.Write("extern ");
                break;

            case CSharpToken.Unsafe:
                sourceEmitterOutput.Write("unsafe ");
                break;

            case CSharpToken.ReadOnly:
                sourceEmitterOutput.Write("readonly ");
                break;

            case CSharpToken.Fixed:
                sourceEmitterOutput.Write("fixed ");
                break;

            case CSharpToken.New:
                sourceEmitterOutput.Write("new ");
                break;

            case CSharpToken.Sealed:
                sourceEmitterOutput.Write("sealed ");
                break;

            case CSharpToken.Virtual:
                sourceEmitterOutput.Write("virtual ");
                break;

            case CSharpToken.Override:
                sourceEmitterOutput.Write("override ");
                break;

            case CSharpToken.Class:
                sourceEmitterOutput.Write("class ");
                break;

            case CSharpToken.Interface:
                sourceEmitterOutput.Write("interface ");
                break;

            case CSharpToken.Struct:
                sourceEmitterOutput.Write("struct ");
                break;

            case CSharpToken.Enum:
                sourceEmitterOutput.Write("enum ");
                break;

            case CSharpToken.Delegate:
                sourceEmitterOutput.Write("delegate ");
                break;

            case CSharpToken.Event:
                sourceEmitterOutput.Write("event ");
                break;

            case CSharpToken.Namespace:
                sourceEmitterOutput.Write("namespace ");
                break;

            case CSharpToken.Null:
                sourceEmitterOutput.Write("null");
                break;

            case CSharpToken.In:
                sourceEmitterOutput.Write("in ");
                break;

            case CSharpToken.Out:
                sourceEmitterOutput.Write("out ");
                break;

            case CSharpToken.Ref:
                sourceEmitterOutput.Write("ref ");
                break;

            case CSharpToken.Boolean:
                sourceEmitterOutput.Write("boolean ");
                break;

            case CSharpToken.Byte:
                sourceEmitterOutput.Write("byte ");
                break;

            case CSharpToken.Char:
                sourceEmitterOutput.Write("char ");
                break;

            case CSharpToken.Double:
                sourceEmitterOutput.Write("double ");
                break;

            case CSharpToken.Short:
                sourceEmitterOutput.Write("short ");
                break;

            case CSharpToken.Int:
                sourceEmitterOutput.Write("int ");
                break;

            case CSharpToken.Long:
                sourceEmitterOutput.Write("long ");
                break;

            case CSharpToken.Object:
                sourceEmitterOutput.Write("object ");
                break;

            case CSharpToken.String:
                sourceEmitterOutput.Write("string ");
                break;

            case CSharpToken.UShort:
                sourceEmitterOutput.Write("ushort ");
                break;

            case CSharpToken.UInt:
                sourceEmitterOutput.Write("uint ");
                break;

            case CSharpToken.ULong:
                sourceEmitterOutput.Write("ulong ");
                break;

            case CSharpToken.Get:
                sourceEmitterOutput.Write("get");
                break;

            case CSharpToken.Set:
                sourceEmitterOutput.Write("set");
                break;

            case CSharpToken.Add:
                sourceEmitterOutput.Write("add");
                break;

            case CSharpToken.Remove:
                sourceEmitterOutput.Write("remove");
                break;

            case CSharpToken.Return:
                sourceEmitterOutput.Write("return");
                break;

            case CSharpToken.This:
                sourceEmitterOutput.Write("this");
                break;

            case CSharpToken.Throw:
                sourceEmitterOutput.Write("throw");
                break;

            case CSharpToken.Try:
                sourceEmitterOutput.Write("try");
                break;

            case CSharpToken.YieldReturn:
                sourceEmitterOutput.Write("yield return");
                break;

            case CSharpToken.YieldBreak:
                sourceEmitterOutput.Write("yield break");
                break;

            case CSharpToken.True:
                sourceEmitterOutput.Write("true");
                break;

            case CSharpToken.False:
                sourceEmitterOutput.Write("false");
                break;

            case CSharpToken.TypeOf:
                sourceEmitterOutput.Write("typeof");
                break;

            default:
                sourceEmitterOutput.Write("Unknown-token");
                break;
            }

            return(true);
        }