コード例 #1
0
        private static int CompareStringLiteralExpression(ILiteralExpression left, ILiteralExpression right, bool usePathCompareSemantics = false)
        {
            // Standard left,right and null checks
            if (left == null && right == null)
            {
                return(0);
            }
            if (left == null)
            {
                return(1);
            }
            if (right == null)
            {
                return(-1);
            }

            // First try to sort on the character wrapper
            var leftKind  = (int?)(left as IStringLiteral)?.LiteralKind;
            var rightKind = (int?)(right as IStringLiteral)?.LiteralKind;

            if (leftKind != rightKind)
            {
                return(leftKind < rightKind ? -1 : 1);
            }

            if (usePathCompareSemantics)
            {
                return(ComparePathStringLiteral(left.Text, right.Text));
            }

            return(string.CompareOrdinal(left.Text, right.Text));
        }
コード例 #2
0
        /// <summary>
        /// Whether the <paramref name="node"/> is an <code>importFrom(...)</code> or <code>importFile(...)</code> with the required number of arguments (i.e. with 1 argument).
        /// </summary>
        public static bool IsImportCall(
            [NotNull] this INode node,
            out ICallExpression callExpression,
            out DScriptImportFunctionKind importKind,
            out IExpression argumentAsExpression,
            out ILiteralExpression argumentAsLiteral)
        {
            Contract.Requires(node != null);

            const int parameterCount = 1;

            callExpression = node.As <ICallExpression>();
            var expressionIdentifier = callExpression?.Expression.As <IIdentifier>();

            if (
                (expressionIdentifier?.Text == Names.InlineImportFunction ||
                 expressionIdentifier?.Text == Names.InlineImportFileFunction) &&
                (callExpression.TypeArguments == null || callExpression.TypeArguments.Count == 0) &&
                callExpression.Arguments.Length >= parameterCount)
            {
                importKind = expressionIdentifier.Text == Names.InlineImportFunction
                    ? DScriptImportFunctionKind.ImportFrom
                    : DScriptImportFunctionKind.ImportFile;

                argumentAsExpression = callExpression.Arguments[0];
                argumentAsLiteral    = argumentAsExpression.As <ILiteralExpression>();

                return(true);
            }

            importKind           = DScriptImportFunctionKind.None;
            argumentAsExpression = null;
            argumentAsLiteral    = null;
            return(false);
        }
コード例 #3
0
        /// <summary>
        /// Extract the initializer for the given TypeDeclaration.
        /// </summary>
        /// <param name="typeDeclaration">TypeDeclaration to extarct the initializer from.</param>
        /// <returns>Value of the initializer as a string.</returns>
        protected virtual string ExtractArtifact(ITypeDeclaration typeDeclaration)
        {
            string value = null;

            // Locate the field for this artifact and extract its initializer
            string expectedFieldName = FieldName;

            foreach (IFieldDeclaration fieldDeclaration in typeDeclaration.Fields)
            {
                // BizTalk 2006 compiles textual representations as private const string fields
                if (fieldDeclaration.Visibility == FieldVisibility.Private)
                {
                    // Loacte the field holding the textual representation of the artifact
                    if (String.CompareOrdinal(expectedFieldName, fieldDeclaration.Name) == 0)
                    {
                        ILiteralExpression litteralExpression = fieldDeclaration.Initializer as ILiteralExpression;
                        if (litteralExpression != null)
                        {
                            value = litteralExpression.Value as string;
                            break;
                        }
                    }
                }
            }

            return(value);
        }
コード例 #4
0
 /// <summary>
 /// Validates that importFile is not used within a spec file
 /// </summary>
 protected override void DoValidateImportFile(IExpression argument, ILiteralExpression stringLiteral, DiagnosticContext context)
 {
     // Cannot use importFile in spec
     context.Logger.ReportImportFileInSpec(
         context.LoggingContext,
         argument.LocationForLogging(context.SourceFile));
 }
