public TaskDefinitionSymbol(string name, Location location, TaskDefinitionSyntax syntax, TaskDeclarationSymbol taskDeclaration) : base(name, location) { Syntax = syntax; AsTaskDeclaration = taskDeclaration; NodeDeclarations = new SymbolCollection<INodeSymbol>(); Transitions = new List<Transition>(); ExitTransitions = new List<ExitTransition>(); }
void AddConnectionPoint(TaskDeclarationSymbol taskDeclaration, ConnectionPointSymbol connectionPoint) { if (taskDeclaration.ConnectionPoints.Contains(connectionPoint.Name)) { var existing = taskDeclaration.ConnectionPoints[connectionPoint.Name]; _diagnostics.Add(new Diagnostic( existing.Location, DiagnosticDescriptors.Semantic.Nav0021ConnectionPointWithName0AlreadyDeclared, existing.Name)); _diagnostics.Add(new Diagnostic( connectionPoint.Location, DiagnosticDescriptors.Semantic.Nav0021ConnectionPointWithName0AlreadyDeclared, connectionPoint.Name)); } else { taskDeclaration.ConnectionPoints.Add(connectionPoint); } }
void AddTaskDeclaration(TaskDeclarationSymbol taskDeclaration) { if (_taskDeklarations.Contains(taskDeclaration.Name)) { var existing = _taskDeklarations[taskDeclaration.Name]; _diagnostics.Add(new Diagnostic( existing.Location, DiagnosticDescriptors.Semantic.Nav0020TaskWithName0AlreadyDeclared, existing.Name)); _diagnostics.Add(new Diagnostic( taskDeclaration.Location, DiagnosticDescriptors.Semantic.Nav0020TaskWithName0AlreadyDeclared, taskDeclaration.Name)); } else { if (!CSharp.IsValidIdentifier(taskDeclaration.Name)) { _diagnostics.Add(new Diagnostic( taskDeclaration.Location, DiagnosticDescriptors.Semantic.Nav2000IdentifierExpected)); } _taskDeklarations.Add(taskDeclaration); } }
void AddConnectionPoints(TaskDeclarationSymbol taskDeclaration, IReadOnlyList<ConnectionPointNodeSyntax> connectionPoints) { if (connectionPoints != null) { foreach (var initNodeSyntax in connectionPoints.OfType<InitNodeDeclarationSyntax>()) { var identifier = initNodeSyntax.Identifier.IsMissing ? initNodeSyntax.InitKeyword : initNodeSyntax.Identifier; var location = identifier.GetLocation(); var name = identifier.ToString(); var init = new InitConnectionPointSymbol(name, location, initNodeSyntax); AddConnectionPoint(taskDeclaration, init); } foreach (var exitNodeSyntax in connectionPoints.OfType<ExitNodeDeclarationSyntax>()) { var identifier = exitNodeSyntax.Identifier.IsMissing ? exitNodeSyntax.ExitKeyword: exitNodeSyntax.Identifier; var location = identifier.GetLocation(); var name = identifier.ToString(); var exit = new ExitConnectionPointSymbol(name, location, exitNodeSyntax); AddConnectionPoint(taskDeclaration, exit); } foreach (var endNodeSyntax in connectionPoints.OfType<EndNodeDeclarationSyntax>()) { var identifier = endNodeSyntax.EndKeyword; var location = identifier.GetLocation(); var name = identifier.ToString(); var end = new EndConnectionPointSymbol(name, location, endNodeSyntax); AddConnectionPoint(taskDeclaration, end); } } }
void ProcessTaskDefinition(TaskDefinitionSyntax taskDefinitionSyntax) { if(null != taskDefinitionSyntax && !taskDefinitionSyntax.Identifier.IsMissing) { var identifier = taskDefinitionSyntax.Identifier; var location = identifier.GetLocation(); if(location != null) { var taskDeclaration = new TaskDeclarationSymbol(identifier.ToString(), location, TaskDeclarationOrigin.TaskDefinition, _processAsIncludedFile); AddConnectionPoints(taskDeclaration, taskDefinitionSyntax.NodeDeclarationBlock?.ConnectionPoints().ToList()); AddTaskDeclaration(taskDeclaration); } } }
void ProcessTaskDeclaration(TaskDeclarationSyntax taskDeclarationSyntax) { if (null != taskDeclarationSyntax && !taskDeclarationSyntax.Identifier.IsMissing) { var identifier = taskDeclarationSyntax.Identifier; var location = identifier.GetLocation(); if(location != null) { var syntax = _processAsIncludedFile ? null : taskDeclarationSyntax; var taskDeclaration = new TaskDeclarationSymbol(identifier.ToString(), location, TaskDeclarationOrigin.TaskDeclaration, _processAsIncludedFile, syntax); AddConnectionPoints(taskDeclaration, taskDeclarationSyntax.ConnectionPoints); AddTaskDeclaration(taskDeclaration); } } }