/// <summary> /// <summary> /// Constructor for Function type. /// </summary> /// <param name="name">The name of the function</param> /// <param name="location">The FileSpan location of the function</param> /// <param name="parent">the parent of the current CodeFile</param> /// <param name="currentCodeFile">The current CodeFile</param> public FunctionDefinition(string name, FileSpan location, ISyntaxEntity parent, CodeFile currentCodeFile) : base(name, location, parent, currentCodeFile) { Parameters = new List <FormalParameter>(); IsOverride = false; ReturnType = String.Empty; }
private AbstractSyntaxEntity(string name, FileSpan location) : this() { //Anonymous functions are AbstractSyntaxEntities but don't have names. So cannot //block empty/null name here. Debug.Assert(location != null, "Location of entity must be specified."); this.Name = name; this.Location = location; }
private static FileSpan processSpan(FileSpan current, FileLinePositionSpan toCombine) { if (current == null) { return(new FileSpan(toCombine)); } else { return(FileSpan.Combine(current, new FileSpan(toCombine))); } }
public IEnumerable <CompileError> GetDiagnostics(string programText) { SyntaxTree tree = CSharpSyntaxTree.ParseText(programText); var diagnostics = tree.GetDiagnostics(); var errorList = new List <CompileError>(); foreach (var diagnostic in diagnostics) { var span = diagnostic.Location.GetMappedLineSpan(); var errorLocation = new FileSpan(span); var error = new CompileError(diagnostic.GetMessage(), errorLocation); errorList.Add(error); } return(errorList); }
internal static Comment GetComment(ISyntaxEntity owner, CSharpSyntaxNode node, SyntaxTree tree, CodeFile currentCodeFile) { var trivias = node.GetLeadingTrivia().Where(t => t.Kind() == SyntaxKind.MultiLineDocumentationCommentTrivia || t.Kind() == SyntaxKind.MultiLineCommentTrivia || t.Kind() == SyntaxKind.SingleLineDocumentationCommentTrivia || t.Kind() == SyntaxKind.SingleLineCommentTrivia); if (trivias.Any()) { string commentText = String.Empty; FileSpan overallSpan = null; foreach (var trivia in trivias) { if (trivia != null && trivia.Token.Value != null) { overallSpan = processSpan(overallSpan, tree.GetLineSpan(trivia.Span)); if (trivia.Kind() == SyntaxKind.MultiLineDocumentationCommentTrivia || trivia.Kind() == SyntaxKind.SingleLineDocumentationCommentTrivia) { var xml = trivia.GetStructure(); commentText += String.Join(Environment.NewLine, xml.GetText().Lines); } else { commentText += trivia.ToFullString(); } } } var comment = new Comment(commentText, overallSpan, owner, currentCodeFile); comment.Parent = owner; currentCodeFile.AddComment(comment); return(comment); } else { return(null); } }
public static FileSpan Combine(FileSpan fileSpan1, FileSpan fileSpan2) { if (fileSpan1 == null) { return(fileSpan2); } if (fileSpan2 == null) { return(fileSpan1); } //Starting line of the new span is the lesser of the two line numbers //Starting column is the column of the 'earlier' span int startLine = fileSpan1.StartLineNumber <= fileSpan2.StartLineNumber ? fileSpan1.StartLineNumber : fileSpan2.StartLineNumber; int startCol = fileSpan1.StartLineNumber <= fileSpan2.StartLineNumber ? fileSpan1.StartColumn : fileSpan2.StartColumn; //Ending line of the new span is the greater of the two line numbers //Ending column is the column of the 'later' span int endLine = fileSpan1.EndLineNumber >= fileSpan2.EndLineNumber ? fileSpan1.EndLineNumber : fileSpan2.EndLineNumber; int endCol = fileSpan1.EndLineNumber >= fileSpan2.EndLineNumber ? fileSpan1.EndColumn : fileSpan2.EndColumn; return(new LanguageService.FileSpan(startLine, startCol, endLine, endCol)); }
public NamespaceDefinition(string typeName, FileSpan fileLocation, ISyntaxEntity parent, CodeFile currentCodeFile) : base(typeName, fileLocation, parent, currentCodeFile) { }
internal MemberProperty(string name, FileSpan loc, ISyntaxEntity parent, CodeFile currentCodeFile) : base(name, loc, parent, currentCodeFile) { }
protected AbstractSyntaxEntity(string name, FileSpan location, ISyntaxEntity parent, CodeFile currentCodeFile) : this(name, location, parent) { this.CurrentCodeFile = currentCodeFile; }
private AbstractSyntaxEntity(string name, FileSpan location, ISyntaxEntity parent) : this(name, location) { this.Parent = parent; //OK if the parent is null. }
public FormalParameter(string typeName, string parameterName, ParameterModifiers modifiers, FileSpan location) : this(typeName, parameterName) { this.Modifiers = modifiers; this.Location = location; }
internal CodeFile(string name, FileSpan location, ILanguage language) : base(name, location, null, null) { base.CurrentCodeFile = this; Language = language; }
protected Variable(string name, FileSpan location, ISyntaxEntity parent, CodeFile currentCodeFile) : base(name, location, parent, currentCodeFile) { }
public UserDefinedType(string text, FileSpan fileSpan, ISyntaxEntity parent, CodeFile currentCodeFile) : base(text, fileSpan, parent, currentCodeFile) { }
public IfBlock(string typeName, FileSpan fileLocation, ISyntaxEntity parent, CodeFile currentCodeFile) : base(typeName, fileLocation, parent, currentCodeFile) { }
public Comment(string text, FileSpan span, ISyntaxEntity belongsTo, CodeFile currentCodeFile) : base(text, span, belongsTo, currentCodeFile) { }
internal AbstractAddressableEntity(string name, FileSpan loc, ISyntaxEntity parent, CodeFile currentCodeFile) : base(name, loc, parent, currentCodeFile) { init(); }
public CompileError(string errorText, FileSpan location) { this.ErrorText = errorText; this.Location = location; this.Name = errorText; }