コード例 #5
0
 public override bool IsAvailable(IUserDataHolder cache)
 {
     var literal = _provider.GetSelectedElement<ILiteralExpression>(true, true);
     //var processor = new YC.ReSharper.AbstractAnalysis.Plugin.Core.Processor(_provider);
     //var parserRes = processor.Process();
     //parserRes.
     ////var style = new TextStyle(FontStyle.Italic, Color.Aqua, Color.Bisque);
     ////var t =  CSharpHighlightingConsumerExtension.AddHighlighting()
     ////t.
     ////ITextControl
     ////var t = _provider.Document. // TextControl;
     ////t.Document.
     ////var h = new TextControlMarkup.HighlighterProcessor();
     ////var gg = HighlighterLayer.
     ////var tt = highli
     ////ITextControl.
     //Console.WriteLine(parserRes);
     if (literal != null && literal.IsConstantValue() && literal.ConstantValue.IsString())
     {
         var s = literal.ConstantValue.Value as string;
         if (!string.IsNullOrEmpty(s))
         {
             _stringLiteral = literal;
             return true;
         }
     }
     return false;
 }
コード例 #6
0
        private static bool IsNullDeclaration(IStatement state)
        {
            IExpressionStatement state_exp = state as IExpressionStatement;

            if (state_exp == null)
            {
                return(false);
            }

            IVariableDeclarationExpression exp_var;

            IAssignExpression exp_assign = state_exp.Expression as IAssignExpression;

            if (exp_assign != null)
            {
                // T value=nullptr; の場合
                ILiteralExpression exp_lit = exp_assign.Expression as ILiteralExpression;
                if (exp_lit == null || exp_lit.Value != null)
                {
                    return(false);
                }
                exp_var = exp_assign.Target as IVariableDeclarationExpression;
            }
            else
            {
                // T value; の場合
                exp_var = state_exp.Expression as IVariableDeclarationExpression;
            }

            return(exp_var != null);
        }
コード例 #7
0
        public override bool IsAvailable(IUserDataHolder cache)
        {
            var literal = _provider.GetSelectedElement <ILiteralExpression>(true, true);

            //var processor = new YC.ReSharper.AbstractAnalysis.Plugin.Core.Processor(_provider);
            //var parserRes = processor.Process();
            //parserRes.
            ////var style = new TextStyle(FontStyle.Italic, Color.Aqua, Color.Bisque);
            ////var t =  CSharpHighlightingConsumerExtension.AddHighlighting()
            ////t.
            ////ITextControl
            ////var t = _provider.Document. // TextControl;
            ////t.Document.
            ////var h = new TextControlMarkup.HighlighterProcessor();
            ////var gg = HighlighterLayer.
            ////var tt = highli
            ////ITextControl.
            //Console.WriteLine(parserRes);
            if (literal != null && literal.IsConstantValue() && literal.ConstantValue.IsString())
            {
                var s = literal.ConstantValue.Value as string;
                if (!string.IsNullOrEmpty(s))
                {
                    _stringLiteral = literal;
                    return(true);
                }
            }
            return(false);
        }
コード例 #8
0
 protected override IExpression ConvertUnary(IUnaryExpression iue)
 {
     iue = (IUnaryExpression)base.ConvertUnary(iue);
     if (iue.Operator == UnaryOperator.BooleanNot)
     {
         if (iue.Expression is ILiteralExpression)
         {
             ILiteralExpression expr = (ILiteralExpression)iue.Expression;
             if (expr.Value is bool)
             {
                 return(Builder.LiteralExpr(!(bool)expr.Value));
             }
         }
         else if (iue.Expression is IUnaryExpression)
         {
             IUnaryExpression iue2 = (IUnaryExpression)iue.Expression;
             if (iue2.Operator == UnaryOperator.BooleanNot) // double negation
             {
                 return(iue2.Expression);
             }
         }
         else if (iue.Expression is IBinaryExpression)
         {
             IBinaryExpression ibe = (IBinaryExpression)iue.Expression;
             BinaryOperator    negatedOp;
             if (Recognizer.TryNegateOperator(ibe.Operator, out negatedOp))
             {
                 // replace !(i==0) with (i != 0)
                 return(Builder.BinaryExpr(ibe.Left, negatedOp, ibe.Right));
             }
         }
     }
     return(iue);
 }
コード例 #9
0
        // e.g. literalExpressionOwner = "InvokeRepeating"
        // targetType = "MyMonoBehaviour"
        public UnityEventFunctionReference(ITypeElement targetType, ILiteralExpression literal, MethodSignature methodSignature)
            : base(literal)
        {
            myTargetType    = targetType;
            MethodSignature = methodSignature;

            // All Unity event functions are instance methods, but handle the method signature
            if (methodSignature.IsStatic == null)
            {
                myAccessContext = new DefaultAccessContext(myOwner);
            }
            else if (methodSignature.IsStatic == true)
            {
                myAccessContext = new StaticAccessContext(myOwner);
            }
            else
            {
                myAccessContext = new NonStaticAccessContext(myOwner);
            }

            myMethodFilter             = new InvokableMethodFilter();
            myStaticFilter             = new StaticFilter(myAccessContext);
            myMethodSignatureFilter    = new MethodSignatureFilter(UnityResolveErrorType.UNITY_STRING_LITERAL_REFERENCE_INCORRECT_SIGNATURE_WARNING, MethodSignature);
            myUserCodeCompletionFilter = new UserCodeCompletionFilter();
        }
