예제 #1
0
 /// <summary>
 /// Вход в выражение.
 /// </summary>
 /// <param name="context">Контекст.</param>
 public override void EnterInvocationCall(IsblParser.InvocationCallContext context)
 {
     if (context.identifier().GetText().Equals(ReferenceProperty, StringComparison.OrdinalIgnoreCase) &&
         context.parameterList() == null)
     {
         ContextWithInvocationErrors.Add(context);
     }
 }
예제 #2
0
            /// <summary>
            /// Вход в выражение.
            /// </summary>
            /// <param name="context">Контекст.</param>
            public override void EnterInvocationCall(IsblParser.InvocationCallContext context)
            {
                if (context.identifier().GetText().Equals(ReferenceFactoryMethod, StringComparison.OrdinalIgnoreCase) &&
                    context.parameterList() != null && context.parameterList().expression().Any())
                {
                    // Обращение к справочнику через ReferencesFactory().
                    var firstParam = context.parameterList().expression(0);
                    CheckReferenceInExpressionExists(firstParam);
                }
                else if (context.Parent.GetChild(0) is IsblParser.VariableContext)
                {
                    var variableName = context.Parent.GetChild(0).GetText().Trim('!');
                    if (variableName.Equals(ReferencesFactoryVar, StringComparison.OrdinalIgnoreCase))
                    {
                        // Обращение к справочнику через предопределенную переменную References.

                        // Проверить, что обращение к справочнику - это первый вызов после переменной References.
                        IsblParser.InvocationCallContext firstInvocationCall = null;
                        for (var i = 0; i < context.Parent.ChildCount; i++)
                        {
                            firstInvocationCall = context.Parent.GetChild(i) as IsblParser.InvocationCallContext;
                            if (firstInvocationCall != null)
                            {
                                break;
                            }
                        }
                        if (firstInvocationCall == context && context.parameterList() == null)
                        {
                            var referenceName = context.identifier().GetText();
                            // Использование "устаревших" наименований справочников в случае с References не допускаются.
                            if (!IsReferenceExists(referenceName, withOldReferences: false))
                            {
                                UsingReferenceEntries.Add(new UsingReferenceEntry
                                {
                                    Context       = context.identifier(),
                                    ReferenceName = referenceName
                                });
                            }
                        }
                    }
                }
            }
예제 #3
0
            public override void EnterInvocationCall(IsblParser.InvocationCallContext context)
            {
                var callMethod = context.GetChild <IsblParser.IdentifierContext>(0);

                if (callMethod == null)
                {
                    return;
                }

                var invokeStatement = context.Parent as IsblParser.InvokeStatementContext;

                if (invokeStatement == null)
                {
                    return;
                }

                var callMethodName = callMethod.GetText();
                var isOpenMethod   = complementMethodNames
                                     .Any(m => m.Key.Equals(callMethodName, StringComparison.OrdinalIgnoreCase));
                var isCloseMethod = complementMethodNames
                                    .Any(m => m.Value.Equals(callMethodName, StringComparison.OrdinalIgnoreCase));

                if (!isOpenMethod && !isCloseMethod)
                {
                    return;
                }

                var invokerName = invokeStatement.children
                                  .TakeWhile(ctx => ctx != context)
                                  .Select(ctx => ctx.GetText())
                                  .Aggregate((accumulate, text) => accumulate + text);

                // Удаляем последнюю точку.
                invokerName = invokerName.Remove(invokerName.Length - 1, 1);

                if (isOpenMethod)
                {
                    var isCachedReference = this.cachedReferenceVariableNames.Contains(invokerName);
                    if (!isCachedReference || !callMethodName.Equals("Open", StringComparison.OrdinalIgnoreCase))
                    {
                        var objectStateDefinition = new ObjectStateDefinition
                        {
                            CallMethodName   = callMethodName,
                            InvokerName      = invokerName,
                            StatementContext = invokeStatement
                        };
                        this.NotRestoredObjectDefinitions.Add(objectStateDefinition);
                    }
                }
                else
                {
                    var openMethodName = complementMethodNames
                                         .First(m => m.Value.Equals(callMethodName, StringComparison.OrdinalIgnoreCase))
                                         .Key;

                    var objectStateDefinitions = this.NotRestoredObjectDefinitions
                                                 .Where(d => d.CallMethodName.Equals(openMethodName, StringComparison.OrdinalIgnoreCase) &&
                                                        d.InvokerName.Equals(invokerName, StringComparison.OrdinalIgnoreCase))
                                                 .ToList();
                    foreach (var objectStateDefinition in objectStateDefinitions)
                    {
                        this.NotRestoredObjectDefinitions.Remove(objectStateDefinition);
                    }
                }
            }
