private void BindToParentDataSet(ScopeTree scopeTree, IRIFReportDataScope scope, ErrorContext errorContext, ParentDataSetContainer parentDataSets) { if (parentDataSets == null) { if (scopeTree.GetParentDataRegion(scope) == null) { if (scopeTree.Report.MappingDataSetIndexToDataSet.Count == 0) { errorContext.Register(ProcessingErrorCode.rsDataRegionWithoutDataSet, Severity.Error, scope.DataScopeObjectType, scope.Name, null); } else { errorContext.Register(ProcessingErrorCode.rsMissingDataSetName, Severity.Error, scope.DataScopeObjectType, scope.Name, "DataSetName"); } } } else if (parentDataSets.Count > 1 && !parentDataSets.AreAllSameDataSet()) { DataRegion parentDataRegion = scopeTree.GetParentDataRegion(scope); IRIFDataScope parentRowScopeForIntersection = scopeTree.GetParentRowScopeForIntersection(scope); IRIFDataScope parentColumnScopeForIntersection = scopeTree.GetParentColumnScopeForIntersection(scope); errorContext.Register(ProcessingErrorCode.rsMissingIntersectionDataSetName, Severity.Error, scope.DataScopeObjectType, parentDataRegion.Name, "DataSetName", parentDataRegion.ObjectType.ToString(), parentRowScopeForIntersection.Name, parentColumnScopeForIntersection.Name); } else { UpdateDataSet(parentDataSets.ParentDataSet, scope); } }
/// <summary> /// Gets the chain of scopes which are associated with the given position in the code. /// </summary> private List <InterpreterScope> FindScopes(int lineNumber) { InterpreterScope curScope = ScopeTree.First(); InterpreterScope prevScope = null; var chain = new List <InterpreterScope> { Scopes[0] }; while (curScope != prevScope) { prevScope = curScope; // TODO: Binary search? // We currently search backwards because the end positions are sometimes unreliable // and go onto the next line overlapping w/ the previous definition. Therefore searching backwards always // hits the valid method first matching on Start. For example: // def f(): # Starts on 1, ends on 3 // pass // def g(): # starts on 3, ends on 4 // pass int lastStart = curScope.Start; for (int i = curScope.Children.Count - 1; i >= 0; i--) { var scope = curScope.Children[i]; if (scope.Start <= lineNumber && (scope.Stop >= lineNumber || lineNumber < lastStart)) { curScope = scope; chain.Add(curScope); break; } lastStart = scope.Start; } } return(chain); }
public void Visit(ClassAst ast) { if (Global == null) { Global = Current; } var classSymbol = ScopeUtil.DefineClassSymbol(ast); Current.Define(classSymbol); SetScopeType(ScopeType.Class); SetScopeSource(classSymbol); ScopeTree.CreateScope(); ast.Body.Visit(this); classSymbol.Symbols = ast.Body.CurrentScope.Symbols; //redefine the class symbol now with actual symbols Current.Define(classSymbol); ast.Body.CurrentScope.AllowAllForwardReferences = true; ScopeTree.PopScope(); if (ast.Global == null) { ast.Global = Global; } SetScopeType(ScopeType.Global); }
private bool HasRelationshipOrDefaultForDataSet(ScopeTree scopeTree, ErrorContext errorContext, IRIFReportDataScope currentScope, DataSet ourDataSet, DataSet parentDataSet, bool hasValidRelationship) { if (DataSet.AreEqualById(parentDataSet, ourDataSet)) { return(true); } if (hasValidRelationship || ourDataSet.HasDefaultRelationship(parentDataSet)) { Relationship activeRelationship = GetActiveRelationship(ourDataSet, parentDataSet); if (activeRelationship == null) { RegisterInvalidCellDataSetNameError(scopeTree, errorContext, currentScope, ourDataSet, parentDataSet); return(false); } if (activeRelationship.IsCrossJoin) { DataRegion parentDataRegion = scopeTree.GetParentDataRegion(currentScope); errorContext.Register(ProcessingErrorCode.rsInvalidIntersectionNaturalCrossJoin, Severity.Error, currentScope.DataScopeObjectType, parentDataRegion.Name, "JoinConditions", parentDataRegion.ObjectType.ToString()); return(false); } return(true); } RegisterInvalidCellDataSetNameError(scopeTree, errorContext, currentScope, ourDataSet, parentDataSet); return(false); }
private void CaptureGroupingFieldsForServerAggregates(InitializationContext context, IRIFDataScope scope) { if (this.m_groupingFieldIndicesForServerAggregates == null) { this.m_groupingFieldIndicesForServerAggregates = new List <int>(); if (this.m_dataSet != null) { ScopeTree scopeTree = context.ScopeTree; if (scopeTree.IsIntersectionScope(scope)) { this.AddGroupingFieldIndicesFromParentScope(context, scopeTree.GetParentRowScopeForIntersection(scope)); this.AddGroupingFieldIndicesFromParentScope(context, scopeTree.GetParentColumnScopeForIntersection(scope)); } else { IRIFDataScope parentScope = scopeTree.GetParentScope(scope); if (parentScope != null) { this.AddGroupingFieldIndicesFromParentScope(context, parentScope); } ReportHierarchyNode reportHierarchyNode = scope as ReportHierarchyNode; if (reportHierarchyNode != null && !reportHierarchyNode.IsStatic && !reportHierarchyNode.Grouping.IsDetail) { foreach (ExpressionInfo groupExpression in reportHierarchyNode.Grouping.GroupExpressions) { if (groupExpression.Type == ExpressionInfo.Types.Field) { this.m_groupingFieldIndicesForServerAggregates.Add(groupExpression.FieldIndex); } } } } } } }
private void BindToNamedDataSet(ScopeTree scopeTree, IRIFReportDataScope scope, ErrorContext errorContext, ParentDataSetContainer parentDataSets) { DataSet dataSet = scopeTree.GetDataSet(this.m_dataSetName); if (dataSet == null) { DataRegion parentDataRegion = scopeTree.GetParentDataRegion(scope); if (parentDataSets != null && parentDataSets.Count == 1 && scope is DataRegion && parentDataRegion != null) { this.UpdateDataSet(parentDataSets.ParentDataSet, scope); this.m_dataSetName = parentDataSets.ParentDataSet.Name; } else { errorContext.Register(ProcessingErrorCode.rsInvalidDataSetName, Severity.Error, scope.DataScopeObjectType, scope.Name, "DataSetName", this.m_dataSetName.MarkAsPrivate()); if (parentDataSets != null) { this.UpdateDataSet(parentDataSets.ParentDataSet, scope); } } } else { this.UpdateDataSet(dataSet, scope); } }
internal override bool ValidateRelationships(ScopeTree scopeTree, ErrorContext errorContext, DataSet ourDataSet, ParentDataSetContainer parentDataSets, IRIFReportDataScope currentScope) { Global.Tracer.Assert(parentDataSets != null && parentDataSets.Count == 1, "LinearJoinInfo can only be used with exactly one parent data set"); m_parentDataSet = parentDataSets.ParentDataSet; if (DataSet.AreEqualById(ourDataSet, m_parentDataSet)) { return(false); } bool flag = false; if (m_relationships != null) { foreach (IdcRelationship relationship in m_relationships) { flag |= relationship.ValidateLinearRelationship(errorContext, m_parentDataSet); } } if (flag || ourDataSet.HasDefaultRelationship(m_parentDataSet)) { Relationship activeRelationship = GetActiveRelationship(ourDataSet); if (activeRelationship == null) { RegisterInvalidInnerDataSetNameError(errorContext, ourDataSet, currentScope); return(false); } if (activeRelationship.IsCrossJoin && (!activeRelationship.NaturalJoin || ScopeHasParentGroups(currentScope, scopeTree))) { errorContext.Register(ProcessingErrorCode.rsInvalidNaturalCrossJoin, Severity.Error, currentScope.DataScopeObjectType, currentScope.Name, "JoinConditions"); return(false); } return(true); } RegisterInvalidInnerDataSetNameError(errorContext, ourDataSet, currentScope); return(false); }
public TECBid() : this(Guid.NewGuid()) { foreach (string item in Defaults.Scope) { var branchToAdd = new TECScopeBranch(); branchToAdd.Label = item; ScopeTree.Add(new TECScopeBranch(branchToAdd)); } foreach (string item in Defaults.Exclusions) { var exclusionToAdd = new TECLabeled(); exclusionToAdd.Label = item; Exclusions.Add(new TECLabeled(exclusionToAdd)); } foreach (string item in Defaults.Notes) { var noteToAdd = new TECLabeled(); noteToAdd.Label = item; Notes.Add(new TECLabeled(noteToAdd)); } foreach (var item in Defaults.BidToDoList) { ToDoList.Add(new TECToDoItem(item.description, item.url)); } _parameters.Markup = 20; }
internal override bool ValidateRelationships(ScopeTree scopeTree, ErrorContext errorContext, DataSet ourDataSet, ParentDataSetContainer parentDataSets, IRIFReportDataScope currentScope) { Global.Tracer.Assert(parentDataSets != null, "IntersectJoinInfo can only be used with one or two parent data sets"); if (parentDataSets.Count == 1) { DataRegion parentDataRegion = scopeTree.GetParentDataRegion(currentScope); errorContext.Register(ProcessingErrorCode.rsUnexpectedCellDataSetName, Severity.Error, currentScope.DataScopeObjectType, parentDataRegion.Name, "DataSetName", parentDataRegion.ObjectType.ToString()); return(false); } if (parentDataSets.AreAllSameDataSet() && DataSet.AreEqualById(parentDataSets.RowParentDataSet, ourDataSet)) { return(false); } m_rowParentDataSet = parentDataSets.RowParentDataSet; m_columnParentDataSet = parentDataSets.ColumnParentDataSet; if (m_rowParentDataSet == null || m_columnParentDataSet == null) { return(false); } bool dataSetAlreadyHasRelationship = false; bool dataSetAlreadyHasRelationship2 = false; if (m_relationships != null) { foreach (IdcRelationship relationship in m_relationships) { if (relationship.ValidateIntersectRelationship(errorContext, currentScope, scopeTree)) { CheckRelationshipDataSetBinding(scopeTree, errorContext, currentScope, relationship, m_rowParentDataSet, ref dataSetAlreadyHasRelationship); CheckRelationshipDataSetBinding(scopeTree, errorContext, currentScope, relationship, m_columnParentDataSet, ref dataSetAlreadyHasRelationship2); continue; } return(false); } } dataSetAlreadyHasRelationship = HasRelationshipOrDefaultForDataSet(scopeTree, errorContext, currentScope, ourDataSet, m_rowParentDataSet, dataSetAlreadyHasRelationship); dataSetAlreadyHasRelationship2 = HasRelationshipOrDefaultForDataSet(scopeTree, errorContext, currentScope, ourDataSet, m_columnParentDataSet, dataSetAlreadyHasRelationship2); if (!dataSetAlreadyHasRelationship || !dataSetAlreadyHasRelationship2) { return(false); } DataRegion parentDataRegion2 = scopeTree.GetParentDataRegion(currentScope); if (ValidateCellBoundTotheSameDataSetAsParentScpoe(m_columnParentDataSet, m_rowParentDataSet, ourDataSet, parentDataRegion2.IsColumnGroupingSwitched)) { IRIFDataScope parentDataRegion3 = scopeTree.GetParentDataRegion(currentScope); IRIFDataScope parentRowScopeForIntersection = scopeTree.GetParentRowScopeForIntersection(currentScope); IRIFDataScope parentColumnScopeForIntersection = scopeTree.GetParentColumnScopeForIntersection(currentScope); if (parentDataRegion2.IsColumnGroupingSwitched) { errorContext.Register(ProcessingErrorCode.rsInvalidIntersectionNaturalJoin, Severity.Error, currentScope.DataScopeObjectType, parentDataRegion3.Name, "ParentScope", parentDataRegion3.DataScopeObjectType.ToString(), parentColumnScopeForIntersection.Name, parentRowScopeForIntersection.Name); return(false); } errorContext.Register(ProcessingErrorCode.rsInvalidIntersectionNaturalJoin, Severity.Error, currentScope.DataScopeObjectType, parentDataRegion3.Name, "ParentScope", parentDataRegion3.DataScopeObjectType.ToString(), parentRowScopeForIntersection.Name, parentColumnScopeForIntersection.Name); return(false); } return(true); }
public void Visit(ScopeDeclr ast) { ScopeTree.CreateScope(); ast.ScopedStatements.ForEach(statement => statement.Visit(this)); SetScope(ast); ScopeTree.PopScope(); }
private static bool ScopeHasParentGroups(IRIFReportDataScope currentScope, ScopeTree scopeTree) { ScopeTree.DirectedScopeTreeVisitor visitor = delegate(IRIFDataScope candidate) { if (candidate == currentScope) { return(true); } return((candidate.DataScopeObjectType != Microsoft.ReportingServices.ReportProcessing.ObjectType.DataShapeMember && candidate.DataScopeObjectType != Microsoft.ReportingServices.ReportProcessing.ObjectType.Grouping) ? true : false); }; return(!scopeTree.Traverse(visitor, currentScope)); }
private void CheckRelationshipDataSetBinding(ScopeTree scopeTree, ErrorContext errorContext, IRIFReportDataScope currentScope, IdcRelationship relationship, DataSet parentDataSetCandidate, ref bool dataSetAlreadyHasRelationship) { if (DataSet.AreEqualById(relationship.RelatedDataSet, parentDataSetCandidate)) { if (dataSetAlreadyHasRelationship) { IRIFDataScope parentDataRegion = scopeTree.GetParentDataRegion(currentScope); IRIFDataScope parentRowScopeForIntersection = scopeTree.GetParentRowScopeForIntersection(currentScope); IRIFDataScope parentColumnScopeForIntersection = scopeTree.GetParentColumnScopeForIntersection(currentScope); errorContext.Register(ProcessingErrorCode.rsInvalidRelationshipDuplicateParentScope, Severity.Error, currentScope.DataScopeObjectType, parentDataRegion.Name, "ParentScope", parentDataRegion.DataScopeObjectType.ToString(), parentRowScopeForIntersection.Name, parentColumnScopeForIntersection.Name); } dataSetAlreadyHasRelationship = true; } }
internal void ValidateDataSetBindingAndRelationships(ScopeTree scopeTree, IRIFReportDataScope scope, ErrorContext errorContext) { if (m_dataSet != null) { return; } ParentDataSetContainer parentDataSetContainer = DetermineParentDataSets(scopeTree, scope); if (m_dataSetName == null) { BindToParentDataSet(scopeTree, scope, errorContext, parentDataSetContainer); } else { BindToNamedDataSet(scopeTree, scope, errorContext, parentDataSetContainer); } if (m_dataSet == null) { return; } if (scopeTree.GetParentDataRegion(scope) == null && m_joinInfo != null) { errorContext.Register(ProcessingErrorCode.rsInvalidRelationshipTopLevelDataRegion, Severity.Error, scope.DataScopeObjectType, scope.Name, "Relationship"); m_joinInfo = null; } if (parentDataSetContainer != null && m_joinInfo == null) { if (parentDataSetContainer.Count == 1) { m_joinInfo = new LinearJoinInfo(); } else { m_joinInfo = new IntersectJoinInfo(); } } if (m_joinInfo != null) { if (!m_joinInfo.ValidateRelationships(scopeTree, errorContext, m_dataSet, parentDataSetContainer, scope)) { m_joinInfo = null; } if (m_joinInfo == null && m_dataSetName != null && m_dataSet != null && !DataSet.AreEqualById(parentDataSetContainer.ParentDataSet, m_dataSet)) { UpdateDataSet(parentDataSetContainer.ParentDataSet, scope); } } }
private static ParentDataSetContainer DetermineParentDataSets(ScopeTree scopeTree, IRIFReportDataScope scope) { if (scopeTree.IsIntersectionScope(scope)) { IRIFDataScope parentRowScopeForIntersection = scopeTree.GetParentRowScopeForIntersection(scope); return(new ParentDataSetContainer(columnParentDataSet: scopeTree.GetParentColumnScopeForIntersection(scope).DataScopeInfo.DataSet, rowParentDataSet: parentRowScopeForIntersection.DataScopeInfo.DataSet)); } IRIFDataScope parentScope = scopeTree.GetParentScope(scope); DataSet dataSet2 = (parentScope != null) ? parentScope.DataScopeInfo.DataSet : scopeTree.GetDefaultTopLevelDataSet(); if (dataSet2 == null) { return(null); } return(new ParentDataSetContainer(dataSet2)); }
public bool ValidateIntersectRelationship(ErrorContext errorContext, IRIFDataScope intersectScope, ScopeTree scopeTree) { IRIFDataScope parentRowScopeForIntersection = scopeTree.GetParentRowScopeForIntersection(intersectScope); IRIFDataScope parentColumnScopeForIntersection = scopeTree.GetParentColumnScopeForIntersection(intersectScope); if (ScopeTree.SameScope(this.m_parentScope, parentRowScopeForIntersection.Name)) { base.m_relatedDataSet = parentRowScopeForIntersection.DataScopeInfo.DataSet; return(true); } if (ScopeTree.SameScope(this.m_parentScope, parentColumnScopeForIntersection.Name)) { base.m_relatedDataSet = parentColumnScopeForIntersection.DataScopeInfo.DataSet; return(true); } IRIFDataScope parentDataRegion = scopeTree.GetParentDataRegion(intersectScope); errorContext.Register(ProcessingErrorCode.rsMissingIntersectionRelationshipParentScope, Severity.Error, intersectScope.DataScopeObjectType, parentDataRegion.Name, "ParentScope", parentDataRegion.DataScopeObjectType.ToString(), parentRowScopeForIntersection.Name, parentColumnScopeForIntersection.Name); return(false); }
private void DetermineDataPipelineID(IRIFReportDataScope scope) { if (scope.DataScopeInfo.DataSet != null) { DataSet dataSet = scope.DataScopeInfo.DataSet; int dataPipelineID; if (scope.DataScopeInfo.NeedsIDC) { if (base.m_tree.IsIntersectionScope(scope)) { if (DataSet.AreEqualById(dataSet, base.m_tree.GetParentRowScopeForIntersection(scope).DataScopeInfo.DataSet) || DataSet.AreEqualById(dataSet, base.m_tree.GetParentColumnScopeForIntersection(scope).DataScopeInfo.DataSet)) { IRIFDataScope canonicalCellScope = base.m_tree.GetCanonicalCellScope(scope); if (ScopeTree.SameScope(scope, canonicalCellScope)) { dataPipelineID = this.m_nextDataPipelineId; this.m_nextDataPipelineId++; } else { dataPipelineID = canonicalCellScope.DataScopeInfo.DataPipelineID; } } else { dataPipelineID = dataSet.IndexInCollection; } } else { dataPipelineID = dataSet.IndexInCollection; } } else { IRIFDataScope iRIFDataScope = (!base.m_tree.IsIntersectionScope(scope)) ? base.m_tree.GetParentScope(scope) : base.m_tree.GetParentRowScopeForIntersection(scope); dataPipelineID = ((iRIFDataScope != null) ? iRIFDataScope.DataScopeInfo.DataPipelineID : dataSet.IndexInCollection); } scope.DataScopeInfo.DataPipelineID = dataPipelineID; } }
public void Visit(MethodDeclr ast) { var previousMethod = CurrentMethod; CurrentMethod = ast; var symbol = ScopeUtil.DefineMethod(ast); Current.Define(symbol); ScopeTree.CreateScope(); ast.Arguments.ForEach(arg => arg.Visit(this)); ast.Body.Visit(this); SetScope(ast); if (symbol.Type.ExpressionType == ExpressionTypes.Inferred) { if (ast.ReturnAst == null) { ast.AstSymbolType = new BuiltInType(ExpressionTypes.Void); } else { ast.AstSymbolType = ast.ReturnAst.AstSymbolType; } } else { ast.AstSymbolType = symbol.Type; } ValidateReturnStatementType(ast, symbol); ScopeTree.PopScope(); CurrentMethod = previousMethod; }
private void DetermineDataPipelineID(IRIFReportDataScope scope) { if (scope.DataScopeInfo.DataSet == null) { return; } DataSet dataSet = scope.DataScopeInfo.DataSet; int dataPipelineID; if (!scope.DataScopeInfo.NeedsIDC) { dataPipelineID = (((!m_tree.IsIntersectionScope(scope)) ? m_tree.GetParentScope(scope) : m_tree.GetParentRowScopeForIntersection(scope))?.DataScopeInfo.DataPipelineID ?? dataSet.IndexInCollection); } else if (m_tree.IsIntersectionScope(scope)) { if (DataSet.AreEqualById(dataSet, m_tree.GetParentRowScopeForIntersection(scope).DataScopeInfo.DataSet) || DataSet.AreEqualById(dataSet, m_tree.GetParentColumnScopeForIntersection(scope).DataScopeInfo.DataSet)) { IRIFDataScope canonicalCellScope = m_tree.GetCanonicalCellScope(scope); if (ScopeTree.SameScope(scope, canonicalCellScope)) { dataPipelineID = m_nextDataPipelineId; m_nextDataPipelineId++; } else { dataPipelineID = canonicalCellScope.DataScopeInfo.DataPipelineID; } } else { dataPipelineID = dataSet.IndexInCollection; } } else { dataPipelineID = dataSet.IndexInCollection; } scope.DataScopeInfo.DataPipelineID = dataPipelineID; }
public ParseResult(ScopeTree scopeTree, string markup) { ScopeTree = scopeTree; Markup = markup; }
private static void RegisterInvalidCellDataSetNameError(ScopeTree scopeTree, ErrorContext errorContext, IRIFReportDataScope currentScope, DataSet ourDataSet, DataSet parentDataSet) { DataRegion parentDataRegion = scopeTree.GetParentDataRegion(currentScope); errorContext.Register(ProcessingErrorCode.rsInvalidCellDataSetName, Severity.Error, currentScope.DataScopeObjectType, parentDataRegion.Name, "DataSetName", parentDataSet.Name.MarkAsPrivate(), ourDataSet.Name.MarkAsPrivate(), parentDataRegion.ObjectType.ToString()); }
protected ScopeTreeBuilder(Report report) { this.m_tree = new ScopeTree(report); }
public abstract bool ValidateRelationships(ScopeTree scopeTree, ErrorContext errorContext, DataSet ourDataSet, ParentDataSetContainer parentDataSets, IRIFReportDataScope currentScope);