コード例 #10
0
        private static bool IsFirstArgumentInMethod(ILiteralExpression literal)
        {
            var argument       = CSharpArgumentNavigator.GetByValue(literal as ICSharpExpression);
            var argumentsOwner = CSharpArgumentsOwnerNavigator.GetByArgument(argument);

            return(argumentsOwner != null && argumentsOwner.ArgumentsEnumerable.FirstOrDefault() == argument);
        }
コード例 #11
0
            public string AppendLiteralExpression(ILiteralExpression ile)
            {
                StringBuilder sb = new StringBuilder();

                this.AppendLiteralExpression(sb, ile);
                return(sb.ToString());
            }
コード例 #12
0
        protected internal virtual DmnExpressionImpl TransformLiteralExpression(ILiteralExpression literalExpression)
        {
            var handler =
                handlerRegistry.getHandler <ILiteralExpression, DmnExpressionImpl>(typeof(ILiteralExpression));

            return(handler.HandleElement(this, literalExpression));
            //return null;
        }
コード例 #13
0
        public static bool IsModuleReference(ILiteralExpression specifier)
        {
            Contract.Requires(IsValidModuleReference(specifier));

            var text = specifier.Text;

            return(text[0] != '.' && text[0] != '/');
        }
コード例 #14
0
        public IExpression Evaluate <T, U>(IBinaryExpression <T, U> ex, IContext context)
        {
            IBinaryFunctionExpression <T, U>        TheFunction           = ex.Function;
            ILiteralExpression <T>                  literalLeft           = this.get <T>(ex.Left, this, context);
            ILiteralExpression <T>                  literalRight          = this.get <T>(ex.Right, this, context);
            ILiteralBinaryFunctionExpression <T, U> literalBinaryFunction = this.get <T, U>(ex.Function, this, context);

            return(literalBinaryFunction.Invoke(literalLeft.Item, literalRight.Item));
        }
コード例 #15
0
 /// <summary>
 /// Creates a new comparative operator
 /// </summary>
 /// <param name="myProperty">The interesting property</param>
 /// <param name="myConstant">The constant value</param>
 /// <param name="myIsLongrunning">Determines whether it is anticipated that the request could take longer</param>
 /// <param name="mySecurityToken">The current security token</param>
 /// <param name="myTransactionToken">The current transaction token</param>
 /// <param name="myVertexStore">The vertex store that is needed to load the vertices</param>
 protected AComparativeOperator(QueryPlanProperty myProperty, ILiteralExpression myConstant, Boolean myIsLongrunning, SecurityToken mySecurityToken, Int64 myTransactionToken, IVertexStore myVertexStore)
 {
     _property = myProperty;
     _constant = myConstant;
     _isLongrunning = myIsLongrunning;
     _vertexStore = myVertexStore;
     _securityToken = mySecurityToken;
     _transactionToken = myTransactionToken;
 }
コード例 #16
0
 /// <summary>
 /// Creates a new comparative operator
 /// </summary>
 /// <param name="myProperty">The interesting property</param>
 /// <param name="myConstant">The constant value</param>
 /// <param name="myIsLongrunning">Determines whether it is anticipated that the request could take longer</param>
 /// <param name="mySecurityToken">The current security token</param>
 /// <param name="myTransactionToken">The current transaction token</param>
 /// <param name="myVertexStore">The vertex store that is needed to load the vertices</param>
 protected AComparativeOperator(QueryPlanProperty myProperty, ILiteralExpression myConstant, Boolean myIsLongrunning, SecurityToken mySecurityToken, Int64 myTransactionToken, IVertexStore myVertexStore)
 {
     _property         = myProperty;
     _constant         = myConstant;
     _isLongrunning    = myIsLongrunning;
     _vertexStore      = myVertexStore;
     _securityToken    = mySecurityToken;
     _transactionToken = myTransactionToken;
 }
