-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
196 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/com/caoccao/javet/swc4j/ast/clazz/Swc4jAstComputedPropName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.caoccao.javet.swc4j.ast.clazz; | ||
|
||
import com.caoccao.javet.swc4j.ast.Swc4jAst; | ||
import com.caoccao.javet.swc4j.ast.enums.Swc4jAstType; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstExpr; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstPropName; | ||
import com.caoccao.javet.swc4j.utils.AssertionUtils; | ||
import com.caoccao.javet.swc4j.utils.SimpleList; | ||
|
||
public class Swc4jAstComputedPropName | ||
extends Swc4jAst | ||
implements ISwc4jAstPropName { | ||
protected final ISwc4jAstExpr expr; | ||
|
||
public Swc4jAstComputedPropName( | ||
ISwc4jAstExpr expr, | ||
int startPosition, | ||
int endPosition) { | ||
super(startPosition, endPosition); | ||
this.expr = AssertionUtils.notNull(expr, "Expr"); | ||
children = SimpleList.immutableOf(expr); | ||
updateParent(); | ||
} | ||
|
||
public ISwc4jAstExpr getExpr() { | ||
return expr; | ||
} | ||
|
||
@Override | ||
public Swc4jAstType getType() { | ||
return Swc4jAstType.ComputedPropName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/java/com/caoccao/javet/swc4j/ast/interfaces/TestISwc4jAstKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.caoccao.javet.swc4j.ast.interfaces; | ||
|
||
import com.caoccao.javet.swc4j.ast.clazz.Swc4jAstPrivateName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class TestISwc4jAstKey { | ||
@Test | ||
public void testAssignable() { | ||
assertTrue(ISwc4jAstKey.class.isAssignableFrom(Swc4jAstPrivateName.class)); | ||
assertTrue(ISwc4jAstKey.class.isAssignableFrom(ISwc4jAstPropName.class)); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/test/java/com/caoccao/javet/swc4j/ast/interfaces/TestISwc4jAstPropName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.caoccao.javet.swc4j.ast.interfaces; | ||
|
||
import com.caoccao.javet.swc4j.ast.clazz.Swc4jAstComputedPropName; | ||
import com.caoccao.javet.swc4j.ast.expr.Swc4jAstIdent; | ||
import com.caoccao.javet.swc4j.ast.expr.lit.Swc4jAstBigInt; | ||
import com.caoccao.javet.swc4j.ast.expr.lit.Swc4jAstNumber; | ||
import com.caoccao.javet.swc4j.ast.expr.lit.Swc4jAstStr; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class TestISwc4jAstPropName { | ||
@Test | ||
public void testAssignable() { | ||
assertTrue(ISwc4jAstPropName.class.isAssignableFrom(Swc4jAstBigInt.class)); | ||
assertTrue(ISwc4jAstPropName.class.isAssignableFrom(Swc4jAstComputedPropName.class)); | ||
assertTrue(ISwc4jAstPropName.class.isAssignableFrom(Swc4jAstIdent.class)); | ||
assertTrue(ISwc4jAstPropName.class.isAssignableFrom(Swc4jAstNumber.class)); | ||
assertTrue(ISwc4jAstPropName.class.isAssignableFrom(Swc4jAstStr.class)); | ||
} | ||
} |