/** * Copyright 2017 Matt Acosta * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { IEquatable } from '@mattacosta/php-common'; import { ISyntaxNode } from './ISyntaxNode'; import { ISyntaxTreeTraversable } from './ISyntaxTreeTraversable'; import { ISyntaxTriviaList } from './ISyntaxTriviaList'; import { TextSpan } from '../../text/TextSpan'; import { TokenKind } from '../TokenKind'; /** * A function that can be used to filter `ISyntaxToken` objects. */ export declare type SyntaxTokenFilter = (token: ISyntaxToken) => boolean; /** * Defines an interface for tokens that can search for adjacent tokens in a * syntax tree. */ export interface ISyntaxTokenQueryable extends ISyntaxTreeTraversable { /** * Finds the next token in the syntax tree. */ nextToken(includeZeroWidth: boolean): T | null; /** * Finds the previous token in the syntax tree. */ previousToken(includeZeroWidth: boolean): T | null; } /** * Defines an interface for the terminal nodes of a syntax tree. * * @todo Add method to get diagnostics. */ export interface ISyntaxToken extends IEquatable, ISyntaxTokenQueryable { /** * Determines if there are any diagnostics attached to this token. */ readonly containsDiagnostics: boolean; /** * The location of the token, with leading trivia. */ readonly fullSpan: TextSpan; /** * Determines if this token was generated by the parser because it was missing. */ readonly isMissing: boolean; /** * A list of insignificant tokens that were scanned prior to this token. */ readonly leadingTrivia: ISyntaxTriviaList | null; /** * The type of token that was scanned. */ readonly kind: TokenKind; /** * The syntax node containing this token. */ readonly parent: ISyntaxNode; /** * The location of the token, without leading trivia. */ readonly span: TextSpan; }