コード例 #17
0
        public SyncVarHookReference(ITypeElement owningType, IType fieldType, ILiteralExpression literal)
            : base(literal)
        {
            myOwningType     = owningType;
            myIsMethodFilter = new DeclaredElementTypeFilter(ResolveErrorType.NOT_RESOLVED, CLRDeclaredElementType.METHOD);

            MethodSignature         = GetMethodSignature(owningType, fieldType);
            myMethodSignatureFilter = new MethodSignatureFilter(
                UnityResolveErrorType.UNITY_STRING_LITERAL_REFERENCE_INCORRECT_SIGNATURE_ERROR,
                MethodSignature);
        }
コード例 #18
0
        public static bool IsExpressionEqualsIntZero(IOperation operation)
        {
            ILiteralExpression literal = operation as ILiteralExpression;

            if (literal == null || !literal.ConstantValue.HasValue)
            {
                return(false);
            }

            return(literal.HasConstantValue(0));
        }
コード例 #19
0
        public override void VisitLiteralExpression(ILiteralExpression operation)
        {
            LogString(nameof(ILiteralExpression));

            if (operation.ConstantValue.HasValue && operation.ConstantValue.Value.ToString() == operation.Text)
            {
                LogString($" (Text: {operation.Text})");
            }

            LogCommonPropertiesAndNewLine(operation);

            base.VisitLiteralExpression(operation);
        }
コード例 #20
0
 public bool IsAvailable(IUserDataHolder cache)
 {
     var literal = _provider.GetSelectedElement<ILiteralExpression>(true, true);
     if (literal != null && literal.IsConstantValue() && literal.ConstantValue.IsString())
     {
         var s = literal.ConstantValue.Value as string;
         if (!string.IsNullOrEmpty(s))
         {
             _stringLiteral = literal;
             return true;
         }
     }
     return false;
 }
コード例 #21
0
ファイル: NodeExtensions.cs プロジェクト: socat/BuildXL
        internal static int AsNumber(this ILiteralExpression literalExpression, bool isNegative)
        {
            Contract.Requires(literalExpression != null);

            string text = isNegative ? I($"-{literalExpression.Text}") : literalExpression.Text;

            var result = LiteralConverter.TryConvertNumber(text);

            if (!result.IsValid)
            {
                Contract.Assert(false, I($"Conversion from literal expression to number should be successful. Text: {literalExpression.Text}"));
            }

            return(result.Value);
        }
コード例 #22
0
        protected TreeTextRange GetTreeTextRange(ILiteralExpression literalExpression)
        {
            var vbLiteral = literalExpression as IVBLiteralExpression;

            if (vbLiteral != null)
            {
                var range = vbLiteral.GetStringLiteralContentTreeRange();
                if (range.Length != 0)
                {
                    return(range);
                }
            }

            return(TreeTextRange.InvalidRange);
        }
コード例 #23
0
        /// <summary>
        /// Validates that importFile is always passed a file literal
        /// </summary>
        protected override void DoValidateImportFile(IExpression argument, ILiteralExpression stringLiteral, DiagnosticContext context)
        {
            (var interpolationKind, ILiteralExpression literal, _, _) = argument.As <ITaggedTemplateExpression>();

            if (interpolationKind != InterpolationKind.FileInterpolation || literal == null)
            {
                // Must pass a file path literal to importFile
                context.Logger.ReportImportFileNotPassedAFileLiteral(
                    context.LoggingContext,
                    argument.LocationForLogging(context.SourceFile),
                    argument.GetFormattedText());
            }

            CheckForFilesThatExposeNothing(literal?.Text, argument, Names.InlineImportFileFunction, context);
        }
コード例 #24
0
        public override bool IsAvailable(IUserDataHolder cache)
        {
            var literal = _provider.GetSelectedElement <ILiteralExpression>(true, true);

            if (literal != null && literal.IsConstantValue() && literal.ConstantValue.IsString())
            {
                var s = literal.ConstantValue.Value as string;
                if (!string.IsNullOrEmpty(s))
                {
                    _stringLiteral = literal;
                    return(true);
                }
            }
            return(false);
        }
コード例 #25
0
 public sealed override void Initialize(AnalysisContext context)
 {
     context.RegisterOperationAction(
         (operationContext) =>
     {
         ILiteralExpression literal = (ILiteralExpression)operationContext.Operation;
         if (literal.ResultType.SpecialType == SpecialType.System_Int32 &&
             literal.ConstantValue != null &&
             (int)literal.ConstantValue == 17)
         {
             operationContext.ReportDiagnostic(Diagnostic.Create(SeventeenDescriptor, literal.Syntax.GetLocation()));
         }
     },
         OperationKind.LiteralExpression);
 }
