Skip to content

Commit

Permalink
Merge pull request #36 from kniazkov/master
Browse files Browse the repository at this point in the history
MOS-1971: Fix incorrect merging of subpatterns during insertion
  • Loading branch information
kniazkov authored Jan 21, 2025
2 parents bd907ff + 04d6e63 commit 111487e
Show file tree
Hide file tree
Showing 169 changed files with 288 additions and 434 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2024 Ivan Kniazkov
Copyright (c) 2025 Ivan Kniazkov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
The MIT License (MIT)
Copyright (c) 2024 Ivan Kniazkov
Copyright (c) 2025 Ivan Kniazkov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -134,7 +134,7 @@ SOFTWARE.
<dependency>
<groupId>com.kniazkov</groupId>
<artifactId>json</artifactId>
<version>1.1</version>
<version>1.2</version>
</dependency>
<dependency>
<groupId>guru.nidi</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cqfn/astranaut/core/Info.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -29,7 +29,6 @@

/**
* Algorithm for measuring the depth of syntax trees.
*
* @since 1.1.0
*/
public final class DepthCalculator {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -30,7 +30,6 @@

/**
* Performs a depth-first traversal of the syntax tree.
*
* @since 1.1.5
*/
public class DepthFirstWalker {
Expand All @@ -49,11 +48,11 @@ public DepthFirstWalker(final Node root) {

/**
* Processes nodes starting from the root. Processes a node first.
* If the stopping criterion is not reached, recursively processes all children of it,
* starting from the first one. Once a node is found that satisfies the criterion,
* stops traversal.<br/>
* And yes, you can use this algorithm not only to find nodes, but also just to traverse
* the tree in the specific order.
* If the stopping criterion is not reached, recursively processes all children of it,
* starting from the first one. Once a node is found that satisfies the criterion,
* stops traversal.<br/>
* And yes, you can use this algorithm not only to find nodes, but also just to traverse
* the tree in the specific order.
* @param visitor Visitor that processes nodes
* @return Found node (optional)
*/
Expand All @@ -63,8 +62,8 @@ public Optional<Node> findFirst(final Visitor visitor) {

/**
* Processes nodes starting from the root.
* If a node matches the criterion, adds it to the set and does not check
* the children of this node, otherwise it does.
* If a node matches the criterion, adds it to the set and does not check
* the children of this node, otherwise it does.
* @param visitor Visitor that processes nodes
* @return List of found nodes (can be empty, but not {@code null})
*/
Expand Down Expand Up @@ -137,7 +136,6 @@ private static void collectAll(final Node node, final List<Node> list) {

/**
* Payload interface for the traversal algorithm.
*
* @since 1.1.5
*/
public interface Visitor {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -36,7 +36,6 @@

/**
* Builder of difference syntax tree, that is, one that stores changes between two trees.
*
* @since 1.1.5
*/
public final class DiffTreeBuilder {
Expand Down Expand Up @@ -107,7 +106,7 @@ public boolean build(final Tree after, final Mapper mapper) {

/**
* Adds an action to the difference tree that inserts a node after another node.
* If no other node is specified, inserts at the beginning of the children's list.
* If no other node is specified, inserts at the beginning of the children's list.
* @param insertion Full information about the node being inserted
* @return Result of operation, {@code true} if action was added
*/
Expand Down Expand Up @@ -208,7 +207,6 @@ private static void buildNodeInfoMap(

/**
* Some additional information about each node needed to insert, replace, or delete nodes.
*
* @since 1.1.0
*/
private static final class NodeInfo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -66,8 +66,7 @@ public Set<Set<Node>> find() {

/**
* Calculates hash recursively for all nodes with non-empty data and
* adds entries to the resulting map.
*
* adds entries to the resulting map.
* @param node The current node to process
* @param result Where to put the result
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -81,7 +81,7 @@ public NodeAllocator(final List<ChildDescriptor> descriptors) {

/**
* Maps the list of nodes by positions.
* The algorithm fills an array in which each node is placed at a suitable position for it.
* The algorithm fills an array in which each node is placed at a suitable position for it.
* @param destination The array in which each node is placed at a suitable position
* @param source The source list of nodes
* @return Mapping result, {@code true} if such a mapping is possible (array was filled)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -32,7 +32,6 @@

/**
* Creator of a new tree with a modified subtree.
*
* @since 1.0
*/
public class NodeReplacer {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -31,7 +31,6 @@

/**
* An algorithm that selects nodes from a tree based on some criteria.
*
* @since 1.1.4
*/
public final class NodeSelector {
Expand Down Expand Up @@ -77,7 +76,6 @@ public interface Criteria {

/**
* Walker that traverses the syntax tree and selects nodes.
*
* @since 1.1.4
*/
private static final class Walker {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -127,8 +127,7 @@ private static void buildNodeInfoMap(final Map<Node, NodeInfo> map, final Patter

/**
* Some additional information about each node needed to make holes.
* So far there's only a parent node here, but we may need something else.
*
* So far there's only a parent node here, but we may need something else.
* @since 1.1.5
*/
private static final class NodeInfo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -84,7 +84,7 @@ public Node convert(final Node root) {

/**
* Converts the [sub]tree to another applying the specified variant
* of conversion.
* of conversion.
* @param variant The variant index
* @param root The root node of the subtree
* @return A converted tree or empty tree if the conversion is impossible
Expand All @@ -111,7 +111,7 @@ public Node partialConvert(final int variant, final Node root) {

/**
* Calculate an amount of possible conversions that one rule may conduct
* within the tree.
* within the tree.
* @param root The root node of the subtree
* @return Amount of conversions
*/
Expand Down Expand Up @@ -151,8 +151,8 @@ private static Node replace(final MutableNode original,

/**
* Creates a list from nodes.
* The list is sorted in descending order of nodes depth in the tree.
* Leaf nodes are at the beginning of the list, and the last element is the root.
* The list is sorted in descending order of nodes depth in the tree.
* Leaf nodes are at the beginning of the list, and the last element is the root.
* @since 0.2.2
*/
private static class NodeListBuilder {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -28,14 +28,12 @@

/**
* Interface for converters that check one rule described in DSL
* and convert the initial AST built to the specified target format.
*
* and convert the initial AST built to the specified target format.
* @since 1.0
*/
public interface Converter {
/**
* Converts an initial AST to the target format.
*
* @param node The root of the AST to be converted
* @param factory The node factory
* @return A new node
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -29,8 +29,7 @@

/**
* Checks if the node matches some structure and extracts the data or (and) children
* if the latter are used in the target [sub]tree.
*
* if the latter are used in the target [sub]tree.
* @since 1.0
*/
public interface Matcher {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
* Copyright (c) 2025 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -28,8 +28,7 @@

/**
* An interface that calculates the hash of a node.
* Hash is a number that uniquely identifies a node by some criteria.
*
* Hash is a number that uniquely identifies a node by some criteria.
* @since 1.1.0
*/
public interface Hash {
Expand Down
Loading

0 comments on commit 111487e

Please sign in to comment.