예제 #4
0
            /// <summary>
            /// Вход в COM вызов.
            /// </summary>
            /// <param name="context">Контекст.</param>
            public override void EnterInvocationCall(IsblParser.InvocationCallContext context)
            {
                var callMethod = context.GetChild <IsblParser.IdentifierContext>(0);

                if (callMethod == null)
                {
                    return;
                }

                var callMethodName = callMethod.GetText();
                var isOpenMethod   = callMethods
                                     .Any(m => m.Key.Equals(callMethodName, StringComparison.OrdinalIgnoreCase));
                var isCloseMethod = callMethods
                                    .Any(m => m.Value.Equals(callMethodName, StringComparison.OrdinalIgnoreCase));

                if (isOpenMethod)
                {
                    var operand = context.Parent as IsblParser.OperandContext;
                    if (operand == null)
                    {
                        return;
                    }

                    var invokerName = operand.children
                                      .TakeWhile(ctx => ctx != context)
                                      .Select(ctx => ctx.GetText())
                                      .Aggregate((accumulate, text) => accumulate + text);
                    // Удаляем последнюю точку.
                    invokerName = invokerName.Remove(invokerName.Length - 1, 1);

                    var assingStatement = GetParentAssignStatementContext(context);
                    if (assingStatement == null)
                    {
                        return;
                    }

                    var identifierState = assingStatement.GetChild <IsblParser.VariableContext>(0);
                    if (identifierState == null)
                    {
                        return;
                    }

                    var identifierStateName = identifierState.GetText();

                    var objectStateDefinition = new ObjectStateDefinition
                    {
                        CallMethodName      = callMethodName,
                        InvokerName         = invokerName,
                        IdentifierStateName = identifierStateName,
                        StatementContext    = assingStatement
                    };
                    this.NotRestoredObjectDefinitions.Add(objectStateDefinition);
                }
                else if (isCloseMethod)
                {
                    var invokeStatement = context.Parent as IsblParser.InvokeStatementContext;
                    if (invokeStatement == null)
                    {
                        return;
                    }

                    var invokerName = invokeStatement.children
                                      .TakeWhile(ctx => ctx != context)
                                      .Select(ctx => ctx.GetText())
                                      .Aggregate((accumulate, text) => accumulate + text);
                    // Удаляем последнюю точку.
                    invokerName = invokerName.Remove(invokerName.Length - 1, 1);

                    var openMethodName = callMethods
                                         .First(m => m.Value.Equals(callMethodName, StringComparison.OrdinalIgnoreCase))
                                         .Key;

                    var parameterList = context.GetChild <IsblParser.ParameterListContext>(0);
                    if (parameterList == null)
                    {
                        return;
                    }

                    var identifierState = parameterList.GetChild <IsblParser.ExpressionContext>(0);
                    if (identifierState == null)
                    {
                        return;
                    }

                    var identifierStateName = identifierState.GetText();

                    var objectStateDefinitions = this.NotRestoredObjectDefinitions
                                                 .Where(d => d.CallMethodName.Equals(openMethodName, StringComparison.OrdinalIgnoreCase) &&
                                                        d.InvokerName.Equals(invokerName, StringComparison.OrdinalIgnoreCase) &&
                                                        d.IdentifierStateName.Equals(identifierStateName, StringComparison.OrdinalIgnoreCase))
                                                 .ToList();
                    foreach (var objectStateDefinition in objectStateDefinitions)
                    {
                        this.NotRestoredObjectDefinitions.Remove(objectStateDefinition);
                    }
                }
            }