コード例 #26
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            ILiteralExpression expression = obj as ILiteralExpression;

            if (expression == null)
            {
                return(false);
            }

            return(this.Value.Equals(expression.Value));
        }
コード例 #27
0
 /// <summary>
 /// Creates a new queryplan that processes a less or equals than operation using indices
 /// </summary>
 /// <param name="mySecurityToken">The current security token</param>
 /// <param name="myTransactionToken">The current transaction token</param>
 /// <param name="myProperty">The interesting property</param>
 /// <param name="myConstant">The constant value</param>
 /// <param name="myVertexStore">The vertex store that is needed to load the vertices</param>
 /// <param name="myIsLongrunning">Determines whether it is anticipated that the request could take longer</param>
 /// <param name="myExpressionIndex">The name of the index which is used to resolve the expression</param>
 public QueryPlanLessOrEqualsThanWithIndex(SecurityToken mySecurityToken, 
                                             Int64 myTransactionToken, 
                                             QueryPlanProperty myProperty, 
                                             ILiteralExpression myConstant, 
                                             IVertexStore myVertexStore, 
                                             Boolean myIsLongrunning, 
                                             IIndexManager myIndexManager,
                                             String myExpressionIndex = null)
     : base(myProperty, 
             myConstant, 
             myIsLongrunning, 
             mySecurityToken, 
             myTransactionToken, 
             myIndexManager, 
             myVertexStore,
             myExpressionIndex)
 { }
コード例 #28
0
        protected void ValidateImportFile(IExpression argument, [CanBeNull] ILiteralExpression stringLiteral, DiagnosticContext context)
        {
            DoValidateImportFile(argument, stringLiteral, context);

            (_, ILiteralExpression literal, _, _) = argument.As <ITaggedTemplateExpression>();

            string text = stringLiteral?.Text ?? literal?.Text;

            if (text != null && text.IndexOfAny(ImportPathHelpers.InvalidPathChars) != -1)
            {
                context.Logger.ReportModuleSpecifierContainsInvalidCharacters(
                    context.LoggingContext,
                    argument.LocationForLogging(context.SourceFile),
                    text,
                    ImportPathHelpers.InvalidPathCharsText);
            }
        }
コード例 #29
0
 /// <summary>
 /// Creates a new comparative index operator
 /// </summary>
 /// <param name="myProperty">The interesting property</param>
 /// <param name="myConstant">The constant value</param>
 /// <param name="myIsLongrunning">Determines whether it is anticipated that the request could take longer</param>
 /// <param name="mySecurityToken">The current security token</param>
 /// <param name="myTransactionToken">The current transaction token</param>
 /// <param name="myIndexManager">The index manager is needed to get the property related indices</param>
 /// <param name="myVertexStore">The vertex store that is needed to load the vertices</param>
 protected AComparativeIndexOperator(QueryPlanProperty myProperty,
                                     ILiteralExpression myConstant,
                                     Boolean myIsLongrunning,
                                     SecurityToken mySecurityToken,
                                     Int64 myTransactionToken,
                                     IIndexManager myIndexManager,
                                     IVertexStore myVertexStore,
                                     String myExpressionIndex = null)
 {
     _property         = myProperty;
     _constant         = myConstant;
     _isLongrunning    = myIsLongrunning;
     _vertexStore      = myVertexStore;
     _indexManager     = myIndexManager;
     _securityToken    = mySecurityToken;
     _transactionToken = myTransactionToken;
     _expressionIndex  = myExpressionIndex;
 }
コード例 #30
0
 /// <summary>
 /// Creates a new queryplan that processes an GreaterOrEquals operation using indices
 /// </summary>
 /// <param name="mySecurityToken">The current security token</param>
 /// <param name="myTransactionToken">The current transaction token</param>
 /// <param name="myProperty">The interesting property</param>
 /// <param name="myConstant">The constant value</param>
 /// <param name="myVertexStore">The vertex store that is needed to load the vertices</param>
 /// <param name="myIsLongrunning">Determines whether it is anticipated that the request could take longer</param>
 public QueryPlanGreaterOrEqualsWithIndex(SecurityToken mySecurityToken,
                                          Int64 myTransactionToken,
                                          QueryPlanProperty myProperty,
                                          ILiteralExpression myConstant,
                                          IVertexStore myVertexStore,
                                          Boolean myIsLongrunning,
                                          IIndexManager myIndexManager,
                                          String myExpressionIndex = null)
     : base(myProperty,
            myConstant,
            myIsLongrunning,
            mySecurityToken,
            myTransactionToken,
            myIndexManager,
            myVertexStore,
            myExpressionIndex)
 {
 }
