Skip to content

Remove static Token EndOfFile #2026

@fm-117

Description

@fm-117

In Token.cs at line 417:

public static Token END_OF_FILE = new Token(TokenType.EndOfFile, 0, -1, TypeCobol.Compiler.Scanner.TokensLine.CreateVirtualLineForInsertedToken(-1, String.Empty));

A Token instance should not be shared amongst several documents, each source file must get its own end-of-file token.
Besides, depending on how the token is used, it may retain large amount of data through its TokenSource and this could cause memory leaks.

  • Track every usage of the shared token and update accordingly
    • compare to TokenType.EndOfFile instead of comparing to the instance
    • create a new instance when needed

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions