-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: move internal code to internal package
- Loading branch information
1 parent
7a457cc
commit 6920fc2
Showing
62 changed files
with
378 additions
and
375 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
80 changes: 80 additions & 0 deletions
80
core/src/main/scala/weaponregex/internal/TokenMutatorSyntax.scala
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,80 @@ | ||
package weaponregex.internal | ||
|
||
import weaponregex.internal.extension.RegexTreeExtension.RegexTreeStringBuilder | ||
import weaponregex.internal.model.regextree.{Node, RegexTree} | ||
import weaponregex.model.Location | ||
import weaponregex.model.mutation.{Mutant, TokenMutator as BaseTokenMutator} | ||
|
||
/** TokenMutator with syntax trait | ||
*/ | ||
private[internal] trait TokenMutator extends BaseTokenMutator with TokenMutatorSyntax | ||
|
||
private[internal] trait TokenMutatorSyntax { | ||
self: BaseTokenMutator => | ||
|
||
/** Extension class for a mutated pattern string to convert it into a [[weaponregex.model.mutation.Mutant]] using the | ||
* information of the current token mutator | ||
* @param pattern | ||
* The string pattern to be converted | ||
*/ | ||
implicit protected class MutatedPatternExtension(pattern: String) { | ||
|
||
/** Convert a mutated pattern string into a [[weaponregex.model.mutation.Mutant]] with the | ||
* [[weaponregex.model.Location]] taken from the provided token | ||
* @param token | ||
* The token for reference | ||
* @param location | ||
* The [[weaponregex.model.Location]] where the mutation occurred. If not provided, this will be taken from the | ||
* provided token. | ||
* @param description | ||
* The description of the mutant. If not provided, the default description of the mutator is used instead. | ||
* @return | ||
* A [[weaponregex.model.mutation.Mutant]] | ||
*/ | ||
def toMutantOf(token: RegexTree, location: Option[Location] = None, description: Option[String] = None): Mutant = { | ||
val loc: Location = location.getOrElse(token.location) | ||
val desc: String = description.getOrElse(self.description(token.build, pattern, loc)) | ||
Mutant(pattern, name, loc, levels, desc) | ||
} | ||
|
||
/** Convert a mutated pattern string into a [[weaponregex.model.mutation.Mutant]] with the | ||
* [[weaponregex.model.Location]] starts from the start of the provided token and ends at the start of the token's | ||
* first child | ||
* | ||
* If the given token has no child, the location of the given token is considered to be the location of the mutant | ||
* @param token | ||
* The token for reference | ||
* @param description | ||
* The description of the mutant. If not provided, the default description of the mutator is used instead. | ||
* @return | ||
* A [[weaponregex.model.mutation.Mutant]] | ||
*/ | ||
def toMutantBeforeChildrenOf(token: RegexTree, description: Option[String] = None): Mutant = { | ||
val loc: Location = token match { | ||
case node: Node if node.children.nonEmpty => Location(token.location.start, node.children.head.location.start) | ||
case _ => token.location | ||
} | ||
toMutantOf(token, Some(loc), description) | ||
} | ||
|
||
/** Convert a mutated pattern string into a [[weaponregex.model.mutation.Mutant]] with the | ||
* [[weaponregex.model.Location]] starts from the end of the provided token's last child and ends at the end of the | ||
* token | ||
* | ||
* If the given token has no child, the location of the given token is considered to be the location of the mutant | ||
* @param token | ||
* The token for reference | ||
* @param description | ||
* The description of the mutant. If not provided, the default description of the mutator is used instead. | ||
* @return | ||
* A [[weaponregex.model.mutation.Mutant]] | ||
*/ | ||
def toMutantAfterChildrenOf(token: RegexTree, description: Option[String] = None): Mutant = { | ||
val loc: Location = token match { | ||
case node: Node if node.children.nonEmpty => Location(node.children.last.location.end, token.location.end) | ||
case _ => token.location | ||
} | ||
toMutantOf(token, Some(loc), description) | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...a/weaponregex/constant/ErrorMessage.scala → ...egex/internal/constant/ErrorMessage.scala
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
4 changes: 2 additions & 2 deletions
4
...aponregex/extension/StringExtension.scala → .../internal/extension/StringExtension.scala
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
4 changes: 2 additions & 2 deletions
4
...gex/extension/TokenMutatorExtension.scala → ...nal/extension/TokenMutatorExtension.scala
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
2 changes: 1 addition & 1 deletion
2
...nregex/model/regextree/boundaryNode.scala → ...ternal/model/regextree/boundaryNode.scala
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
2 changes: 1 addition & 1 deletion
2
.../model/regextree/characterClassNode.scala → .../model/regextree/characterClassNode.scala
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
2 changes: 1 addition & 1 deletion
2
...regex/model/regextree/characterNode.scala → ...ernal/model/regextree/characterNode.scala
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
2 changes: 1 addition & 1 deletion
2
...onregex/model/regextree/logicalNode.scala → ...nternal/model/regextree/logicalNode.scala
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
2 changes: 1 addition & 1 deletion
2
...l/regextree/predefinedCharClassNode.scala → ...l/regextree/predefinedCharClassNode.scala
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
2 changes: 1 addition & 1 deletion
2
...regex/model/regextree/quotationNode.scala → ...ernal/model/regextree/quotationNode.scala
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
2 changes: 1 addition & 1 deletion
2
...regex/model/regextree/referenceNode.scala → ...ernal/model/regextree/referenceNode.scala
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
9 changes: 5 additions & 4 deletions
9
...weaponregex/mutator/boundaryMutator.scala → ...ex/internal/mutator/boundaryMutator.scala
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
9 changes: 5 additions & 4 deletions
9
...eaponregex/mutator/capturingMutator.scala → ...x/internal/mutator/capturingMutator.scala
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
9 changes: 5 additions & 4 deletions
9
...eaponregex/mutator/charClassMutator.scala → ...x/internal/mutator/charClassMutator.scala
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
Oops, something went wrong.