コード例 #31
0
            public ProcessedTagTemplateExpression(
                ITaggedTemplateExpression taggedTemplate,
                InterpolationKind kind,
                ILiteralExpression literal,
                ITemplateLiteralFragment head,
                INodeArray <ITemplateSpan> templateSpans)
            {
                Contract.Requires(taggedTemplate != null);
                Contract.Requires(
                    kind == InterpolationKind.Unknown || (literal != null || (head != null && templateSpans != null)),
                    "If interpolation is a well-known factory method, then Literal or Head+Templates should be valid.");

                TaggedTemplate = taggedTemplate;
                Kind           = kind;
                Literal        = literal;
                Head           = head;
                TemplateSpans  = templateSpans;
            }
コード例 #32
0
        /// <summary>
        /// Validates that importFrom is used in package and root config files in V1, where the argument passed to importFrom is not a package name.
        /// </summary>
        protected override void ValidateImportFrom(IExpression argument, ILiteralExpression stringLiteral, DiagnosticContext context)
        {
            string text = stringLiteral?.Text;

            if (!string.IsNullOrEmpty(text))
            {
                if (ImportPathHelpers.IsPackageName(text))
                {
                    // add error because importFrom must be passed file names, not package names
                    context.Logger.ReportNamedImportInConfigOrPackage(
                        context.LoggingContext,
                        argument.LocationForLogging(context.SourceFile),
                        Names.InlineImportFunction,
                        argument.GetFormattedText());
                }

                CheckForFilesThatExposeNothing(text, argument, Names.InlineImportFunction, context);
            }
        }
コード例 #33
0
 public override void VisitLiteralExpression(ILiteralExpression value)
 {
     if (value.Value is string)
     {
         _formatter.WriteLiteral("\"" + value.Value + "\"");
     }
     else if (value.Value is bool)
     {
         _formatter.WriteKeyword("$" + value.Value.ToString().ToLower());
     }
     else if (value.Value == null)
     {
         _formatter.WriteLiteral("$null");
     }
     else
     {
         _formatter.Write(value.Value.ToString());
     }
 }
コード例 #34
0
        protected override IStatement ConvertSwitch(ISwitchStatement iss)
        {
            ISwitchStatement ss = Builder.SwitchStmt();

            context.SetPrimaryOutput(ss);
            ss.Expression = ConvertExpression(iss.Expression);
            foreach (ISwitchCase isc in iss.Cases)
            {
                if (isc is IConditionCase)
                {
                    IExpression        cond = ((IConditionCase)isc).Condition;
                    ILiteralExpression ile  = cond as ILiteralExpression;
                    if ((ile != null) && (ile.Value is int) && ((int)ile.Value < 0))
                    {
                        continue;
                    }
                }
                ConvertSwitchCase(ss.Cases, isc);
            }
            return(ss);
        }
コード例 #35
0
ファイル: QueryPlanManager.cs プロジェクト: anukat2015/sones
        /// <summary>
        /// This method extracts the property and the constant out of a binary expression
        /// </summary>
        /// <param name="myBinaryExpression">The binary expression</param>
        /// <param name="myTransactionToken">The current transaction token</param>
        /// <param name="mySecurityToken">The current security token</param>
        /// <param name="myProperty">The property out parameter</param>
        /// <param name="myConstant">The constant out parameter</param>
        private void FindPropertyAndConstant(BinaryExpression myBinaryExpression, 
                                                Int64 myTransactionToken, 
                                                SecurityToken mySecurityToken, 
                                                out QueryPlanProperty myProperty, 
                                                out ILiteralExpression myConstant)
        {
            if (myBinaryExpression.Left is PropertyExpression)
            {
                myProperty = GenerateQueryPlanProperty((PropertyExpression)myBinaryExpression.Left, 
                                                        myTransactionToken, 
                                                        mySecurityToken);

                myConstant = (ILiteralExpression)myBinaryExpression.Right;
            }
            else
            {
                myProperty = GenerateQueryPlanProperty((PropertyExpression)myBinaryExpression.Right, 
                                                        myTransactionToken, 
                                                        mySecurityToken);

                myConstant = (ILiteralExpression)myBinaryExpression.Left;
            }
        }
