| | package org.nittalab.dtram.languageserver.model; |
---|
| | |
---|
| | import java.util.Objects; |
---|
| | |
---|
| | /** |
---|
| | * {@link SemanticToken} class represents the token with its semantic meaning. |
---|
| | * |
---|
| | * @author Shohei Yamagiwa |
---|
| | * @since 0.1 |
---|
| | */ |
---|
| | public class SemanticToken extends Token { |
---|
| | private final String semanticType; |
---|
| | |
---|
| | public SemanticToken(String semanticType, Token token) { |
---|
| | super(token.getText(), token.getStartPos(), token.getEndPos(), token.isAtomic()); |
---|
| | this.semanticType = semanticType; |
---|
| | } |
---|
| | |
---|
| | public String getSemanticType() { |
---|
| | return semanticType; |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public String toString() { |
---|
| | return "[" + semanticType + "]" + " " + super.toString(); |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public boolean equals(Object other) { |
---|
| | if (other == null || getClass() != other.getClass()) { |
---|
| | return false; |
---|
| | } |
---|
| | if (!super.equals(other)) { |
---|
| | return false; |
---|
| | } |
---|
| | SemanticToken that = (SemanticToken) other; |
---|
| | return Objects.equals(semanticType, that.semanticType); |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public int hashCode() { |
---|
| | return Objects.hash(super.hashCode(), semanticType); |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | |