Skip to content

Commit

Permalink
Merge pull request #5 from cqfn/master
Browse files Browse the repository at this point in the history
Update fork to master
  • Loading branch information
kniazkov authored Nov 26, 2024
2 parents e84df49 + 992be15 commit 5c135cc
Show file tree
Hide file tree
Showing 154 changed files with 8,469 additions and 2,607 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
cache: maven
- name: Maven Build and Verify
run: mvn -B clean verify
- uses: codecov/codecov-action@v4.0.0-beta.3
- uses: codecov/codecov-action@v4
with:
name: Code coverage report
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
file: ./target/site/jacoco/jacoco.xml
fail_ci_if_error: true
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Astranaut Core

![Build and test](https://github.com/unified-ast/astranaut-core/workflows/Build%20and%20test/badge.svg)
[![Codecov](https://codecov.io/gh/unified-ast/astranaut-core/branch/master/graph/badge.svg)](https://codecov.io/gh/unified-ast/astranaut-core)
![Build and test](https://github.com/cqfn/astranaut-core/workflows/Build%20and%20test/badge.svg)
[![Codecov](https://codecov.io/gh/cqfn/astranaut-core/branch/master/graph/badge.svg)](https://codecov.io/gh/cqfn/astranaut-core)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/unified-ast//astranaut-core/blob/master/LICENSE.txt)
___

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SOFTWARE.
</parent>
<groupId>org.cqfn</groupId>
<artifactId>astranaut-core</artifactId>
<version>1.0-SNAPSHOT</version>
<version>2.0.0</version>
<packaging>jar</packaging>
<developers>
<developer>
Expand Down Expand Up @@ -134,7 +134,7 @@ SOFTWARE.
<dependency>
<groupId>com.kniazkov</groupId>
<artifactId>json</artifactId>
<version>1.0</version>
<version>1.1</version>
</dependency>
<dependency>
<groupId>guru.nidi</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@
package org.cqfn.astranaut.core;

/**
* Some methods/data that could not be placed to other classes.
*
* This class provides static information about the library, such as the version.
* @since 1.0.6
*/
public final class Common {
public final class Info {
/**
* The core version.
*/
public static final String VERSION = "1.1.4";
public static final String VERSION = "2.0.0";

/**
* Private constructor.
*/
private Common() {
private Info() {
}
}
177 changes: 0 additions & 177 deletions src/main/java/org/cqfn/astranaut/core/Node.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

import java.util.HashMap;
import java.util.Map;
import org.cqfn.astranaut.core.Node;
import org.cqfn.astranaut.core.base.Node;

/**
* Algorithm for measuring the depth of syntax trees.
*
* @since 1.1.0
*/
public final class Depth {
public final class DepthCalculator {
/**
* A table with the calculated values.
* Since nodes are immutable, depth calculated once for a node will never change.
Expand All @@ -42,7 +42,7 @@ public final class Depth {
/**
* Constructor.
*/
public Depth() {
public DepthCalculator() {
this.calculated = new HashMap<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.cqfn.astranaut.core.Node;
import org.cqfn.astranaut.core.base.Node;

/**
* Performs a deep traversal of the syntax tree.
* Performs a depth-first traversal of the syntax tree.
*
* @since 1.1.5
*/
public class DeepTraversal {
public class DepthFirstWalker {
/**
* The root node of the tree being traversed.
*/
Expand All @@ -43,7 +43,7 @@ public class DeepTraversal {
* Constructor.
* @param root The root node of the tree being traversed
*/
public DeepTraversal(final Node root) {
public DepthFirstWalker(final Node root) {
this.root = root;
}

Expand All @@ -58,7 +58,7 @@ public DeepTraversal(final Node root) {
* @return Found node (optional)
*/
public Optional<Node> findFirst(final Visitor visitor) {
return Optional.ofNullable(DeepTraversal.findFirst(this.root, visitor));
return Optional.ofNullable(DepthFirstWalker.findFirst(this.root, visitor));
}

/**
Expand All @@ -70,7 +70,17 @@ public Optional<Node> findFirst(final Visitor visitor) {
*/
public List<Node> findAll(final Visitor visitor) {
final List<Node> list = new ArrayList<>(0);
DeepTraversal.findAll(this.root, visitor, list);
DepthFirstWalker.findAll(this.root, visitor, list);
return list;
}

/**
* Collects all nodes without criteria in the order corresponding to the traversal in depth.
* @return List of collected nodes (can't be empty)
*/
public List<Node> collectAll() {
final List<Node> list = new ArrayList<>(1 + this.root.getChildCount());
DepthFirstWalker.collectAll(this.root, list);
return list;
}

Expand All @@ -88,7 +98,7 @@ private static Node findFirst(final Node node, final Visitor visitor) {
} else {
final int count = node.getChildCount();
for (int index = 0; index < count && result == null; index = index + 1) {
result = DeepTraversal.findFirst(node.getChild(index), visitor);
result = DepthFirstWalker.findFirst(node.getChild(index), visitor);
}
}
return result;
Expand All @@ -107,11 +117,24 @@ private static void findAll(final Node node, final Visitor visitor, final List<N
} else {
final int count = node.getChildCount();
for (int index = 0; index < count; index = index + 1) {
DeepTraversal.findAll(node.getChild(index), visitor, list);
DepthFirstWalker.findAll(node.getChild(index), visitor, list);
}
}
}

/**
* Recursive method that implements the "Collect all starting from the root" algorithm.
* @param node Current node to be processed
* @param list List of found nodes
*/
private static void collectAll(final Node node, final List<Node> list) {
list.add(node);
final int count = node.getChildCount();
for (int index = 0; index < count; index = index + 1) {
DepthFirstWalker.collectAll(node.getChild(index), list);
}
}

/**
* Payload interface for the traversal algorithm.
*
Expand Down
Loading

0 comments on commit 5c135cc

Please sign in to comment.