コード例 #36
0
 public virtual void VisitLiteralExpression(ILiteralExpression operation)
 {
     DefaultVisit(operation);
 }
コード例 #37
0
        /// <summary>
        /// Negates the literal expression.
        /// </summary>
        /// <param name="factory">
        /// The factory.
        /// </param>
        /// <param name="literalExpression">
        /// The literal expression.
        /// </param>
        private static void NegateLiteralExpression(CSharpElementFactory factory, ILiteralExpression literalExpression)
        {
            ICSharpExpression csharpExpression = literalExpression as ICSharpExpression;
              if (csharpExpression == null)
              {
            return;
              }

              var text = literalExpression.GetText();

              if (text == "true")
              {
            text = "false";
              }
              else if (text == "false")
              {
            text = "true";
              }
              else
              {
            return;
              }

              var expression = factory.CreateExpression(text);

              ExpressionUtil.ReplaceExpression(csharpExpression, expression);
        }
コード例 #38
0
        protected TreeTextRange GetTreeTextRange(ILiteralExpression literalExpression)
        {
            var csharpLiteral = literalExpression as ICSharpLiteralExpression;
            if (csharpLiteral != null)
            {
                var range = csharpLiteral.GetStringLiteralContentTreeRange();
                if (range.Length != 0)
                    return range;
            }

            return TreeTextRange.InvalidRange;
        }
コード例 #39
0
 public SpliceStringWarning(ILiteralExpression element, string replacement)
 {
     _element = element;
     _replacement = replacement;
 }
コード例 #40
0
 /// <summary>
 /// Creates a new queryplan that processes a less than operation using indices
 /// </summary>
 /// <param name="mySecurityToken">The current security token</param>
 /// <param name="myTransactionToken">The current transaction token</param>
 /// <param name="myProperty">The interesting property</param>
 /// <param name="myConstant">The constant value</param>
 /// <param name="myVertexStore">The vertex store that is needed to load the vertices</param>
 /// <param name="myIsLongrunning">Determines whether it is anticipated that the request could take longer</param>
 public QueryPlanLessThanWithIndex(SecurityToken mySecurityToken, TransactionToken myTransactionToken, QueryPlanProperty myProperty, ILiteralExpression myConstant, IVertexStore myVertexStore, Boolean myIsLongrunning, IIndexManager myIndexManager)
     : base(myProperty, myConstant, myIsLongrunning, mySecurityToken, myTransactionToken, myIndexManager, myVertexStore)
 {
 }
コード例 #41
0
            private void WriteLiteralExpression(ILiteralExpression value, IFormatter formatter)
            {
                if (value.Value == null)
                {
                    formatter.WriteLiteral("null");
                }
                else if (value.Value is char)
                {
                    string text = new string(new char[] { (char)value.Value });
                    text = this.QuoteLiteralExpression(text);
                    formatter.WriteLiteral("\"" + text + "\"");
                }
                else if (value.Value is string)
                {
                    string text = (string)value.Value;
                    text = this.QuoteLiteralExpression(text);
                    formatter.WriteLiteral("\"" + text + "\"");
                }
                else if (value.Value is byte)
                {
                    this.WriteNumber((byte)value.Value, formatter);
                }
                else if (value.Value is sbyte)
                {
                    this.WriteNumber((sbyte)value.Value, formatter);
                }
                else if (value.Value is short)
                {
                    this.WriteNumber((short)value.Value, formatter);
                }
                else if (value.Value is ushort)
                {
                    this.WriteNumber((ushort)value.Value, formatter);
                }
                else if (value.Value is int)
                {
                    this.WriteNumber((int)value.Value, formatter);
                }
                else if (value.Value is uint)
                {
                    this.WriteNumber((uint)value.Value, formatter);
                }
                else if (value.Value is long)
                {
                    this.WriteNumber((long)value.Value, formatter);
                }
                else if (value.Value is ulong)
                {
                    this.WriteNumber((ulong)value.Value, formatter);
                }
                else if (value.Value is float)
                {
                    // TODO
                    formatter.WriteLiteral(((float)value.Value).ToString(CultureInfo.InvariantCulture));
                }
                else if (value.Value is double)
                {
                    // TODO
                    formatter.WriteLiteral(((double)value.Value).ToString("R", CultureInfo.InvariantCulture));
                }
                else if (value.Value is decimal)
                {
                    formatter.WriteLiteral(((decimal)value.Value).ToString(CultureInfo.InvariantCulture));
                }
                else if (value.Value is bool)
                {
                    formatter.WriteLiteral(((bool)value.Value) ? "true" : "false");
                }
                /*
                else if (expression.Value is byte[])
                {
                    formatter.WriteComment("{ ");

                    byte[] bytes = (byte[])expression.Value;
                    for (int i = 0; i < bytes.Length; i++)
                    {
                        if (i != 0)
                        {
                            formatter.Write(", ");
                        }

                        formatter.WriteComment("0x" + bytes[i].ToString("X2", CultureInfo.InvariantCulture));
                    }

                    formatter.WriteComment(" }");
                }
                */
                else
                {
                    throw new ArgumentException("expression");
                }
            }
