Created semantic token based from Token.java
1 parent a4bd7d4 commit 715357c3ea14e0031ff970ada67d54afc1a1c3a0
Shohei Yamagiwa authored 7 days ago
Showing 1 changed file
View
45
LanguageServer/src/main/java/org/nittalab/dtram/languageserver/model/SemanticToken.java 0 → 100644
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);
}
}