Skip to content

Commit

Permalink
🦄 refactor: Add span to ast
Browse files Browse the repository at this point in the history
  • Loading branch information
caoccao committed Apr 3, 2024
1 parent 17cfec4 commit 7e03b88
Show file tree
Hide file tree
Showing 88 changed files with 1,314 additions and 1,332 deletions.
1,106 changes: 578 additions & 528 deletions rust/src/ast_utils.rs

Large diffs are not rendered by default.

266 changes: 144 additions & 122 deletions rust/src/token_utils.rs

Large diffs are not rendered by default.

29 changes: 9 additions & 20 deletions src/main/java/com/caoccao/javet/swc4j/ast/Swc4jAst.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.caoccao.javet.swc4j.ast;

import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAst;
import com.caoccao.javet.swc4j.utils.AssertionUtils;
import com.caoccao.javet.swc4j.utils.SimpleList;

import java.util.List;
Expand All @@ -35,17 +36,11 @@ public abstract class Swc4jAst implements ISwc4jAst {
*/
protected static final List<ISwc4jAst> EMPTY_CHILDREN = SimpleList.immutableOf();
/**
* The End position.
* The Span.
*
* @since 0.2.0
*/
protected final int endPosition;
/**
* The Start position.
*
* @since 0.2.0
*/
protected final int startPosition;
protected final Swc4jAstSpan span;
/**
* The Children.
*
Expand All @@ -62,35 +57,29 @@ public abstract class Swc4jAst implements ISwc4jAst {
/**
* Instantiates a new Swc4j ast.
*
* @param startPosition the start position
* @param endPosition the end position
* @param span the span
* @since 0.2.0
*/
protected Swc4jAst(int startPosition, int endPosition) {
protected Swc4jAst(
Swc4jAstSpan span) {
children = EMPTY_CHILDREN;
this.endPosition = endPosition;
parent = null;
this.startPosition = startPosition;
this.span = AssertionUtils.notNull(span, "Span");
}

@Override
public List<ISwc4jAst> getChildren() {
return children;
}

@Override
public int getEndPosition() {
return endPosition;
}

@Override
public ISwc4jAst getParent() {
return parent;
}

@Override
public int getStartPosition() {
return startPosition;
public Swc4jAstSpan getSpan() {
return span;
}

@Override
Expand Down
Loading

0 comments on commit 7e03b88

Please sign in to comment.