コード例 #42
0
 protected ITypeConversionRule GetTypeConversionRule(ILiteralExpression literal)
 {
     return (literal as IVBTreeNode).GetTypeConversionRule();
 }
コード例 #43
0
 protected abstract IReference CreateReference(ITypeElement typeElement, ILiteralExpression literalExpression);
コード例 #44
0
 protected override IReference CreateReference(ITypeElement typeElement, ILiteralExpression literalExpression)
 {
     return new MemberDataReference(typeElement, literalExpression, GetTreeTextRange, GetTypeConversionRule);
 }
コード例 #45
0
 public virtual void VisitLiteralExpression(ILiteralExpression value)
 {
 }
コード例 #46
0
ファイル: TestOperationWalker.cs プロジェクト: CAPCHIK/roslyn
        public override void VisitLiteralExpression(ILiteralExpression operation)
        {
            var text = operation.Text;

            base.VisitLiteralExpression(operation);
        }
コード例 #47
0
 /// <summary>
 /// Creates a new comparative index operator
 /// </summary>
 /// <param name="myProperty">The interesting property</param>
 /// <param name="myConstant">The constant value</param>
 /// <param name="myIsLongrunning">Determines whether it is anticipated that the request could take longer</param>
 /// <param name="mySecurityToken">The current security token</param>
 /// <param name="myTransactionToken">The current transaction token</param>
 /// <param name="myIndexManager">The index manager is needed to get the property related indices</param>
 /// <param name="myVertexStore">The vertex store that is needed to load the vertices</param>
 protected AComparativeIndexOperator(QueryPlanProperty myProperty, 
                                     ILiteralExpression myConstant, 
                                     Boolean myIsLongrunning, 
                                     SecurityToken mySecurityToken, 
                                     Int64 myTransactionToken, 
                                     IIndexManager myIndexManager, 
                                     IVertexStore myVertexStore,
                                     String myExpressionIndex = null)
 {
     _property = myProperty;
     _constant = myConstant;
     _isLongrunning = myIsLongrunning;
     _vertexStore = myVertexStore;
     _indexManager = myIndexManager;
     _securityToken = mySecurityToken;
     _transactionToken = myTransactionToken;
     _expressionIndex = myExpressionIndex;
 }
コード例 #48
0
 public SpliceStringFix(SpliceStringWarning warning)
 {
     _literalExpression = warning.LiteralExpression;
     _replacement = warning.Replacement;
 }
コード例 #49
0
 protected override IReference CreateReference(ITypeElement typeElement, ILiteralExpression literalExpression)
 {
     return new PropertyDataReference(typeElement, literalExpression, GetTreeTextRange, p => GetTypeConversionRule(literalExpression));
 }
コード例 #50
0
 /// <summary>
 /// Creates a new queryplan that processes a like operation without any index
 /// </summary>
 /// <param name="mySecurityToken">The current security token</param>
 /// <param name="myTransactionToken">The current transaction token</param>
 /// <param name="myProperty">The interesting property</param>
 /// <param name="myConstant">The constant value</param>
 /// <param name="myVertexStore">The vertex store that is needed to load the vertices</param>
 /// <param name="myIsLongrunning">Determines whether it is anticipated that the request could take longer</param>
 public QueryPlanLikeWithoutIndex(SecurityToken mySecurityToken, Int64 myTransactionToken, QueryPlanProperty myProperty, ILiteralExpression myConstant, IVertexStore myVertexStore, Boolean myIsLongrunning)
     : base(myProperty, myConstant, myIsLongrunning, mySecurityToken, myTransactionToken, myVertexStore)            
 {
 }
コード例 #51
0
 public virtual IExpression TransformLiteralExpression(ILiteralExpression value)
 {
     return value;
 }