From 7e251698cb73189714a642f82b1479f94fe571e5 Mon Sep 17 00:00:00 2001 From: Vest Date: Sat, 16 May 2026 14:39:53 +0200 Subject: [PATCH 01/29] Convert PCGen-base and PCGen-Formula to JPMS subprojects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restructure the build to make PCGen-base and PCGen-Formula proper Java modules (JPMS) as Gradle subprojects, replacing the old external JAR dependencies (net.sourceforge.pcgen:PCGen-base:1.0.170 and net.sourceforge.pcgen:PCGen-Formula:1.0.200). Build infrastructure: - Add 'PCGen-base' and 'PCGen-Formula' to settings.gradle as included projects - Write new build.gradle for each subproject (java-library, Java 25, JUnit 5) - Replace external JAR deps with project(':PCGen-base') and project(':PCGen-Formula') - Remove ivy fileRepo repository (no longer needed) - Remove PCGen-base/PCGen-Formula from jlink forceMerge (proper named modules now) - Move JavaCompile/Test task config out of allprojects{} to root-only scope Module descriptors: - Create module-info.java for pcgen.base (exports utility packages) - Create module-info.java for pcgen.formula (requires transitive pcgen.base, exports formula parser and solver packages) - Update main module-info.java: requires pcgen.base; requires pcgen.formula Split-package resolution (JPMS forbids two modules owning same package): - Move generic formula classes to PCGen-Formula: AddingFormula, DividingFormula, MultiplyingFormula, SubtractingFormula, ReferenceFormula - Move generic format/test classes to PCGen-base: Dice, Die, DiceFormat, InequalityTester - Delete TypeSafeConstant from main (identical copy exists in PCGen-base) - Relocate pcgen.base.formula.Formula to pcgen.cdom.formula.Formula (legacy interface that depends on pcgen.core — cannot live in generic module) - Relocate pcgen.base.calculation.* to pcgen.cdom.calculation.* (PCGen-specific adapter layer, not part of the generic solver) Pre-commit JavaCC parser: - Generate parser source from formula.jjt using jjtree+javacc 7.0.13 - Place all generated files in PCGen-Formula/code/src/java/pcgen/base/formula/parse/ - No build-time generation needed Update ~150 files for import changes across main source and tests. Both subprojects compile successfully. Main source has remaining compilation errors from API differences between the old published JARs and the current in-repo source (Phase 6: API migration still needed). --- PCGen-Formula/build.gradle | 183 ++--------------- PCGen-Formula/code/src/java/module-info.java | 20 ++ .../pcgen/base/formula/AddingFormula.java | 0 .../pcgen/base/formula/DividingFormula.java | 0 .../base/formula/MultiplyingFormula.java | 0 .../pcgen/base/formula/ReferenceFormula.java | 0 .../base/formula/SubtractingFormula.java | 0 .../base/formula/parse/ASTArithmetic.java | 23 +++ .../pcgen/base/formula/parse/ASTEquality.java | 23 +++ .../pcgen/base/formula/parse/ASTExpon.java | 23 +++ .../pcgen/base/formula/parse/ASTFParen.java | 23 +++ .../base/formula/parse/ASTGeometric.java | 23 +++ .../pcgen/base/formula/parse/ASTLogical.java | 23 +++ .../java/pcgen/base/formula/parse/ASTNum.java | 23 +++ .../base/formula/parse/ASTPCGenBracket.java | 23 +++ .../base/formula/parse/ASTPCGenLookup.java | 23 +++ .../formula/parse/ASTPCGenSingleWord.java | 23 +++ .../pcgen/base/formula/parse/ASTParen.java | 23 +++ .../base/formula/parse/ASTQuotString.java | 23 +++ .../base/formula/parse/ASTRelational.java | 23 +++ .../pcgen/base/formula/parse/ASTRoot.java | 23 +++ .../base/formula/parse/ASTUnaryMinus.java | 23 +++ .../pcgen/base/formula/parse/ASTUnaryNot.java | 23 +++ .../parse/FormulaParserDefaultVisitor.java | 61 ++++++ .../parse/FormulaParserTreeConstants.java | 45 +++++ .../formula/parse/FormulaParserVisitor.java | 24 +++ .../formula/parse/JJTFormulaParserState.java | 123 ++++++++++++ .../java/pcgen/base/formula/parse/Node.java | 41 ++++ .../pcgen/base/formula/parse/SimpleNode.java | 184 ++++++++++++++++++ PCGen-Formula/settings.gradle | 1 - PCGen-base/build.gradle | 147 ++------------ PCGen-base/code/src/java/module-info.java | 21 ++ .../src/java/pcgen/base/format/dice/Dice.java | 0 .../pcgen/base/format/dice/DiceFormat.java | 0 .../src/java/pcgen/base/format/dice/Die.java | 0 .../pcgen/base/test/InequalityTester.java | 0 PCGen-base/settings.gradle | 1 - build.gradle | 87 +++++---- code/src/java/module-info.java | 4 +- .../base/enumeration/TypeSafeConstant.java | 55 ------ code/src/java/pcgen/cdom/base/CDOMObject.java | 2 +- .../java/pcgen/cdom/base/ChooseDriver.java | 2 +- .../ConcretePersistentTransitionChoice.java | 2 +- .../cdom/base/ConcreteTransitionChoice.java | 2 +- .../java/pcgen/cdom/base/FormulaFactory.java | 2 +- code/src/java/pcgen/cdom/base/JEPFormula.java | 2 +- .../pcgen/cdom/base/TransitionChoice.java | 2 +- .../calculation/AbstractNEPCalculation.java | 2 +- .../calculation/AbstractPCGenModifier.java | 2 +- .../calculation/BasicCalculation.java | 2 +- .../calculation/CalculationInfo.java | 2 +- .../calculation/CalculationModifier.java | 2 +- .../calculation/FormulaCalculation.java | 2 +- .../calculation/FormulaModifier.java | 2 +- .../calculation/IgnoreVariables.java | 2 +- .../calculation/NEPCalculation.java | 2 +- .../calculation/package-info.java | 2 +- .../java/pcgen/cdom/content/CNAbility.java | 2 +- .../pcgen/cdom/content/ChallengeRating.java | 2 +- .../pcgen/cdom/content/DamageReduction.java | 2 +- .../cdom/content/IndirectCalculation.java | 4 +- .../cdom/content/LevelCommandFactory.java | 2 +- .../cdom/content/ProcessCalculation.java | 4 +- .../pcgen/cdom/content/SpellLikeAbility.java | 2 +- .../pcgen/cdom/content/SpellResistance.java | 2 +- .../java/pcgen/cdom/content/VarModifier.java | 2 +- .../cdom/enumeration/AssociationKey.java | 2 +- .../pcgen/cdom/enumeration/FormulaKey.java | 2 +- .../java/pcgen/cdom/enumeration/ListKey.java | 2 +- .../pcgen/cdom/enumeration/ObjectKey.java | 2 +- .../pcgen/cdom/facet/ActiveSpellsFacet.java | 2 +- .../java/pcgen/cdom/facet/AddLevelFacet.java | 2 +- .../cdom/facet/FormulaResolvingFacet.java | 2 +- .../java/pcgen/cdom/facet/ModifierFacet.java | 2 +- .../pcgen/cdom/facet/RemoteModifierFacet.java | 2 +- .../java/pcgen/cdom/facet/SpellsFacet.java | 2 +- .../facet/analysis/ChallengeRatingFacet.java | 2 +- .../CharacterSpellResistanceFacet.java | 2 +- .../cdom/facet/analysis/InitiativeFacet.java | 2 +- .../pcgen/cdom/facet/analysis/LevelFacet.java | 2 +- .../cdom/facet/analysis/LevelTableFacet.java | 2 +- .../pcgen/cdom/facet/analysis/LoadFacet.java | 2 +- .../cdom/facet/analysis/VariableFacet.java | 2 +- .../cdom/facet/analysis/VisionFacet.java | 2 +- .../pcgen/cdom/facet/model/SizeFacet.java | 2 +- .../pcgen/cdom/formula/FixedSizeFormula.java | 2 +- .../pcgen/{base => cdom}/formula/Formula.java | 8 +- .../local/DefinedWrappingModifier.java | 2 +- .../formula/local/ModifierDecoration.java | 2 +- .../formula/local/RemoteWrappingModifier.java | 2 +- .../java/pcgen/cdom/helper/FollowerLimit.java | 2 +- .../java/pcgen/cdom/helper/OptionBound.java | 2 +- .../pcgen/cdom/helper/SpellLevelInfo.java | 2 +- code/src/java/pcgen/cdom/helper/StatLock.java | 2 +- code/src/java/pcgen/core/AbilityCategory.java | 2 +- code/src/java/pcgen/core/BonusManager.java | 2 +- code/src/java/pcgen/core/Domain.java | 2 +- code/src/java/pcgen/core/Equipment.java | 2 +- .../java/pcgen/core/EquipmentModifier.java | 2 +- code/src/java/pcgen/core/Kit.java | 2 +- code/src/java/pcgen/core/PCTemplate.java | 2 +- code/src/java/pcgen/core/PlayerCharacter.java | 2 +- code/src/java/pcgen/core/Race.java | 2 +- code/src/java/pcgen/core/Skill.java | 2 +- .../pcgen/core/SpellProgressionCache.java | 2 +- .../pcgen/core/SpellSupportForPCClass.java | 2 +- code/src/java/pcgen/core/Vision.java | 2 +- .../core/analysis/DomainApplication.java | 2 +- code/src/java/pcgen/core/bonus/Bonus.java | 2 +- code/src/java/pcgen/core/bonus/BonusObj.java | 2 +- code/src/java/pcgen/core/bonus/BonusPair.java | 2 +- .../java/pcgen/core/character/SpellBook.java | 2 +- .../pcgen/core/chooser/CDOMChoiceManager.java | 2 +- .../pcgen/core/chooser/ChooserUtilities.java | 2 +- .../pcgen/core/display/CharacterDisplay.java | 2 +- code/src/java/pcgen/core/kit/BaseKit.java | 2 +- code/src/java/pcgen/core/kit/KitClass.java | 2 +- code/src/java/pcgen/core/kit/KitDeity.java | 2 +- code/src/java/pcgen/core/kit/KitFunds.java | 2 +- code/src/java/pcgen/core/kit/KitGear.java | 2 +- code/src/java/pcgen/core/kit/KitSelect.java | 2 +- code/src/java/pcgen/core/kit/KitSpells.java | 2 +- code/src/java/pcgen/core/kit/KitStat.java | 2 +- code/src/java/pcgen/core/kit/KitTable.java | 2 +- .../pcgen/gui2/facade/Gui2InfoFactory.java | 2 +- .../rules/context/AbstractObjectContext.java | 2 +- .../ConsolidatedObjectCommitStrategy.java | 2 +- .../rules/context/ObjectCommitStrategy.java | 2 +- .../pcgen/rules/context/VariableContext.java | 4 +- .../AbstractFixedSetModifierFactory.java | 2 +- .../token/AbstractNumberModifierFactory.java | 10 +- .../AbstractRestrictedSpellPrimitive.java | 2 +- .../token/AbstractSetModifierFactory.java | 8 +- .../persistence/token/ModifierFactory.java | 2 +- code/src/java/pcgen/util/NamedFormula.java | 2 +- code/src/java/plugin/lsttokens/ChooseLst.java | 2 +- code/src/java/plugin/lsttokens/DefineLst.java | 2 +- .../java/plugin/lsttokens/DefineStatLst.java | 2 +- code/src/java/plugin/lsttokens/DrLst.java | 2 +- .../java/plugin/lsttokens/FollowersLst.java | 2 +- code/src/java/plugin/lsttokens/KitLst.java | 2 +- code/src/java/plugin/lsttokens/ModifyLst.java | 2 +- .../plugin/lsttokens/NaturalattacksLst.java | 2 +- code/src/java/plugin/lsttokens/SelectLst.java | 2 +- code/src/java/plugin/lsttokens/SpellsLst.java | 2 +- code/src/java/plugin/lsttokens/SrLst.java | 2 +- .../plugin/lsttokens/add/AbilityToken.java | 2 +- .../lsttokens/add/ClassSkillsLevelToken.java | 2 +- .../lsttokens/add/ClassSkillsToken.java | 2 +- .../java/plugin/lsttokens/add/EquipToken.java | 2 +- .../plugin/lsttokens/add/LanguageToken.java | 2 +- .../java/plugin/lsttokens/add/SkillToken.java | 2 +- .../lsttokens/add/SpellCasterToken.java | 2 +- .../plugin/lsttokens/add/TemplateToken.java | 2 +- .../lsttokens/choose/SpellLevelToken.java | 2 +- .../lsttokens/choose/UserInputToken.java | 2 +- .../lsttokens/deprecated/AddFeatToken.java | 2 +- .../lsttokens/deprecated/AddVFeatToken.java | 2 +- .../lsttokens/deprecated/RemoveFeatToken.java | 2 +- .../lsttokens/equipment/PageUsageToken.java | 2 +- .../equipmentmodifier/CostToken.java | 2 +- .../equipmentmodifier/CostpreToken.java | 2 +- .../gamemode/abilitycategory/PoolToken.java | 2 +- .../lsttokens/gamemode/ageset/KitToken.java | 2 +- .../plugin/lsttokens/kit/SelectToken.java | 2 +- .../java/plugin/lsttokens/kit/StatToken.java | 2 +- .../lsttokens/kit/basekit/LookupToken.java | 2 +- .../lsttokens/kit/basekit/OptionToken.java | 2 +- .../lsttokens/kit/clazz/LevelToken.java | 2 +- .../lsttokens/kit/deity/CountToken.java | 2 +- .../plugin/lsttokens/kit/funds/QtyToken.java | 2 +- .../plugin/lsttokens/kit/gear/QtyToken.java | 2 +- .../lsttokens/kit/spells/CountToken.java | 2 +- .../kit/startpack/EquipBuyToken.java | 2 +- .../kit/startpack/TotalCostToken.java | 2 +- .../lsttokens/kit/table/ValuesToken.java | 2 +- .../lsttokens/pcclass/CrformulaToken.java | 2 +- .../lsttokens/pcclass/SkilllistToken.java | 2 +- .../lsttokens/pcclass/SpelllistToken.java | 2 +- .../lsttokens/pcclass/StartskillptsToken.java | 2 +- .../lsttokens/pcclass/level/CastToken.java | 2 +- .../lsttokens/pcclass/level/KnownToken.java | 2 +- .../pcclass/level/SpecialtyknownToken.java | 2 +- .../java/plugin/lsttokens/race/CrToken.java | 2 +- .../java/plugin/lsttokens/race/FaceToken.java | 2 +- .../lsttokens/race/LeveladjustmentToken.java | 2 +- .../java/plugin/lsttokens/race/SizeToken.java | 2 +- .../race/XtraskillptsperlvlToken.java | 2 +- .../statsandchecks/stat/StatmodToken.java | 2 +- .../lsttokens/template/AddLevelToken.java | 2 +- .../template/LeveladjustmentToken.java | 2 +- .../plugin/lsttokens/template/SizeToken.java | 2 +- .../modifier/cdom/SetModifierFactory.java | 8 +- .../modifier/dynamic/SetModifierFactory.java | 6 +- .../modifier/number/SetModifierFactory.java | 8 +- .../modifier/set/AddModifierFactory.java | 4 +- .../modifier/set/SetModifierFactory.java | 4 +- .../plugin/primitive/race/BaseSizeToken.java | 2 +- .../pcgen/core/SpellProgressionCacheTest.java | 2 +- .../base/solver/SetSolverManagerTest.java | 8 +- .../CharacterSpellResistanceFacetTest.java | 2 +- .../formula/testsupport/AbstractModifier.java | 8 +- .../src/utest/plugin/lsttokens/SrLstTest.java | 2 +- .../lsttokens/add/AbilityTokenTest.java | 2 +- .../kit/startpack/EquipBuyTokenTest.java | 2 +- .../kit/startpack/TotalCostTokenTest.java | 2 +- .../AbstractSpellCastingTokenTestCase.java | 2 +- .../pcclass/level/CastTokenTest.java | 2 +- .../pcclass/level/KnownTokenTest.java | 2 +- .../level/SpecialtyKnownTokenTest.java | 2 +- .../testsupport/AbstractAddTokenTestCase.java | 2 +- .../AbstractFormulaTokenTestCase.java | 2 +- .../AbstractGlobalFormulaTokenTestCase.java | 2 +- .../modifier/bool/SetBooleanModifierTest.java | 2 +- .../number/AddNumberModifierTest.java | 4 +- .../number/DivideNumberModifierTest.java | 4 +- .../number/MaxNumberModifierTest.java | 4 +- .../number/MinNumberModifierTest.java | 4 +- .../number/MultiplyNumberModifierTest.java | 4 +- .../modifier/number/OverallModifierTest.java | 2 +- .../number/SetNumberModifierTest.java | 2 +- .../SetOrderedPairModifierTest.java | 2 +- .../string/SetStringModifierTest.java | 2 +- settings.gradle | 1 + 224 files changed, 1195 insertions(+), 605 deletions(-) create mode 100644 PCGen-Formula/code/src/java/module-info.java rename {code => PCGen-Formula/code}/src/java/pcgen/base/formula/AddingFormula.java (100%) rename {code => PCGen-Formula/code}/src/java/pcgen/base/formula/DividingFormula.java (100%) rename {code => PCGen-Formula/code}/src/java/pcgen/base/formula/MultiplyingFormula.java (100%) rename {code => PCGen-Formula/code}/src/java/pcgen/base/formula/ReferenceFormula.java (100%) rename {code => PCGen-Formula/code}/src/java/pcgen/base/formula/SubtractingFormula.java (100%) create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTArithmetic.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTEquality.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTExpon.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTFParen.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTGeometric.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTLogical.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTNum.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenBracket.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenLookup.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenSingleWord.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTParen.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTQuotString.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRelational.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRoot.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryMinus.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryNot.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserDefaultVisitor.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserTreeConstants.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserVisitor.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/JJTFormulaParserState.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/Node.java create mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/SimpleNode.java delete mode 100644 PCGen-Formula/settings.gradle create mode 100644 PCGen-base/code/src/java/module-info.java rename {code => PCGen-base/code}/src/java/pcgen/base/format/dice/Dice.java (100%) rename {code => PCGen-base/code}/src/java/pcgen/base/format/dice/DiceFormat.java (100%) rename {code => PCGen-base/code}/src/java/pcgen/base/format/dice/Die.java (100%) rename {code => PCGen-base/code}/src/java/pcgen/base/test/InequalityTester.java (100%) delete mode 100644 PCGen-base/settings.gradle delete mode 100644 code/src/java/pcgen/base/enumeration/TypeSafeConstant.java rename code/src/java/pcgen/{base => cdom}/calculation/AbstractNEPCalculation.java (98%) rename code/src/java/pcgen/{base => cdom}/calculation/AbstractPCGenModifier.java (98%) rename code/src/java/pcgen/{base => cdom}/calculation/BasicCalculation.java (98%) rename code/src/java/pcgen/{base => cdom}/calculation/CalculationInfo.java (98%) rename code/src/java/pcgen/{base => cdom}/calculation/CalculationModifier.java (99%) rename code/src/java/pcgen/{base => cdom}/calculation/FormulaCalculation.java (99%) rename code/src/java/pcgen/{base => cdom}/calculation/FormulaModifier.java (99%) rename code/src/java/pcgen/{base => cdom}/calculation/IgnoreVariables.java (97%) rename code/src/java/pcgen/{base => cdom}/calculation/NEPCalculation.java (99%) rename code/src/java/pcgen/{base => cdom}/calculation/package-info.java (97%) rename code/src/java/pcgen/{base => cdom}/formula/Formula.java (91%) diff --git a/PCGen-Formula/build.gradle b/PCGen-Formula/build.gradle index 1d9dcf1bf90..1fe6a5ec3c9 100644 --- a/PCGen-Formula/build.gradle +++ b/PCGen-Formula/build.gradle @@ -1,186 +1,39 @@ -/* - * PCGen formula component build using the Gradle tool. This file specifies the - * core build tasks and refers to other files in the code/gradle directory for - * additional tasks for specific output. - * - * Developer build: gradle - * Incremental dev build: gradle build - * Full build: gradle all - */ - plugins { - id "ca.coglinc2.javacc" version "3.0.0" - id 'java' - id 'eclipse' - id 'jacoco' - id 'ivy-publish' - id 'checkstyle' - id 'pmd' - id 'com.github.ben-manes.versions' version '0.39.0' - id 'com.github.spotbugs' version '4.7.5' + id 'java-library' } group = 'net.sourceforge.pcgen' -description = """PCGen formula library""" - -defaultTasks 'clean', 'build' - -sourceCompatibility = 1.11 -targetCompatibility = 1.11 +description = 'PCGen formula library - generic expression parser and solver system' -ext { - majorVersion = 1 - minorVersion = 0 -} - -repositories { - mavenCentral() - ivy { - name "Pcgen Repo" - url 'http://pc-gen.org/librepo' - allowInsecureProtocol true +java { + toolchain { + languageVersion = JavaLanguageVersion.of(25) } -} - -dependencies { - // Use this if you want to reference your own local pcgen base, alter the - // relative path to what you need. - //compile files("../../pcgen-base/PCGen-base/build/libs/PCgen-base-1.0.jar") - - implementation group: 'net.sourceforge.pcgen', name: 'PCGen-base', version:'1.0.220' - testImplementation group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.8.0' - testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.7.2' - testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.0' - testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.8.0' - testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.0' + modularity.inferModulePath = true } sourceSets { main { - java { - srcDirs 'code/src/java' - } - } - javacc { - java { - srcDirs 'code/src/javacc' - } + java { srcDirs = ['code/src/java'] } } test { - java { - srcDirs 'code/src/test' - } - } -} - -test { - useJUnitPlatform() - reports { - junitXml.enabled = true - html.enabled = false - } - systemProperties 'property': 'value' -} - -jacocoTestReport { - reports { - xml { - enabled true // coveralls plugin depends on xml format report - } - - html { - enabled true - } - } - - afterEvaluate { - getClassDirectories().from(files(classDirectories.files.collect { - fileTree(dir: it, exclude: ['**/testsupport/**', '**/Abstract**TestCase', '**/**Test', 'pcgen/base/formula/parse/FormulaParser**', 'pcgen/base/formula/parse/AST**', 'pcgen/base/formula/parse/JJT**', 'pcgen/base/formula/parse/Node**', 'pcgen/base/formula/parse/ParseException**', 'pcgen/base/formula/parse/SimpleCharStream**', 'pcgen/base/formula/parse/Token**']) - })) + java { srcDirs = ['code/src/test'] } } } -compileJjtree { - inputDirectory = file('code/src/jjtree') - // We consciously choose to put the output in the main repo tree so that - // SimpleNode only exists once... - outputDirectory = file('code/src/javacc/') - include '**/*.java' -} - -compileJavacc { - inputDirectory = file('code/src/javacc/') - outputDirectory = file('code/src/java/') -} - -// Calculate the version number - runs in the parse phase -allprojects { - ext.buildTimestamp = new Date().format('yyyy-MM-dd HH:mm:ss Z') - if (System.env.BUILD_NUMBER) { - project.version = "$majorVersion.$minorVersion.$System.env.BUILD_NUMBER" - } - else { - project.version = "$majorVersion.$minorVersion" - } -} - -task echoVer() doLast { - println "${project.name} Version: ${project.version} (${buildTimestamp})" -} - -jar { - manifest { - attributes 'Implementation-Title': 'PCGenFormulaLibrary', 'Implementation-Version': project.version, - 'Built-On': buildTimestamp - } -} - -task sourceJar(type: Jar) { - from sourceSets.main.java - classifier "sources" +repositories { + mavenCentral() } -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} +dependencies { + api project(':PCGen-base') -// Rules for how we publish our artifacts in ivy compliant format -publishing { - repositories { - ivy { - name "fileRepo" - url '/var/www/librepo' - } - } - publications { - ivy(IvyPublication) { - from components.java - configurations { - sources {} - javadoc {} - } - artifact(sourceJar) { - type "sources" - conf "sources" - } - artifact(javadocJar) { - type "javadoc" - conf "javadoc" - } - descriptor.withXml { - asNode().info[0].appendNode('description', description) - } - } - } + testImplementation platform('org.junit:junit-bom:5.11.4') + testImplementation 'org.junit.jupiter:junit-jupiter-api' + testImplementation 'org.junit.jupiter:junit-jupiter-params' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' } -//We end up with an unneeded task with SpotBugs and JavaCC that causes a failure -//see: https://github.com/spotbugs/spotbugs-gradle-plugin/issues/70 -tasks.whenTaskAdded {task -> - if(task.name.contains("spotbugsJavacc")) { - task.enabled = false - } +tasks.named('test') { + useJUnitPlatform() } - -apply from: 'gradle/reporting.gradle' diff --git a/PCGen-Formula/code/src/java/module-info.java b/PCGen-Formula/code/src/java/module-info.java new file mode 100644 index 00000000000..d5c73237997 --- /dev/null +++ b/PCGen-Formula/code/src/java/module-info.java @@ -0,0 +1,20 @@ +module pcgen.formula { + requires transitive pcgen.base; + + exports pcgen.base.formula; + exports pcgen.base.formula.analysis; + exports pcgen.base.formula.base; + exports pcgen.base.formula.exception; + exports pcgen.base.formula.factory; + exports pcgen.base.formula.function; + exports pcgen.base.formula.inst; + exports pcgen.base.formula.library; + exports pcgen.base.formula.operator.array; + exports pcgen.base.formula.operator.bool; + exports pcgen.base.formula.operator.generic; + exports pcgen.base.formula.operator.number; + exports pcgen.base.formula.operator.string; + exports pcgen.base.formula.parse; + exports pcgen.base.formula.visitor; + exports pcgen.base.solver; +} diff --git a/code/src/java/pcgen/base/formula/AddingFormula.java b/PCGen-Formula/code/src/java/pcgen/base/formula/AddingFormula.java similarity index 100% rename from code/src/java/pcgen/base/formula/AddingFormula.java rename to PCGen-Formula/code/src/java/pcgen/base/formula/AddingFormula.java diff --git a/code/src/java/pcgen/base/formula/DividingFormula.java b/PCGen-Formula/code/src/java/pcgen/base/formula/DividingFormula.java similarity index 100% rename from code/src/java/pcgen/base/formula/DividingFormula.java rename to PCGen-Formula/code/src/java/pcgen/base/formula/DividingFormula.java diff --git a/code/src/java/pcgen/base/formula/MultiplyingFormula.java b/PCGen-Formula/code/src/java/pcgen/base/formula/MultiplyingFormula.java similarity index 100% rename from code/src/java/pcgen/base/formula/MultiplyingFormula.java rename to PCGen-Formula/code/src/java/pcgen/base/formula/MultiplyingFormula.java diff --git a/code/src/java/pcgen/base/formula/ReferenceFormula.java b/PCGen-Formula/code/src/java/pcgen/base/formula/ReferenceFormula.java similarity index 100% rename from code/src/java/pcgen/base/formula/ReferenceFormula.java rename to PCGen-Formula/code/src/java/pcgen/base/formula/ReferenceFormula.java diff --git a/code/src/java/pcgen/base/formula/SubtractingFormula.java b/PCGen-Formula/code/src/java/pcgen/base/formula/SubtractingFormula.java similarity index 100% rename from code/src/java/pcgen/base/formula/SubtractingFormula.java rename to PCGen-Formula/code/src/java/pcgen/base/formula/SubtractingFormula.java diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTArithmetic.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTArithmetic.java new file mode 100644 index 00000000000..2e6f6fae567 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTArithmetic.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTArithmetic.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTArithmetic extends SimpleNode { + public ASTArithmetic(int id) { + super(id); + } + + public ASTArithmetic(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=2d57b59bce9ef4b54fce0027dcc9f692 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTEquality.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTEquality.java new file mode 100644 index 00000000000..fe140ea847c --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTEquality.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTEquality.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTEquality extends SimpleNode { + public ASTEquality(int id) { + super(id); + } + + public ASTEquality(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=6b15c0d0d26194d6f19ca211da84876d (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTExpon.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTExpon.java new file mode 100644 index 00000000000..d0f7972939d --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTExpon.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTExpon.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTExpon extends SimpleNode { + public ASTExpon(int id) { + super(id); + } + + public ASTExpon(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=6185c1f4af5db16b1087742fe429c2e2 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTFParen.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTFParen.java new file mode 100644 index 00000000000..4f890cbbfe8 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTFParen.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTFParen.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTFParen extends SimpleNode { + public ASTFParen(int id) { + super(id); + } + + public ASTFParen(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=8f3d619301c820763d7af3a2783c1eef (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTGeometric.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTGeometric.java new file mode 100644 index 00000000000..a8bbdf9aea7 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTGeometric.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTGeometric.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTGeometric extends SimpleNode { + public ASTGeometric(int id) { + super(id); + } + + public ASTGeometric(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=7a4828bcf98f617118060eb449338e23 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTLogical.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTLogical.java new file mode 100644 index 00000000000..62bd89cb368 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTLogical.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTLogical.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTLogical extends SimpleNode { + public ASTLogical(int id) { + super(id); + } + + public ASTLogical(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=83279545290394d1779e2e528f4afcd0 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTNum.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTNum.java new file mode 100644 index 00000000000..de6eabdd4cd --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTNum.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTNum.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTNum extends SimpleNode { + public ASTNum(int id) { + super(id); + } + + public ASTNum(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=be2bb918925ae586e74cecab1a343ab8 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenBracket.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenBracket.java new file mode 100644 index 00000000000..1a8234dc5b2 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenBracket.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTPCGenBracket.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTPCGenBracket extends SimpleNode { + public ASTPCGenBracket(int id) { + super(id); + } + + public ASTPCGenBracket(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=1f63e88d05343dc29c20300804c79465 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenLookup.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenLookup.java new file mode 100644 index 00000000000..b0841517486 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenLookup.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTPCGenLookup.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTPCGenLookup extends SimpleNode { + public ASTPCGenLookup(int id) { + super(id); + } + + public ASTPCGenLookup(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=d12904f08404654952d30a3216dd7866 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenSingleWord.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenSingleWord.java new file mode 100644 index 00000000000..1f17202a026 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenSingleWord.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTPCGenSingleWord.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTPCGenSingleWord extends SimpleNode { + public ASTPCGenSingleWord(int id) { + super(id); + } + + public ASTPCGenSingleWord(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=d626bc36cd2aa53587e1116d6ff6df64 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTParen.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTParen.java new file mode 100644 index 00000000000..5e29d9d74e3 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTParen.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTParen.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTParen extends SimpleNode { + public ASTParen(int id) { + super(id); + } + + public ASTParen(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=70762d05ebb34f6e3120781dbaab0d6c (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTQuotString.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTQuotString.java new file mode 100644 index 00000000000..5d9400ab87d --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTQuotString.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTQuotString.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTQuotString extends SimpleNode { + public ASTQuotString(int id) { + super(id); + } + + public ASTQuotString(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=d734b4df84554414609b0bb72d2f014c (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRelational.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRelational.java new file mode 100644 index 00000000000..9f28ba290ef --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRelational.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTRelational.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTRelational extends SimpleNode { + public ASTRelational(int id) { + super(id); + } + + public ASTRelational(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=85072a7adfcaf4cfcee127e887fb0c0a (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRoot.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRoot.java new file mode 100644 index 00000000000..c4a99dad487 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRoot.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTRoot.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTRoot extends SimpleNode { + public ASTRoot(int id) { + super(id); + } + + public ASTRoot(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=fc5ceb4a982d63684ab851caf3f3cc0d (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryMinus.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryMinus.java new file mode 100644 index 00000000000..ccdebab5af4 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryMinus.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTUnaryMinus.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTUnaryMinus extends SimpleNode { + public ASTUnaryMinus(int id) { + super(id); + } + + public ASTUnaryMinus(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=e41f6a1191e4fcd7112cf27ac19e3eda (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryNot.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryNot.java new file mode 100644 index 00000000000..774f3a42a89 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryNot.java @@ -0,0 +1,23 @@ +/* Generated By:JJTree: Do not edit this line. ASTUnaryNot.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +public +class ASTUnaryNot extends SimpleNode { + public ASTUnaryNot(int id) { + super(id); + } + + public ASTUnaryNot(FormulaParser p, int id) { + super(p, id); + } + + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data) { + + return + visitor.visit(this, data); + } +} +/* JavaCC - OriginalChecksum=c6a8fd33e361b3fed43d8221ef686f1c (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserDefaultVisitor.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserDefaultVisitor.java new file mode 100644 index 00000000000..cd66058885d --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserDefaultVisitor.java @@ -0,0 +1,61 @@ +/* Generated By:JavaCC: Do not edit this line. FormulaParserDefaultVisitor.java Version 7.0.13 */ +package pcgen.base.formula.parse; + +public class FormulaParserDefaultVisitor implements FormulaParserVisitor{ + public Object defaultVisit(SimpleNode node, Object data){ + node.childrenAccept(this, data); + return data; + } + public Object visit(SimpleNode node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTRoot node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTLogical node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTEquality node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTRelational node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTArithmetic node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTGeometric node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTUnaryMinus node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTUnaryNot node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTExpon node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTParen node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTNum node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTPCGenLookup node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTPCGenSingleWord node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTPCGenBracket node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTFParen node, Object data){ + return defaultVisit(node, data); + } + public Object visit(ASTQuotString node, Object data){ + return defaultVisit(node, data); + } +} +/* JavaCC - OriginalChecksum=ef6ff0786bb1f3018972ad2d72bd2057 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserTreeConstants.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserTreeConstants.java new file mode 100644 index 00000000000..86bb61bcdd5 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserTreeConstants.java @@ -0,0 +1,45 @@ +/* Generated By:JavaCC: Do not edit this line. FormulaParserTreeConstants.java Version 7.0.13 */ +package pcgen.base.formula.parse; + +public interface FormulaParserTreeConstants +{ + public int JJTROOT = 0; + public int JJTVOID = 1; + public int JJTLOGICAL = 2; + public int JJTEQUALITY = 3; + public int JJTRELATIONAL = 4; + public int JJTARITHMETIC = 5; + public int JJTGEOMETRIC = 6; + public int JJTUNARYMINUS = 7; + public int JJTUNARYNOT = 8; + public int JJTEXPON = 9; + public int JJTPAREN = 10; + public int JJTNUM = 11; + public int JJTPCGENLOOKUP = 12; + public int JJTPCGENSINGLEWORD = 13; + public int JJTPCGENBRACKET = 14; + public int JJTFPAREN = 15; + public int JJTQUOTSTRING = 16; + + + public String[] jjtNodeName = { + "Root", + "void", + "Logical", + "Equality", + "Relational", + "Arithmetic", + "Geometric", + "UnaryMinus", + "UnaryNot", + "Expon", + "Paren", + "Num", + "PCGenLookup", + "PCGenSingleWord", + "PCGenBracket", + "FParen", + "QuotString", + }; +} +/* JavaCC - OriginalChecksum=b6023e47faca655aaa5937d5713ac8bb (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserVisitor.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserVisitor.java new file mode 100644 index 00000000000..0a8e93e2323 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserVisitor.java @@ -0,0 +1,24 @@ +/* Generated By:JavaCC: Do not edit this line. FormulaParserVisitor.java Version 7.0.13 */ +package pcgen.base.formula.parse; + +public interface FormulaParserVisitor +{ + public Object visit(SimpleNode node, Object data); + public Object visit(ASTRoot node, Object data); + public Object visit(ASTLogical node, Object data); + public Object visit(ASTEquality node, Object data); + public Object visit(ASTRelational node, Object data); + public Object visit(ASTArithmetic node, Object data); + public Object visit(ASTGeometric node, Object data); + public Object visit(ASTUnaryMinus node, Object data); + public Object visit(ASTUnaryNot node, Object data); + public Object visit(ASTExpon node, Object data); + public Object visit(ASTParen node, Object data); + public Object visit(ASTNum node, Object data); + public Object visit(ASTPCGenLookup node, Object data); + public Object visit(ASTPCGenSingleWord node, Object data); + public Object visit(ASTPCGenBracket node, Object data); + public Object visit(ASTFParen node, Object data); + public Object visit(ASTQuotString node, Object data); +} +/* JavaCC - OriginalChecksum=d380ad9d2317a3447548ec484828a7ff (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/JJTFormulaParserState.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/JJTFormulaParserState.java new file mode 100644 index 00000000000..9bd89b2ff9b --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/JJTFormulaParserState.java @@ -0,0 +1,123 @@ +/* Generated By:JavaCC: Do not edit this line. JJTFormulaParserState.java Version 7.0.13 */ +package pcgen.base.formula.parse; + +public class JJTFormulaParserState { + private java.util.List nodes; + private java.util.List marks; + + private int sp; // number of nodes on stack + private int mk; // current mark + private boolean node_created; + + public JJTFormulaParserState() { + nodes = new java.util.ArrayList(); + marks = new java.util.ArrayList(); + sp = 0; + mk = 0; + } + + /* Determines whether the current node was actually closed and + pushed. This should only be called in the final user action of a + node scope. */ + public boolean nodeCreated() { + return node_created; + } + + /* Call this to reinitialize the node stack. It is called + automatically by the parser's ReInit() method. */ + public void reset() { + nodes.clear(); + marks.clear(); + sp = 0; + mk = 0; + } + + /* Returns the root node of the AST. It only makes sense to call + this after a successful parse. */ + public Node rootNode() { + return nodes.get(0); + } + + /* Pushes a node on to the stack. */ + public void pushNode(Node n) { + nodes.add(n); + ++sp; + } + + /* Returns the node on the top of the stack, and remove it from the + stack. */ + public Node popNode() { + if (--sp < mk) { + mk = marks.remove(marks.size()-1); + } + return nodes.remove(nodes.size()-1); + } + + /* Returns the node currently on the top of the stack. */ + public Node peekNode() { + return nodes.get(nodes.size()-1); + } + + /* Returns the number of children on the stack in the current node + scope. */ + public int nodeArity() { + return sp - mk; + } + + + public void clearNodeScope(Node n) { + while (sp > mk) { + popNode(); + } + mk = marks.remove(marks.size()-1); + } + + + public void openNodeScope(Node n) { + marks.add(mk); + mk = sp; + n.jjtOpen(); + } + + + /* A definite node is constructed from a specified number of + children. That number of nodes are popped from the stack and + made the children of the definite node. Then the definite node + is pushed on to the stack. */ + public void closeNodeScope(Node n, int num) { + mk = marks.remove(marks.size()-1); + while (num-- > 0) { + Node c = popNode(); + c.jjtSetParent(n); + n.jjtAddChild(c, num); + } + n.jjtClose(); + pushNode(n); + node_created = true; + } + + + /* A conditional node is constructed if its condition is true. All + the nodes that have been pushed since the node was opened are + made children of the conditional node, which is then pushed + on to the stack. If the condition is false the node is not + constructed and they are left on the stack. */ + public void closeNodeScope(Node n, boolean condition) { + if (condition) { + int a = nodeArity(); + mk = marks.remove(marks.size()-1); + while (a-- > 0) { + Node c = popNode(); + c.jjtSetParent(n); + n.jjtAddChild(c, a); + } + n.jjtClose(); + pushNode(n); + node_created = true; + } else { + mk = marks.remove(marks.size()-1); + node_created = false; + } + } +} +/* JavaCC - OriginalChecksum=f86caf1856b37b54e22879b7eb7e5260 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/Node.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/Node.java new file mode 100644 index 00000000000..1db4d1639cb --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/Node.java @@ -0,0 +1,41 @@ +/* Generated By:JJTree: Do not edit this line. Node.java Version 7.0 */ +/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package pcgen.base.formula.parse; + +/* All AST nodes must implement this interface. It provides basic + machinery for constructing the parent and child relationships + between nodes. */ + +public +interface Node { + + /** This method is called after the node has been made the current + node. It indicates that child nodes can now be added to it. */ + public void jjtOpen(); + + /** This method is called after all the child nodes have been + added. */ + public void jjtClose(); + + /** This pair of methods are used to inform the node of its + parent. */ + public void jjtSetParent(Node n); + public Node jjtGetParent(); + + /** This method tells the node to add its argument to the node's + list of children. */ + public void jjtAddChild(Node n, int i); + + /** This method returns a child node. The children are numbered + from zero, left to right. */ + public Node jjtGetChild(int i); + + /** Return the number of children the node has. */ + public int jjtGetNumChildren(); + + public int getId(); + + /** Accept the visitor. **/ + public Object jjtAccept(FormulaParserVisitor visitor, Object data); +} +/* JavaCC - OriginalChecksum=a3cc9e5f83b9a1a826f5a893dd258e12 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/SimpleNode.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/SimpleNode.java new file mode 100644 index 00000000000..221f7148921 --- /dev/null +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/SimpleNode.java @@ -0,0 +1,184 @@ +/* Generated By:JJTree: Do not edit this line. SimpleNode.java */ + +/* + * Copyright (c) Andrew Wilson, 2010. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +package pcgen.base.formula.parse; + +public class SimpleNode implements Node +{ + private Node parent; + private Node[] children; + private int id; + private FormulaParser parser; + + public SimpleNode(int i) + { + id = i; + } + + public SimpleNode(FormulaParser p, int i) + { + this(i); + parser = p; + } + + public void jjtOpen() + { + } + + public void jjtClose() + { + } + + public void jjtSetParent(Node n) + { + parent = n; + } + + public Node jjtGetParent() + { + return parent; + } + + public void jjtAddChild(Node n, int i) + { + if (children == null) + { + children = new Node[i + 1]; + } + else if (i >= children.length) + { + Node[] c = new Node[i + 1]; + System.arraycopy(children, 0, c, 0, children.length); + children = c; + } + children[i] = n; + } + + public Node jjtGetChild(int i) + { + return children[i]; + } + + public int jjtGetNumChildren() + { + return (children == null) ? 0 : children.length; + } + + public Object jjtAccept(FormulaParserVisitor visitor, Object data) + { + return visitor.visit(this, data); + } + + public Object childrenAccept(FormulaParserVisitor visitor, Object data) + { + if (children != null) + { + for (Node aChildren : children) + { + aChildren.jjtAccept(visitor, data); + } + } + return data; + } + + /* + * Items below this point are not auto-generated by javacc, but content + * unique to this implementation. + */ + /** + * The Operator for this node, if any. This is only loaded for relations, + * arithmetic calculations and other "operations" in a formula. + * + * Generally nodes that have a text String will not have an operator. + */ + private Operator operator; + + /** + * The String containing the text for the node, if any. This is only loaded + * for text-related nodes (variables, formula names, etc.). This does + * include numerical nodes, as they are stored as a String until the formula + * is visited. + */ + private String text; + + /** + * Sets the Operator for this Node. Under normal circumstances, this method + * should only be called by the parser, not by any method at runtime. + * + * @param operator + * The Operator for this Node + */ + public void setOperator(Operator operator) + { + this.operator = operator; + } + + /** + * Sets the text String contained by the node. Under normal circumstances, + * this method should only be called by the parser, not by any method at + * runtime. + * + * @param s + * The text String contained by the node + */ + public void setToken(String s) + { + text = s; + } + + /** + * Returns the ID of this node. The ID is a numerical representation of the + * type of node in the tree. It is arguably redundant information to the + * class of the node, but is nonetheless useful for accessing the array in + * pcgen.base.formula.parse.FormulaParserTreeConstants in order to get a + * String representation of the node type. + * + * @return The ID of this node. + */ + @Override + public int getId() + { + return id; + } + + /** + * Returns the Operator for this node, if any. Null may be returned if no + * operator has been set. + * + * @return The Operator for this node, if any. Null is a legal return value + * if no operator is set. + */ + public Operator getOperator() + { + return operator; + } + + /** + * Returns the text representation of this node, if any. Null may be + * returned if no text representation has been set. + * + * @return The text representation of this node, if any. Null is a legal + * return value if text representation has been set. + */ + public String getText() + { + return text; + } +} diff --git a/PCGen-Formula/settings.gradle b/PCGen-Formula/settings.gradle deleted file mode 100644 index e64944b26e7..00000000000 --- a/PCGen-Formula/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'pcgen' diff --git a/PCGen-base/build.gradle b/PCGen-base/build.gradle index 684daefa378..b1ad54f8020 100644 --- a/PCGen-base/build.gradle +++ b/PCGen-base/build.gradle @@ -1,148 +1,37 @@ -/* - * PCGen base build using the Gradle tool. This file specifies the core build tasks - * and refers to other files in the code/gradle directory for additional tasks - * for specific output. - * - * Developer build: gradle - * Incremental dev build: gradle build - * Full build: gradle all - */ - plugins { - id 'java' - id 'eclipse' - id "jacoco" - id 'ivy-publish' - id 'checkstyle' - id 'pmd' - id "com.github.spotbugs" version '4.7.5' - id 'com.github.ben-manes.versions' version '0.39.0' + id 'java-library' } group = 'net.sourceforge.pcgen' -description = """PCGen base library""" - -defaultTasks 'clean', 'build' - -sourceCompatibility = "1.11" -targetCompatibility = "1.11" - -ext { - majorVersion = 1 - minorVersion = 0 -} - -repositories { - mavenCentral() -} +description = 'PCGen base library - stable value-semantic utilities' -dependencies { - testImplementation group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.8.0' - testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.8.0' - testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.0' - testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.8.0' - testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.0' +java { + toolchain { + languageVersion = JavaLanguageVersion.of(25) + } + modularity.inferModulePath = true } sourceSets { main { - java { - srcDirs 'code/src/java' - } + java { srcDirs = ['code/src/java'] } } test { - java { - srcDirs 'code/src/test' - } - } -} - -def testSources = ['**/testsupport/**', '**/Abstract**TestCase', '**/*Test'] - -test { - useJUnitPlatform() - reports { - junitXml.enabled = true - html.enabled = false - } - systemProperties 'property': 'value' -} - -jacocoTestReport { - afterEvaluate { - getSourceDirectories().setFrom(files(classDirectories.files.collect {fileTree(dir: it, exclude: testSources)})) + java { srcDirs = ['code/src/test'] } } - reports { - html { - enabled true - } - } -} - -// Calculate the version number - runs in the parse phase -allprojects { - ext.buildTimestamp = new Date().format('yyyy-MM-dd HH:mm:ss Z') - if (System.env.BUILD_NUMBER) { - project.version = "$majorVersion.$minorVersion.$System.env.BUILD_NUMBER" - } - else { - project.version = "$majorVersion.$minorVersion" - } -} - -task echoVer() doLast { - println "${project.name} Version: ${project.version} (${buildTimestamp})" -} - -jar { - manifest { - attributes 'Implementation-Title': 'PCGenBaseLibrary', 'Implementation-Version': project.version, - 'Built-On': buildTimestamp - } -} - -task sourceJar(type: Jar) { - from sourceSets.main.java - classifier "sources" } -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir +repositories { + mavenCentral() } -// Rules for how we publish our artifacts in ivy compliant format -publishing { - repositories { - ivy { - name "fileRepo" - url '/var/www/librepo' - } - } - publications { - ivy(IvyPublication) { - from components.java - configurations { - sources {} - javadoc {} - } - artifact(sourceJar) { - type "sources" - conf "sources" - } - artifact(javadocJar) { - type "javadoc" - conf "javadoc" - } - descriptor.withXml { - asNode().info[0].appendNode('description', description) - } - } - } +dependencies { + testImplementation platform('org.junit:junit-bom:5.11.4') + testImplementation 'org.junit.jupiter:junit-jupiter-api' + testImplementation 'org.junit.jupiter:junit-jupiter-params' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' } -wrapper { - distributionType = Wrapper.DistributionType.ALL +tasks.named('test') { + useJUnitPlatform() } - -apply from: 'gradle/reporting.gradle' diff --git a/PCGen-base/code/src/java/module-info.java b/PCGen-base/code/src/java/module-info.java new file mode 100644 index 00000000000..dae47aec8cc --- /dev/null +++ b/PCGen-base/code/src/java/module-info.java @@ -0,0 +1,21 @@ +module pcgen.base { + requires java.desktop; + + exports pcgen.base.enumeration; + exports pcgen.base.format; + exports pcgen.base.format.compound; + exports pcgen.base.format.dice; + exports pcgen.base.formatmanager; + exports pcgen.base.graph.base; + exports pcgen.base.graph.inst; + exports pcgen.base.graph.search; + exports pcgen.base.graph.util; + exports pcgen.base.lang; + exports pcgen.base.logging; + exports pcgen.base.math; + exports pcgen.base.proxy; + exports pcgen.base.spotbugs; + exports pcgen.base.test; + exports pcgen.base.text; + exports pcgen.base.util; +} diff --git a/code/src/java/pcgen/base/format/dice/Dice.java b/PCGen-base/code/src/java/pcgen/base/format/dice/Dice.java similarity index 100% rename from code/src/java/pcgen/base/format/dice/Dice.java rename to PCGen-base/code/src/java/pcgen/base/format/dice/Dice.java diff --git a/code/src/java/pcgen/base/format/dice/DiceFormat.java b/PCGen-base/code/src/java/pcgen/base/format/dice/DiceFormat.java similarity index 100% rename from code/src/java/pcgen/base/format/dice/DiceFormat.java rename to PCGen-base/code/src/java/pcgen/base/format/dice/DiceFormat.java diff --git a/code/src/java/pcgen/base/format/dice/Die.java b/PCGen-base/code/src/java/pcgen/base/format/dice/Die.java similarity index 100% rename from code/src/java/pcgen/base/format/dice/Die.java rename to PCGen-base/code/src/java/pcgen/base/format/dice/Die.java diff --git a/code/src/java/pcgen/base/test/InequalityTester.java b/PCGen-base/code/src/java/pcgen/base/test/InequalityTester.java similarity index 100% rename from code/src/java/pcgen/base/test/InequalityTester.java rename to PCGen-base/code/src/java/pcgen/base/test/InequalityTester.java diff --git a/PCGen-base/settings.gradle b/PCGen-base/settings.gradle deleted file mode 100644 index e64944b26e7..00000000000 --- a/PCGen-base/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'pcgen' diff --git a/build.gradle b/build.gradle index e4f392e4278..e26dbd8e83a 100644 --- a/build.gradle +++ b/build.gradle @@ -237,17 +237,8 @@ dependencies { implementation 'net.sourceforge.argparse4j:argparse4j:0.9.0' implementation 'org.xmlunit:xmlunit-core:2.11.0' implementation 'org.controlsfx:controlsfx:11.2.3' - implementation 'net.sourceforge.pcgen:PCGen-base:1.0.170' - // The latest Base, but pcgen core would need refactoring to support it. - //implementation group: 'net.sourceforge.pcgen', name: 'PCGen-base', version:'1.0.237' - // Use this if you're working from your local PCGen Base - //implementation files("../pcgen-base/PCGen-base/build/libs/PCgen-base-1.0.jar") - - implementation 'net.sourceforge.pcgen:PCGen-Formula:1.0.200' - // The latest Formula, but pcgen core would need refactoring to support it. - //implementation group: 'net.sourceforge.pcgen', name: 'PCGen-Formula', version:'1.0.266' - // Use if you're working from your local PCGen Formula - //implementation files("../pcgen-formula/PCGen-formula/build/libs/PCgen-formula-1.0.jar") + implementation project(':PCGen-base') + implementation project(':PCGen-Formula') compileOnly 'org.jetbrains:annotations:26.1.0' compileOnly 'com.yuvimasory:orange-extensions:1.3.0' @@ -303,7 +294,7 @@ jar { */ jlink { options = ['--strip-debug', '--no-header-files', '--no-man-pages'] - forceMerge('PCGen-base', 'PCGen-Formula', 'jep', 'fop', 'Saxon-HE', + forceMerge('jep', 'fop', 'Saxon-HE', 'commons-lang3', 'commons-io', 'spring', 'freemarker', 'jdom2', 'argparse4j', 'xmlunit', 'controlsfx', 'annotations', 'spotbugs', 'xmlresolver') @@ -826,30 +817,6 @@ allprojects { ] } - tasks.withType(JavaCompile).configureEach { - dependsOn extractJavaFXLocal - options.fork = true - options.release = project.ext.javaVersion - - def modsLibPath = layout.projectDirectory.dir("mods/lib").asFile.absolutePath - def depJars = configurations.runtimeClasspath.files.findAll { - !it.name.startsWith('javafx-') - }.collect { it.absolutePath }.join(File.pathSeparator) - def compileOnlyJars = configurations.compileClasspath.files.findAll { - it.name.contains('annotations') || it.name.contains('spotbugs') - }.collect { it.absolutePath }.join(File.pathSeparator) - - doFirst { - if (name.toLowerCase().contains("test")) { - options.compilerArgs << "--module-path" << modsLibPath - options.compilerArgs << "--add-modules" << "javafx.controls,javafx.web,javafx.swing,javafx.fxml,javafx.graphics" - } else if (name == "compileJava") { - def modulePath = [modsLibPath, depJars, compileOnlyJars].findAll { it }.join(File.pathSeparator) - options.compilerArgs << "--module-path" << modulePath - } - println "Args for for $name are $options.allCompilerArgs" - } - } // https://youtrack.jetbrains.com/issue/KT-46165 tasks.withType(Jar).configureEach { duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -859,6 +826,54 @@ allprojects { } } +tasks.withType(Test).configureEach { + jvmArgs += [ + '-Djava.awt.headless=true', + '-Dtestfx.robot=glass', + '-Dtestfx.headless=true', + '-Dprism.order=sw', + '-Dprism.verbose=true', + '-Djavafx.macosx.embedded=true', + '-Djava.security.manager=disallow', + + "--module-path", layout.projectDirectory.dir("mods/lib"), + "--add-modules", "javafx.controls,javafx.web,javafx.swing,javafx.fxml,javafx.graphics", + + // Needed to fix issue with testfx test crashing due to issue with modularity of whole program. Slightly related issue. https://github.com/TestFX/TestFX/issues/638 + '--add-exports', 'javafx.graphics/com.sun.javafx.application=ALL-UNNAMED', + // Next two needed to support monocle testing + '--add-exports', 'javafx.graphics/com.sun.javafx.util=ALL-UNNAMED', + '--add-exports', 'javafx.base/com.sun.javafx.logging=ALL-UNNAMED', + '--add-opens', 'javafx.graphics/com.sun.glass.ui=ALL-UNNAMED', + '--enable-native-access=javafx.graphics', + ] +} + +tasks.withType(JavaCompile).configureEach { + dependsOn extractJavaFXLocal + options.fork = true + options.release = project.ext.javaVersion + + def modsLibPath = layout.projectDirectory.dir("mods/lib").asFile.absolutePath + def depJars = configurations.runtimeClasspath.files.findAll { + !it.name.startsWith('javafx-') + }.collect { it.absolutePath }.join(File.pathSeparator) + def compileOnlyJars = configurations.compileClasspath.files.findAll { + it.name.contains('annotations') || it.name.contains('spotbugs') + }.collect { it.absolutePath }.join(File.pathSeparator) + + doFirst { + if (name.toLowerCase().contains("test")) { + options.compilerArgs << "--module-path" << modsLibPath + options.compilerArgs << "--add-modules" << "javafx.controls,javafx.web,javafx.swing,javafx.fxml,javafx.graphics" + } else if (name == "compileJava") { + def modulePath = [modsLibPath, depJars, compileOnlyJars].findAll { it }.join(File.pathSeparator) + options.compilerArgs << "--module-path" << modulePath + } + println "Args for for $name are $options.allCompilerArgs" + } +} + tasks.named("dependencyUpdates") { revision = 'release' diff --git a/code/src/java/module-info.java b/code/src/java/module-info.java index e9d1e15e877..eaf2fdba6c3 100644 --- a/code/src/java/module-info.java +++ b/code/src/java/module-info.java @@ -19,8 +19,8 @@ requires javafx.swing; requires javafx.web; - requires PCGen.base; - requires PCGen.Formula; + requires pcgen.base; + requires pcgen.formula; requires org.apache.commons.lang3; requires org.apache.commons.io; diff --git a/code/src/java/pcgen/base/enumeration/TypeSafeConstant.java b/code/src/java/pcgen/base/enumeration/TypeSafeConstant.java deleted file mode 100644 index c2a72c985d9..00000000000 --- a/code/src/java/pcgen/base/enumeration/TypeSafeConstant.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2006 Tom Parker - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - */ -package pcgen.base.enumeration; - -/** - * A TypeSafeConstant is an object which will provide a unique integer - * identifier to every instance of that class (not unique to every - * TypeSafeConstant). - * - * As an example, If Classes A and B both extend TypeSafeConstant, then there - * may be an instance of Class A that has ordinal 1 and an instance of Class B - * that has ordinal 1, but only one instance of each class may have any ordinal. - * (Two instances of Class A may not share ordinal 1 and still respect the - * TypeSafeConstant interface) - * - * This emulates behavior by the enum system in Java 1.5+. Note that the - * identifier should be unique per virtual machine; thus serialization and other - * forms of persistence of classes must ensure the uniqueness of identifiers of - * a TypeSafeConstant. - * - * It is considered good behavior for a TypeSafeConstant to begin the ordinal - * count at zero. There may be an expectation by classes that use - * TypeSafeConstants that expect this behavior. In that case, such behavioral - * limitations should be documented in the TypeSafeConstant-using class. - * - */ -@FunctionalInterface -public interface TypeSafeConstant -{ - - /** - * Returns the unique ordinal for the instance of the TypeSafeConstant - * class. - * - * @return An integer identifier unique to this instance of the class. - */ - public int getOrdinal(); - -} diff --git a/code/src/java/pcgen/cdom/base/CDOMObject.java b/code/src/java/pcgen/cdom/base/CDOMObject.java index 43824565d27..25fcbf2dac5 100644 --- a/code/src/java/pcgen/cdom/base/CDOMObject.java +++ b/code/src/java/pcgen/cdom/base/CDOMObject.java @@ -35,7 +35,7 @@ import java.util.Set; import org.jetbrains.annotations.NotNull; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.formula.base.VarScoped; import pcgen.base.lang.StringUtil; import pcgen.base.util.DoubleKeyMapToList; diff --git a/code/src/java/pcgen/cdom/base/ChooseDriver.java b/code/src/java/pcgen/cdom/base/ChooseDriver.java index 0b107e92070..e4113bfbf55 100644 --- a/code/src/java/pcgen/cdom/base/ChooseDriver.java +++ b/code/src/java/pcgen/cdom/base/ChooseDriver.java @@ -19,7 +19,7 @@ import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; public interface ChooseDriver { diff --git a/code/src/java/pcgen/cdom/base/ConcretePersistentTransitionChoice.java b/code/src/java/pcgen/cdom/base/ConcretePersistentTransitionChoice.java index 1870520caa7..6a5066345a2 100644 --- a/code/src/java/pcgen/cdom/base/ConcretePersistentTransitionChoice.java +++ b/code/src/java/pcgen/cdom/base/ConcretePersistentTransitionChoice.java @@ -19,7 +19,7 @@ import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.AssociationListKey; import pcgen.core.PlayerCharacter; import pcgen.rules.context.LoadContext; diff --git a/code/src/java/pcgen/cdom/base/ConcreteTransitionChoice.java b/code/src/java/pcgen/cdom/base/ConcreteTransitionChoice.java index e18c9408d8a..da353856f5e 100644 --- a/code/src/java/pcgen/cdom/base/ConcreteTransitionChoice.java +++ b/code/src/java/pcgen/cdom/base/ConcreteTransitionChoice.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Set; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.AssociationListKey; import pcgen.core.PlayerCharacter; import pcgen.core.chooser.CDOMChooserFacadeImpl; diff --git a/code/src/java/pcgen/cdom/base/FormulaFactory.java b/code/src/java/pcgen/cdom/base/FormulaFactory.java index 6ea551f6476..f49fe71c109 100644 --- a/code/src/java/pcgen/cdom/base/FormulaFactory.java +++ b/code/src/java/pcgen/cdom/base/FormulaFactory.java @@ -20,7 +20,7 @@ import java.util.Objects; import java.util.Optional; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; import pcgen.base.formula.base.FormulaManager; diff --git a/code/src/java/pcgen/cdom/base/JEPFormula.java b/code/src/java/pcgen/cdom/base/JEPFormula.java index c3ceb88544a..e2296f77b39 100644 --- a/code/src/java/pcgen/cdom/base/JEPFormula.java +++ b/code/src/java/pcgen/cdom/base/JEPFormula.java @@ -17,7 +17,7 @@ */ package pcgen.cdom.base; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.core.Equipment; import pcgen.core.PlayerCharacter; diff --git a/code/src/java/pcgen/cdom/base/TransitionChoice.java b/code/src/java/pcgen/cdom/base/TransitionChoice.java index 46d9cfb9e20..c40fe33af38 100644 --- a/code/src/java/pcgen/cdom/base/TransitionChoice.java +++ b/code/src/java/pcgen/cdom/base/TransitionChoice.java @@ -19,7 +19,7 @@ import java.util.Collection; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.core.PlayerCharacter; /** diff --git a/code/src/java/pcgen/base/calculation/AbstractNEPCalculation.java b/code/src/java/pcgen/cdom/calculation/AbstractNEPCalculation.java similarity index 98% rename from code/src/java/pcgen/base/calculation/AbstractNEPCalculation.java rename to code/src/java/pcgen/cdom/calculation/AbstractNEPCalculation.java index e5765887d33..d64d4d049dc 100644 --- a/code/src/java/pcgen/base/calculation/AbstractNEPCalculation.java +++ b/code/src/java/pcgen/cdom/calculation/AbstractNEPCalculation.java @@ -15,7 +15,7 @@ * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -package pcgen.base.calculation; +package pcgen.cdom.calculation; import java.util.Objects; diff --git a/code/src/java/pcgen/base/calculation/AbstractPCGenModifier.java b/code/src/java/pcgen/cdom/calculation/AbstractPCGenModifier.java similarity index 98% rename from code/src/java/pcgen/base/calculation/AbstractPCGenModifier.java rename to code/src/java/pcgen/cdom/calculation/AbstractPCGenModifier.java index 95f9bc46bed..f420bdf23a5 100644 --- a/code/src/java/pcgen/base/calculation/AbstractPCGenModifier.java +++ b/code/src/java/pcgen/cdom/calculation/AbstractPCGenModifier.java @@ -13,7 +13,7 @@ * this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, * Suite 330, Boston, MA 02111-1307 USA */ -package pcgen.base.calculation; +package pcgen.cdom.calculation; import java.util.Collection; import java.util.Collections; diff --git a/code/src/java/pcgen/base/calculation/BasicCalculation.java b/code/src/java/pcgen/cdom/calculation/BasicCalculation.java similarity index 98% rename from code/src/java/pcgen/base/calculation/BasicCalculation.java rename to code/src/java/pcgen/cdom/calculation/BasicCalculation.java index 91aa55ee1e0..9ac952c7511 100644 --- a/code/src/java/pcgen/base/calculation/BasicCalculation.java +++ b/code/src/java/pcgen/cdom/calculation/BasicCalculation.java @@ -15,7 +15,7 @@ * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -package pcgen.base.calculation; +package pcgen.cdom.calculation; /** * A BasicCalculation is a calculation performed on two objects of the same diff --git a/code/src/java/pcgen/base/calculation/CalculationInfo.java b/code/src/java/pcgen/cdom/calculation/CalculationInfo.java similarity index 98% rename from code/src/java/pcgen/base/calculation/CalculationInfo.java rename to code/src/java/pcgen/cdom/calculation/CalculationInfo.java index c21ec5f6d3a..ca442f12a75 100644 --- a/code/src/java/pcgen/base/calculation/CalculationInfo.java +++ b/code/src/java/pcgen/cdom/calculation/CalculationInfo.java @@ -15,7 +15,7 @@ * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -package pcgen.base.calculation; +package pcgen.cdom.calculation; /** * CalculationInfo is a shared interface used to collect common information diff --git a/code/src/java/pcgen/base/calculation/CalculationModifier.java b/code/src/java/pcgen/cdom/calculation/CalculationModifier.java similarity index 99% rename from code/src/java/pcgen/base/calculation/CalculationModifier.java rename to code/src/java/pcgen/cdom/calculation/CalculationModifier.java index dd8a326c1fc..86e3c46b1b4 100644 --- a/code/src/java/pcgen/base/calculation/CalculationModifier.java +++ b/code/src/java/pcgen/cdom/calculation/CalculationModifier.java @@ -15,7 +15,7 @@ * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -package pcgen.base.calculation; +package pcgen.cdom.calculation; import java.util.Objects; diff --git a/code/src/java/pcgen/base/calculation/FormulaCalculation.java b/code/src/java/pcgen/cdom/calculation/FormulaCalculation.java similarity index 99% rename from code/src/java/pcgen/base/calculation/FormulaCalculation.java rename to code/src/java/pcgen/cdom/calculation/FormulaCalculation.java index 943b1300863..d62e6e3cddd 100644 --- a/code/src/java/pcgen/base/calculation/FormulaCalculation.java +++ b/code/src/java/pcgen/cdom/calculation/FormulaCalculation.java @@ -15,7 +15,7 @@ * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -package pcgen.base.calculation; +package pcgen.cdom.calculation; import java.util.Objects; diff --git a/code/src/java/pcgen/base/calculation/FormulaModifier.java b/code/src/java/pcgen/cdom/calculation/FormulaModifier.java similarity index 99% rename from code/src/java/pcgen/base/calculation/FormulaModifier.java rename to code/src/java/pcgen/cdom/calculation/FormulaModifier.java index e7b3e50e5af..337bf1e1a85 100644 --- a/code/src/java/pcgen/base/calculation/FormulaModifier.java +++ b/code/src/java/pcgen/cdom/calculation/FormulaModifier.java @@ -15,7 +15,7 @@ * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -package pcgen.base.calculation; +package pcgen.cdom.calculation; import java.util.Collection; diff --git a/code/src/java/pcgen/base/calculation/IgnoreVariables.java b/code/src/java/pcgen/cdom/calculation/IgnoreVariables.java similarity index 97% rename from code/src/java/pcgen/base/calculation/IgnoreVariables.java rename to code/src/java/pcgen/cdom/calculation/IgnoreVariables.java index 4ff00ced8aa..927d2e46178 100644 --- a/code/src/java/pcgen/base/calculation/IgnoreVariables.java +++ b/code/src/java/pcgen/cdom/calculation/IgnoreVariables.java @@ -13,7 +13,7 @@ * this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, * Suite 330, Boston, MA 02111-1307 USA */ -package pcgen.base.calculation; +package pcgen.cdom.calculation; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.VariableStrategy; diff --git a/code/src/java/pcgen/base/calculation/NEPCalculation.java b/code/src/java/pcgen/cdom/calculation/NEPCalculation.java similarity index 99% rename from code/src/java/pcgen/base/calculation/NEPCalculation.java rename to code/src/java/pcgen/cdom/calculation/NEPCalculation.java index 83b10d22acd..323f2a2a7fe 100644 --- a/code/src/java/pcgen/base/calculation/NEPCalculation.java +++ b/code/src/java/pcgen/cdom/calculation/NEPCalculation.java @@ -15,7 +15,7 @@ * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -package pcgen.base.calculation; +package pcgen.cdom.calculation; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; diff --git a/code/src/java/pcgen/base/calculation/package-info.java b/code/src/java/pcgen/cdom/calculation/package-info.java similarity index 97% rename from code/src/java/pcgen/base/calculation/package-info.java rename to code/src/java/pcgen/cdom/calculation/package-info.java index ce69c840384..9a7c39d55a2 100644 --- a/code/src/java/pcgen/base/calculation/package-info.java +++ b/code/src/java/pcgen/cdom/calculation/package-info.java @@ -20,4 +20,4 @@ * Formula. This is usually one "step" in a calculation (where a step can be * much more than just addition or subtraction, it can be a full equation). */ -package pcgen.base.calculation; +package pcgen.cdom.calculation; diff --git a/code/src/java/pcgen/cdom/content/CNAbility.java b/code/src/java/pcgen/cdom/content/CNAbility.java index f95adc2f659..bc7ff290d3e 100644 --- a/code/src/java/pcgen/cdom/content/CNAbility.java +++ b/code/src/java/pcgen/cdom/content/CNAbility.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Objects; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.Category; import pcgen.cdom.base.ChooseDriver; diff --git a/code/src/java/pcgen/cdom/content/ChallengeRating.java b/code/src/java/pcgen/cdom/content/ChallengeRating.java index 8c00d341ef2..f9e4d0adc33 100644 --- a/code/src/java/pcgen/cdom/content/ChallengeRating.java +++ b/code/src/java/pcgen/cdom/content/ChallengeRating.java @@ -17,7 +17,7 @@ */ package pcgen.cdom.content; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ConcretePrereqObject; import pcgen.cdom.base.FormulaFactory; import pcgen.core.SettingsHandler; diff --git a/code/src/java/pcgen/cdom/content/DamageReduction.java b/code/src/java/pcgen/cdom/content/DamageReduction.java index 9536d465a08..792b4c0a838 100644 --- a/code/src/java/pcgen/cdom/content/DamageReduction.java +++ b/code/src/java/pcgen/cdom/content/DamageReduction.java @@ -25,7 +25,7 @@ import java.util.Set; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ConcretePrereqObject; import pcgen.cdom.base.QualifyingObject; diff --git a/code/src/java/pcgen/cdom/content/IndirectCalculation.java b/code/src/java/pcgen/cdom/content/IndirectCalculation.java index ae8c3645d89..da7e414530c 100644 --- a/code/src/java/pcgen/cdom/content/IndirectCalculation.java +++ b/code/src/java/pcgen/cdom/content/IndirectCalculation.java @@ -17,8 +17,8 @@ import java.util.Objects; -import pcgen.base.calculation.AbstractNEPCalculation; -import pcgen.base.calculation.BasicCalculation; +import pcgen.cdom.calculation.AbstractNEPCalculation; +import pcgen.cdom.calculation.BasicCalculation; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; import pcgen.base.formula.base.FormulaSemantics; diff --git a/code/src/java/pcgen/cdom/content/LevelCommandFactory.java b/code/src/java/pcgen/cdom/content/LevelCommandFactory.java index d0f10733f7f..c8792b09e77 100644 --- a/code/src/java/pcgen/cdom/content/LevelCommandFactory.java +++ b/code/src/java/pcgen/cdom/content/LevelCommandFactory.java @@ -19,7 +19,7 @@ import java.util.Objects; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ConcretePrereqObject; import pcgen.cdom.reference.CDOMSingleRef; import pcgen.cdom.reference.ReferenceUtilities; diff --git a/code/src/java/pcgen/cdom/content/ProcessCalculation.java b/code/src/java/pcgen/cdom/content/ProcessCalculation.java index 37b721fcac8..aab990e71de 100644 --- a/code/src/java/pcgen/cdom/content/ProcessCalculation.java +++ b/code/src/java/pcgen/cdom/content/ProcessCalculation.java @@ -19,8 +19,8 @@ import java.util.Objects; -import pcgen.base.calculation.AbstractNEPCalculation; -import pcgen.base.calculation.BasicCalculation; +import pcgen.cdom.calculation.AbstractNEPCalculation; +import pcgen.cdom.calculation.BasicCalculation; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; import pcgen.base.formula.base.FormulaSemantics; diff --git a/code/src/java/pcgen/cdom/content/SpellLikeAbility.java b/code/src/java/pcgen/cdom/content/SpellLikeAbility.java index 3cba91b9833..956028fe55e 100644 --- a/code/src/java/pcgen/cdom/content/SpellLikeAbility.java +++ b/code/src/java/pcgen/cdom/content/SpellLikeAbility.java @@ -17,7 +17,7 @@ */ package pcgen.cdom.content; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ConcretePrereqObject; import pcgen.cdom.base.QualifyingObject; import pcgen.core.spell.Spell; diff --git a/code/src/java/pcgen/cdom/content/SpellResistance.java b/code/src/java/pcgen/cdom/content/SpellResistance.java index 9dbb9035544..9a1d0ad8300 100644 --- a/code/src/java/pcgen/cdom/content/SpellResistance.java +++ b/code/src/java/pcgen/cdom/content/SpellResistance.java @@ -17,7 +17,7 @@ */ package pcgen.cdom.content; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ConcretePrereqObject; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/pcgen/cdom/content/VarModifier.java b/code/src/java/pcgen/cdom/content/VarModifier.java index 131a3ec6e59..b95b78fed20 100644 --- a/code/src/java/pcgen/cdom/content/VarModifier.java +++ b/code/src/java/pcgen/cdom/content/VarModifier.java @@ -19,7 +19,7 @@ import java.util.Objects; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.LegalScope; import pcgen.cdom.formula.scope.PCGenScope; diff --git a/code/src/java/pcgen/cdom/enumeration/AssociationKey.java b/code/src/java/pcgen/cdom/enumeration/AssociationKey.java index e1a59ba89bb..cb5a3f437d7 100644 --- a/code/src/java/pcgen/cdom/enumeration/AssociationKey.java +++ b/code/src/java/pcgen/cdom/enumeration/AssociationKey.java @@ -21,7 +21,7 @@ import java.lang.reflect.Modifier; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.UnreachableError; import pcgen.base.util.CaseInsensitiveMap; import pcgen.cdom.base.CDOMObject; diff --git a/code/src/java/pcgen/cdom/enumeration/FormulaKey.java b/code/src/java/pcgen/cdom/enumeration/FormulaKey.java index b6818faa635..f24f6a8ffa7 100644 --- a/code/src/java/pcgen/cdom/enumeration/FormulaKey.java +++ b/code/src/java/pcgen/cdom/enumeration/FormulaKey.java @@ -22,7 +22,7 @@ import java.util.Objects; import pcgen.base.enumeration.TypeSafeConstant; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.util.CaseInsensitiveMap; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.formula.FixedSizeFormula; diff --git a/code/src/java/pcgen/cdom/enumeration/ListKey.java b/code/src/java/pcgen/cdom/enumeration/ListKey.java index 8e4263f1715..1d731e82704 100644 --- a/code/src/java/pcgen/cdom/enumeration/ListKey.java +++ b/code/src/java/pcgen/cdom/enumeration/ListKey.java @@ -22,7 +22,7 @@ import java.util.HashSet; import java.util.Map; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.UnreachableError; import pcgen.base.util.CaseInsensitiveMap; import pcgen.cdom.base.CDOMReference; diff --git a/code/src/java/pcgen/cdom/enumeration/ObjectKey.java b/code/src/java/pcgen/cdom/enumeration/ObjectKey.java index 479cd832c77..15160571126 100644 --- a/code/src/java/pcgen/cdom/enumeration/ObjectKey.java +++ b/code/src/java/pcgen/cdom/enumeration/ObjectKey.java @@ -26,7 +26,7 @@ import java.util.HashSet; import java.util.Map; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.UnreachableError; import pcgen.base.util.CaseInsensitiveMap; import pcgen.cdom.base.CDOMListObject; diff --git a/code/src/java/pcgen/cdom/facet/ActiveSpellsFacet.java b/code/src/java/pcgen/cdom/facet/ActiveSpellsFacet.java index 6ddf2aa86e3..9d4e9f96ee8 100644 --- a/code/src/java/pcgen/cdom/facet/ActiveSpellsFacet.java +++ b/code/src/java/pcgen/cdom/facet/ActiveSpellsFacet.java @@ -21,7 +21,7 @@ import java.util.Set; import java.util.TreeMap; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.content.SpellLikeAbility; import pcgen.cdom.enumeration.CharID; diff --git a/code/src/java/pcgen/cdom/facet/AddLevelFacet.java b/code/src/java/pcgen/cdom/facet/AddLevelFacet.java index ba3f3c9f7c8..bf4755f00a9 100644 --- a/code/src/java/pcgen/cdom/facet/AddLevelFacet.java +++ b/code/src/java/pcgen/cdom/facet/AddLevelFacet.java @@ -19,7 +19,7 @@ import java.util.List; import java.util.ListIterator; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.Constants; import pcgen.cdom.content.LevelCommandFactory; import pcgen.cdom.enumeration.CharID; diff --git a/code/src/java/pcgen/cdom/facet/FormulaResolvingFacet.java b/code/src/java/pcgen/cdom/facet/FormulaResolvingFacet.java index 264a13bff8c..f338fe2e8ec 100644 --- a/code/src/java/pcgen/cdom/facet/FormulaResolvingFacet.java +++ b/code/src/java/pcgen/cdom/facet/FormulaResolvingFacet.java @@ -17,7 +17,7 @@ */ package pcgen.cdom.facet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.CharID; /** diff --git a/code/src/java/pcgen/cdom/facet/ModifierFacet.java b/code/src/java/pcgen/cdom/facet/ModifierFacet.java index 74d6d08a80b..137bea1af8b 100644 --- a/code/src/java/pcgen/cdom/facet/ModifierFacet.java +++ b/code/src/java/pcgen/cdom/facet/ModifierFacet.java @@ -19,7 +19,7 @@ import java.util.Optional; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.ScopeInstance; import pcgen.base.formula.base.VarScoped; import pcgen.base.solver.Modifier; diff --git a/code/src/java/pcgen/cdom/facet/RemoteModifierFacet.java b/code/src/java/pcgen/cdom/facet/RemoteModifierFacet.java index 5aed10d32c1..b0087b33e01 100644 --- a/code/src/java/pcgen/cdom/facet/RemoteModifierFacet.java +++ b/code/src/java/pcgen/cdom/facet/RemoteModifierFacet.java @@ -21,7 +21,7 @@ import java.util.Set; import java.util.function.Consumer; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.ScopeInstance; import pcgen.base.formula.base.VarScoped; import pcgen.base.solver.Modifier; diff --git a/code/src/java/pcgen/cdom/facet/SpellsFacet.java b/code/src/java/pcgen/cdom/facet/SpellsFacet.java index 9b9c17d9fb5..097cb3a27b4 100644 --- a/code/src/java/pcgen/cdom/facet/SpellsFacet.java +++ b/code/src/java/pcgen/cdom/facet/SpellsFacet.java @@ -19,7 +19,7 @@ import java.util.Collection; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.AssociatedPrereqObject; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; diff --git a/code/src/java/pcgen/cdom/facet/analysis/ChallengeRatingFacet.java b/code/src/java/pcgen/cdom/facet/analysis/ChallengeRatingFacet.java index 110897f4656..0b1920a39ca 100644 --- a/code/src/java/pcgen/cdom/facet/analysis/ChallengeRatingFacet.java +++ b/code/src/java/pcgen/cdom/facet/analysis/ChallengeRatingFacet.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.content.ChallengeRating; import pcgen.cdom.content.LevelCommandFactory; diff --git a/code/src/java/pcgen/cdom/facet/analysis/CharacterSpellResistanceFacet.java b/code/src/java/pcgen/cdom/facet/analysis/CharacterSpellResistanceFacet.java index 2694fd52097..bbeea46b44b 100644 --- a/code/src/java/pcgen/cdom/facet/analysis/CharacterSpellResistanceFacet.java +++ b/code/src/java/pcgen/cdom/facet/analysis/CharacterSpellResistanceFacet.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.Set; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.content.SpellResistance; import pcgen.cdom.enumeration.CharID; diff --git a/code/src/java/pcgen/cdom/facet/analysis/InitiativeFacet.java b/code/src/java/pcgen/cdom/facet/analysis/InitiativeFacet.java index 192e448baed..f1bd4d49792 100644 --- a/code/src/java/pcgen/cdom/facet/analysis/InitiativeFacet.java +++ b/code/src/java/pcgen/cdom/facet/analysis/InitiativeFacet.java @@ -17,7 +17,7 @@ */ package pcgen.cdom.facet.analysis; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.CharID; import pcgen.cdom.facet.BonusCheckingFacet; diff --git a/code/src/java/pcgen/cdom/facet/analysis/LevelFacet.java b/code/src/java/pcgen/cdom/facet/analysis/LevelFacet.java index dbc66e63772..dc20c41dd35 100644 --- a/code/src/java/pcgen/cdom/facet/analysis/LevelFacet.java +++ b/code/src/java/pcgen/cdom/facet/analysis/LevelFacet.java @@ -22,7 +22,7 @@ import javax.swing.event.EventListenerList; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.CharID; import pcgen.cdom.enumeration.FormulaKey; import pcgen.cdom.facet.FormulaResolvingFacet; diff --git a/code/src/java/pcgen/cdom/facet/analysis/LevelTableFacet.java b/code/src/java/pcgen/cdom/facet/analysis/LevelTableFacet.java index f46579bbfc4..346470951af 100644 --- a/code/src/java/pcgen/cdom/facet/analysis/LevelTableFacet.java +++ b/code/src/java/pcgen/cdom/facet/analysis/LevelTableFacet.java @@ -17,7 +17,7 @@ */ package pcgen.cdom.facet.analysis; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.CharID; import pcgen.cdom.facet.FormulaResolvingFacet; diff --git a/code/src/java/pcgen/cdom/facet/analysis/LoadFacet.java b/code/src/java/pcgen/cdom/facet/analysis/LoadFacet.java index 5ee32161756..ac9ba8816ad 100644 --- a/code/src/java/pcgen/cdom/facet/analysis/LoadFacet.java +++ b/code/src/java/pcgen/cdom/facet/analysis/LoadFacet.java @@ -19,7 +19,7 @@ import java.math.BigDecimal; import java.util.regex.Pattern; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.CharID; import pcgen.cdom.facet.BonusCheckingFacet; diff --git a/code/src/java/pcgen/cdom/facet/analysis/VariableFacet.java b/code/src/java/pcgen/cdom/facet/analysis/VariableFacet.java index f54501699fb..a4ce89a48ac 100644 --- a/code/src/java/pcgen/cdom/facet/analysis/VariableFacet.java +++ b/code/src/java/pcgen/cdom/facet/analysis/VariableFacet.java @@ -24,7 +24,7 @@ import java.util.Map; import java.util.Set; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.enumeration.CharID; import pcgen.cdom.enumeration.VariableKey; diff --git a/code/src/java/pcgen/cdom/facet/analysis/VisionFacet.java b/code/src/java/pcgen/cdom/facet/analysis/VisionFacet.java index 9c694a42808..74e6b7a76fe 100644 --- a/code/src/java/pcgen/cdom/facet/analysis/VisionFacet.java +++ b/code/src/java/pcgen/cdom/facet/analysis/VisionFacet.java @@ -25,7 +25,7 @@ import java.util.Set; import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.AssociatedPrereqObject; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; diff --git a/code/src/java/pcgen/cdom/facet/model/SizeFacet.java b/code/src/java/pcgen/cdom/facet/model/SizeFacet.java index e19af3ccdd6..bc4cdced9ed 100644 --- a/code/src/java/pcgen/cdom/facet/model/SizeFacet.java +++ b/code/src/java/pcgen/cdom/facet/model/SizeFacet.java @@ -19,7 +19,7 @@ import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.ItemFacet; import pcgen.cdom.enumeration.CharID; diff --git a/code/src/java/pcgen/cdom/formula/FixedSizeFormula.java b/code/src/java/pcgen/cdom/formula/FixedSizeFormula.java index 84f2aec139f..2b852b3e681 100644 --- a/code/src/java/pcgen/cdom/formula/FixedSizeFormula.java +++ b/code/src/java/pcgen/cdom/formula/FixedSizeFormula.java @@ -19,7 +19,7 @@ import java.util.Objects; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.IntegerKey; import pcgen.cdom.reference.CDOMSingleRef; import pcgen.core.Equipment; diff --git a/code/src/java/pcgen/base/formula/Formula.java b/code/src/java/pcgen/cdom/formula/Formula.java similarity index 91% rename from code/src/java/pcgen/base/formula/Formula.java rename to code/src/java/pcgen/cdom/formula/Formula.java index bc9e2becefb..6c6de45b45b 100644 --- a/code/src/java/pcgen/base/formula/Formula.java +++ b/code/src/java/pcgen/cdom/formula/Formula.java @@ -15,14 +15,16 @@ * along with this library; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -package pcgen.base.formula; +package pcgen.cdom.formula; import pcgen.core.Equipment; import pcgen.core.PlayerCharacter; /** - * - * A Formula is a mathematical formula which requires a context to resolve. + * A legacy formula interface for PCGen's JEP-based formula resolution. Resolves formulas + * against a PlayerCharacter context. This is distinct from the generic formula parser + * system in module pcgen.formula ({@code pcgen.base.formula.parse}), which provides a + * context-free expression parser with visitor-based evaluation. */ public interface Formula { diff --git a/code/src/java/pcgen/cdom/formula/local/DefinedWrappingModifier.java b/code/src/java/pcgen/cdom/formula/local/DefinedWrappingModifier.java index 6aa49bee6d5..2e071c9c4d1 100644 --- a/code/src/java/pcgen/cdom/formula/local/DefinedWrappingModifier.java +++ b/code/src/java/pcgen/cdom/formula/local/DefinedWrappingModifier.java @@ -17,7 +17,7 @@ import java.util.Objects; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; import pcgen.base.formula.base.FormulaManager; diff --git a/code/src/java/pcgen/cdom/formula/local/ModifierDecoration.java b/code/src/java/pcgen/cdom/formula/local/ModifierDecoration.java index b67ecafaf49..360b0619024 100644 --- a/code/src/java/pcgen/cdom/formula/local/ModifierDecoration.java +++ b/code/src/java/pcgen/cdom/formula/local/ModifierDecoration.java @@ -17,7 +17,7 @@ import java.util.Objects; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; import pcgen.base.solver.Modifier; diff --git a/code/src/java/pcgen/cdom/formula/local/RemoteWrappingModifier.java b/code/src/java/pcgen/cdom/formula/local/RemoteWrappingModifier.java index 7a17cb7f072..9b37663b095 100644 --- a/code/src/java/pcgen/cdom/formula/local/RemoteWrappingModifier.java +++ b/code/src/java/pcgen/cdom/formula/local/RemoteWrappingModifier.java @@ -17,7 +17,7 @@ import java.util.Objects; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; import pcgen.base.formula.base.FormulaManager; diff --git a/code/src/java/pcgen/cdom/helper/FollowerLimit.java b/code/src/java/pcgen/cdom/helper/FollowerLimit.java index acb16f23b02..325e036d42c 100644 --- a/code/src/java/pcgen/cdom/helper/FollowerLimit.java +++ b/code/src/java/pcgen/cdom/helper/FollowerLimit.java @@ -19,7 +19,7 @@ import java.util.Objects; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.list.CompanionList; import pcgen.cdom.reference.CDOMSingleRef; diff --git a/code/src/java/pcgen/cdom/helper/OptionBound.java b/code/src/java/pcgen/cdom/helper/OptionBound.java index bbc8168e829..3f07832d63d 100644 --- a/code/src/java/pcgen/cdom/helper/OptionBound.java +++ b/code/src/java/pcgen/cdom/helper/OptionBound.java @@ -17,7 +17,7 @@ */ package pcgen.cdom.helper; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.core.PlayerCharacter; /** diff --git a/code/src/java/pcgen/cdom/helper/SpellLevelInfo.java b/code/src/java/pcgen/cdom/helper/SpellLevelInfo.java index e3f23fa6a96..3e3993afaf1 100644 --- a/code/src/java/pcgen/cdom/helper/SpellLevelInfo.java +++ b/code/src/java/pcgen/cdom/helper/SpellLevelInfo.java @@ -20,7 +20,7 @@ import java.util.Collection; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.Constants; import pcgen.cdom.base.Converter; import pcgen.cdom.base.PrimitiveCollection; diff --git a/code/src/java/pcgen/cdom/helper/StatLock.java b/code/src/java/pcgen/cdom/helper/StatLock.java index abaf85dcf63..ee92a93dc80 100644 --- a/code/src/java/pcgen/cdom/helper/StatLock.java +++ b/code/src/java/pcgen/cdom/helper/StatLock.java @@ -19,7 +19,7 @@ import java.util.Objects; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.reference.CDOMSingleRef; import pcgen.core.PCStat; diff --git a/code/src/java/pcgen/core/AbilityCategory.java b/code/src/java/pcgen/core/AbilityCategory.java index e40877f9e52..8e3bddbcd67 100644 --- a/code/src/java/pcgen/core/AbilityCategory.java +++ b/code/src/java/pcgen/core/AbilityCategory.java @@ -29,7 +29,7 @@ import java.util.Set; import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.BasicClassIdentity; import pcgen.cdom.base.Category; import pcgen.cdom.base.ChooseInformation; diff --git a/code/src/java/pcgen/core/BonusManager.java b/code/src/java/pcgen/core/BonusManager.java index 1bff36ea64d..99f14f46c21 100644 --- a/code/src/java/pcgen/core/BonusManager.java +++ b/code/src/java/pcgen/core/BonusManager.java @@ -34,7 +34,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.BonusContainer; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.Constants; diff --git a/code/src/java/pcgen/core/Domain.java b/code/src/java/pcgen/core/Domain.java index 0869df0bff2..8c9a5171629 100644 --- a/code/src/java/pcgen/core/Domain.java +++ b/code/src/java/pcgen/core/Domain.java @@ -19,7 +19,7 @@ import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ChooseDriver; import pcgen.cdom.base.ChooseInformation; import pcgen.cdom.base.ChooseSelectionActor; diff --git a/code/src/java/pcgen/core/Equipment.java b/code/src/java/pcgen/core/Equipment.java index 2e4c1195b5b..1cb99932c8f 100644 --- a/code/src/java/pcgen/core/Equipment.java +++ b/code/src/java/pcgen/core/Equipment.java @@ -40,7 +40,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.StringUtil; import pcgen.base.util.FixedStringList; import pcgen.cdom.base.CDOMObject; diff --git a/code/src/java/pcgen/core/EquipmentModifier.java b/code/src/java/pcgen/core/EquipmentModifier.java index a2467203834..49737b6c0a4 100644 --- a/code/src/java/pcgen/core/EquipmentModifier.java +++ b/code/src/java/pcgen/core/EquipmentModifier.java @@ -22,7 +22,7 @@ import java.util.Optional; import java.util.regex.Pattern; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.formula.base.VarScoped; import pcgen.base.lang.StringUtil; import pcgen.cdom.base.CDOMObject; diff --git a/code/src/java/pcgen/core/Kit.java b/code/src/java/pcgen/core/Kit.java index d435d92cf35..5edffd43b68 100644 --- a/code/src/java/pcgen/core/Kit.java +++ b/code/src/java/pcgen/core/Kit.java @@ -24,7 +24,7 @@ import java.util.Comparator; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.StringUtil; import pcgen.cdom.enumeration.KitApply; import pcgen.cdom.enumeration.ListKey; diff --git a/code/src/java/pcgen/core/PCTemplate.java b/code/src/java/pcgen/core/PCTemplate.java index 283b1a39fe9..62cc6c2e787 100644 --- a/code/src/java/pcgen/core/PCTemplate.java +++ b/code/src/java/pcgen/core/PCTemplate.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ChooseDriver; import pcgen.cdom.base.ChooseInformation; import pcgen.cdom.base.ChooseSelectionActor; diff --git a/code/src/java/pcgen/core/PlayerCharacter.java b/code/src/java/pcgen/core/PlayerCharacter.java index 447da86e5d5..7b7d59628aa 100644 --- a/code/src/java/pcgen/core/PlayerCharacter.java +++ b/code/src/java/pcgen/core/PlayerCharacter.java @@ -32,7 +32,7 @@ import java.util.StringTokenizer; import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.formula.base.FormulaManager; import pcgen.base.formula.inst.NEPFormula; import pcgen.base.solver.SolverManager; diff --git a/code/src/java/pcgen/core/Race.java b/code/src/java/pcgen/core/Race.java index 6346d426cd1..ebee93cb229 100644 --- a/code/src/java/pcgen/core/Race.java +++ b/code/src/java/pcgen/core/Race.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Optional; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ChooseDriver; import pcgen.cdom.base.ChooseInformation; import pcgen.cdom.base.ChooseSelectionActor; diff --git a/code/src/java/pcgen/core/Skill.java b/code/src/java/pcgen/core/Skill.java index 8cc182fe275..08e6b781439 100644 --- a/code/src/java/pcgen/core/Skill.java +++ b/code/src/java/pcgen/core/Skill.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Optional; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.formula.base.VarScoped; import pcgen.cdom.base.ChooseDriver; import pcgen.cdom.base.ChooseInformation; diff --git a/code/src/java/pcgen/core/SpellProgressionCache.java b/code/src/java/pcgen/core/SpellProgressionCache.java index 50846f77b11..0cfcc6f4363 100644 --- a/code/src/java/pcgen/core/SpellProgressionCache.java +++ b/code/src/java/pcgen/core/SpellProgressionCache.java @@ -25,7 +25,7 @@ import java.util.Map.Entry; import java.util.TreeMap; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; /** * SpellProgressionInfo contains information about Spell Progression in support diff --git a/code/src/java/pcgen/core/SpellSupportForPCClass.java b/code/src/java/pcgen/core/SpellSupportForPCClass.java index 2e197009c35..f88b6ef35ee 100644 --- a/code/src/java/pcgen/core/SpellSupportForPCClass.java +++ b/code/src/java/pcgen/core/SpellSupportForPCClass.java @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.Constants; import pcgen.cdom.content.BonusSpellInfo; import pcgen.cdom.content.KnownSpellIdentifier; diff --git a/code/src/java/pcgen/core/Vision.java b/code/src/java/pcgen/core/Vision.java index 9bba0c195f7..fcd01a92ff3 100644 --- a/code/src/java/pcgen/core/Vision.java +++ b/code/src/java/pcgen/core/Vision.java @@ -21,7 +21,7 @@ import java.util.Objects; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/pcgen/core/analysis/DomainApplication.java b/code/src/java/pcgen/core/analysis/DomainApplication.java index 5ceb08aea42..c4a15fbce8a 100644 --- a/code/src/java/pcgen/core/analysis/DomainApplication.java +++ b/code/src/java/pcgen/core/analysis/DomainApplication.java @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.AssociatedPrereqObject; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.enumeration.AssociationKey; diff --git a/code/src/java/pcgen/core/bonus/Bonus.java b/code/src/java/pcgen/core/bonus/Bonus.java index 52e492639f0..b05c91bce58 100644 --- a/code/src/java/pcgen/core/bonus/Bonus.java +++ b/code/src/java/pcgen/core/bonus/Bonus.java @@ -21,7 +21,7 @@ import java.util.Locale; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.Constants; import pcgen.core.bonus.BonusObj.StackType; diff --git a/code/src/java/pcgen/core/bonus/BonusObj.java b/code/src/java/pcgen/core/bonus/BonusObj.java index 7812abc019f..c4370f92980 100644 --- a/code/src/java/pcgen/core/bonus/BonusObj.java +++ b/code/src/java/pcgen/core/bonus/BonusObj.java @@ -24,7 +24,7 @@ import java.util.Map; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ConcretePrereqObject; import pcgen.cdom.base.Constants; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/pcgen/core/bonus/BonusPair.java b/code/src/java/pcgen/core/bonus/BonusPair.java index d023bf7413f..d5823e3aebd 100644 --- a/code/src/java/pcgen/core/bonus/BonusPair.java +++ b/code/src/java/pcgen/core/bonus/BonusPair.java @@ -18,7 +18,7 @@ */ package pcgen.core.bonus; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.Constants; import pcgen.core.PlayerCharacter; diff --git a/code/src/java/pcgen/core/character/SpellBook.java b/code/src/java/pcgen/core/character/SpellBook.java index 7836d1cbaa5..94c5fd6bf17 100644 --- a/code/src/java/pcgen/core/character/SpellBook.java +++ b/code/src/java/pcgen/core/character/SpellBook.java @@ -17,7 +17,7 @@ */ package pcgen.core.character; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.Constants; import pcgen.cdom.enumeration.FormulaKey; import pcgen.cdom.enumeration.IntegerKey; diff --git a/code/src/java/pcgen/core/chooser/CDOMChoiceManager.java b/code/src/java/pcgen/core/chooser/CDOMChoiceManager.java index 3ea353312c2..d039f18f54f 100644 --- a/code/src/java/pcgen/core/chooser/CDOMChoiceManager.java +++ b/code/src/java/pcgen/core/chooser/CDOMChoiceManager.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ChooseDriver; import pcgen.cdom.base.ChooseInformation; import pcgen.core.Globals; diff --git a/code/src/java/pcgen/core/chooser/ChooserUtilities.java b/code/src/java/pcgen/core/chooser/ChooserUtilities.java index 8871209e6b9..994d6930256 100644 --- a/code/src/java/pcgen/core/chooser/ChooserUtilities.java +++ b/code/src/java/pcgen/core/chooser/ChooserUtilities.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ChooseDriver; import pcgen.cdom.base.ChooseInformation; import pcgen.cdom.content.CNAbility; diff --git a/code/src/java/pcgen/core/display/CharacterDisplay.java b/code/src/java/pcgen/core/display/CharacterDisplay.java index 4e544de7800..9b25d1f2071 100644 --- a/code/src/java/pcgen/core/display/CharacterDisplay.java +++ b/code/src/java/pcgen/core/display/CharacterDisplay.java @@ -31,7 +31,7 @@ import java.util.TreeSet; import java.util.stream.Collectors; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.util.NamedValue; import pcgen.cdom.base.CDOMList; import pcgen.cdom.base.CDOMObject; diff --git a/code/src/java/pcgen/core/kit/BaseKit.java b/code/src/java/pcgen/core/kit/BaseKit.java index a4ddbd81e07..480286e1e9e 100644 --- a/code/src/java/pcgen/core/kit/BaseKit.java +++ b/code/src/java/pcgen/core/kit/BaseKit.java @@ -24,7 +24,7 @@ import java.util.Collections; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.ConcretePrereqObject; import pcgen.cdom.base.Loadable; import pcgen.cdom.helper.OptionBound; diff --git a/code/src/java/pcgen/core/kit/KitClass.java b/code/src/java/pcgen/core/kit/KitClass.java index 6960e469588..c2577a65c8f 100644 --- a/code/src/java/pcgen/core/kit/KitClass.java +++ b/code/src/java/pcgen/core/kit/KitClass.java @@ -19,7 +19,7 @@ import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.Constants; import pcgen.cdom.reference.CDOMSingleRef; diff --git a/code/src/java/pcgen/core/kit/KitDeity.java b/code/src/java/pcgen/core/kit/KitDeity.java index 35495bb7d70..7742282e5b8 100644 --- a/code/src/java/pcgen/core/kit/KitDeity.java +++ b/code/src/java/pcgen/core/kit/KitDeity.java @@ -22,7 +22,7 @@ import java.util.Iterator; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.reference.CDOMSingleRef; import pcgen.cdom.util.CControl; import pcgen.core.Deity; diff --git a/code/src/java/pcgen/core/kit/KitFunds.java b/code/src/java/pcgen/core/kit/KitFunds.java index 11216c36459..2f953cffe9f 100644 --- a/code/src/java/pcgen/core/kit/KitFunds.java +++ b/code/src/java/pcgen/core/kit/KitFunds.java @@ -20,7 +20,7 @@ import java.math.BigDecimal; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.util.CControl; import pcgen.core.Kit; import pcgen.core.PlayerCharacter; diff --git a/code/src/java/pcgen/core/kit/KitGear.java b/code/src/java/pcgen/core/kit/KitGear.java index 8a90e7cc996..1838f89273c 100644 --- a/code/src/java/pcgen/core/kit/KitGear.java +++ b/code/src/java/pcgen/core/kit/KitGear.java @@ -24,7 +24,7 @@ import java.util.LinkedList; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.util.NamedFormula; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.Constants; diff --git a/code/src/java/pcgen/core/kit/KitSelect.java b/code/src/java/pcgen/core/kit/KitSelect.java index bb37e948dde..2e0b4dc4f3e 100644 --- a/code/src/java/pcgen/core/kit/KitSelect.java +++ b/code/src/java/pcgen/core/kit/KitSelect.java @@ -19,7 +19,7 @@ import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.core.Kit; import pcgen.core.PlayerCharacter; diff --git a/code/src/java/pcgen/core/kit/KitSpells.java b/code/src/java/pcgen/core/kit/KitSpells.java index 0c7e137d9fe..ef951a282f9 100644 --- a/code/src/java/pcgen/core/kit/KitSpells.java +++ b/code/src/java/pcgen/core/kit/KitSpells.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Set; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.util.DoubleKeyMap; import pcgen.cdom.base.CDOMList; import pcgen.cdom.content.KnownSpellIdentifier; diff --git a/code/src/java/pcgen/core/kit/KitStat.java b/code/src/java/pcgen/core/kit/KitStat.java index c1bd12a2c49..beeaecbdf90 100644 --- a/code/src/java/pcgen/core/kit/KitStat.java +++ b/code/src/java/pcgen/core/kit/KitStat.java @@ -24,7 +24,7 @@ import java.util.Set; import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.StringUtil; import pcgen.cdom.base.Constants; import pcgen.cdom.reference.CDOMSingleRef; diff --git a/code/src/java/pcgen/core/kit/KitTable.java b/code/src/java/pcgen/core/kit/KitTable.java index a42a78ce07f..56c9f2296a8 100644 --- a/code/src/java/pcgen/core/kit/KitTable.java +++ b/code/src/java/pcgen/core/kit/KitTable.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.core.Kit; import pcgen.core.PlayerCharacter; diff --git a/code/src/java/pcgen/gui2/facade/Gui2InfoFactory.java b/code/src/java/pcgen/gui2/facade/Gui2InfoFactory.java index 90bf6346875..fa73a9e57c4 100644 --- a/code/src/java/pcgen/gui2/facade/Gui2InfoFactory.java +++ b/code/src/java/pcgen/gui2/facade/Gui2InfoFactory.java @@ -33,7 +33,7 @@ import java.util.TreeMap; import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.StringUtil; import pcgen.base.util.Indirect; import pcgen.cdom.base.CDOMObject; diff --git a/code/src/java/pcgen/rules/context/AbstractObjectContext.java b/code/src/java/pcgen/rules/context/AbstractObjectContext.java index 54f225023e0..47af1f00227 100644 --- a/code/src/java/pcgen/rules/context/AbstractObjectContext.java +++ b/code/src/java/pcgen/rules/context/AbstractObjectContext.java @@ -23,7 +23,7 @@ import java.util.Objects; import java.util.Set; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.util.DoubleKeyMap; import pcgen.base.util.DoubleKeyMapToList; import pcgen.base.util.HashMapToList; diff --git a/code/src/java/pcgen/rules/context/ConsolidatedObjectCommitStrategy.java b/code/src/java/pcgen/rules/context/ConsolidatedObjectCommitStrategy.java index d8b8b862e4e..ac993a454d5 100644 --- a/code/src/java/pcgen/rules/context/ConsolidatedObjectCommitStrategy.java +++ b/code/src/java/pcgen/rules/context/ConsolidatedObjectCommitStrategy.java @@ -22,7 +22,7 @@ import java.util.Set; import java.util.regex.Pattern; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.util.Indirect; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.ConcretePrereqObject; diff --git a/code/src/java/pcgen/rules/context/ObjectCommitStrategy.java b/code/src/java/pcgen/rules/context/ObjectCommitStrategy.java index b017e8a2c7f..1919caed918 100644 --- a/code/src/java/pcgen/rules/context/ObjectCommitStrategy.java +++ b/code/src/java/pcgen/rules/context/ObjectCommitStrategy.java @@ -20,7 +20,7 @@ import java.net.URI; import java.util.Set; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.util.Indirect; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.ConcretePrereqObject; diff --git a/code/src/java/pcgen/rules/context/VariableContext.java b/code/src/java/pcgen/rules/context/VariableContext.java index 87964217848..b3962fe5842 100644 --- a/code/src/java/pcgen/rules/context/VariableContext.java +++ b/code/src/java/pcgen/rules/context/VariableContext.java @@ -23,8 +23,8 @@ import java.util.Optional; import java.util.function.Supplier; -import pcgen.base.calculation.FormulaModifier; -import pcgen.base.calculation.IgnoreVariables; +import pcgen.cdom.calculation.FormulaModifier; +import pcgen.cdom.calculation.IgnoreVariables; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.FormulaFunction; import pcgen.base.formula.base.FormulaManager; diff --git a/code/src/java/pcgen/rules/persistence/token/AbstractFixedSetModifierFactory.java b/code/src/java/pcgen/rules/persistence/token/AbstractFixedSetModifierFactory.java index c71890ede26..f3fb1a8de2d 100644 --- a/code/src/java/pcgen/rules/persistence/token/AbstractFixedSetModifierFactory.java +++ b/code/src/java/pcgen/rules/persistence/token/AbstractFixedSetModifierFactory.java @@ -15,7 +15,7 @@ */ package pcgen.rules.persistence.token; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.util.FormatManager; /** diff --git a/code/src/java/pcgen/rules/persistence/token/AbstractNumberModifierFactory.java b/code/src/java/pcgen/rules/persistence/token/AbstractNumberModifierFactory.java index 7dc06e45fba..7ad98e0aed0 100644 --- a/code/src/java/pcgen/rules/persistence/token/AbstractNumberModifierFactory.java +++ b/code/src/java/pcgen/rules/persistence/token/AbstractNumberModifierFactory.java @@ -17,11 +17,11 @@ */ package pcgen.rules.persistence.token; -import pcgen.base.calculation.BasicCalculation; -import pcgen.base.calculation.CalculationModifier; -import pcgen.base.calculation.FormulaCalculation; -import pcgen.base.calculation.FormulaModifier; -import pcgen.base.calculation.NEPCalculation; +import pcgen.cdom.calculation.BasicCalculation; +import pcgen.cdom.calculation.CalculationModifier; +import pcgen.cdom.calculation.FormulaCalculation; +import pcgen.cdom.calculation.FormulaModifier; +import pcgen.cdom.calculation.NEPCalculation; import pcgen.base.formula.inst.NEPFormula; import pcgen.base.util.FormatManager; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/pcgen/rules/persistence/token/AbstractRestrictedSpellPrimitive.java b/code/src/java/pcgen/rules/persistence/token/AbstractRestrictedSpellPrimitive.java index 01d9c3c327d..84234bdad85 100644 --- a/code/src/java/pcgen/rules/persistence/token/AbstractRestrictedSpellPrimitive.java +++ b/code/src/java/pcgen/rules/persistence/token/AbstractRestrictedSpellPrimitive.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMList; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.Converter; diff --git a/code/src/java/pcgen/rules/persistence/token/AbstractSetModifierFactory.java b/code/src/java/pcgen/rules/persistence/token/AbstractSetModifierFactory.java index 48c2074f766..db0c265bace 100644 --- a/code/src/java/pcgen/rules/persistence/token/AbstractSetModifierFactory.java +++ b/code/src/java/pcgen/rules/persistence/token/AbstractSetModifierFactory.java @@ -17,10 +17,10 @@ */ package pcgen.rules.persistence.token; -import pcgen.base.calculation.BasicCalculation; -import pcgen.base.calculation.CalculationModifier; -import pcgen.base.calculation.FormulaModifier; -import pcgen.base.calculation.NEPCalculation; +import pcgen.cdom.calculation.BasicCalculation; +import pcgen.cdom.calculation.CalculationModifier; +import pcgen.cdom.calculation.FormulaModifier; +import pcgen.cdom.calculation.NEPCalculation; import pcgen.base.util.FormatManager; import pcgen.cdom.content.ProcessCalculation; diff --git a/code/src/java/pcgen/rules/persistence/token/ModifierFactory.java b/code/src/java/pcgen/rules/persistence/token/ModifierFactory.java index fa690fdd674..77928346f00 100644 --- a/code/src/java/pcgen/rules/persistence/token/ModifierFactory.java +++ b/code/src/java/pcgen/rules/persistence/token/ModifierFactory.java @@ -17,7 +17,7 @@ */ package pcgen.rules.persistence.token; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.util.FormatManager; /** diff --git a/code/src/java/pcgen/util/NamedFormula.java b/code/src/java/pcgen/util/NamedFormula.java index f7301da55dc..c5c0ae6966f 100644 --- a/code/src/java/pcgen/util/NamedFormula.java +++ b/code/src/java/pcgen/util/NamedFormula.java @@ -17,7 +17,7 @@ */ package pcgen.util; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; /** * A NamedFormula is a String-Formula pair (similar to a Map.Entry). This is diff --git a/code/src/java/plugin/lsttokens/ChooseLst.java b/code/src/java/plugin/lsttokens/ChooseLst.java index 1875ba55f40..b98905fc35b 100644 --- a/code/src/java/plugin/lsttokens/ChooseLst.java +++ b/code/src/java/plugin/lsttokens/ChooseLst.java @@ -19,7 +19,7 @@ import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.ChooseInformation; import pcgen.cdom.base.ChooseSelectionActor; diff --git a/code/src/java/plugin/lsttokens/DefineLst.java b/code/src/java/plugin/lsttokens/DefineLst.java index 401db49207d..596874dd809 100644 --- a/code/src/java/plugin/lsttokens/DefineLst.java +++ b/code/src/java/plugin/lsttokens/DefineLst.java @@ -20,7 +20,7 @@ import java.util.Set; import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.Constants; diff --git a/code/src/java/plugin/lsttokens/DefineStatLst.java b/code/src/java/plugin/lsttokens/DefineStatLst.java index bcc1d2ddc7d..e90179d4da6 100644 --- a/code/src/java/plugin/lsttokens/DefineStatLst.java +++ b/code/src/java/plugin/lsttokens/DefineStatLst.java @@ -19,7 +19,7 @@ import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.Constants; diff --git a/code/src/java/plugin/lsttokens/DrLst.java b/code/src/java/plugin/lsttokens/DrLst.java index 57534bb49e7..de738ba93b4 100644 --- a/code/src/java/plugin/lsttokens/DrLst.java +++ b/code/src/java/plugin/lsttokens/DrLst.java @@ -24,7 +24,7 @@ import java.util.StringTokenizer; import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.Constants; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/plugin/lsttokens/FollowersLst.java b/code/src/java/plugin/lsttokens/FollowersLst.java index aae77907654..e7afa64459b 100644 --- a/code/src/java/plugin/lsttokens/FollowersLst.java +++ b/code/src/java/plugin/lsttokens/FollowersLst.java @@ -21,7 +21,7 @@ import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.Constants; diff --git a/code/src/java/plugin/lsttokens/KitLst.java b/code/src/java/plugin/lsttokens/KitLst.java index 671e53c2f81..dad959d6cb4 100644 --- a/code/src/java/plugin/lsttokens/KitLst.java +++ b/code/src/java/plugin/lsttokens/KitLst.java @@ -24,7 +24,7 @@ import java.util.StringTokenizer; import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.ChoiceActor; diff --git a/code/src/java/plugin/lsttokens/ModifyLst.java b/code/src/java/plugin/lsttokens/ModifyLst.java index 0617ee5e0f8..3419da3d75a 100644 --- a/code/src/java/plugin/lsttokens/ModifyLst.java +++ b/code/src/java/plugin/lsttokens/ModifyLst.java @@ -24,7 +24,7 @@ import java.util.Optional; import java.util.Set; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.FormulaManager; import pcgen.base.formula.base.FunctionLibrary; import pcgen.base.lang.StringUtil; diff --git a/code/src/java/plugin/lsttokens/NaturalattacksLst.java b/code/src/java/plugin/lsttokens/NaturalattacksLst.java index 1a8ae23b722..cb0ec15bf4d 100644 --- a/code/src/java/plugin/lsttokens/NaturalattacksLst.java +++ b/code/src/java/plugin/lsttokens/NaturalattacksLst.java @@ -24,7 +24,7 @@ import java.util.Set; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.StringUtil; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.Constants; diff --git a/code/src/java/plugin/lsttokens/SelectLst.java b/code/src/java/plugin/lsttokens/SelectLst.java index 179ff6bdbc3..d698f3b9568 100644 --- a/code/src/java/plugin/lsttokens/SelectLst.java +++ b/code/src/java/plugin/lsttokens/SelectLst.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.base.Ungranted; diff --git a/code/src/java/plugin/lsttokens/SpellsLst.java b/code/src/java/plugin/lsttokens/SpellsLst.java index b5044c42c92..230c7322a33 100644 --- a/code/src/java/plugin/lsttokens/SpellsLst.java +++ b/code/src/java/plugin/lsttokens/SpellsLst.java @@ -27,7 +27,7 @@ import java.util.Set; import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.StringUtil; import pcgen.base.text.ParsingSeparator; import pcgen.base.util.DoubleKeyMap; diff --git a/code/src/java/plugin/lsttokens/SrLst.java b/code/src/java/plugin/lsttokens/SrLst.java index 4389c868574..5f8b6f1bfd5 100644 --- a/code/src/java/plugin/lsttokens/SrLst.java +++ b/code/src/java/plugin/lsttokens/SrLst.java @@ -20,7 +20,7 @@ import java.util.LinkedList; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.Constants; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/plugin/lsttokens/add/AbilityToken.java b/code/src/java/plugin/lsttokens/add/AbilityToken.java index 5f9a2807d20..8c165b0ea7b 100644 --- a/code/src/java/plugin/lsttokens/add/AbilityToken.java +++ b/code/src/java/plugin/lsttokens/add/AbilityToken.java @@ -22,7 +22,7 @@ import java.util.Collection; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; diff --git a/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java b/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java index 86c04cb7aef..061339ffae2 100644 --- a/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java +++ b/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.ChoiceSet; diff --git a/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java b/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java index c1e4ec1cb95..5835b47ff8e 100644 --- a/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java +++ b/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.ChoiceSet; diff --git a/code/src/java/plugin/lsttokens/add/EquipToken.java b/code/src/java/plugin/lsttokens/add/EquipToken.java index a635b705fa3..4aa05684eef 100644 --- a/code/src/java/plugin/lsttokens/add/EquipToken.java +++ b/code/src/java/plugin/lsttokens/add/EquipToken.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; diff --git a/code/src/java/plugin/lsttokens/add/LanguageToken.java b/code/src/java/plugin/lsttokens/add/LanguageToken.java index 565af9492a5..c80e7d19cc9 100644 --- a/code/src/java/plugin/lsttokens/add/LanguageToken.java +++ b/code/src/java/plugin/lsttokens/add/LanguageToken.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; diff --git a/code/src/java/plugin/lsttokens/add/SkillToken.java b/code/src/java/plugin/lsttokens/add/SkillToken.java index 171ab5c6a06..52f6add0524 100644 --- a/code/src/java/plugin/lsttokens/add/SkillToken.java +++ b/code/src/java/plugin/lsttokens/add/SkillToken.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; diff --git a/code/src/java/plugin/lsttokens/add/SpellCasterToken.java b/code/src/java/plugin/lsttokens/add/SpellCasterToken.java index b42833c3822..a3844275219 100644 --- a/code/src/java/plugin/lsttokens/add/SpellCasterToken.java +++ b/code/src/java/plugin/lsttokens/add/SpellCasterToken.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; diff --git a/code/src/java/plugin/lsttokens/add/TemplateToken.java b/code/src/java/plugin/lsttokens/add/TemplateToken.java index 28efc687a55..a427d976b72 100644 --- a/code/src/java/plugin/lsttokens/add/TemplateToken.java +++ b/code/src/java/plugin/lsttokens/add/TemplateToken.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; diff --git a/code/src/java/plugin/lsttokens/choose/SpellLevelToken.java b/code/src/java/plugin/lsttokens/choose/SpellLevelToken.java index 52050d311cb..e65f71316a6 100644 --- a/code/src/java/plugin/lsttokens/choose/SpellLevelToken.java +++ b/code/src/java/plugin/lsttokens/choose/SpellLevelToken.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.ChooseDriver; diff --git a/code/src/java/plugin/lsttokens/choose/UserInputToken.java b/code/src/java/plugin/lsttokens/choose/UserInputToken.java index 426c166235e..e5315be3a7b 100644 --- a/code/src/java/plugin/lsttokens/choose/UserInputToken.java +++ b/code/src/java/plugin/lsttokens/choose/UserInputToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.choose; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.ChooseInformation; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/plugin/lsttokens/deprecated/AddFeatToken.java b/code/src/java/plugin/lsttokens/deprecated/AddFeatToken.java index 304ba280ae4..7c50eafbeeb 100644 --- a/code/src/java/plugin/lsttokens/deprecated/AddFeatToken.java +++ b/code/src/java/plugin/lsttokens/deprecated/AddFeatToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.deprecated; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/plugin/lsttokens/deprecated/AddVFeatToken.java b/code/src/java/plugin/lsttokens/deprecated/AddVFeatToken.java index 24fc2529233..cbe3a826d71 100644 --- a/code/src/java/plugin/lsttokens/deprecated/AddVFeatToken.java +++ b/code/src/java/plugin/lsttokens/deprecated/AddVFeatToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.deprecated; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/plugin/lsttokens/deprecated/RemoveFeatToken.java b/code/src/java/plugin/lsttokens/deprecated/RemoveFeatToken.java index 221dc817a86..053d08e93f2 100644 --- a/code/src/java/plugin/lsttokens/deprecated/RemoveFeatToken.java +++ b/code/src/java/plugin/lsttokens/deprecated/RemoveFeatToken.java @@ -22,7 +22,7 @@ import java.util.Collection; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMObjectUtilities; diff --git a/code/src/java/plugin/lsttokens/equipment/PageUsageToken.java b/code/src/java/plugin/lsttokens/equipment/PageUsageToken.java index 993e5f8a023..0c88900f7f5 100644 --- a/code/src/java/plugin/lsttokens/equipment/PageUsageToken.java +++ b/code/src/java/plugin/lsttokens/equipment/PageUsageToken.java @@ -18,7 +18,7 @@ */ package plugin.lsttokens.equipment; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; import pcgen.core.Equipment; diff --git a/code/src/java/plugin/lsttokens/equipmentmodifier/CostToken.java b/code/src/java/plugin/lsttokens/equipmentmodifier/CostToken.java index bd438118b8b..bae40275c32 100644 --- a/code/src/java/plugin/lsttokens/equipmentmodifier/CostToken.java +++ b/code/src/java/plugin/lsttokens/equipmentmodifier/CostToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.equipmentmodifier; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; import pcgen.core.EquipmentModifier; diff --git a/code/src/java/plugin/lsttokens/equipmentmodifier/CostpreToken.java b/code/src/java/plugin/lsttokens/equipmentmodifier/CostpreToken.java index c832b1fa507..8ec00e6c1b8 100644 --- a/code/src/java/plugin/lsttokens/equipmentmodifier/CostpreToken.java +++ b/code/src/java/plugin/lsttokens/equipmentmodifier/CostpreToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.equipmentmodifier; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; import pcgen.core.EquipmentModifier; diff --git a/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PoolToken.java b/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PoolToken.java index 447694d5fbb..23aeaeac3bb 100644 --- a/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PoolToken.java +++ b/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PoolToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.gamemode.abilitycategory; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.core.AbilityCategory; import pcgen.rules.context.LoadContext; diff --git a/code/src/java/plugin/lsttokens/gamemode/ageset/KitToken.java b/code/src/java/plugin/lsttokens/gamemode/ageset/KitToken.java index 1a488a6359b..2340b6dbd6c 100644 --- a/code/src/java/plugin/lsttokens/gamemode/ageset/KitToken.java +++ b/code/src/java/plugin/lsttokens/gamemode/ageset/KitToken.java @@ -23,7 +23,7 @@ import java.util.StringTokenizer; import java.util.TreeSet; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.ChoiceActor; diff --git a/code/src/java/plugin/lsttokens/kit/SelectToken.java b/code/src/java/plugin/lsttokens/kit/SelectToken.java index 292d20b92af..81c9aee9ebd 100644 --- a/code/src/java/plugin/lsttokens/kit/SelectToken.java +++ b/code/src/java/plugin/lsttokens/kit/SelectToken.java @@ -18,7 +18,7 @@ package plugin.lsttokens.kit; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.core.kit.KitSelect; import pcgen.rules.context.LoadContext; diff --git a/code/src/java/plugin/lsttokens/kit/StatToken.java b/code/src/java/plugin/lsttokens/kit/StatToken.java index cb20fcfc2a4..d859740f61c 100644 --- a/code/src/java/plugin/lsttokens/kit/StatToken.java +++ b/code/src/java/plugin/lsttokens/kit/StatToken.java @@ -20,7 +20,7 @@ import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.Constants; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.ListKey; diff --git a/code/src/java/plugin/lsttokens/kit/basekit/LookupToken.java b/code/src/java/plugin/lsttokens/kit/basekit/LookupToken.java index 94aa36ef6c2..33bebbccfb9 100644 --- a/code/src/java/plugin/lsttokens/kit/basekit/LookupToken.java +++ b/code/src/java/plugin/lsttokens/kit/basekit/LookupToken.java @@ -22,7 +22,7 @@ import java.util.Collection; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.util.NamedFormula; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/plugin/lsttokens/kit/basekit/OptionToken.java b/code/src/java/plugin/lsttokens/kit/basekit/OptionToken.java index 83b0bf36cd1..ce2f19e24af 100644 --- a/code/src/java/plugin/lsttokens/kit/basekit/OptionToken.java +++ b/code/src/java/plugin/lsttokens/kit/basekit/OptionToken.java @@ -22,7 +22,7 @@ import java.util.Collection; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.StringUtil; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.Constants; diff --git a/code/src/java/plugin/lsttokens/kit/clazz/LevelToken.java b/code/src/java/plugin/lsttokens/kit/clazz/LevelToken.java index 83b0188b6c5..faab25f5a79 100644 --- a/code/src/java/plugin/lsttokens/kit/clazz/LevelToken.java +++ b/code/src/java/plugin/lsttokens/kit/clazz/LevelToken.java @@ -18,7 +18,7 @@ package plugin.lsttokens.kit.clazz; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.core.kit.KitClass; import pcgen.rules.context.LoadContext; diff --git a/code/src/java/plugin/lsttokens/kit/deity/CountToken.java b/code/src/java/plugin/lsttokens/kit/deity/CountToken.java index 655ee9a65f8..2d0f7658597 100644 --- a/code/src/java/plugin/lsttokens/kit/deity/CountToken.java +++ b/code/src/java/plugin/lsttokens/kit/deity/CountToken.java @@ -18,7 +18,7 @@ package plugin.lsttokens.kit.deity; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.core.kit.KitDeity; import pcgen.rules.context.LoadContext; diff --git a/code/src/java/plugin/lsttokens/kit/funds/QtyToken.java b/code/src/java/plugin/lsttokens/kit/funds/QtyToken.java index 4e8b68c6e36..9de10fb61bb 100644 --- a/code/src/java/plugin/lsttokens/kit/funds/QtyToken.java +++ b/code/src/java/plugin/lsttokens/kit/funds/QtyToken.java @@ -18,7 +18,7 @@ package plugin.lsttokens.kit.funds; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.core.kit.KitFunds; import pcgen.rules.context.LoadContext; diff --git a/code/src/java/plugin/lsttokens/kit/gear/QtyToken.java b/code/src/java/plugin/lsttokens/kit/gear/QtyToken.java index 2fce80f4544..f9773d2f54e 100644 --- a/code/src/java/plugin/lsttokens/kit/gear/QtyToken.java +++ b/code/src/java/plugin/lsttokens/kit/gear/QtyToken.java @@ -18,7 +18,7 @@ package plugin.lsttokens.kit.gear; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.core.kit.KitGear; import pcgen.rules.context.LoadContext; diff --git a/code/src/java/plugin/lsttokens/kit/spells/CountToken.java b/code/src/java/plugin/lsttokens/kit/spells/CountToken.java index f93ac61e8f0..21557b0cdf2 100644 --- a/code/src/java/plugin/lsttokens/kit/spells/CountToken.java +++ b/code/src/java/plugin/lsttokens/kit/spells/CountToken.java @@ -18,7 +18,7 @@ package plugin.lsttokens.kit.spells; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.core.kit.KitSpells; import pcgen.rules.context.LoadContext; diff --git a/code/src/java/plugin/lsttokens/kit/startpack/EquipBuyToken.java b/code/src/java/plugin/lsttokens/kit/startpack/EquipBuyToken.java index 2ee601b9bf9..5dcbc0e7ab1 100644 --- a/code/src/java/plugin/lsttokens/kit/startpack/EquipBuyToken.java +++ b/code/src/java/plugin/lsttokens/kit/startpack/EquipBuyToken.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.Constants; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/plugin/lsttokens/kit/startpack/TotalCostToken.java b/code/src/java/plugin/lsttokens/kit/startpack/TotalCostToken.java index ae5c2ff3f0d..eda15f950f1 100644 --- a/code/src/java/plugin/lsttokens/kit/startpack/TotalCostToken.java +++ b/code/src/java/plugin/lsttokens/kit/startpack/TotalCostToken.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.Constants; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/plugin/lsttokens/kit/table/ValuesToken.java b/code/src/java/plugin/lsttokens/kit/table/ValuesToken.java index 165124aa294..5695a010c7a 100644 --- a/code/src/java/plugin/lsttokens/kit/table/ValuesToken.java +++ b/code/src/java/plugin/lsttokens/kit/table/ValuesToken.java @@ -21,7 +21,7 @@ import java.util.Collection; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.Constants; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/plugin/lsttokens/pcclass/CrformulaToken.java b/code/src/java/plugin/lsttokens/pcclass/CrformulaToken.java index 9f3c3203892..ec650c3e1b0 100644 --- a/code/src/java/plugin/lsttokens/pcclass/CrformulaToken.java +++ b/code/src/java/plugin/lsttokens/pcclass/CrformulaToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.pcclass; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; import pcgen.core.PCClass; diff --git a/code/src/java/plugin/lsttokens/pcclass/SkilllistToken.java b/code/src/java/plugin/lsttokens/pcclass/SkilllistToken.java index b0d275957aa..6936a35ddca 100644 --- a/code/src/java/plugin/lsttokens/pcclass/SkilllistToken.java +++ b/code/src/java/plugin/lsttokens/pcclass/SkilllistToken.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.ChoiceSet; import pcgen.cdom.base.ConcreteTransitionChoice; diff --git a/code/src/java/plugin/lsttokens/pcclass/SpelllistToken.java b/code/src/java/plugin/lsttokens/pcclass/SpelllistToken.java index ef883956828..dda3542ea96 100644 --- a/code/src/java/plugin/lsttokens/pcclass/SpelllistToken.java +++ b/code/src/java/plugin/lsttokens/pcclass/SpelllistToken.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.StringTokenizer; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMListObject; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.ChoiceSet; diff --git a/code/src/java/plugin/lsttokens/pcclass/StartskillptsToken.java b/code/src/java/plugin/lsttokens/pcclass/StartskillptsToken.java index 0849f36d403..d91164b5170 100644 --- a/code/src/java/plugin/lsttokens/pcclass/StartskillptsToken.java +++ b/code/src/java/plugin/lsttokens/pcclass/StartskillptsToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.pcclass; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; import pcgen.core.PCClass; diff --git a/code/src/java/plugin/lsttokens/pcclass/level/CastToken.java b/code/src/java/plugin/lsttokens/pcclass/level/CastToken.java index ba279d42a62..a472d953432 100644 --- a/code/src/java/plugin/lsttokens/pcclass/level/CastToken.java +++ b/code/src/java/plugin/lsttokens/pcclass/level/CastToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.pcclass.level; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.StringUtil; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.Constants; diff --git a/code/src/java/plugin/lsttokens/pcclass/level/KnownToken.java b/code/src/java/plugin/lsttokens/pcclass/level/KnownToken.java index 946be0e4664..54013452898 100644 --- a/code/src/java/plugin/lsttokens/pcclass/level/KnownToken.java +++ b/code/src/java/plugin/lsttokens/pcclass/level/KnownToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.pcclass.level; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.StringUtil; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.Constants; diff --git a/code/src/java/plugin/lsttokens/pcclass/level/SpecialtyknownToken.java b/code/src/java/plugin/lsttokens/pcclass/level/SpecialtyknownToken.java index 978d4d8ef0c..93fc9a595d1 100644 --- a/code/src/java/plugin/lsttokens/pcclass/level/SpecialtyknownToken.java +++ b/code/src/java/plugin/lsttokens/pcclass/level/SpecialtyknownToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.pcclass.level; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.lang.StringUtil; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.Constants; diff --git a/code/src/java/plugin/lsttokens/race/CrToken.java b/code/src/java/plugin/lsttokens/race/CrToken.java index 4a9746c0bff..d9519627cf3 100644 --- a/code/src/java/plugin/lsttokens/race/CrToken.java +++ b/code/src/java/plugin/lsttokens/race/CrToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.race; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.content.ChallengeRating; import pcgen.cdom.enumeration.FormulaKey; diff --git a/code/src/java/plugin/lsttokens/race/FaceToken.java b/code/src/java/plugin/lsttokens/race/FaceToken.java index 89048bc6576..107f131b69c 100644 --- a/code/src/java/plugin/lsttokens/race/FaceToken.java +++ b/code/src/java/plugin/lsttokens/race/FaceToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.race; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.math.OrderedPair; import pcgen.base.util.FormatManager; import pcgen.cdom.base.LimitedVarContainer; diff --git a/code/src/java/plugin/lsttokens/race/LeveladjustmentToken.java b/code/src/java/plugin/lsttokens/race/LeveladjustmentToken.java index e5ae5221101..c3881ce16a8 100644 --- a/code/src/java/plugin/lsttokens/race/LeveladjustmentToken.java +++ b/code/src/java/plugin/lsttokens/race/LeveladjustmentToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.race; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; import pcgen.core.Race; diff --git a/code/src/java/plugin/lsttokens/race/SizeToken.java b/code/src/java/plugin/lsttokens/race/SizeToken.java index 2884abdb114..bee37fe2763 100644 --- a/code/src/java/plugin/lsttokens/race/SizeToken.java +++ b/code/src/java/plugin/lsttokens/race/SizeToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.race; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.FormulaKey; import pcgen.cdom.formula.FixedSizeFormula; import pcgen.cdom.reference.CDOMSingleRef; diff --git a/code/src/java/plugin/lsttokens/race/XtraskillptsperlvlToken.java b/code/src/java/plugin/lsttokens/race/XtraskillptsperlvlToken.java index 442890668b2..309fb6b2d36 100644 --- a/code/src/java/plugin/lsttokens/race/XtraskillptsperlvlToken.java +++ b/code/src/java/plugin/lsttokens/race/XtraskillptsperlvlToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.race; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; import pcgen.core.Race; diff --git a/code/src/java/plugin/lsttokens/statsandchecks/stat/StatmodToken.java b/code/src/java/plugin/lsttokens/statsandchecks/stat/StatmodToken.java index add230a1111..da70d410d59 100644 --- a/code/src/java/plugin/lsttokens/statsandchecks/stat/StatmodToken.java +++ b/code/src/java/plugin/lsttokens/statsandchecks/stat/StatmodToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.statsandchecks.stat; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; import pcgen.core.PCStat; diff --git a/code/src/java/plugin/lsttokens/template/AddLevelToken.java b/code/src/java/plugin/lsttokens/template/AddLevelToken.java index 19c08ed0f3d..2336632cd30 100644 --- a/code/src/java/plugin/lsttokens/template/AddLevelToken.java +++ b/code/src/java/plugin/lsttokens/template/AddLevelToken.java @@ -21,7 +21,7 @@ import java.util.Collection; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.base.text.ParsingSeparator; import pcgen.cdom.base.Constants; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/plugin/lsttokens/template/LeveladjustmentToken.java b/code/src/java/plugin/lsttokens/template/LeveladjustmentToken.java index f2f60510e54..82499d69738 100644 --- a/code/src/java/plugin/lsttokens/template/LeveladjustmentToken.java +++ b/code/src/java/plugin/lsttokens/template/LeveladjustmentToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.template; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; import pcgen.core.PCTemplate; diff --git a/code/src/java/plugin/lsttokens/template/SizeToken.java b/code/src/java/plugin/lsttokens/template/SizeToken.java index eb1feda9971..e92a2c5e27b 100644 --- a/code/src/java/plugin/lsttokens/template/SizeToken.java +++ b/code/src/java/plugin/lsttokens/template/SizeToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.template; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; import pcgen.cdom.enumeration.StringKey; diff --git a/code/src/java/plugin/modifier/cdom/SetModifierFactory.java b/code/src/java/plugin/modifier/cdom/SetModifierFactory.java index eeb8aef1c79..d260ef1522f 100644 --- a/code/src/java/plugin/modifier/cdom/SetModifierFactory.java +++ b/code/src/java/plugin/modifier/cdom/SetModifierFactory.java @@ -17,10 +17,10 @@ */ package plugin.modifier.cdom; -import pcgen.base.calculation.CalculationModifier; -import pcgen.base.calculation.FormulaCalculation; -import pcgen.base.calculation.FormulaModifier; -import pcgen.base.calculation.NEPCalculation; +import pcgen.cdom.calculation.CalculationModifier; +import pcgen.cdom.calculation.FormulaCalculation; +import pcgen.cdom.calculation.FormulaModifier; +import pcgen.cdom.calculation.NEPCalculation; import pcgen.base.formula.inst.NEPFormula; import pcgen.base.util.FormatManager; import pcgen.cdom.base.CDOMObject; diff --git a/code/src/java/plugin/modifier/dynamic/SetModifierFactory.java b/code/src/java/plugin/modifier/dynamic/SetModifierFactory.java index c65c7ca4772..189e5ed0a82 100644 --- a/code/src/java/plugin/modifier/dynamic/SetModifierFactory.java +++ b/code/src/java/plugin/modifier/dynamic/SetModifierFactory.java @@ -17,9 +17,9 @@ */ package plugin.modifier.dynamic; -import pcgen.base.calculation.CalculationModifier; -import pcgen.base.calculation.FormulaModifier; -import pcgen.base.calculation.NEPCalculation; +import pcgen.cdom.calculation.CalculationModifier; +import pcgen.cdom.calculation.FormulaModifier; +import pcgen.cdom.calculation.NEPCalculation; import pcgen.base.util.FormatManager; import pcgen.base.util.Indirect; import pcgen.cdom.content.IndirectCalculation; diff --git a/code/src/java/plugin/modifier/number/SetModifierFactory.java b/code/src/java/plugin/modifier/number/SetModifierFactory.java index 040b81cab7c..5c48a9e7272 100644 --- a/code/src/java/plugin/modifier/number/SetModifierFactory.java +++ b/code/src/java/plugin/modifier/number/SetModifierFactory.java @@ -17,10 +17,10 @@ */ package plugin.modifier.number; -import pcgen.base.calculation.CalculationModifier; -import pcgen.base.calculation.FormulaCalculation; -import pcgen.base.calculation.FormulaModifier; -import pcgen.base.calculation.NEPCalculation; +import pcgen.cdom.calculation.CalculationModifier; +import pcgen.cdom.calculation.FormulaCalculation; +import pcgen.cdom.calculation.FormulaModifier; +import pcgen.cdom.calculation.NEPCalculation; import pcgen.base.formula.inst.NEPFormula; import pcgen.base.util.FormatManager; import pcgen.cdom.base.FormulaFactory; diff --git a/code/src/java/plugin/modifier/set/AddModifierFactory.java b/code/src/java/plugin/modifier/set/AddModifierFactory.java index 983cf4b57d0..527ac9d0fe9 100644 --- a/code/src/java/plugin/modifier/set/AddModifierFactory.java +++ b/code/src/java/plugin/modifier/set/AddModifierFactory.java @@ -22,8 +22,8 @@ import java.util.HashSet; import java.util.Set; -import pcgen.base.calculation.AbstractPCGenModifier; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.AbstractPCGenModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; import pcgen.base.formula.base.FormulaSemantics; diff --git a/code/src/java/plugin/modifier/set/SetModifierFactory.java b/code/src/java/plugin/modifier/set/SetModifierFactory.java index 3d0f1eac3c0..3978225de56 100644 --- a/code/src/java/plugin/modifier/set/SetModifierFactory.java +++ b/code/src/java/plugin/modifier/set/SetModifierFactory.java @@ -17,8 +17,8 @@ */ package plugin.modifier.set; -import pcgen.base.calculation.AbstractPCGenModifier; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.AbstractPCGenModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; import pcgen.base.formula.base.FormulaSemantics; diff --git a/code/src/java/plugin/primitive/race/BaseSizeToken.java b/code/src/java/plugin/primitive/race/BaseSizeToken.java index ebde0dcb46d..3852d7e512b 100644 --- a/code/src/java/plugin/primitive/race/BaseSizeToken.java +++ b/code/src/java/plugin/primitive/race/BaseSizeToken.java @@ -19,7 +19,7 @@ import java.util.Collection; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.Converter; import pcgen.cdom.base.PrimitiveFilter; diff --git a/code/src/test/pcgen/core/SpellProgressionCacheTest.java b/code/src/test/pcgen/core/SpellProgressionCacheTest.java index d79813cbdaf..98202cbe6d4 100644 --- a/code/src/test/pcgen/core/SpellProgressionCacheTest.java +++ b/code/src/test/pcgen/core/SpellProgressionCacheTest.java @@ -9,7 +9,7 @@ import java.util.ArrayList; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import org.junit.jupiter.api.AfterEach; diff --git a/code/src/utest/pcgen/base/solver/SetSolverManagerTest.java b/code/src/utest/pcgen/base/solver/SetSolverManagerTest.java index 57030f2722c..20e7db0111e 100644 --- a/code/src/utest/pcgen/base/solver/SetSolverManagerTest.java +++ b/code/src/utest/pcgen/base/solver/SetSolverManagerTest.java @@ -24,10 +24,10 @@ import java.util.Objects; import java.util.Optional; -import pcgen.base.calculation.BasicCalculation; -import pcgen.base.calculation.CalculationModifier; -import pcgen.base.calculation.FormulaModifier; -import pcgen.base.calculation.NEPCalculation; +import pcgen.cdom.calculation.BasicCalculation; +import pcgen.cdom.calculation.CalculationModifier; +import pcgen.cdom.calculation.FormulaModifier; +import pcgen.cdom.calculation.NEPCalculation; import pcgen.base.format.ArrayFormatManager; import pcgen.base.formatmanager.FormatUtilities; import pcgen.base.formula.base.DependencyManager; diff --git a/code/src/utest/pcgen/cdom/facet/analysis/CharacterSpellResistanceFacetTest.java b/code/src/utest/pcgen/cdom/facet/analysis/CharacterSpellResistanceFacetTest.java index 6774f220de7..9bcc271dbc3 100644 --- a/code/src/utest/pcgen/cdom/facet/analysis/CharacterSpellResistanceFacetTest.java +++ b/code/src/utest/pcgen/cdom/facet/analysis/CharacterSpellResistanceFacetTest.java @@ -17,7 +17,7 @@ */ package pcgen.cdom.facet.analysis; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.content.SpellResistance; diff --git a/code/src/utest/pcgen/cdom/formula/testsupport/AbstractModifier.java b/code/src/utest/pcgen/cdom/formula/testsupport/AbstractModifier.java index 87098a45929..fc0bf40aa4b 100644 --- a/code/src/utest/pcgen/cdom/formula/testsupport/AbstractModifier.java +++ b/code/src/utest/pcgen/cdom/formula/testsupport/AbstractModifier.java @@ -20,10 +20,10 @@ import java.lang.reflect.Array; import pcgen.TestConstants; -import pcgen.base.calculation.CalculationModifier; -import pcgen.base.calculation.FormulaCalculation; -import pcgen.base.calculation.FormulaModifier; -import pcgen.base.calculation.NEPCalculation; +import pcgen.cdom.calculation.CalculationModifier; +import pcgen.cdom.calculation.FormulaCalculation; +import pcgen.cdom.calculation.FormulaModifier; +import pcgen.cdom.calculation.NEPCalculation; import pcgen.base.formatmanager.FormatUtilities; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; diff --git a/code/src/utest/plugin/lsttokens/SrLstTest.java b/code/src/utest/plugin/lsttokens/SrLstTest.java index 77252dd37ac..5208095a74f 100644 --- a/code/src/utest/plugin/lsttokens/SrLstTest.java +++ b/code/src/utest/plugin/lsttokens/SrLstTest.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.content.SpellResistance; import pcgen.cdom.enumeration.FormulaKey; diff --git a/code/src/utest/plugin/lsttokens/add/AbilityTokenTest.java b/code/src/utest/plugin/lsttokens/add/AbilityTokenTest.java index 51ef043ed34..af4219c54ff 100644 --- a/code/src/utest/plugin/lsttokens/add/AbilityTokenTest.java +++ b/code/src/utest/plugin/lsttokens/add/AbilityTokenTest.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.ChoiceSet.AbilityChoiceSet; diff --git a/code/src/utest/plugin/lsttokens/kit/startpack/EquipBuyTokenTest.java b/code/src/utest/plugin/lsttokens/kit/startpack/EquipBuyTokenTest.java index bfed74db7ba..a686bbede87 100644 --- a/code/src/utest/plugin/lsttokens/kit/startpack/EquipBuyTokenTest.java +++ b/code/src/utest/plugin/lsttokens/kit/startpack/EquipBuyTokenTest.java @@ -21,7 +21,7 @@ import java.net.URISyntaxException; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.FormulaKey; import pcgen.cdom.enumeration.ObjectKey; import pcgen.core.Kit; diff --git a/code/src/utest/plugin/lsttokens/kit/startpack/TotalCostTokenTest.java b/code/src/utest/plugin/lsttokens/kit/startpack/TotalCostTokenTest.java index 5cd4b6429c4..5c2e4ab7c66 100644 --- a/code/src/utest/plugin/lsttokens/kit/startpack/TotalCostTokenTest.java +++ b/code/src/utest/plugin/lsttokens/kit/startpack/TotalCostTokenTest.java @@ -21,7 +21,7 @@ import java.net.URISyntaxException; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.FormulaKey; import pcgen.cdom.enumeration.ObjectKey; import pcgen.core.Kit; diff --git a/code/src/utest/plugin/lsttokens/pcclass/level/AbstractSpellCastingTokenTestCase.java b/code/src/utest/plugin/lsttokens/pcclass/level/AbstractSpellCastingTokenTestCase.java index 7ad8deae8b0..1337bf3da34 100644 --- a/code/src/utest/plugin/lsttokens/pcclass/level/AbstractSpellCastingTokenTestCase.java +++ b/code/src/utest/plugin/lsttokens/pcclass/level/AbstractSpellCastingTokenTestCase.java @@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.ListKey; import pcgen.persistence.PersistenceLayerException; diff --git a/code/src/utest/plugin/lsttokens/pcclass/level/CastTokenTest.java b/code/src/utest/plugin/lsttokens/pcclass/level/CastTokenTest.java index 2d648a23ffb..d3715c8aead 100644 --- a/code/src/utest/plugin/lsttokens/pcclass/level/CastTokenTest.java +++ b/code/src/utest/plugin/lsttokens/pcclass/level/CastTokenTest.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.pcclass.level; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.ListKey; import pcgen.cdom.inst.PCClassLevel; import pcgen.rules.persistence.token.CDOMPrimaryToken; diff --git a/code/src/utest/plugin/lsttokens/pcclass/level/KnownTokenTest.java b/code/src/utest/plugin/lsttokens/pcclass/level/KnownTokenTest.java index 6d5ce2d0da8..f6f206aaa9a 100644 --- a/code/src/utest/plugin/lsttokens/pcclass/level/KnownTokenTest.java +++ b/code/src/utest/plugin/lsttokens/pcclass/level/KnownTokenTest.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.pcclass.level; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.ListKey; import pcgen.cdom.inst.PCClassLevel; import pcgen.rules.persistence.token.CDOMPrimaryToken; diff --git a/code/src/utest/plugin/lsttokens/pcclass/level/SpecialtyKnownTokenTest.java b/code/src/utest/plugin/lsttokens/pcclass/level/SpecialtyKnownTokenTest.java index 0121eee950d..3a7c13f8618 100644 --- a/code/src/utest/plugin/lsttokens/pcclass/level/SpecialtyKnownTokenTest.java +++ b/code/src/utest/plugin/lsttokens/pcclass/level/SpecialtyKnownTokenTest.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.pcclass.level; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.ListKey; import pcgen.cdom.inst.PCClassLevel; import pcgen.rules.persistence.token.CDOMPrimaryToken; diff --git a/code/src/utest/plugin/lsttokens/testsupport/AbstractAddTokenTestCase.java b/code/src/utest/plugin/lsttokens/testsupport/AbstractAddTokenTestCase.java index 2bf77fad213..5e2288f465d 100644 --- a/code/src/utest/plugin/lsttokens/testsupport/AbstractAddTokenTestCase.java +++ b/code/src/utest/plugin/lsttokens/testsupport/AbstractAddTokenTestCase.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.List; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.ChoiceActor; diff --git a/code/src/utest/plugin/lsttokens/testsupport/AbstractFormulaTokenTestCase.java b/code/src/utest/plugin/lsttokens/testsupport/AbstractFormulaTokenTestCase.java index 0eb92486cc6..b111385e629 100644 --- a/code/src/utest/plugin/lsttokens/testsupport/AbstractFormulaTokenTestCase.java +++ b/code/src/utest/plugin/lsttokens/testsupport/AbstractFormulaTokenTestCase.java @@ -21,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; diff --git a/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalFormulaTokenTestCase.java b/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalFormulaTokenTestCase.java index fe08b948f2b..88eedb36c64 100644 --- a/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalFormulaTokenTestCase.java +++ b/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalFormulaTokenTestCase.java @@ -22,7 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import pcgen.base.formula.Formula; +import pcgen.cdom.formula.Formula; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.FormulaKey; import pcgen.persistence.PersistenceLayerException; diff --git a/code/src/utest/plugin/modifier/bool/SetBooleanModifierTest.java b/code/src/utest/plugin/modifier/bool/SetBooleanModifierTest.java index 2b995b4a31d..be8e6a2b6ec 100644 --- a/code/src/utest/plugin/modifier/bool/SetBooleanModifierTest.java +++ b/code/src/utest/plugin/modifier/bool/SetBooleanModifierTest.java @@ -20,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.format.BooleanManager; import pcgen.base.util.FormatManager; import pcgen.rules.persistence.token.ModifierFactory; diff --git a/code/src/utest/plugin/modifier/number/AddNumberModifierTest.java b/code/src/utest/plugin/modifier/number/AddNumberModifierTest.java index 49045fb1ba1..62fa364e6f1 100644 --- a/code/src/utest/plugin/modifier/number/AddNumberModifierTest.java +++ b/code/src/utest/plugin/modifier/number/AddNumberModifierTest.java @@ -20,8 +20,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -import pcgen.base.calculation.BasicCalculation; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.BasicCalculation; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.format.NumberManager; import pcgen.base.util.FormatManager; import pcgen.rules.persistence.token.ModifierFactory; diff --git a/code/src/utest/plugin/modifier/number/DivideNumberModifierTest.java b/code/src/utest/plugin/modifier/number/DivideNumberModifierTest.java index 8b5c8b32c96..ea1da4999a6 100644 --- a/code/src/utest/plugin/modifier/number/DivideNumberModifierTest.java +++ b/code/src/utest/plugin/modifier/number/DivideNumberModifierTest.java @@ -20,8 +20,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -import pcgen.base.calculation.BasicCalculation; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.BasicCalculation; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.format.NumberManager; import pcgen.base.util.FormatManager; diff --git a/code/src/utest/plugin/modifier/number/MaxNumberModifierTest.java b/code/src/utest/plugin/modifier/number/MaxNumberModifierTest.java index 0ba4899e83f..2d55b49e52d 100644 --- a/code/src/utest/plugin/modifier/number/MaxNumberModifierTest.java +++ b/code/src/utest/plugin/modifier/number/MaxNumberModifierTest.java @@ -20,8 +20,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -import pcgen.base.calculation.BasicCalculation; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.BasicCalculation; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.format.NumberManager; import pcgen.base.util.FormatManager; import pcgen.rules.persistence.token.ModifierFactory; diff --git a/code/src/utest/plugin/modifier/number/MinNumberModifierTest.java b/code/src/utest/plugin/modifier/number/MinNumberModifierTest.java index 5bba91edecb..335ec466f63 100644 --- a/code/src/utest/plugin/modifier/number/MinNumberModifierTest.java +++ b/code/src/utest/plugin/modifier/number/MinNumberModifierTest.java @@ -20,8 +20,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -import pcgen.base.calculation.BasicCalculation; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.BasicCalculation; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.format.NumberManager; import pcgen.base.util.FormatManager; import pcgen.rules.persistence.token.ModifierFactory; diff --git a/code/src/utest/plugin/modifier/number/MultiplyNumberModifierTest.java b/code/src/utest/plugin/modifier/number/MultiplyNumberModifierTest.java index 4230947f245..10a42756de4 100644 --- a/code/src/utest/plugin/modifier/number/MultiplyNumberModifierTest.java +++ b/code/src/utest/plugin/modifier/number/MultiplyNumberModifierTest.java @@ -20,8 +20,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -import pcgen.base.calculation.BasicCalculation; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.BasicCalculation; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.format.NumberManager; import pcgen.base.util.FormatManager; import pcgen.rules.persistence.token.ModifierFactory; diff --git a/code/src/utest/plugin/modifier/number/OverallModifierTest.java b/code/src/utest/plugin/modifier/number/OverallModifierTest.java index 25a3f1e4bb9..ca0420a9726 100644 --- a/code/src/utest/plugin/modifier/number/OverallModifierTest.java +++ b/code/src/utest/plugin/modifier/number/OverallModifierTest.java @@ -20,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; -import pcgen.base.calculation.CalculationInfo; +import pcgen.cdom.calculation.CalculationInfo; import org.junit.jupiter.api.Test; diff --git a/code/src/utest/plugin/modifier/number/SetNumberModifierTest.java b/code/src/utest/plugin/modifier/number/SetNumberModifierTest.java index bd6969bae31..7f55a165d98 100644 --- a/code/src/utest/plugin/modifier/number/SetNumberModifierTest.java +++ b/code/src/utest/plugin/modifier/number/SetNumberModifierTest.java @@ -20,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.format.NumberManager; import pcgen.base.formula.base.EvaluationManager; import pcgen.base.formula.base.FormulaManager; diff --git a/code/src/utest/plugin/modifier/orderedpair/SetOrderedPairModifierTest.java b/code/src/utest/plugin/modifier/orderedpair/SetOrderedPairModifierTest.java index 1529c1d4d4c..a13b0d7ef65 100644 --- a/code/src/utest/plugin/modifier/orderedpair/SetOrderedPairModifierTest.java +++ b/code/src/utest/plugin/modifier/orderedpair/SetOrderedPairModifierTest.java @@ -20,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.format.OrderedPairManager; import pcgen.base.math.OrderedPair; import pcgen.base.util.FormatManager; diff --git a/code/src/utest/plugin/modifier/string/SetStringModifierTest.java b/code/src/utest/plugin/modifier/string/SetStringModifierTest.java index c1c3f66a26a..c1f4d09a92e 100644 --- a/code/src/utest/plugin/modifier/string/SetStringModifierTest.java +++ b/code/src/utest/plugin/modifier/string/SetStringModifierTest.java @@ -20,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -import pcgen.base.calculation.FormulaModifier; +import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.format.StringManager; import pcgen.base.util.FormatManager; import pcgen.rules.persistence.token.ModifierFactory; diff --git a/settings.gradle b/settings.gradle index e64944b26e7..4374ea0181a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,2 @@ rootProject.name = 'pcgen' +include 'PCGen-base', 'PCGen-Formula' From 2fa9e7f6b99ae643cf6200b19c21bc92c3872e0a Mon Sep 17 00:00:00 2001 From: Vest Date: Sat, 16 May 2026 15:24:10 +0200 Subject: [PATCH 02/29] Phase 6: Migrate main source to new PCGen-Formula/PCGen-base APIs Complete API migration enabling the main module to compile against the in-repo PCGen-Formula and PCGen-base subprojects (current source) rather than the old published JARs. Key API changes applied: - LegalScope -> ImplementedScope (getParentScope -> drawsFrom/isGlobal) - FormulaManager removed; replaced by ManagerFactory pattern - ScopeManagerInst -> ImplementedScopeLibrary (registerScope -> addScope) - VariableStrategy -> DependencyStrategy - Modifier.getDependencies -> captureDependencies; added isValid - NEPFormula.getDependencies -> captureDependencies - ScopeInstance.getLegalScope -> getImplementedScope - VarScoped: removed getLocalScopeName/getVariableParent from interface, added getProviderFor(ImplementedScope) for scope hierarchy navigation - SolverManager: addModifierAndSolve -> addModifier, solveChildren -> processSolver, getDefaultValue -> getDefault - FormatManagerFactory.build and FormatManagerLibrary.getFormatManager signature changes (Optional parameters) - VariableLibrary.getVariableFormat now returns Optional> - ScopeInstanceFactory.get(String, VarScoped) replaces old Optional-based API - FormulaFactory.getValidFormula no longer takes FormulaManager parameter Structural additions: - GlobalPCVarScoped: sentinel VarScoped for PC global scope instances - PCGenScoped.getLocalScopeName(): moved from VarScoped interface to PCGen-specific PCGenScoped interface - ImplementedScopeLibrary.getScopes(): collection accessor for GUI code - VariableContext.validateDefaults(): delegates to SupplierValueStore --- PCGen-Formula/build.gradle | 2 + .../formula/inst/ImplementedScopeLibrary.java | 10 + code/src/java/pcgen/cdom/base/CDOMObject.java | 23 +- .../java/pcgen/cdom/base/FormulaFactory.java | 18 +- .../cdom/calculation/FormulaCalculation.java | 2 +- .../cdom/calculation/IgnoreVariables.java | 8 +- .../java/pcgen/cdom/content/VarModifier.java | 3 +- .../java/pcgen/cdom/facet/ModifierFacet.java | 2 +- .../pcgen/cdom/facet/RemoteModifierFacet.java | 4 +- .../src/java/pcgen/cdom/facet/ScopeFacet.java | 72 +++-- .../pcgen/cdom/facet/SolverManagerFacet.java | 3 +- .../java/pcgen/cdom/facet/StatValueFacet.java | 2 +- .../format/table/ColumnFormatFactory.java | 10 +- .../cdom/format/table/TableFormatFactory.java | 10 +- .../java/pcgen/cdom/formula/PCGenScoped.java | 16 +- .../pcgen/cdom/formula/VariableChannel.java | 4 +- .../pcgen/cdom/formula/VariableUtilities.java | 4 +- .../pcgen/cdom/formula/VariableWrapper.java | 2 +- .../local/DefinedWrappingModifier.java | 34 +- .../formula/local/ModifierDecoration.java | 10 +- .../formula/local/RemoteWrappingModifier.java | 36 ++- .../cdom/formula/scope/DynamicScope.java | 23 +- .../formula/scope/EquipmentPartScope.java | 21 +- .../cdom/formula/scope/EquipmentScope.java | 21 +- .../cdom/formula/scope/GlobalEQScope.java | 13 +- .../cdom/formula/scope/GlobalPCScope.java | 13 +- .../cdom/formula/scope/GlobalPCVarScoped.java | 57 ++++ .../formula/scope/LegalScopeUtilities.java | 26 +- .../pcgen/cdom/formula/scope/PCGenScope.java | 10 +- .../pcgen/cdom/formula/scope/RaceScope.java | 21 +- .../pcgen/cdom/formula/scope/SaveScope.java | 27 +- .../pcgen/cdom/formula/scope/SizeScope.java | 27 +- .../pcgen/cdom/formula/scope/SkillScope.java | 27 +- .../pcgen/cdom/formula/scope/StatScope.java | 27 +- .../cdom/grouping/GroupingInfoFactory.java | 4 +- .../cdom/grouping/GroupingScopeFilter.java | 4 +- code/src/java/pcgen/cdom/inst/Dynamic.java | 16 +- code/src/java/pcgen/core/PlayerCharacter.java | 4 +- .../gui2/solverview/LegalScopeWrapper.java | 18 +- .../gui2/solverview/SolverViewFrame.java | 16 +- .../output/channel/ChannelUtilities.java | 2 +- .../pcgen/persistence/SourceFileLoader.java | 4 +- .../context/AbstractReferenceContext.java | 3 +- .../pcgen/rules/context/LoadContextInst.java | 19 +- .../rules/context/PCGenManagerFactory.java | 99 ++++-- .../pcgen/rules/context/VariableContext.java | 294 +++++++++--------- .../plugin/function/GetOtherFunction.java | 36 ++- .../java/plugin/function/InputFunction.java | 15 +- .../java/plugin/function/LookupFunction.java | 10 +- code/src/java/plugin/lsttokens/ModifyLst.java | 41 +-- .../java/plugin/lsttokens/ModifyOtherLst.java | 43 +-- .../java/plugin/lsttokens/race/FaceToken.java | 5 +- .../plugin/lsttokens/variable/LocalToken.java | 4 +- 53 files changed, 728 insertions(+), 497 deletions(-) create mode 100644 code/src/java/pcgen/cdom/formula/scope/GlobalPCVarScoped.java diff --git a/PCGen-Formula/build.gradle b/PCGen-Formula/build.gradle index 1fe6a5ec3c9..5206fcdf25c 100644 --- a/PCGen-Formula/build.gradle +++ b/PCGen-Formula/build.gradle @@ -31,7 +31,9 @@ dependencies { testImplementation platform('org.junit:junit-bom:5.11.4') testImplementation 'org.junit.jupiter:junit-jupiter-api' testImplementation 'org.junit.jupiter:junit-jupiter-params' + testImplementation 'junit:junit:4.13.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' + testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } tasks.named('test') { diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/inst/ImplementedScopeLibrary.java b/PCGen-Formula/code/src/java/pcgen/base/formula/inst/ImplementedScopeLibrary.java index d0ff82f3c04..f56c1cce028 100644 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/inst/ImplementedScopeLibrary.java +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/inst/ImplementedScopeLibrary.java @@ -15,6 +15,7 @@ */ package pcgen.base.formula.inst; +import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -70,4 +71,13 @@ public boolean isRelated(ImplementedScope scope1, ImplementedScope scope2) || scope2.drawsFrom().contains(scope1); } + /** + * Returns a Collection of all ImplementedScope objects in this library. + * + * @return A Collection of all ImplementedScope objects + */ + public Collection getScopes() + { + return scopeCache.values(); + } } diff --git a/code/src/java/pcgen/cdom/base/CDOMObject.java b/code/src/java/pcgen/cdom/base/CDOMObject.java index 25fcbf2dac5..fdf8c70fca9 100644 --- a/code/src/java/pcgen/cdom/base/CDOMObject.java +++ b/code/src/java/pcgen/cdom/base/CDOMObject.java @@ -36,6 +36,7 @@ import org.jetbrains.annotations.NotNull; import pcgen.cdom.formula.Formula; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.formula.base.VarScoped; import pcgen.base.lang.StringUtil; import pcgen.base.util.DoubleKeyMapToList; @@ -1232,20 +1233,38 @@ public CDOMObject getCDOMObject() return this; } - @Override public Optional getLocalScopeName() { //I don't have one return Optional.empty(); } - @Override public Optional getVariableParent() { //Fall back to Global return Optional.empty(); } + @Override + public VarScoped getProviderFor(ImplementedScope implScope) + { + if (implScope.isGlobal()) + { + return this; + } + Optional localName = getLocalScopeName(); + if (localName.isPresent() && localName.get().equals(implScope.getName())) + { + return this; + } + Optional parent = getVariableParent(); + if (parent.isPresent()) + { + return parent.get().getProviderFor(implScope); + } + return this; + } + @Override public boolean hasPrerequisites() { diff --git a/code/src/java/pcgen/cdom/base/FormulaFactory.java b/code/src/java/pcgen/cdom/base/FormulaFactory.java index f49fe71c109..abb83d09e73 100644 --- a/code/src/java/pcgen/cdom/base/FormulaFactory.java +++ b/code/src/java/pcgen/cdom/base/FormulaFactory.java @@ -23,8 +23,8 @@ import pcgen.cdom.formula.Formula; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; -import pcgen.base.formula.base.FormulaManager; import pcgen.base.formula.base.FormulaSemantics; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.formula.base.ManagerFactory; import pcgen.base.formula.exception.SemanticsException; import pcgen.base.formula.inst.ComplexNEPFormula; @@ -281,7 +281,7 @@ public boolean equals(Object obj) } @Override - public void getDependencies(DependencyManager fdm) + public void captureDependencies(DependencyManager fdm) { //None } @@ -344,22 +344,20 @@ public static NEPFormula getNEPFormulaFor(FormatManager fmtManager, St /** * Returns a "valid" NEPFormula for the given expression. - * + * * If the given expression does not represent a valid formula, then this * will throw an IllegalArgumentException. - * + * * If the given expression does not return an object of the type in the * given FormatManager, then this will throw an IllegalArgumentException. - * + * * @param expression * The String representation of the formula to be converted to a * NEPFormula * @param managerFactory * The ManagerFactory to be used for building the FormulaSemantics - * @param formulaManager - * The FormulaManager to be used for validating the NEPFormula * @param varScope - * The PCGenScope in which the NEPFormula is established and + * The scope in which the NEPFormula is established and * checked * @param formatManager * The FormatManager in which the NEPFormula is established and @@ -367,10 +365,10 @@ public static NEPFormula getNEPFormulaFor(FormatManager fmtManager, St * @return a "valid" NEPFormula for the given expression */ public static NEPFormula getValidFormula(String expression, ManagerFactory managerFactory, - FormulaManager formulaManager, PCGenScope varScope, FormatManager formatManager) + ImplementedScope varScope, FormatManager formatManager) { NEPFormula formula = getNEPFormulaFor(formatManager, expression); - FormulaSemantics semantics = managerFactory.generateFormulaSemantics(formulaManager, varScope); + FormulaSemantics semantics = managerFactory.generateFormulaSemantics(varScope); semantics = semantics.getWith(FormulaSemantics.INPUT_FORMAT, Optional.of(formatManager)); try { diff --git a/code/src/java/pcgen/cdom/calculation/FormulaCalculation.java b/code/src/java/pcgen/cdom/calculation/FormulaCalculation.java index d62e6e3cddd..2e2a842b094 100644 --- a/code/src/java/pcgen/cdom/calculation/FormulaCalculation.java +++ b/code/src/java/pcgen/cdom/calculation/FormulaCalculation.java @@ -85,7 +85,7 @@ public T process(EvaluationManager evalManager) @Override public void getDependencies(DependencyManager fdm) { - formula.getDependencies(fdm); + formula.captureDependencies(fdm); } @Override diff --git a/code/src/java/pcgen/cdom/calculation/IgnoreVariables.java b/code/src/java/pcgen/cdom/calculation/IgnoreVariables.java index 927d2e46178..9fa92385e64 100644 --- a/code/src/java/pcgen/cdom/calculation/IgnoreVariables.java +++ b/code/src/java/pcgen/cdom/calculation/IgnoreVariables.java @@ -16,17 +16,17 @@ package pcgen.cdom.calculation; import pcgen.base.formula.base.DependencyManager; -import pcgen.base.formula.base.VariableStrategy; +import pcgen.base.formula.base.DependencyStrategy; /** - * IgnoreVariables is a VariableStrategy for a DependencyManager indicating that variables + * IgnoreVariables is a DependencyStrategy for a DependencyManager indicating that variables * are to be ignored */ -public class IgnoreVariables implements VariableStrategy +public class IgnoreVariables implements DependencyStrategy { @Override - public void addVariable(DependencyManager mgr, String varName) + public void addVariable(DependencyManager depManager, String varName) { //ignore } diff --git a/code/src/java/pcgen/cdom/content/VarModifier.java b/code/src/java/pcgen/cdom/content/VarModifier.java index b95b78fed20..cfd57239136 100644 --- a/code/src/java/pcgen/cdom/content/VarModifier.java +++ b/code/src/java/pcgen/cdom/content/VarModifier.java @@ -20,7 +20,6 @@ import java.util.Objects; import pcgen.cdom.calculation.FormulaModifier; -import pcgen.base.formula.base.LegalScope; import pcgen.cdom.formula.scope.PCGenScope; /** @@ -140,7 +139,7 @@ public boolean equals(Object o) */ public String getFullLegalScopeName() { - return LegalScope.getFullName(getLegalScope()); + return getLegalScope().getName(); } @Override diff --git a/code/src/java/pcgen/cdom/facet/ModifierFacet.java b/code/src/java/pcgen/cdom/facet/ModifierFacet.java index 137bea1af8b..10c9b04d7a4 100644 --- a/code/src/java/pcgen/cdom/facet/ModifierFacet.java +++ b/code/src/java/pcgen/cdom/facet/ModifierFacet.java @@ -73,7 +73,7 @@ private void processAddition(CharID id, VarScoped obj, VarModifier vm, Sc private Modifier getModifier(CharID id, ScopeInstance source, FormulaModifier modifier, VarScoped thisValue) { - PCGenScope legalScope = (PCGenScope) source.getLegalScope(); + PCGenScope legalScope = (PCGenScope) source.getImplementedScope(); LoadContext context = loadContextFacet.get(id.getDatasetID()).get(); Modifier returnValue; Optional> formatManager = legalScope.getFormatManager(context); diff --git a/code/src/java/pcgen/cdom/facet/RemoteModifierFacet.java b/code/src/java/pcgen/cdom/facet/RemoteModifierFacet.java index b0087b33e01..11760ce7b02 100644 --- a/code/src/java/pcgen/cdom/facet/RemoteModifierFacet.java +++ b/code/src/java/pcgen/cdom/facet/RemoteModifierFacet.java @@ -106,10 +106,10 @@ varModifier, target, getModifier(id, formulaModifier, modSource, private Modifier getModifier(CharID id, FormulaModifier modifier, VarScoped source, ScopeInstance sourceInstance, VarScoped target, ScopeInstance targetInstance) { - PCGenScope sourceScope = (PCGenScope) sourceInstance.getLegalScope(); + PCGenScope sourceScope = (PCGenScope) sourceInstance.getImplementedScope(); LoadContext context = loadContextFacet.get(id.getDatasetID()).get(); Optional> sourceFormatManager = sourceScope.getFormatManager(context); - PCGenScope targetScope = (PCGenScope) targetInstance.getLegalScope(); + PCGenScope targetScope = (PCGenScope) targetInstance.getImplementedScope(); Optional> targetFormatManager = targetScope.getFormatManager(context); Modifier returnValue; if (sourceFormatManager.isPresent() && targetFormatManager.isPresent()) diff --git a/code/src/java/pcgen/cdom/facet/ScopeFacet.java b/code/src/java/pcgen/cdom/facet/ScopeFacet.java index 68f66552b3a..1ece07a74ee 100644 --- a/code/src/java/pcgen/cdom/facet/ScopeFacet.java +++ b/code/src/java/pcgen/cdom/facet/ScopeFacet.java @@ -1,23 +1,24 @@ /* * Copyright (c) Thomas Parker, 2015. - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ package pcgen.cdom.facet; -import java.util.Optional; +import java.util.HashMap; +import java.util.Map; import pcgen.base.formula.base.ScopeInstance; import pcgen.base.formula.base.ScopeInstanceFactory; @@ -25,6 +26,7 @@ import pcgen.cdom.enumeration.CharID; import pcgen.cdom.facet.base.AbstractItemFacet; import pcgen.cdom.formula.scope.GlobalPCScope; +import pcgen.cdom.formula.scope.GlobalPCVarScoped; /** * ScopeFacet stores the relationship from a Character, LegalScope, and @@ -32,10 +34,28 @@ */ public class ScopeFacet extends AbstractItemFacet { + private final Map globalVarScopedMap = new HashMap<>(); + + @Override + public boolean set(CharID id, ScopeInstanceFactory factory) + { + boolean result = super.set(id, factory); + GlobalPCVarScoped globalVS = new GlobalPCVarScoped(GlobalPCScope.GLOBAL_SCOPE_NAME); + globalVarScopedMap.put(id, globalVS); + return result; + } + + @Override + public ScopeInstanceFactory remove(CharID id) + { + globalVarScopedMap.remove(id); + return super.remove(id); + } + /** * Returns the Global ScopeInstance for the PlayerCharacter represented by * the given CharID. - * + * * @param id * The CharID representing the PlayerCharacter for which the * Global ScopeInstance should be returned @@ -44,45 +64,43 @@ public class ScopeFacet extends AbstractItemFacet */ public ScopeInstance getGlobalScope(CharID id) { - return get(id).getGlobalInstance(GlobalPCScope.GLOBAL_SCOPE_NAME); + return get(id).get(GlobalPCScope.GLOBAL_SCOPE_NAME, globalVarScopedMap.get(id)); } /** - * Returns the ScopeInstance (within the given LegalScope and + * Returns the ScopeInstance (within the given scope name and * PlayerCharacter represented by the given CharID) for the given VarScoped * object. - * + * * @param id * The CharID representing the PlayerCharacter within which the * returned ScopeInstance exists - * @param legalScopeName - * The LegalScope name within which the returned ScopeInstance - * exists + * @param scopeName + * The scope name within which the returned ScopeInstance exists * @param scopedObject * The VarScoped object for which the ScopeInstance object should * be returned * @return The ScopeInstance for the CharID representing the PlayerCharacter - * and the given LegalScope and VarScoped objects + * and the given scope name and VarScoped objects */ - public ScopeInstance get(CharID id, String legalScopeName, VarScoped scopedObject) + public ScopeInstance get(CharID id, String scopeName, VarScoped scopedObject) { - return get(id).get(legalScopeName, Optional.of(scopedObject)); + return get(id).get(scopeName, scopedObject); } + /** + * Returns the ScopeInstance for the given VarScoped object within the PC identified + * by the given CharID. Uses the global scope name since VarScoped.getProviderFor + * will walk the hierarchy. + * + * @param id + * The CharID representing the PlayerCharacter + * @param vs + * The VarScoped object for which the ScopeInstance should be returned + * @return The ScopeInstance for the given VarScoped object + */ public ScopeInstance get(CharID id, VarScoped vs) { - Optional localName = vs.getLocalScopeName(); - VarScoped active = vs; - while (localName.isEmpty()) - { - Optional parent = active.getVariableParent(); - if (parent.isEmpty()) - { - return getGlobalScope(id); - } - active = parent.get(); - localName = active.getLocalScopeName(); - } - return get(id, localName.get(), vs); + return get(id).get(GlobalPCScope.GLOBAL_SCOPE_NAME, vs); } } diff --git a/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java b/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java index 1a315da46aa..85f85f43b09 100644 --- a/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java +++ b/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java @@ -52,7 +52,8 @@ public boolean addModifier(CharID id, VarModifier vm, VarScoped thisValue ScopeInstance scope = scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue); VariableID varID = (VariableID) loadContextFacet.get(id.getDatasetID()).get().getVariableContext() .getVariableID(scope, vm.getVarName()); - return get(id).addModifierAndSolve(varID, modifier, source); + get(id).addModifier(varID, modifier, source); + return true; } /** diff --git a/code/src/java/pcgen/cdom/facet/StatValueFacet.java b/code/src/java/pcgen/cdom/facet/StatValueFacet.java index d1f469249d5..5bee85d7c45 100644 --- a/code/src/java/pcgen/cdom/facet/StatValueFacet.java +++ b/code/src/java/pcgen/cdom/facet/StatValueFacet.java @@ -206,7 +206,7 @@ private VariableID getVarID(CharID id, PCStat stat, String channelName) String varName = ChannelUtilities.createVarName(channelName); ScopeInstanceFactory instFactory = SCOPE_FACET.get(id); Optional localScopeName = stat.getLocalScopeName(); - ScopeInstance scopeInst = instFactory.get(localScopeName.get(), Optional.of(stat)); + ScopeInstance scopeInst = instFactory.get(localScopeName.get(), stat); try { return (VariableID) loadContextFacet.get(id.getDatasetID()).get() diff --git a/code/src/java/pcgen/cdom/format/table/ColumnFormatFactory.java b/code/src/java/pcgen/cdom/format/table/ColumnFormatFactory.java index 657d824a69b..54594c49f05 100644 --- a/code/src/java/pcgen/cdom/format/table/ColumnFormatFactory.java +++ b/code/src/java/pcgen/cdom/format/table/ColumnFormatFactory.java @@ -17,7 +17,7 @@ */ package pcgen.cdom.format.table; -import java.util.Objects; +import java.util.Optional; import java.util.regex.Pattern; import pcgen.base.formatmanager.FormatManagerFactory; @@ -56,9 +56,11 @@ public ColumnFormatFactory(FormatManager columnFormat) } @Override - public FormatManager build(String subFormatName, FormatManagerLibrary library) + public FormatManager build(Optional parentFormat, + Optional subFormat, FormatManagerLibrary library) { - Objects.requireNonNull(subFormatName, "Column Format cannot be built from no instructions"); + String subFormatName = subFormat.orElseThrow( + () -> new IllegalArgumentException("Column Format cannot be built from no instructions")); if (SUB_PATTERN.matcher(subFormatName).find()) { /* @@ -68,7 +70,7 @@ public FormatManager build(String subFormatName, FormatManagerLibra throw new IllegalArgumentException( "Column Subformat not supported: " + subFormatName + " may not contain COLUMN inside COLUMN"); } - FormatManager formatManager = library.getFormatManager(subFormatName); + FormatManager formatManager = library.getFormatManager(parentFormat, subFormatName); return proc(formatManager); } diff --git a/code/src/java/pcgen/cdom/format/table/TableFormatFactory.java b/code/src/java/pcgen/cdom/format/table/TableFormatFactory.java index bce06a3bc8c..9050b43a2b2 100644 --- a/code/src/java/pcgen/cdom/format/table/TableFormatFactory.java +++ b/code/src/java/pcgen/cdom/format/table/TableFormatFactory.java @@ -17,7 +17,7 @@ */ package pcgen.cdom.format.table; -import java.util.Objects; +import java.util.Optional; import java.util.regex.Pattern; import pcgen.base.formatmanager.FormatManagerFactory; @@ -56,9 +56,11 @@ public TableFormatFactory(FormatManager tableFormat) } @Override - public FormatManager build(String subFormatName, FormatManagerLibrary library) + public FormatManager build(Optional parentFormat, + Optional subFormat, FormatManagerLibrary library) { - Objects.requireNonNull(subFormatName, "Table Format cannot be built from no instructions"); + String subFormatName = subFormat.orElseThrow( + () -> new IllegalArgumentException("Table Format cannot be built from no instructions")); if (SUB_PATTERN.matcher(subFormatName).find()) { /* @@ -69,7 +71,7 @@ public FormatManager build(String subFormatName, FormatManagerLibrary throw new IllegalArgumentException( "Multidimensional Table format not supported: " + subFormatName + " may not contain brackets"); } - return new TableFormatManager(tableFormat, library.getFormatManager(subFormatName)); + return new TableFormatManager(tableFormat, library.getFormatManager(parentFormat, subFormatName)); } @Override diff --git a/code/src/java/pcgen/cdom/formula/PCGenScoped.java b/code/src/java/pcgen/cdom/formula/PCGenScoped.java index eaffaa9ad9d..43339c06c29 100644 --- a/code/src/java/pcgen/cdom/formula/PCGenScoped.java +++ b/code/src/java/pcgen/cdom/formula/PCGenScoped.java @@ -18,6 +18,7 @@ package pcgen.cdom.formula; import java.util.List; +import java.util.Optional; import pcgen.base.formula.base.VarScoped; import pcgen.cdom.base.VarContainer; @@ -28,10 +29,17 @@ */ public interface PCGenScoped extends VarContainer, VarScoped { + /** + * Returns the name of the local scope for this object, if it has one. + * + * @return The name of the local scope, or empty if this object is in the global scope + */ + public Optional getLocalScopeName(); + /** * Returns the local child of the given child type and child name. Returns null if no * such type or no child of that type with the given name exists. - * + * * @param childType * The child type for which the child should be returned * @param childName @@ -42,10 +50,10 @@ public interface PCGenScoped extends VarContainer, VarScoped /** * Returns the List of child types that this PCGenScoped contains. - * + * * Contract for implementations of this method: Will not return null (return an empty * list instead). - * + * * @return The List of child types that this PCGenScoped contains */ public List getChildTypes(); @@ -53,7 +61,7 @@ public interface PCGenScoped extends VarContainer, VarScoped /** * Returns the List of children of the given child type. Returns null if this * PCGenScoped has no children of the given type. - * + * * @param childType * The child type for which the list of children should be returned * @return The List of children of the given child type diff --git a/code/src/java/pcgen/cdom/formula/VariableChannel.java b/code/src/java/pcgen/cdom/formula/VariableChannel.java index e8830ddd62d..39b7d1f19d7 100644 --- a/code/src/java/pcgen/cdom/formula/VariableChannel.java +++ b/code/src/java/pcgen/cdom/formula/VariableChannel.java @@ -95,7 +95,7 @@ public T get() T value = varStore.get(varID); if (value == null) { - return manager.getDefaultValue(varID.getFormatManager()); + return manager.getDefault(varID.getFormatManager()); } return value; } @@ -106,7 +106,7 @@ public void set(T object) if (!checkForVeto(object)) { varStore.put(varID, object); - manager.solveChildren(varID); + manager.processSolver(varID); } } diff --git a/code/src/java/pcgen/cdom/formula/VariableUtilities.java b/code/src/java/pcgen/cdom/formula/VariableUtilities.java index 6042a5011a2..8187cf9142a 100644 --- a/code/src/java/pcgen/cdom/formula/VariableUtilities.java +++ b/code/src/java/pcgen/cdom/formula/VariableUtilities.java @@ -180,9 +180,7 @@ public static VariableID getLocalVariableID(CharID id, VarScoped owner, String name) { ScopeInstanceFactory instFactory = SCOPE_FACET.get(id); - Optional localScopeName = owner.getLocalScopeName(); - ScopeInstance scopeInst = - instFactory.get(localScopeName.get(), Optional.of(owner)); + ScopeInstance scopeInst = SCOPE_FACET.get(id, owner); return VariableUtilities.getLocalVariableID(id, scopeInst, name); } } diff --git a/code/src/java/pcgen/cdom/formula/VariableWrapper.java b/code/src/java/pcgen/cdom/formula/VariableWrapper.java index 938229ec848..128d8c1841c 100644 --- a/code/src/java/pcgen/cdom/formula/VariableWrapper.java +++ b/code/src/java/pcgen/cdom/formula/VariableWrapper.java @@ -84,7 +84,7 @@ public T get() T value = varStore.get(varID); if (value == null) { - return manager.getDefaultValue(varID.getFormatManager()); + return manager.getDefault(varID.getFormatManager()); } return value; } diff --git a/code/src/java/pcgen/cdom/formula/local/DefinedWrappingModifier.java b/code/src/java/pcgen/cdom/formula/local/DefinedWrappingModifier.java index 2e071c9c4d1..dd8b07feb4d 100644 --- a/code/src/java/pcgen/cdom/formula/local/DefinedWrappingModifier.java +++ b/code/src/java/pcgen/cdom/formula/local/DefinedWrappingModifier.java @@ -1,14 +1,14 @@ /* * Copyright 2018 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License along with * this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, * Suite 330, Boston, MA 02111-1307 USA @@ -20,8 +20,9 @@ import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; -import pcgen.base.formula.base.FormulaManager; +import pcgen.base.formula.base.FormulaSemantics; import pcgen.base.formula.base.FunctionLibrary; +import pcgen.base.formula.exception.SemanticsException; import pcgen.base.solver.Modifier; import pcgen.base.util.FormatManager; @@ -29,7 +30,7 @@ * A DefinedWrappingModifier wraps a FormulaModifier and projects it to the formula system * as a Modifier, while also inserting any new formula system functions supported by the * given java.util.function.Function. - * + * * @param * The format that this DefinedWrappingModifier acts upon */ @@ -59,7 +60,7 @@ public class DefinedWrappingModifier implements Modifier /** * Constructs a new DefinedWrappingModifier for the given FormulaModifier and * Function. - * + * * @param modifier * The underlying FormulaModifier * @param definedName @@ -82,22 +83,25 @@ public DefinedWrappingModifier(FormulaModifier modifier, String definedName, @Override public T process(EvaluationManager manager) { - FormulaManager formulaManager = decorateFormulaManager(manager.get(EvaluationManager.FMANAGER)); - return modifier.process(manager.getWith(EvaluationManager.FMANAGER, formulaManager)); + FunctionLibrary functionLib = manager.get(EvaluationManager.FUNCTION); + functionLib = new DefinedWrappingLibrary(functionLib, definedName, definedValue, formatManager); + return modifier.process(manager.getWith(EvaluationManager.FUNCTION, functionLib)); } @Override - public void getDependencies(DependencyManager fdm) + public void captureDependencies(DependencyManager fdm) { - FormulaManager formulaManager = decorateFormulaManager(fdm.get(DependencyManager.FMANAGER)); - modifier.getDependencies(fdm.getWith(DependencyManager.FMANAGER, formulaManager)); + FunctionLibrary functionLib = fdm.get(DependencyManager.FUNCTION); + functionLib = new DefinedWrappingLibrary(functionLib, definedName, definedValue, formatManager); + modifier.getDependencies(fdm.getWith(DependencyManager.FUNCTION, functionLib)); } - private FormulaManager decorateFormulaManager(FormulaManager formulaManager) + @Override + public void isValid(FormulaSemantics semantics) throws SemanticsException { - FunctionLibrary functionManager = formulaManager.get(FormulaManager.FUNCTION); - functionManager = new DefinedWrappingLibrary(functionManager, definedName, definedValue, formatManager); - return formulaManager.getWith(FormulaManager.FUNCTION, functionManager); + FunctionLibrary functionLib = semantics.get(FormulaSemantics.FUNCTION); + functionLib = new DefinedWrappingLibrary(functionLib, definedName, definedValue, formatManager); + modifier.isValid(semantics.getWith(FormulaSemantics.FUNCTION, functionLib)); } @Override diff --git a/code/src/java/pcgen/cdom/formula/local/ModifierDecoration.java b/code/src/java/pcgen/cdom/formula/local/ModifierDecoration.java index 360b0619024..05c20c9d274 100644 --- a/code/src/java/pcgen/cdom/formula/local/ModifierDecoration.java +++ b/code/src/java/pcgen/cdom/formula/local/ModifierDecoration.java @@ -20,6 +20,8 @@ import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; +import pcgen.base.formula.base.FormulaSemantics; +import pcgen.base.formula.exception.SemanticsException; import pcgen.base.solver.Modifier; import pcgen.base.util.FormatManager; @@ -55,11 +57,17 @@ public T process(EvaluationManager manager) } @Override - public void getDependencies(DependencyManager fdm) + public void captureDependencies(DependencyManager fdm) { modifier.getDependencies(fdm); } + @Override + public void isValid(FormulaSemantics semantics) throws SemanticsException + { + modifier.isValid(semantics); + } + @Override public long getPriority() { diff --git a/code/src/java/pcgen/cdom/formula/local/RemoteWrappingModifier.java b/code/src/java/pcgen/cdom/formula/local/RemoteWrappingModifier.java index 9b37663b095..6836211001f 100644 --- a/code/src/java/pcgen/cdom/formula/local/RemoteWrappingModifier.java +++ b/code/src/java/pcgen/cdom/formula/local/RemoteWrappingModifier.java @@ -1,14 +1,14 @@ /* * Copyright 2018 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License along with * this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, * Suite 330, Boston, MA 02111-1307 USA @@ -20,9 +20,10 @@ import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; -import pcgen.base.formula.base.FormulaManager; +import pcgen.base.formula.base.FormulaSemantics; import pcgen.base.formula.base.FunctionLibrary; import pcgen.base.formula.base.VarScoped; +import pcgen.base.formula.exception.SemanticsException; import pcgen.base.solver.Modifier; import pcgen.base.util.FormatManager; @@ -30,7 +31,7 @@ * A RemoteWrappingModifier wraps a FormulaModifier and projects it to the formula system * as a Modifier, while also inserting any new formula system functions supported by the * given java.util.function.Function. - * + * * @param * The format that this RemoteWrappingModifier acts upon */ @@ -65,7 +66,7 @@ public class RemoteWrappingModifier implements Modifier /** * Constructs a new RemoteWrappingModifier for the given FormulaModifier and Function. - * + * * @param modifier * The underlying FormulaModifier * @param sourceValue @@ -92,23 +93,28 @@ public RemoteWrappingModifier(FormulaModifier modifier, VarScoped sourceValue @Override public T process(EvaluationManager manager) { - FormulaManager formulaManager = decorateFormulaManager(manager.get(EvaluationManager.FMANAGER)); - return modifier.process(manager.getWith(EvaluationManager.FMANAGER, formulaManager)); + FunctionLibrary functionLib = manager.get(EvaluationManager.FUNCTION); + functionLib = new RemoteWrappingLibrary(functionLib, sourceValue, sourceFormatManager, targetValue, + targetFormatManager); + return modifier.process(manager.getWith(EvaluationManager.FUNCTION, functionLib)); } @Override - public void getDependencies(DependencyManager fdm) + public void captureDependencies(DependencyManager fdm) { - FormulaManager formulaManager = decorateFormulaManager(fdm.get(DependencyManager.FMANAGER)); - modifier.getDependencies(fdm.getWith(DependencyManager.FMANAGER, formulaManager)); + FunctionLibrary functionLib = fdm.get(DependencyManager.FUNCTION); + functionLib = new RemoteWrappingLibrary(functionLib, sourceValue, sourceFormatManager, targetValue, + targetFormatManager); + modifier.getDependencies(fdm.getWith(DependencyManager.FUNCTION, functionLib)); } - private FormulaManager decorateFormulaManager(FormulaManager formulaManager) + @Override + public void isValid(FormulaSemantics semantics) throws SemanticsException { - FunctionLibrary functionManager = formulaManager.get(FormulaManager.FUNCTION); - functionManager = new RemoteWrappingLibrary(functionManager, sourceValue, sourceFormatManager, targetValue, + FunctionLibrary functionLib = semantics.get(FormulaSemantics.FUNCTION); + functionLib = new RemoteWrappingLibrary(functionLib, sourceValue, sourceFormatManager, targetValue, targetFormatManager); - return formulaManager.getWith(FormulaManager.FUNCTION, functionManager); + modifier.isValid(semantics.getWith(FormulaSemantics.FUNCTION, functionLib)); } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/DynamicScope.java b/code/src/java/pcgen/cdom/formula/scope/DynamicScope.java index d3178a19258..31ad8b4579a 100644 --- a/code/src/java/pcgen/cdom/formula/scope/DynamicScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/DynamicScope.java @@ -1,23 +1,25 @@ /* * Copyright 2018 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License along with * this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, * Suite 330, Boston, MA 02111-1307 USA */ package pcgen.cdom.formula.scope; +import java.util.List; import java.util.Objects; import java.util.Optional; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.FormatManager; import pcgen.cdom.helper.SpringHelper; import pcgen.cdom.inst.Dynamic; @@ -32,7 +34,8 @@ public class DynamicScope implements PCGenScope /** * The parent PCGenScope for all DynamicScope objects is the GlobalPCScope. */ - private static final Optional PARENT_SCOPE = Optional.of(SpringHelper.getBean(GlobalPCScope.class)); + private static final List DRAWS_FROM = + List.of(SpringHelper.getBean(GlobalPCScope.class)); /** * The DynamicCategory indicating the objects contained by this DynamicScope. @@ -47,7 +50,7 @@ public class DynamicScope implements PCGenScope /** * Constructs a new DynamicScope for the given DynamicCategory and containing the * objects identified in the given FormatManager. - * + * * @param category * The DynamicCategory indicating the objects contained by this * DynamicScope @@ -67,9 +70,15 @@ public String getName() } @Override - public Optional getParentScope() + public boolean isGlobal() { - return PARENT_SCOPE; + return false; + } + + @Override + public List drawsFrom() + { + return DRAWS_FROM; } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/EquipmentPartScope.java b/code/src/java/pcgen/cdom/formula/scope/EquipmentPartScope.java index 457f138df6c..3abc165f9d8 100644 --- a/code/src/java/pcgen/cdom/formula/scope/EquipmentPartScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/EquipmentPartScope.java @@ -17,8 +17,11 @@ */ package pcgen.cdom.formula.scope; +import java.util.Collections; +import java.util.List; import java.util.Optional; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.FormatManager; import pcgen.rules.context.LoadContext; @@ -35,9 +38,9 @@ public class EquipmentPartScope implements PCGenScope public static final String PC_EQUIPMENT_PART = "PC.EQUIPMENT.PART"; /** - * The parent of this scope (once loaded) + * The scopes this scope draws from (once loaded) */ - private Optional parent; + private List drawsFrom = Collections.emptyList(); @Override public String getName() @@ -46,20 +49,26 @@ public String getName() } @Override - public Optional getParentScope() + public boolean isGlobal() { - return parent; + return false; + } + + @Override + public List drawsFrom() + { + return drawsFrom; } /** * Sets the parent PCGenScope for this EquipmentPartScope. - * + * * @param parent * The parent PCGenScope for this EquipmentPartScope */ public void setParent(PCGenScope parent) { - this.parent = Optional.of(parent); + this.drawsFrom = List.of(parent); } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/EquipmentScope.java b/code/src/java/pcgen/cdom/formula/scope/EquipmentScope.java index 798030150de..856638de6ae 100644 --- a/code/src/java/pcgen/cdom/formula/scope/EquipmentScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/EquipmentScope.java @@ -17,8 +17,11 @@ */ package pcgen.cdom.formula.scope; +import java.util.Collections; +import java.util.List; import java.util.Optional; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.FormatManager; import pcgen.rules.context.LoadContext; @@ -30,9 +33,9 @@ public class EquipmentScope implements PCGenScope { /** - * The parent of this scope (once loaded) + * The scopes this scope draws from (once loaded) */ - private Optional parent; + private List drawsFrom = Collections.emptyList(); @Override public String getName() @@ -41,20 +44,26 @@ public String getName() } @Override - public Optional getParentScope() + public boolean isGlobal() { - return parent; + return false; + } + + @Override + public List drawsFrom() + { + return drawsFrom; } /** * Sets the parent PCGenScope for this EquipmentScope. - * + * * @param parent * The parent PCGenScope for this EquipmentScope */ public void setParent(PCGenScope parent) { - this.parent = Optional.of(parent); + this.drawsFrom = List.of(parent); } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/GlobalEQScope.java b/code/src/java/pcgen/cdom/formula/scope/GlobalEQScope.java index 6a45861a788..7f531bdef97 100644 --- a/code/src/java/pcgen/cdom/formula/scope/GlobalEQScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/GlobalEQScope.java @@ -17,8 +17,11 @@ */ package pcgen.cdom.formula.scope; +import java.util.Collections; +import java.util.List; import java.util.Optional; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.FormatManager; import pcgen.rules.context.LoadContext; @@ -44,9 +47,15 @@ public String getName() } @Override - public Optional getParentScope() + public boolean isGlobal() { - return Optional.empty(); + return true; + } + + @Override + public List drawsFrom() + { + return Collections.emptyList(); } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/GlobalPCScope.java b/code/src/java/pcgen/cdom/formula/scope/GlobalPCScope.java index af221a90cde..7df7cc3045a 100644 --- a/code/src/java/pcgen/cdom/formula/scope/GlobalPCScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/GlobalPCScope.java @@ -17,8 +17,11 @@ */ package pcgen.cdom.formula.scope; +import java.util.Collections; +import java.util.List; import java.util.Optional; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.FormatManager; import pcgen.rules.context.LoadContext; @@ -39,9 +42,15 @@ public String getName() } @Override - public Optional getParentScope() + public boolean isGlobal() { - return Optional.empty(); + return true; + } + + @Override + public List drawsFrom() + { + return Collections.emptyList(); } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/GlobalPCVarScoped.java b/code/src/java/pcgen/cdom/formula/scope/GlobalPCVarScoped.java new file mode 100644 index 00000000000..4209638445f --- /dev/null +++ b/code/src/java/pcgen/cdom/formula/scope/GlobalPCVarScoped.java @@ -0,0 +1,57 @@ +/* + * Copyright 2024 (C) PCGen Developers + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package pcgen.cdom.formula.scope; + +import pcgen.base.formula.base.ImplementedScope; +import pcgen.base.formula.base.VarScoped; + +/** + * A VarScoped sentinel representing the global PC scope for a character. + */ +public class GlobalPCVarScoped implements VarScoped +{ + private final String name; + + public GlobalPCVarScoped(String name) + { + this.name = name; + } + + @Override + public String getKeyName() + { + return name; + } + + @Override + public VarScoped getProviderFor(ImplementedScope implScope) + { + if (implScope.isGlobal()) + { + return this; + } + throw new IllegalArgumentException( + "GlobalPCVarScoped cannot provide for non-global scope: " + implScope.getName()); + } + + @Override + public String toString() + { + return "PC Global Scope (" + name + ")"; + } +} diff --git a/code/src/java/pcgen/cdom/formula/scope/LegalScopeUtilities.java b/code/src/java/pcgen/cdom/formula/scope/LegalScopeUtilities.java index 31377c5bbb4..c304bd13a7b 100644 --- a/code/src/java/pcgen/cdom/formula/scope/LegalScopeUtilities.java +++ b/code/src/java/pcgen/cdom/formula/scope/LegalScopeUtilities.java @@ -1,23 +1,23 @@ /* * Copyright 2015 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package pcgen.cdom.formula.scope; -import pcgen.base.formula.inst.ScopeManagerInst; +import pcgen.base.formula.inst.ImplementedScopeLibrary; import pcgen.cdom.helper.SpringHelper; public final class LegalScopeUtilities @@ -28,15 +28,15 @@ private LegalScopeUtilities() //Do not construct utility class } - public static void loadLegalScopeLibrary(ScopeManagerInst library) + public static void loadLegalScopeLibrary(ImplementedScopeLibrary library) { - library.registerScope(SpringHelper.getBean(GlobalPCScope.class)); - library.registerScope(SpringHelper.getBean(EquipmentScope.class)); - library.registerScope(SpringHelper.getBean(EquipmentPartScope.class)); - library.registerScope(SpringHelper.getBean(RaceScope.class)); - library.registerScope(SpringHelper.getBean(SaveScope.class)); - library.registerScope(SpringHelper.getBean(SizeScope.class)); - library.registerScope(SpringHelper.getBean(SkillScope.class)); - library.registerScope(SpringHelper.getBean(StatScope.class)); + library.addScope(SpringHelper.getBean(GlobalPCScope.class)); + library.addScope(SpringHelper.getBean(EquipmentScope.class)); + library.addScope(SpringHelper.getBean(EquipmentPartScope.class)); + library.addScope(SpringHelper.getBean(RaceScope.class)); + library.addScope(SpringHelper.getBean(SaveScope.class)); + library.addScope(SpringHelper.getBean(SizeScope.class)); + library.addScope(SpringHelper.getBean(SkillScope.class)); + library.addScope(SpringHelper.getBean(StatScope.class)); } } diff --git a/code/src/java/pcgen/cdom/formula/scope/PCGenScope.java b/code/src/java/pcgen/cdom/formula/scope/PCGenScope.java index 6079f39450c..fa25f2806c7 100644 --- a/code/src/java/pcgen/cdom/formula/scope/PCGenScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/PCGenScope.java @@ -17,22 +17,20 @@ import java.util.Optional; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.FormatManager; import pcgen.rules.context.LoadContext; /** - * A PCGenScope is an expanded LegalScope for use in PCGen that can also provide the + * A PCGenScope is an expanded ImplementedScope for use in PCGen that can also provide the * FormatManager related to the Scope. */ -public interface PCGenScope extends LegalScope +public interface PCGenScope extends ImplementedScope { - @Override - public Optional getParentScope(); /** * Returns the FormatManager used to process objects that are within this PCGenScope. - * + * * @param context * The LoadContext used to resolve the actual FormatManager * @return The FormatManager used to process objects that are within this PCGenScope diff --git a/code/src/java/pcgen/cdom/formula/scope/RaceScope.java b/code/src/java/pcgen/cdom/formula/scope/RaceScope.java index 3197c352bf9..d8f69566600 100644 --- a/code/src/java/pcgen/cdom/formula/scope/RaceScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/RaceScope.java @@ -17,8 +17,11 @@ */ package pcgen.cdom.formula.scope; +import java.util.Collections; +import java.util.List; import java.util.Optional; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.FormatManager; import pcgen.core.Race; import pcgen.rules.context.LoadContext; @@ -30,9 +33,9 @@ public class RaceScope implements PCGenScope { /** - * The parent of this scope (once loaded) + * The scopes this scope draws from (once loaded) */ - private Optional parent; + private List drawsFrom = Collections.emptyList(); @Override public String getName() @@ -41,20 +44,26 @@ public String getName() } @Override - public Optional getParentScope() + public boolean isGlobal() { - return parent; + return false; + } + + @Override + public List drawsFrom() + { + return drawsFrom; } /** * Sets the parent PCGenScope for this RaceScope. - * + * * @param parent * The parent PCGenScope for this RaceScope */ public void setParent(PCGenScope parent) { - this.parent = Optional.of(parent); + this.drawsFrom = List.of(parent); } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/SaveScope.java b/code/src/java/pcgen/cdom/formula/scope/SaveScope.java index 43531352f94..3998e974a6c 100644 --- a/code/src/java/pcgen/cdom/formula/scope/SaveScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/SaveScope.java @@ -1,24 +1,27 @@ /* * Copyright 2016 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package pcgen.cdom.formula.scope; +import java.util.Collections; +import java.util.List; import java.util.Optional; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.FormatManager; import pcgen.core.PCCheck; import pcgen.rules.context.LoadContext; @@ -30,9 +33,9 @@ public class SaveScope implements PCGenScope { /** - * The parent of this scope (once loaded) + * The scopes this scope draws from (once loaded) */ - private Optional parent; + private List drawsFrom = Collections.emptyList(); @Override public String getName() @@ -41,20 +44,26 @@ public String getName() } @Override - public Optional getParentScope() + public boolean isGlobal() { - return parent; + return false; + } + + @Override + public List drawsFrom() + { + return drawsFrom; } /** * Sets the parent PCGenScope for this SaveScope. - * + * * @param parent * The parent PCGenScope for this SaveScope */ public void setParent(PCGenScope parent) { - this.parent = Optional.of(parent); + this.drawsFrom = List.of(parent); } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/SizeScope.java b/code/src/java/pcgen/cdom/formula/scope/SizeScope.java index 8eb0dd1f787..f1e56c3803d 100644 --- a/code/src/java/pcgen/cdom/formula/scope/SizeScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/SizeScope.java @@ -1,24 +1,27 @@ /* * Copyright 2016 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package pcgen.cdom.formula.scope; +import java.util.Collections; +import java.util.List; import java.util.Optional; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.FormatManager; import pcgen.core.SizeAdjustment; import pcgen.rules.context.LoadContext; @@ -30,9 +33,9 @@ public class SizeScope implements PCGenScope { /** - * The parent of this scope (once loaded) + * The scopes this scope draws from (once loaded) */ - private Optional parent; + private List drawsFrom = Collections.emptyList(); @Override public String getName() @@ -41,20 +44,26 @@ public String getName() } @Override - public Optional getParentScope() + public boolean isGlobal() { - return parent; + return false; + } + + @Override + public List drawsFrom() + { + return drawsFrom; } /** * Sets the parent PCGenScope for this SizeAdjustmentScope. - * + * * @param parent * The parent PCGenScope for this SizeAdjustmentScope */ public void setParent(PCGenScope parent) { - this.parent = Optional.of(parent); + this.drawsFrom = List.of(parent); } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/SkillScope.java b/code/src/java/pcgen/cdom/formula/scope/SkillScope.java index e53f5743e94..a32dd29eb55 100644 --- a/code/src/java/pcgen/cdom/formula/scope/SkillScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/SkillScope.java @@ -1,24 +1,27 @@ /* * Copyright 2015 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package pcgen.cdom.formula.scope; +import java.util.Collections; +import java.util.List; import java.util.Optional; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.FormatManager; import pcgen.core.Skill; import pcgen.rules.context.LoadContext; @@ -30,9 +33,9 @@ public class SkillScope implements PCGenScope { /** - * The parent of this scope (once loaded) + * The scopes this scope draws from (once loaded) */ - private Optional parent; + private List drawsFrom = Collections.emptyList(); @Override public String getName() @@ -41,20 +44,26 @@ public String getName() } @Override - public Optional getParentScope() + public boolean isGlobal() { - return parent; + return false; + } + + @Override + public List drawsFrom() + { + return drawsFrom; } /** * Sets the parent PCGenScope for this SkillScope. - * + * * @param parent * The parent PCGenScope for this SkillScope */ public void setParent(PCGenScope parent) { - this.parent = Optional.of(parent); + this.drawsFrom = List.of(parent); } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/StatScope.java b/code/src/java/pcgen/cdom/formula/scope/StatScope.java index 32a70be88a1..a4aeb2177b8 100644 --- a/code/src/java/pcgen/cdom/formula/scope/StatScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/StatScope.java @@ -1,24 +1,27 @@ /* * Copyright 2016 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package pcgen.cdom.formula.scope; +import java.util.Collections; +import java.util.List; import java.util.Optional; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.FormatManager; import pcgen.core.PCStat; import pcgen.rules.context.LoadContext; @@ -30,9 +33,9 @@ public class StatScope implements PCGenScope { /** - * The parent of this scope (once loaded) + * The scopes this scope draws from (once loaded) */ - private Optional parent; + private List drawsFrom = Collections.emptyList(); @Override public String getName() @@ -41,20 +44,26 @@ public String getName() } @Override - public Optional getParentScope() + public boolean isGlobal() { - return parent; + return false; + } + + @Override + public List drawsFrom() + { + return drawsFrom; } /** * Sets the parent PCGenScope for this PCStatScope. - * + * * @param parent * The parent PCGenScope for this PCStatScope */ public void setParent(PCGenScope parent) { - this.parent = Optional.of(parent); + this.drawsFrom = List.of(parent); } @Override diff --git a/code/src/java/pcgen/cdom/grouping/GroupingInfoFactory.java b/code/src/java/pcgen/cdom/grouping/GroupingInfoFactory.java index ce9ea0e68de..e4e7f80cd70 100644 --- a/code/src/java/pcgen/cdom/grouping/GroupingInfoFactory.java +++ b/code/src/java/pcgen/cdom/grouping/GroupingInfoFactory.java @@ -18,7 +18,7 @@ import java.util.Arrays; import java.util.Stack; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.ImplementedScope; import pcgen.cdom.formula.scope.PCGenScope; /** @@ -67,7 +67,7 @@ public class GroupingInfoFactory */ public GroupingInfo process(PCGenScope scope, String instructions) throws GroupingStateException { - String fullScopeName = LegalScope.getFullName(scope); + String fullScopeName = scope.getName(); this.scopeName = fullScopeName.split("\\."); depth = 0; expected.clear(); diff --git a/code/src/java/pcgen/cdom/grouping/GroupingScopeFilter.java b/code/src/java/pcgen/cdom/grouping/GroupingScopeFilter.java index dddf550ccd1..777bb3bb9cc 100644 --- a/code/src/java/pcgen/cdom/grouping/GroupingScopeFilter.java +++ b/code/src/java/pcgen/cdom/grouping/GroupingScopeFilter.java @@ -19,7 +19,7 @@ import java.util.Optional; import java.util.function.Consumer; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.ImplementedScope; import pcgen.cdom.formula.PCGenScoped; import pcgen.cdom.formula.scope.PCGenScope; @@ -67,7 +67,7 @@ public class GroupingScopeFilter implements GroupingCollection */ public GroupingScopeFilter(PCGenScope scope, GroupingCollection grouping) { - this.scopeName = LegalScope.getFullName(scope); + this.scopeName = scope.getName(); this.underlying = Objects.requireNonNull(grouping); } diff --git a/code/src/java/pcgen/cdom/inst/Dynamic.java b/code/src/java/pcgen/cdom/inst/Dynamic.java index 144aaf021cf..74f289ccf3e 100644 --- a/code/src/java/pcgen/cdom/inst/Dynamic.java +++ b/code/src/java/pcgen/cdom/inst/Dynamic.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Optional; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.formula.base.VarScoped; import pcgen.cdom.base.Categorized; import pcgen.cdom.base.Category; @@ -123,12 +124,25 @@ public void setCDOMCategory(Category cat) } @Override + public VarScoped getProviderFor(ImplementedScope implScope) + { + if (implScope.isGlobal()) + { + return this; + } + String scopeName = implScope.getName(); + if (category != null && category.getKeyName().equals(scopeName)) + { + return this; + } + return this; + } + public Optional getLocalScopeName() { return Optional.of("PC." + category.getKeyName()); } - @Override public Optional getVariableParent() { return Optional.empty(); diff --git a/code/src/java/pcgen/core/PlayerCharacter.java b/code/src/java/pcgen/core/PlayerCharacter.java index 7b7d59628aa..bf8a7ee3df5 100644 --- a/code/src/java/pcgen/core/PlayerCharacter.java +++ b/code/src/java/pcgen/core/PlayerCharacter.java @@ -33,7 +33,6 @@ import java.util.TreeSet; import pcgen.cdom.formula.Formula; -import pcgen.base.formula.base.FormulaManager; import pcgen.base.formula.inst.NEPFormula; import pcgen.base.solver.SolverManager; import pcgen.base.util.HashMapToList; @@ -608,9 +607,8 @@ private static void setProf(final Equipment equip, final Equipment eqm) private void doFormulaSetup(LoadContext context) { VariableContext variableContext = context.getVariableContext(); - FormulaManager formulaManager = variableContext.getPCFormulaManager(); MonitorableVariableStore varStore = new MonitorableVariableStore(); - scopeFacet.set(id, formulaManager.getScopeInstanceFactory()); + scopeFacet.set(id, variableContext.getScopeInstanceFactory()); variableStoreFacet.set(id, varStore); solverManagerFacet.set(id, variableContext.generateSolverManager(varStore)); ChannelUtilities.watchChannel(this, CControl.AGEINPUT, ageSetFacet); diff --git a/code/src/java/pcgen/gui2/solverview/LegalScopeWrapper.java b/code/src/java/pcgen/gui2/solverview/LegalScopeWrapper.java index cb544c4641d..6441a76ab4e 100644 --- a/code/src/java/pcgen/gui2/solverview/LegalScopeWrapper.java +++ b/code/src/java/pcgen/gui2/solverview/LegalScopeWrapper.java @@ -17,10 +17,10 @@ */ package pcgen.gui2.solverview; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.ImplementedScope; /** - * An LegalScopeWrapper wraps a LegalScope in order to display an informative + * An LegalScopeWrapper wraps a ImplementedScope in order to display an informative * String from the toString() method. This allows the LegalScopeWrapper to be * directly used in the UI without worrying about the actual toString() behavior * of any given LegalScope. @@ -30,31 +30,31 @@ class LegalScopeWrapper /** * The underlying LegalScope. */ - private final LegalScope legalScope; + private final ImplementedScope legalScope; /** * Constructs a new LegalScopeWrapper with the given LegalScope * * @param legalScope - * The LegalScope that this LegalScopeWrapper will represent + * The ImplementedScope that this LegalScopeWrapper will represent */ - LegalScopeWrapper(LegalScope legalScope) + LegalScopeWrapper(ImplementedScope legalScope) { this.legalScope = legalScope; } /** - * Returns the LegalScope underlying this LegalScopeWrapper. + * Returns the ImplementedScope underlying this LegalScopeWrapper. * - * @return the LegalScope underlying this LegalScopeWrapper + * @return the ImplementedScope underlying this LegalScopeWrapper */ - public LegalScope getLegalScope() + public ImplementedScope getLegalScope() { return legalScope; } /** - * Returns an informative String identifying the LegalScope underlying this + * Returns an informative String identifying the ImplementedScope underlying this * LegalScopeWrapper */ @Override diff --git a/code/src/java/pcgen/gui2/solverview/SolverViewFrame.java b/code/src/java/pcgen/gui2/solverview/SolverViewFrame.java index 4e45a084d55..4abffd5ad30 100644 --- a/code/src/java/pcgen/gui2/solverview/SolverViewFrame.java +++ b/code/src/java/pcgen/gui2/solverview/SolverViewFrame.java @@ -38,7 +38,7 @@ import javax.swing.event.DocumentListener; import javax.swing.table.AbstractTableModel; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.formula.base.ScopeInstance; import pcgen.base.formula.base.VarScoped; import pcgen.base.formula.base.VariableID; @@ -65,7 +65,7 @@ public final class SolverViewFrame extends JFrame private final LoadContextFacet loadContextFacet = FacetLibrary.getFacet(LoadContextFacet.class); private final JComboBox scopeChooser; - private LegalScope selectedScope; + private ImplementedScope selectedScope; private final JTextField varName; private String varNameText = " "; @@ -111,7 +111,7 @@ public SolverViewFrame() private void update() { updateObjects(); - if ((activeObject == null) && (selectedScope.getParentScope().isPresent())) + if ((activeObject == null) && (!selectedScope.isGlobal())) { //scopeFacet will error if we continue... tableModel.setSteps(Collections.emptyList()); @@ -124,10 +124,10 @@ private void update() } else { - scope = scopeFacet.get(activeIdentifier, LegalScope.getFullName(selectedScope), activeObject); + scope = scopeFacet.get(activeIdentifier, selectedScope.getName(), activeObject); } if (loadContextFacet.get(activeIdentifier.getDatasetID()).get().getVariableContext() - .isLegalVariableID(scope.getLegalScope(), varNameText)) + .isLegalVariableID(scope.getImplementedScope(), varNameText)) { displayInfo(scope); } @@ -220,7 +220,7 @@ public void actionPerformed(ActionEvent e) Object item = identifierChooser.getSelectedItem(); activeIdentifier = ((PCRef) item).id; LoadContext loadContext = loadContextFacet.get(activeIdentifier.getDatasetID()).get(); - for (LegalScope lvs : loadContext.getVariableContext().getScopes()) + for (ImplementedScope lvs : loadContext.getVariableContext().getScopes()) { scopeChooser.addItem(new LegalScopeWrapper(lvs)); } @@ -235,8 +235,8 @@ private void updateObjects() { Collection objects = varScopedFacet.getSet(activeIdentifier); objectChooser.removeAllItems(); - String scopeName = LegalScope.getFullName(selectedScope); - for (VarScoped cdo : objects) + String scopeName = selectedScope.getName(); + for (PCGenScoped cdo : objects) { Optional localScopeName = cdo.getLocalScopeName(); if (localScopeName.isPresent() && scopeName.equals(localScopeName.get())) diff --git a/code/src/java/pcgen/output/channel/ChannelUtilities.java b/code/src/java/pcgen/output/channel/ChannelUtilities.java index 81c4f5d1a09..922b73a4b61 100644 --- a/code/src/java/pcgen/output/channel/ChannelUtilities.java +++ b/code/src/java/pcgen/output/channel/ChannelUtilities.java @@ -100,7 +100,7 @@ public static void setGlobalChannel(CharID id, String channelName, Object value) { VariableID varID = getChannelVariableID(id, channelName); RESULT_FACET.get(id).put(varID, value); - SOLVER_MANAGER_FACET.get(id).solveChildren(varID); + SOLVER_MANAGER_FACET.get(id).processSolver(varID); } /** diff --git a/code/src/java/pcgen/persistence/SourceFileLoader.java b/code/src/java/pcgen/persistence/SourceFileLoader.java index 5068a3f7428..43c8a26a6e6 100644 --- a/code/src/java/pcgen/persistence/SourceFileLoader.java +++ b/code/src/java/pcgen/persistence/SourceFileLoader.java @@ -35,7 +35,7 @@ import java.util.stream.Stream; import pcgen.base.formatmanager.FormatUtilities; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.util.AbstractMapToList; import pcgen.base.util.FormatManager; import pcgen.base.util.HashMapToList; @@ -675,7 +675,7 @@ private static void enableBuiltInControl(LoadContext context, private static void defineVariable(VariableContext varContext, FormatManager formatManager, String varName) { - LegalScope varScope = varContext.getScope(GlobalPCScope.GLOBAL_SCOPE_NAME); + ImplementedScope varScope = varContext.getScope(GlobalPCScope.GLOBAL_SCOPE_NAME); varContext.assertLegalVariableID(varName, varScope, formatManager); } diff --git a/code/src/java/pcgen/rules/context/AbstractReferenceContext.java b/code/src/java/pcgen/rules/context/AbstractReferenceContext.java index 2a1a0961f2b..530f118ecc7 100644 --- a/code/src/java/pcgen/rules/context/AbstractReferenceContext.java +++ b/code/src/java/pcgen/rules/context/AbstractReferenceContext.java @@ -25,6 +25,7 @@ import java.util.Comparator; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.TreeSet; @@ -486,7 +487,7 @@ private List generateList(Class cl, Comparator getFormatManager(String clName) { - return fmtLibrary.getFormatManager(clName); + return fmtLibrary.getFormatManager(Optional.empty(), clName); } void importCDOMToFormat(Class cl) diff --git a/code/src/java/pcgen/rules/context/LoadContextInst.java b/code/src/java/pcgen/rules/context/LoadContextInst.java index 0394b798f64..540356c78cc 100644 --- a/code/src/java/pcgen/rules/context/LoadContextInst.java +++ b/code/src/java/pcgen/rules/context/LoadContextInst.java @@ -27,6 +27,7 @@ import java.util.logging.Logger; import java.util.logging.Level; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.formula.inst.NEPFormula; import pcgen.base.proxy.DeferredMethodController; import pcgen.base.text.ParsingSeparator; @@ -116,7 +117,7 @@ public LoadContextInst(AbstractReferenceContext rc, AbstractListContext lc, Abst ref = rc; list = lc; obj = oc; - var = new VariableContext(new PCGenManagerFactory(this)); + var = new VariableContext(this); } @Override @@ -549,13 +550,16 @@ public void addDeferredMethodController(DeferredMethodController commitTask) private LoadContext dropIntoContext(PCGenScope lvs) { - Optional parent = lvs.getParentScope(); - if (!parent.isPresent()) + if (lvs.isGlobal()) { - //is Global return this; } - LoadContext parentLC = dropIntoContext(parent.get()); + List parents = lvs.drawsFrom(); + if (parents.isEmpty()) + { + return this; + } + LoadContext parentLC = dropIntoContext((PCGenScope) parents.get(0)); return new DerivedLoadContext(parentLC, lvs); } @@ -829,12 +833,13 @@ public LoadContext dropIntoContext(String scope) { return this; } - else if (!toScope.getParentScope().isPresent()) + else if (toScope.isGlobal()) { //No parent is global return parent; } - else if (toScope.getParentScope().get().equals(derivedScope)) + else if (!toScope.drawsFrom().isEmpty() + && toScope.drawsFrom().get(0).equals(derivedScope)) { //Direct drop from this return new DerivedLoadContext(this, toScope); diff --git a/code/src/java/pcgen/rules/context/PCGenManagerFactory.java b/code/src/java/pcgen/rules/context/PCGenManagerFactory.java index cdf157f5c96..507f7ae8204 100644 --- a/code/src/java/pcgen/rules/context/PCGenManagerFactory.java +++ b/code/src/java/pcgen/rules/context/PCGenManagerFactory.java @@ -1,16 +1,16 @@ /* * Copyright 2017 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -18,14 +18,20 @@ package pcgen.rules.context; import java.lang.ref.WeakReference; +import java.util.Objects; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; -import pcgen.base.formula.base.FormulaManager; import pcgen.base.formula.base.FormulaSemantics; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.FunctionLibrary; +import pcgen.base.formula.base.ImplementedScope; +import pcgen.base.formula.base.OperatorLibrary; +import pcgen.base.formula.base.ScopeImplementer; +import pcgen.base.formula.base.ScopeInstanceFactory; import pcgen.base.formula.base.ManagerFactory; -import pcgen.base.formula.base.ScopeInstance; +import pcgen.base.formula.base.VariableLibrary; +import pcgen.base.formula.base.VariableStore; +import pcgen.base.formula.base.WriteableVariableStore; import pcgen.cdom.formula.ManagerKey; import pcgen.cdom.helper.ReferenceDependency; @@ -37,40 +43,87 @@ public class PCGenManagerFactory implements ManagerFactory { private final WeakReference context; + private final ScopeImplementer scopeLib; + private final OperatorLibrary opLib; + private final VariableLibrary varLib; + private final FunctionLibrary functionLib; + private final VariableStore varStore; + private final ScopeInstanceFactory siFactory; /** - * Constructs a new PCGenManagerFactory with the provided LoadContext to be included - * in each Manager that is returned. - * + * Constructs a new PCGenManagerFactory with the provided components. + * * @param context - * The LoadContext for this ManagerFactory to include in each Manager that - * is returned + * The LoadContext for this ManagerFactory + * @param scopeLib + * The ScopeImplementer + * @param opLib + * The OperatorLibrary + * @param varLib + * The VariableLibrary + * @param functionLib + * The FunctionLibrary + * @param varStore + * The VariableStore + * @param siFactory + * The ScopeInstanceFactory */ - public PCGenManagerFactory(LoadContext context) + public PCGenManagerFactory(LoadContext context, ScopeImplementer scopeLib, + OperatorLibrary opLib, VariableLibrary varLib, FunctionLibrary functionLib, + VariableStore varStore, ScopeInstanceFactory siFactory) { - this.context = new WeakReference<>(context); + this.context = new WeakReference<>(Objects.requireNonNull(context)); + this.scopeLib = Objects.requireNonNull(scopeLib); + this.opLib = Objects.requireNonNull(opLib); + this.varLib = Objects.requireNonNull(varLib); + this.functionLib = Objects.requireNonNull(functionLib); + this.varStore = Objects.requireNonNull(varStore); + this.siFactory = Objects.requireNonNull(siFactory); } @Override - public FormulaSemantics generateFormulaSemantics(FormulaManager manager, LegalScope legalScope) + public DependencyManager generateDependencyManager() { - FormulaSemantics semantics = ManagerFactory.super.generateFormulaSemantics(manager, legalScope); - return semantics.getWith(ManagerKey.CONTEXT, context.get()); + DependencyManager depManager = new DependencyManager(); + depManager = depManager.getWith(DependencyManager.FUNCTION, functionLib); + depManager = depManager.getWith(DependencyManager.SCOPELIB, scopeLib); + depManager = depManager.getWith(DependencyManager.VARLIB, varLib); + depManager = depManager.getWith(DependencyManager.SIFACTORY, siFactory); + depManager = depManager.getWith(DependencyManager.OPLIB, opLib); + depManager = depManager.getWith(ManagerKey.CONTEXT, context.get()); + return depManager.getWith(ManagerKey.REFERENCES, new ReferenceDependency()); } @Override - public EvaluationManager generateEvaluationManager(FormulaManager formulaManager) + public FormulaSemantics generateFormulaSemantics(ImplementedScope scope) { - EvaluationManager evalManager = ManagerFactory.super.generateEvaluationManager(formulaManager); - return evalManager.getWith(ManagerKey.CONTEXT, context.get()); + FormulaSemantics semantics = new FormulaSemantics(); + semantics = semantics.getWith(FormulaSemantics.FUNCTION, functionLib); + semantics = semantics.getWith(FormulaSemantics.OPLIB, opLib); + semantics = semantics.getWith(FormulaSemantics.SCOPELIB, scopeLib); + semantics = semantics.getWith(FormulaSemantics.VARLIB, varLib); + semantics = semantics.getWith(FormulaSemantics.SIFACTORY, siFactory); + semantics = semantics.getWith(FormulaSemantics.SCOPE, scope); + return semantics.getWith(ManagerKey.CONTEXT, context.get()); } @Override - public DependencyManager generateDependencyManager(FormulaManager formulaManager, ScopeInstance scopeInst) + public EvaluationManager generateEvaluationManager() { - DependencyManager depManager = ManagerFactory.super.generateDependencyManager(formulaManager, scopeInst); - return depManager.getWith(ManagerKey.CONTEXT, context.get()).getWith(ManagerKey.REFERENCES, - new ReferenceDependency()); + EvaluationManager manager = new EvaluationManager(); + manager = manager.getWith(EvaluationManager.FUNCTION, functionLib); + manager = manager.getWith(EvaluationManager.OPLIB, opLib); + manager = manager.getWith(EvaluationManager.SCOPELIB, scopeLib); + manager = manager.getWith(EvaluationManager.VARLIB, varLib); + manager = manager.getWith(EvaluationManager.SIFACTORY, siFactory); + manager = manager.getWith(EvaluationManager.RESULTS, varStore); + return manager.getWith(ManagerKey.CONTEXT, context.get()); } + @Override + public PCGenManagerFactory createReplacement(WriteableVariableStore newVarStore) + { + return new PCGenManagerFactory(context.get(), scopeLib, opLib, varLib, + functionLib, newVarStore, siFactory); + } } diff --git a/code/src/java/pcgen/rules/context/VariableContext.java b/code/src/java/pcgen/rules/context/VariableContext.java index b3962fe5842..0acb327238b 100644 --- a/code/src/java/pcgen/rules/context/VariableContext.java +++ b/code/src/java/pcgen/rules/context/VariableContext.java @@ -1,16 +1,16 @@ /* * Copyright 2014-9 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -26,12 +26,14 @@ import pcgen.cdom.calculation.FormulaModifier; import pcgen.cdom.calculation.IgnoreVariables; import pcgen.base.formula.base.DependencyManager; +import pcgen.base.formula.base.DependencyStrategy; import pcgen.base.formula.base.FormulaFunction; -import pcgen.base.formula.base.FormulaManager; import pcgen.base.formula.base.FormulaSemantics; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.formula.base.ManagerFactory; import pcgen.base.formula.base.ScopeInstance; +import pcgen.base.formula.base.OperatorLibrary; +import pcgen.base.formula.base.ScopeInstanceFactory; import pcgen.base.formula.base.VarScoped; import pcgen.base.formula.base.VariableID; import pcgen.base.formula.base.VariableLibrary; @@ -39,17 +41,15 @@ import pcgen.base.formula.base.WriteableVariableStore; import pcgen.base.formula.exception.SemanticsException; import pcgen.base.formula.inst.FormulaUtilities; +import pcgen.base.formula.inst.ImplementedScopeLibrary; import pcgen.base.formula.inst.NEPFormula; -import pcgen.base.formula.inst.ScopeManagerInst; +import pcgen.base.formula.inst.SimpleOperatorLibrary; import pcgen.base.formula.inst.SimpleFunctionLibrary; +import pcgen.base.formula.inst.SimpleScopeInstanceFactory; import pcgen.base.formula.inst.VariableManager; -import pcgen.base.solver.DynamicSolverManager; -import pcgen.base.solver.FormulaSetupFactory; -import pcgen.base.solver.SimpleSolverFactory; -import pcgen.base.solver.SolverFactory; +import pcgen.base.solver.SimpleSolverManager; import pcgen.base.solver.SolverManager; import pcgen.base.solver.SupplierValueStore; -import pcgen.base.util.ComplexResult; import pcgen.base.util.FormatManager; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.enumeration.CharID; @@ -76,67 +76,51 @@ public class VariableContext implements VariableChannelFactory, VariableWrapperFactory, VariableLibrary { + /** - * This is the FormulaSetupFactory for this VariableContext. This is used to generate - * a FormulaManager for each PC. + * The FunctionLibrary for this VariableContext. Local so that we can add functions + * based on plugins and data. */ - private final FormulaSetupFactory formulaSetupFactory = new FormulaSetupFactory(); + private final WriteableFunctionLibrary myFunctionLibrary = new SimpleFunctionLibrary(); /** - * This is the ManagerFactory for this VariableContext. This is used to generate an - * EvaluationManager, FormulaSemantics and other relevant items provided to the - * formula system during formula processing. + * The ValueStore for this VariableContext. Local so that we can set the defaults for + * variable formats from data. */ - private final ManagerFactory managerFactory; + private final SupplierValueStore myValueStore = new SupplierValueStore(); - /* - * There are a series of items we override in the FormulaSetupFactory, and keep - * locally for certain types of processing. - */ /** - * The FunctionLibrary for the FormulaSetupFactory and this VariableContext. Local so - * that we can add functions based on plugins and data. + * The ImplementedScopeLibrary for this VariableContext. Local so that we can load + * scopes based on data and provide it to the VariableManager. */ - private final WriteableFunctionLibrary myFunctionLibrary = new SimpleFunctionLibrary(); + private final ImplementedScopeLibrary scopeLibrary = new ImplementedScopeLibrary(); /** - * The ValueStore for the FormulaSetupFactory and this VariableContext. Local so - * that we can set the defaults for variable formats from data. + * The OperatorLibrary for this VariableContext. */ - private final SupplierValueStore myValueStore = new SupplierValueStore(); + private final OperatorLibrary operatorLibrary; /** - * The SolverFactory for the FormulaSetupFactory and this VariableContext. Local so - * that we can set the defaults for variable formats from data. + * The ScopeInstanceFactory for this VariableContext. */ - private final SolverFactory solverFactory = new SimpleSolverFactory(myValueStore); + private final ScopeInstanceFactory scopeInstanceFactory; /** - * The LegalScopeManager for the FormulaSetupFactory and this VariableContext. Local - * so that we can load scopes based on data (like DYNAMICSCOPE:) and provide it to the - * VariableManager. + * The VariableManager for this VariableContext. Local so the data can assert legal + * variables. */ - private final ScopeManagerInst legalScopeManager = new ScopeManagerInst(); + private final VariableManager variableManager; /** - * The VariableManager for the FormulaSetupFactory and this VariableContext. Local so - * the data can assert legal variables. + * The ManagerFactory for this VariableContext. Lazily initialized because it needs + * a VariableStore, which isn't available until a PC is created. */ - private final VariableManager variableManager = - new VariableManager(legalScopeManager, myValueStore); + private PCGenManagerFactory managerFactory; /** - * The naive FormulaManager for this VariableContext. This serves only as a base item - * for loading formulas, not for evaluation. - * - * Each PC will also have its own FormulaManager (which will contain a dedicated - * VariableStore for that PC). This specific FormulaManager is derived from this - * FormulaManager in generateSolverManager(). - * - * Lazy instantiation to avoid trying to pull the "Global" scope before it is loaded - * from plugins. - */ - private FormulaManager loadFormulaManager = null; + * The LoadContext that owns this VariableContext. + */ + private final LoadContext loadContext; /** * Contains a VariableChannelFactory used to develop VariableChannels for this @@ -152,56 +136,60 @@ public class VariableContext implements VariableChannelFactory, new VariableWrapperFactoryInst(); /** - * Constructs a new VariableContext with the given ManagerFactory. - * - * @param managerFactory - * The ManagerFactory used to generate managers for formula evaluation by - * all items loaded while this VariableContext is active + * Constructs a new VariableContext for the given LoadContext. + * + * @param loadContext + * The LoadContext that owns this VariableContext */ - public VariableContext(ManagerFactory managerFactory) + public VariableContext(LoadContext loadContext) { - this.managerFactory = Objects.requireNonNull(managerFactory); + this.loadContext = Objects.requireNonNull(loadContext); for (FormulaFunction f : PluginFunctionLibrary.getInstance().getFunctions()) { myFunctionLibrary.addFunction(f); } FormulaUtilities.loadBuiltInFunctions(myFunctionLibrary); - LegalScopeUtilities.loadLegalScopeLibrary(legalScopeManager); - formulaSetupFactory.setValueStoreSupplier(() -> myValueStore); - formulaSetupFactory.setLegalScopeManagerSupplier(() -> legalScopeManager); - formulaSetupFactory.setFunctionLibrarySupplier(() -> myFunctionLibrary); - formulaSetupFactory.setVariableLibraryFunction((lsm, vs) -> variableManager); + LegalScopeUtilities.loadLegalScopeLibrary(scopeLibrary); + operatorLibrary = FormulaUtilities.loadBuiltInOperators(new SimpleOperatorLibrary()); + scopeInstanceFactory = new SimpleScopeInstanceFactory(scopeLibrary); + variableManager = new VariableManager(scopeLibrary, scopeLibrary, + scopeInstanceFactory, myValueStore); } /** - * Returns the FormulaManager for this VariableContext. - * - * Lazy instantiation to avoid trying to pull the "Global" scope before it is loaded - * from plugins (so care should be taken to only call this method after the "Global" - * scope is loaded). - * - * @return The FormulaManager for this VariableContext - */ - public FormulaManager getFormulaManager() + * Returns the ManagerFactory for this VariableContext. Creates a base ManagerFactory + * using a default (empty) variable store for load-time formula checking. + * + * @return The ManagerFactory for this VariableContext + */ + public ManagerFactory getManagerFactory() { - if (loadFormulaManager == null) + if (managerFactory == null) { - loadFormulaManager = formulaSetupFactory.generate(); + managerFactory = new PCGenManagerFactory(loadContext, scopeLibrary, + operatorLibrary, variableManager, myFunctionLibrary, + new pcgen.base.formula.inst.SimpleVariableStore(), scopeInstanceFactory); } - return loadFormulaManager; + return managerFactory; } /** - * Returns a new FormulaManager; method is designed to be used once with each PC. + * Returns a new ManagerFactory for a specific PC, using the given WriteableVariableStore. + * + * @param varStore + * The WriteableVariableStore for the PC + * @return A new ManagerFactory for a PC */ - public FormulaManager getPCFormulaManager() + public ManagerFactory getPCManagerFactory(WriteableVariableStore varStore) { - return formulaSetupFactory.generate(); + return new PCGenManagerFactory(loadContext, scopeLibrary, + operatorLibrary, variableManager, myFunctionLibrary, + varStore, scopeInstanceFactory); } /** * Returns a FormulaModifier based on the given information. - * + * * @param modType * The type of the modifier to be generated (e.g. "ADD") * @param instructions @@ -214,8 +202,7 @@ public FormulaManager getPCFormulaManager() * @return a FormulaModifier based on the given information */ public FormulaModifier getModifier(String modType, - String instructions, FormulaManager formulaManager, PCGenScope varScope, - FormatManager formatManager) + String instructions, PCGenScope varScope, FormatManager formatManager) { Class varClass = formatManager.getManagedClass(); ModifierFactory factory = TokenLibrary.getModifier(varClass, modType); @@ -226,9 +213,19 @@ public FormulaModifier getModifier(String modType, } FormulaModifier modifier = factory.getModifier(instructions, formatManager); - - FormulaSemantics semantics = managerFactory.generateFormulaSemantics(formulaManager, varScope); + + ManagerFactory mf = getManagerFactory(); + FormulaSemantics semantics = mf.generateFormulaSemantics(varScope); semantics = semantics.getWith(FormulaSemantics.INPUT_FORMAT, Optional.of(formatManager)); + Optional> scopeFormat = varScope.getFormatManager(loadContext); + if (scopeFormat.isPresent()) + { + pcgen.base.formula.base.FunctionLibrary functionLib = + semantics.get(FormulaSemantics.FUNCTION); + functionLib = new pcgen.cdom.formula.local.DefinedWrappingLibrary( + functionLib, "this", new Object(), scopeFormat.get()); + semantics = semantics.getWith(FormulaSemantics.FUNCTION, functionLib); + } try { modifier.isValid(semantics); @@ -240,11 +237,12 @@ public FormulaModifier getModifier(String modType, } /* - * getDependencies needs to be called during LST load, so that object references are captured + * getDependencies needs to be called during LST load, so that object references + * are captured */ - DependencyManager fdm = managerFactory.generateDependencyManager(formulaManager, null); + DependencyManager fdm = mf.generateDependencyManager(); fdm = fdm.getWith(DependencyManager.SCOPE, Optional.of(varScope)); - fdm = fdm.getWith(DependencyManager.VARSTRATEGY, Optional.of(new IgnoreVariables())); + fdm = fdm.getWith(DependencyManager.VARSTRATEGY, Optional.of(new IgnoreVariables())); fdm = fdm.getWith(ManagerKey.REFERENCES, new ReferenceDependency()); modifier.getDependencies(fdm); modifier.addReferences(fdm.get(ManagerKey.REFERENCES).getReferences()); @@ -253,10 +251,7 @@ public FormulaModifier getModifier(String modType, /** * Adds a FormulaFunction to the VariableContext. - * - * Behavior is not defined if an an attempt is made to add null or a FormulaFunction - * with a null name. An exception may be thrown. - * + * * @param function * The FormulaFunction to be added to the VariableContext */ @@ -267,101 +262,83 @@ public void addFunction(FormulaFunction function) /** * Returns the PCGenScope for the given name. - * + * * @param name * The name of the PCGenScope to be returned * @return The PCGenScope for the given name */ public PCGenScope getScope(String name) { - return (PCGenScope) legalScopeManager.getScope(name); + return (PCGenScope) scopeLibrary.getImplementedScope(name); } /** * Registers the given PCGenScope. - * + * * @param scope * The PCGenScope to be registered */ public void registerScope(PCGenScope scope) { - legalScopeManager.registerScope(scope); + scopeLibrary.addScope(scope); } /** - * Returns a Collection of the LegalScope objects for this Context. - * - * @return A Collection of the LegalScope objects for this Context + * Returns the ImplementedScopeLibrary for this VariableContext. + * + * @return The ImplementedScopeLibrary for this VariableContext */ - public Collection getScopes() + public ImplementedScopeLibrary getScopeLibrary() { - return legalScopeManager.getLegalScopes(); + return scopeLibrary; } /** - * Validates the default values provided to the formula system. Effectively ensures - * that each default value is not dependent on variables or in other ways can't be - * directly calculated. Will report to the error system any results from the analysis. + * Returns a Collection of all ImplementedScope objects registered in this + * VariableContext. + * + * @return A Collection of all ImplementedScope objects */ - public void validateDefaults() + public Collection getScopes() { - ComplexResult result = solverFactory.validateDefaults(); - if (!result.get()) - { - result.getMessages().stream().forEach(Logging::errorPrint); - } + return scopeLibrary.getScopes(); } /** - * Generates a SolverManager with a FormulaManager using the given - * WriteableVariableStore. - * + * Generates a SolverManager with the given WriteableVariableStore. + * * @param varStore * The WriteableVariableStore to be used for the returned SolverManager - * @return A SolverManager with a FormulaManager using the given - * WriteableVariableStore + * @return A SolverManager using the given WriteableVariableStore */ public SolverManager generateSolverManager(WriteableVariableStore varStore) { - FormulaManager derived = getFormulaManager().getWith(FormulaManager.RESULTS, varStore); - return new DynamicSolverManager(derived, managerFactory, solverFactory, varStore); + ManagerFactory mf = getPCManagerFactory(varStore); + return new SimpleSolverManager(variableManager::isLegalVariableID, + mf, myValueStore, varStore); } /** * Returns a "valid" NEPFormula for the given expression. - * - * If the given expression does not represent a valid formula, then this - * will throw an IllegalArgumentException. - * - * If the given expression does not return an object of the type in the - * given FormatManager, then this will throw an IllegalArgumentException. - * + * * @param activeScope - * The PCGenScope in which the NEPFormula is established and - * checked + * The PCGenScope in which the NEPFormula is established and checked * @param formatManager - * The FormatManager in which the NEPFormula is established and - * checked + * The FormatManager in which the NEPFormula is established and checked * @param instructions - * The String representation of the formula to be converted to a - * NEPFormula + * The String representation of the formula to be converted to a NEPFormula * @return a "valid" NEPFormula for the given expression */ public NEPFormula getValidFormula(PCGenScope activeScope, FormatManager formatManager, String instructions) { - return FormulaFactory.getValidFormula(instructions, managerFactory, getFormulaManager(), activeScope, + return FormulaFactory.getValidFormula(instructions, getManagerFactory(), activeScope, formatManager); } /** - * Adds a relationship between a Solver format and a default Supplier for that format - * of Solver to this VariableContext. - * - * The default Supplier for a format of Solver may not be redefined for a - * SolverFactory. Once a given default Supplier has been established for a format of - * Solver, this method MUST NOT be called a second time for that format of Solver. - * + * Adds a relationship between a Solver format and a default Supplier for that format. + * * @param * The format (class) of object changed by the given Supplier * @param varFormat @@ -370,18 +347,15 @@ public NEPFormula getValidFormula(PCGenScope activeScope, FormatManager void addDefault(FormatManager varFormat, Supplier defaultValue) { - solverFactory.addSolverFormat(varFormat, defaultValue); + myValueStore.addSolverFormat(varFormat, defaultValue); } /** * Returns the default value for a given Format (provided as a FormatManager). - * + * * @param * The format (class) of object for which the default value should be * returned @@ -391,18 +365,20 @@ public void addDefault(FormatManager varFormat, Supplier defaultValue) */ public T getDefaultValue(FormatManager variableFormat) { - return solverFactory.getDefault(variableFormat); + return variableFormat.initializeFrom(myValueStore); + } + + /** + * Validates that all defaults in the ValueStore are consistent. + */ + public void validateDefaults() + { + myValueStore.validateDefaults(); } /** * Returns true if there is a default modifier set for the given FormatManager. - * - * Warning: This is NOT whether there is a Default Value for the given FormatManager. - * This is a much simpler test that checks if there is a specifically provided Default - * Modifier. The distinction here is that a format like ARRAY[NUMBER] will return - * false from this; while it is legal, it never have a specifically defined default, - * as it is a derived default value. - * + * * @param formatManager * The FormatManager indicating the format to check for a default modifier * @return true if there is a default modifier set for the given FormatManager; false @@ -413,17 +389,27 @@ public boolean hasDefaultModifier(FormatManager formatManager) return myValueStore.get(formatManager) != null; } + /** + * Returns the ScopeInstanceFactory for this VariableContext. + * + * @return The ScopeInstanceFactory + */ + public ScopeInstanceFactory getScopeInstanceFactory() + { + return scopeInstanceFactory; + } + /* * Begin: (Delegated) Items part of VariableLibrary interface */ @Override - public boolean isLegalVariableID(LegalScope varScope, String varName) + public boolean isLegalVariableID(ImplementedScope varScope, String varName) { return variableManager.isLegalVariableID(varScope, varName); } @Override - public FormatManager getVariableFormat(LegalScope varScope, String varName) + public Optional> getVariableFormat(ImplementedScope varScope, String varName) { return variableManager.getVariableFormat(varScope, varName); } @@ -435,7 +421,7 @@ public VariableID getVariableID(ScopeInstance instance, String varName) } @Override - public void assertLegalVariableID(String varName, LegalScope varScope, FormatManager formatManager) + public void assertLegalVariableID(String varName, ImplementedScope varScope, FormatManager formatManager) { variableManager.assertLegalVariableID(varName, varScope, formatManager); } @@ -445,6 +431,12 @@ public List> getInvalidFormats() { return variableManager.getInvalidFormats(); } + + @Override + public T getDefault(FormatManager formatManager) + { + return variableManager.getDefault(formatManager); + } /* * End: (Delegated) Items part of VariableLibrary interface */ diff --git a/code/src/java/plugin/function/GetOtherFunction.java b/code/src/java/plugin/function/GetOtherFunction.java index ed78c0d630a..4ea402acfb9 100644 --- a/code/src/java/plugin/function/GetOtherFunction.java +++ b/code/src/java/plugin/function/GetOtherFunction.java @@ -22,13 +22,14 @@ import pcgen.base.formula.base.DynamicDependency; import pcgen.base.formula.base.EvaluationManager; import pcgen.base.formula.base.FormulaFunction; -import pcgen.base.formula.base.FormulaManager; import pcgen.base.formula.base.FormulaSemantics; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.ScopeImplementer; import pcgen.base.formula.base.ScopeInstance; import pcgen.base.formula.base.ScopeInstanceFactory; import pcgen.base.formula.base.TrainingStrategy; +import pcgen.base.formula.base.VarIDResolver; import pcgen.base.formula.base.VarScoped; +import pcgen.base.formula.base.VariableLibrary; import pcgen.base.formula.exception.SemanticsFailureException; import pcgen.base.formula.parse.ASTQuotString; import pcgen.base.formula.parse.Node; @@ -83,8 +84,8 @@ public FormatManager allowArgs(SemanticsVisitor visitor, Node[] args, Formula + " Static String (first arg cannot be evaluated)"); } String legalScopeName = qs.getText(); - FormulaManager formulaManager = semantics.get(FormulaSemantics.FMANAGER); - PCGenScope legalScope = (PCGenScope) formulaManager.getScopeInstanceFactory().getScope(legalScopeName); + ScopeImplementer scopeImplementer = semantics.get(FormulaSemantics.SCOPELIB); + PCGenScope legalScope = (PCGenScope) scopeImplementer.getImplementedScope(legalScopeName); if (legalScope == null) { throw new SemanticsFailureException( @@ -125,16 +126,13 @@ public FormatManager allowArgs(SemanticsVisitor visitor, Node[] args, Formula public Object evaluate(EvaluateVisitor visitor, Node[] args, EvaluationManager manager) { String legalScopeName = ((ASTQuotString) args[0]).getText(); - FormulaManager formulaManager = manager.get(EvaluationManager.FMANAGER); - PCGenScope legalScope = (PCGenScope) formulaManager.getScopeInstanceFactory().getScope(legalScopeName); + ScopeImplementer scopeImplementer = manager.get(EvaluationManager.SCOPELIB); + PCGenScope legalScope = (PCGenScope) scopeImplementer.getImplementedScope(legalScopeName); LoadContext context = manager.get(ManagerKey.CONTEXT); VarScoped vs = (VarScoped) args[1].jjtAccept(visitor, manager.getWith(EvaluationManager.ASSERTED, legalScope.getFormatManager(context))); - FormulaManager fm = manager.get(EvaluationManager.FMANAGER); - ScopeInstanceFactory siFactory = fm.getScopeInstanceFactory(); - Optional localScopeName = vs.getLocalScopeName(); - //TODO This may be a bug? What if it doesn't have a localScopeName? - ScopeInstance scopeInst = siFactory.get(localScopeName.get(), Optional.of(vs)); + ScopeInstanceFactory siFactory = manager.get(EvaluationManager.SIFACTORY); + ScopeInstance scopeInst = siFactory.get(legalScopeName, vs); //Rest of Equation return args[2].jjtAccept(visitor, manager.getWith(EvaluationManager.INSTANCE, scopeInst)); } @@ -144,17 +142,21 @@ public Optional> getDependencies(DependencyVisitor visitor, Dep { String legalScopeName = ((ASTQuotString) args[0]).getText(); TrainingStrategy ts = new TrainingStrategy(); - FormulaManager formulaManager = fdm.get(DependencyManager.FMANAGER); - ScopeInstanceFactory scopeInstanceFactory = formulaManager.getScopeInstanceFactory(); - PCGenScope legalScope = (PCGenScope) scopeInstanceFactory.getScope(legalScopeName); + ScopeImplementer scopeImplementer = fdm.get(DependencyManager.SCOPELIB); + PCGenScope legalScope = (PCGenScope) scopeImplementer.getImplementedScope(legalScopeName); LoadContext context = fdm.get(ManagerKey.CONTEXT); args[1].jjtAccept(visitor, fdm.getWith(DependencyManager.VARSTRATEGY, Optional.of(ts)) .getWith(DependencyManager.ASSERTED, legalScope.getFormatManager(context))); - DynamicDependency dd = new DynamicDependency(ts.getControlVar(), LegalScope.getFullName(legalScope)); - fdm.get(DependencyManager.DYNAMIC).addDependency(dd); + ScopeInstanceFactory siFactory = fdm.get(DependencyManager.SIFACTORY); + VariableLibrary varLib = fdm.get(DependencyManager.VARLIB); + VarIDResolver varResolver = (scopeName, sourceObject, varName) -> + varLib.getVariableID(siFactory.get(scopeName, sourceObject), varName); + DynamicDependency dd = new DynamicDependency(varResolver, ts.getControlVar(), legalScope.getName()); DependencyManager dynamic = fdm.getWith(DependencyManager.VARSTRATEGY, Optional.of(dd)); dynamic = dynamic.getWith(DependencyManager.SCOPE, Optional.of(legalScope)); //Rest of Equation - return (Optional>) args[2].jjtAccept(visitor, dynamic); + FormatManager returnFormat = (FormatManager) args[2].jjtAccept(visitor, dynamic); + fdm.get(DependencyManager.DYNAMIC).addDependency(dd); + return Optional.of(returnFormat); } } diff --git a/code/src/java/plugin/function/InputFunction.java b/code/src/java/plugin/function/InputFunction.java index 5783821c7bc..34c0b9dee67 100644 --- a/code/src/java/plugin/function/InputFunction.java +++ b/code/src/java/plugin/function/InputFunction.java @@ -24,7 +24,7 @@ import pcgen.base.formula.base.EvaluationManager; import pcgen.base.formula.base.FormulaFunction; import pcgen.base.formula.base.FormulaSemantics; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.formula.base.VariableLibrary; import pcgen.base.formula.exception.SemanticsFailureException; import pcgen.base.formula.parse.ASTQuotString; @@ -38,6 +38,7 @@ import pcgen.base.util.FormatManager; import pcgen.output.channel.ChannelUtilities; + /** * InputFunction is a function designed to allow pulling information from a channel (as * defined by the argument to the input function). @@ -74,14 +75,14 @@ public final FormatManager allowArgs(SemanticsVisitor visitor, Node[] args, F } String inputName = ((SimpleNode) inputNode).getText(); String varName = ChannelUtilities.createVarName(inputName); - VariableLibrary varLib = semantics.get(FormulaSemantics.FMANAGER).getFactory(); - LegalScope scope = semantics.get(FormulaSemantics.SCOPE); - FormatManager formatManager = varLib.getVariableFormat(scope, varName); - if (formatManager == null) + VariableLibrary varLib = semantics.get(FormulaSemantics.VARLIB); + ImplementedScope scope = semantics.get(FormulaSemantics.SCOPE); + Optional> formatManager = varLib.getVariableFormat(scope, varName); + if (formatManager.isEmpty()) { throw new SemanticsFailureException("Input Channel: " + varName + " was not found"); } - return formatManager; + return formatManager.get(); } @Override @@ -103,6 +104,6 @@ public Optional> getDependencies(DependencyVisitor visitor, Dep { ASTQuotString inputName = (ASTQuotString) args[0]; String varName = inputName.getText(); - return visitor.visitVariable(ChannelUtilities.createVarName(varName), fdm); + return Optional.of(visitor.visitVariable(ChannelUtilities.createVarName(varName), fdm)); } } diff --git a/code/src/java/plugin/function/LookupFunction.java b/code/src/java/plugin/function/LookupFunction.java index dfe4a6f6e84..2d9ac57c203 100644 --- a/code/src/java/plugin/function/LookupFunction.java +++ b/code/src/java/plugin/function/LookupFunction.java @@ -24,8 +24,8 @@ import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; import pcgen.base.formula.base.FormulaFunction; -import pcgen.base.formula.base.FormulaManager; import pcgen.base.formula.base.FormulaSemantics; +import pcgen.base.formula.base.VariableLibrary; import pcgen.base.formula.exception.SemanticsFailureException; import pcgen.base.formula.parse.ASTQuotString; import pcgen.base.formula.parse.Node; @@ -163,8 +163,8 @@ public Object evaluate(EvaluateVisitor visitor, Node[] args, EvaluationManager m FormatManager fmt = column.getFormatManager(); System.out.println("Lookup called on invalid column: '" + columnName + "' is not present on table '" + dataTable.getName() + "' assuming default for " + fmt.getIdentifierType()); - FormulaManager fm = manager.get(EvaluationManager.FMANAGER); - return fm.getDefault(fmt); + VariableLibrary varLib = manager.get(EvaluationManager.VARLIB); + return varLib.getDefault(fmt); } String lookupRule = "EXACT"; if (args.length == 4) @@ -179,8 +179,8 @@ public Object evaluate(EvaluateVisitor visitor, Node[] args, EvaluationManager m System.out.println( "Lookup called on invalid item: '" + lookupValue + "' is not present in the first row of table '" + dataTable.getName() + "' assuming default for " + fmt.getIdentifierType()); - FormulaManager fm = manager.get(EvaluationManager.FMANAGER); - return fm.getDefault(fmt); + VariableLibrary varLib = manager.get(EvaluationManager.VARLIB); + return varLib.getDefault(fmt); } return dataTable.lookup(lookupType, lookupValue, columnName); } diff --git a/code/src/java/plugin/lsttokens/ModifyLst.java b/code/src/java/plugin/lsttokens/ModifyLst.java index 3419da3d75a..2d5b6078bce 100644 --- a/code/src/java/plugin/lsttokens/ModifyLst.java +++ b/code/src/java/plugin/lsttokens/ModifyLst.java @@ -25,8 +25,6 @@ import java.util.Set; import pcgen.cdom.calculation.FormulaModifier; -import pcgen.base.formula.base.FormulaManager; -import pcgen.base.formula.base.FunctionLibrary; import pcgen.base.lang.StringUtil; import pcgen.base.text.ParsingSeparator; import pcgen.base.util.CaseInsensitiveMap; @@ -35,7 +33,6 @@ import pcgen.cdom.base.VarContainer; import pcgen.cdom.base.VarHolder; import pcgen.cdom.content.VarModifier; -import pcgen.cdom.formula.local.DefinedWrappingLibrary; import pcgen.cdom.formula.scope.PCGenScope; import pcgen.rules.context.LoadContext; import pcgen.rules.persistence.token.AbstractNonEmptyToken; @@ -63,7 +60,7 @@ public ParseResult parseNonEmptyToken(LoadContext context, VarHolder obj, String { PCGenScope scope = context.getActiveScope(); VarModifier varModifier = parseModifyInfo(context, value, scope, - generateFormulaManager(context, scope), getTokenName(), 0); + getTokenName(), 0); obj.addModifier(varModifier); } catch (ModifyException e) @@ -76,7 +73,7 @@ public ParseResult parseNonEmptyToken(LoadContext context, VarHolder obj, String /** * Parses the 3 arguments plus associations that are part of a token doing a * modification. - * + * * @param context * The LoadContext for processing * @param value @@ -92,14 +89,9 @@ public ParseResult parseNonEmptyToken(LoadContext context, VarHolder obj, String * if the parsing failed. The message contains information about the error */ public static VarModifier parseModifyInfo(LoadContext context, - String value, PCGenScope scope, FormulaManager formulaManager, + String value, PCGenScope scope, String tokenName, int argsConsumed) throws ModifyException { - /* - * TODO CODE-3299 Need to check the object type of the VarHolder to make sure it - * is legal. Note it's a proxy, so a @ReadOnly method needs to be used to support - * the analysis. - */ ParsingSeparator sep = new ParsingSeparator(value, '|'); sep.addGroupingPair('[', ']'); sep.addGroupingPair('(', ')'); @@ -130,10 +122,16 @@ public static VarModifier parseModifyInfo(LoadContext context, FormulaModifier modifier; try { - FormatManager format = context.getVariableContext().getVariableFormat(scope, varName); + Optional> format = context.getVariableContext().getVariableFormat(scope, varName); + if (format.isEmpty()) + { + throw new ModifyException( + tokenName + " found no format for var name: " + varName + + "(scope: " + scope.getName() + ")"); + } modifier = context.getVariableContext().getModifier(modIdentification, - modInstructions, formulaManager, scope, format); + modInstructions, scope, format.get()); } catch (IllegalArgumentException e) { @@ -166,23 +164,6 @@ public static VarModifier parseModifyInfo(LoadContext context, return new VarModifier<>(varName, scope, modifier); } - private final FormulaManager generateFormulaManager(LoadContext context, PCGenScope scope) - { - FormulaManager formulaManager = - context.getVariableContext().getFormulaManager(); - Optional> formatManager = scope.getFormatManager(context); - if (formatManager.isEmpty()) - { - //Okay, we won't add this() - return formulaManager; - } - //Note: Passing new Object() as DefinedValue is a dummy - FunctionLibrary functionLibrary = new DefinedWrappingLibrary( - formulaManager.get(FormulaManager.FUNCTION), "this", new Object(), - formatManager.get()); - return formulaManager.getWith(FormulaManager.FUNCTION, functionLibrary); - } - @Override public String[] unparse(LoadContext context, VarContainer obj) { diff --git a/code/src/java/plugin/lsttokens/ModifyOtherLst.java b/code/src/java/plugin/lsttokens/ModifyOtherLst.java index 517e5721d9e..c2025359cbf 100644 --- a/code/src/java/plugin/lsttokens/ModifyOtherLst.java +++ b/code/src/java/plugin/lsttokens/ModifyOtherLst.java @@ -19,23 +19,16 @@ import java.util.ArrayList; import java.util.List; -import java.util.Optional; import java.util.StringJoiner; -import pcgen.base.formula.base.FormulaManager; -import pcgen.base.formula.base.FunctionLibrary; -import pcgen.base.formula.base.LegalScope; import pcgen.base.text.ParsingSeparator; -import pcgen.base.util.FormatManager; import pcgen.cdom.base.Constants; import pcgen.cdom.base.VarContainer; import pcgen.cdom.base.VarHolder; import pcgen.cdom.content.RemoteModifier; import pcgen.cdom.content.VarModifier; -import pcgen.cdom.formula.local.DefinedWrappingLibrary; import pcgen.cdom.formula.scope.PCGenScope; import pcgen.cdom.grouping.GroupingCollection; -import pcgen.rules.context.AbstractObjectContext.DummyCDOMObject; import pcgen.rules.context.LoadContext; import pcgen.rules.persistence.token.AbstractNonEmptyToken; import pcgen.rules.persistence.token.CDOMInterfaceToken; @@ -72,7 +65,7 @@ public ParseResult parseNonEmptyToken(LoadContext context, VarHolder obj, String return new ParseResult.Fail( getTokenName() + " found illegal variable scope: " + scopeName + " as first argument: " + value); } - if (lvs.getParentScope() == null) + if (lvs.isGlobal()) { return new ParseResult.Fail( getTokenName() + " found illegal variable scope: " + scopeName + " is a global scope"); @@ -81,7 +74,7 @@ public ParseResult parseNonEmptyToken(LoadContext context, VarHolder obj, String { return new ParseResult.Fail(getTokenName() + " needed 2nd argument: " + value); } - String fullName = LegalScope.getFullName(lvs); + String fullName = lvs.getName(); LoadContext subContext = context.dropIntoContext(fullName); String groupingName = sep.next(); @@ -96,7 +89,7 @@ public ParseResult parseNonEmptyToken(LoadContext context, VarHolder obj, String try { VarModifier vm = ModifyLst.parseModifyInfo(subContext, sb.toString(), - scope, generateFormulaManager(context, scope), getTokenName(), 2); + scope, getTokenName(), 2); obj.addRemoteModifier(new RemoteModifier<>(group, vm)); } catch (ModifyException e) @@ -106,34 +99,6 @@ public ParseResult parseNonEmptyToken(LoadContext context, VarHolder obj, String return ParseResult.SUCCESS; } - private final FormulaManager generateFormulaManager(LoadContext context, PCGenScope scope) - { - FormulaManager formulaManager = - context.getVariableContext().getFormulaManager(); - FunctionLibrary functionManager = formulaManager.get(FormulaManager.FUNCTION); - boolean modified = false; - Optional> sourceFormatManager = scope.getFormatManager(context); - if (sourceFormatManager.isPresent()) - { - functionManager = new DefinedWrappingLibrary(functionManager, - "source", new DummyCDOMObject(), sourceFormatManager.get()); - modified = true; - } - Optional> targetFormatManager = scope.getFormatManager(context); - if (targetFormatManager.isPresent()) - { - functionManager = new DefinedWrappingLibrary(functionManager, - "target", new DummyCDOMObject(), targetFormatManager.get()); - modified = true; - } - if (!modified) - { - //Fine then :P - return formulaManager; - } - return formulaManager.getWith(FormulaManager.FUNCTION, functionManager); - } - @Override public String[] unparse(LoadContext context, VarContainer obj) { @@ -144,7 +109,7 @@ public String[] unparse(LoadContext context, VarContainer obj) VarModifier vm = rm.getVarModifier(); StringBuilder sb = new StringBuilder(); GroupingCollection og = rm.getGrouping(); - sb.append(LegalScope.getFullName(vm.getLegalScope())); + sb.append(vm.getLegalScope().getName()); sb.append(Constants.PIPE); sb.append(og.getInstructions()); sb.append(Constants.PIPE); diff --git a/code/src/java/plugin/lsttokens/race/FaceToken.java b/code/src/java/plugin/lsttokens/race/FaceToken.java index 107f131b69c..ad23f51286d 100644 --- a/code/src/java/plugin/lsttokens/race/FaceToken.java +++ b/code/src/java/plugin/lsttokens/race/FaceToken.java @@ -72,8 +72,7 @@ protected ParseResult parseNonEmptyToken(LoadContext context, LimitedVarHolder r { modifier = context.getVariableContext().getModifier(MOD_IDENTIFICATION, - value, context.getVariableContext().getFormulaManager(), - scope, formatManager); + value, scope, formatManager); } catch (IllegalArgumentException iae) { @@ -112,7 +111,7 @@ public String[] unparse(LoadContext context, LimitedVarContainer race) { FormulaModifier modifier = vm.getModifier(); if (CControl.FACE.getDefaultValue().equals(vm.getVarName()) - && (!vm.getLegalScope().getParentScope().isPresent()) + && (vm.getLegalScope().isGlobal()) && (modifier.getIdentification().equals(MOD_IDENTIFICATION))) { face = modifier.getInstructions(); diff --git a/code/src/java/plugin/lsttokens/variable/LocalToken.java b/code/src/java/plugin/lsttokens/variable/LocalToken.java index f4467bbf827..b7870107baa 100644 --- a/code/src/java/plugin/lsttokens/variable/LocalToken.java +++ b/code/src/java/plugin/lsttokens/variable/LocalToken.java @@ -17,7 +17,7 @@ */ package plugin.lsttokens.variable; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.ImplementedScope; import pcgen.base.formula.exception.LegalVariableException; import pcgen.base.util.FormatManager; import pcgen.cdom.base.Constants; @@ -137,7 +137,7 @@ public String[] unparse(LoadContext context, DatasetVariable dv) return null; } StringBuilder sb = new StringBuilder(); - sb.append(LegalScope.getFullName(scope)); + sb.append(scope.getName()); sb.append(Constants.PIPE); String identifier = format.getIdentifierType(); if (!"NUMBER".equals(identifier)) From 08034b6c928fb8baaf196beaf7d4a390b1e94b92 Mon Sep 17 00:00:00 2001 From: Vest Date: Sat, 16 May 2026 15:36:22 +0200 Subject: [PATCH 03/29] Fix simple test compilation errors for new PCGen-Formula/PCGen-base APIs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mechanical updates to test/testcommon sources to align with renamed and reshaped APIs in the JPMS subprojects: - Modifier.getDependencies → captureDependencies, added isValid stub - NEPFormula.getDependencies → captureDependencies - LegalScope → ImplementedScope / PCGenScope type references - SimpleScopeInstance constructor: removed Optional parent parameter - AggressiveSolverManager/DynamicSolverManager → SimpleSolverManager - ColumnFormatFactory/TableFormatFactory.build() now takes Optional params Remaining test errors require rewriting AbstractFormulaTestCase (removes FormulaManager) and dependent test classes — left for a separate change. --- .../compare/InequalityTesterInst.java | 6 +-- .../testcommon/util/SimpleSetModifier.java | 9 +++- .../formula/testsupport/AbstractModifier.java | 13 ++++-- .../pcgen/cdom/helper/BridgeListenerTest.java | 5 +-- .../plugin/function/LookupFunctionTest.java | 43 ++++++++++--------- .../utest/plugin/lsttokens/ModifyLstTest.java | 4 +- .../plugin/lsttokens/ModifyOtherLstTest.java | 4 +- 7 files changed, 48 insertions(+), 36 deletions(-) diff --git a/code/src/testcommon/compare/InequalityTesterInst.java b/code/src/testcommon/compare/InequalityTesterInst.java index 8e8fa30ec11..b20525fbcb3 100644 --- a/code/src/testcommon/compare/InequalityTesterInst.java +++ b/code/src/testcommon/compare/InequalityTesterInst.java @@ -30,8 +30,7 @@ import pcgen.base.formula.base.ScopeInstanceFactory; import pcgen.base.formula.inst.SimpleVariableStore; import pcgen.base.lang.StringUtil; -import pcgen.base.solver.AggressiveSolverManager; -import pcgen.base.solver.DynamicSolverManager; +import pcgen.base.solver.SimpleSolverManager; import pcgen.base.test.InequalityTester; import pcgen.cdom.facet.model.ClassFacet; import pcgen.cdom.formula.MonitorableVariableStore; @@ -56,8 +55,7 @@ public final class InequalityTesterInst implements InequalityTester INEQ_MAP.put(PlayerCharacter.class, new IgnoreInequality()); INEQ_MAP.put(SpellSupportForPCClass.class, new IgnoreInequality()); INEQ_MAP.put(ScopeInstanceFactory.class, new IgnoreInequality()); - INEQ_MAP.put(AggressiveSolverManager.class, new IgnoreInequality()); - INEQ_MAP.put(DynamicSolverManager.class, new IgnoreInequality()); + INEQ_MAP.put(SimpleSolverManager.class, new IgnoreInequality()); //TODO SimpleVariableStore should not be ignored - but needs (hard?) custom comparator due to scopes... INEQ_MAP.put(SimpleVariableStore.class, new IgnoreInequality()); //TODO MonitorableVariableStore should not be ignored - but needs (hard?) custom comparator due to scopes... diff --git a/code/src/testcommon/util/SimpleSetModifier.java b/code/src/testcommon/util/SimpleSetModifier.java index fa30d447362..eca285107f8 100644 --- a/code/src/testcommon/util/SimpleSetModifier.java +++ b/code/src/testcommon/util/SimpleSetModifier.java @@ -17,6 +17,8 @@ import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; +import pcgen.base.formula.base.FormulaSemantics; +import pcgen.base.formula.exception.SemanticsException; import pcgen.base.solver.Modifier; import pcgen.base.util.FormatManager; @@ -39,7 +41,12 @@ public T process(EvaluationManager manager) } @Override - public void getDependencies(DependencyManager fdm) + public void captureDependencies(DependencyManager fdm) + { + } + + @Override + public void isValid(FormulaSemantics semantics) throws SemanticsException { } diff --git a/code/src/utest/pcgen/cdom/formula/testsupport/AbstractModifier.java b/code/src/utest/pcgen/cdom/formula/testsupport/AbstractModifier.java index fc0bf40aa4b..f394b8a891c 100644 --- a/code/src/utest/pcgen/cdom/formula/testsupport/AbstractModifier.java +++ b/code/src/utest/pcgen/cdom/formula/testsupport/AbstractModifier.java @@ -27,6 +27,8 @@ import pcgen.base.formatmanager.FormatUtilities; import pcgen.base.formula.base.DependencyManager; import pcgen.base.formula.base.EvaluationManager; +import pcgen.base.formula.base.FormulaSemantics; +import pcgen.base.formula.exception.SemanticsException; import pcgen.base.formula.inst.ComplexNEPFormula; import pcgen.base.formula.inst.NEPFormula; import pcgen.base.lang.NumberUtilities; @@ -53,7 +55,12 @@ public AbstractModifier(int inherent, FormatManager cl, int priority) } @Override - public void getDependencies(DependencyManager fdm) + public void captureDependencies(DependencyManager fdm) + { + } + + @Override + public void isValid(FormulaSemantics semantics) throws SemanticsException { } @@ -217,9 +224,9 @@ public Number process(EvaluationManager manager) } @Override - public void getDependencies(DependencyManager fdm) + public void captureDependencies(DependencyManager fdm) { - value.getDependencies(fdm); + value.captureDependencies(fdm); } @Override diff --git a/code/src/utest/pcgen/cdom/helper/BridgeListenerTest.java b/code/src/utest/pcgen/cdom/helper/BridgeListenerTest.java index 476f6c53952..04f27ec810c 100644 --- a/code/src/utest/pcgen/cdom/helper/BridgeListenerTest.java +++ b/code/src/utest/pcgen/cdom/helper/BridgeListenerTest.java @@ -23,7 +23,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.util.Optional; import pcgen.base.formula.base.ScopeInstance; import pcgen.base.formula.base.VariableID; @@ -93,7 +92,7 @@ void testVariableBasic() BridgeListener bridge = new BridgeListener(id, target, this); GlobalPCScope scope = new GlobalPCScope(); ScopeInstance instance = - new SimpleScopeInstance(Optional.empty(), scope, owner); + new SimpleScopeInstance(scope, owner); TransparentFormatManager formatManager = new TransparentFormatManager(PCTemplate.class, "PCTEMPLATE"); @@ -126,7 +125,7 @@ void testVariableArray() BridgeListener bridge = new BridgeListener(id, target, this); GlobalPCScope scope = new GlobalPCScope(); ScopeInstance instance = - new SimpleScopeInstance(Optional.empty(), scope, owner); + new SimpleScopeInstance(scope, owner); TransparentFormatManager formatManager = new TransparentFormatManager(PCTemplate[].class, "PCTEMPLATE"); diff --git a/code/src/utest/plugin/function/LookupFunctionTest.java b/code/src/utest/plugin/function/LookupFunctionTest.java index 879119239cc..05d190a45bd 100644 --- a/code/src/utest/plugin/function/LookupFunctionTest.java +++ b/code/src/utest/plugin/function/LookupFunctionTest.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; import pcgen.base.formatmanager.FormatUtilities; import pcgen.base.formatmanager.SimpleFormatManagerLibrary; @@ -154,7 +155,7 @@ public void testInvalidWrongFormat1() VariableLibrary vl = getVariableLibrary(); WriteableVariableStore vs = getVariableStore(); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("STRING", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("STRING"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID columnID = @@ -182,14 +183,14 @@ public void testInvalidWrongFormat2() WriteableVariableStore vs = getVariableStore(); TableFormatFactory fac = new TableFormatFactory(tablefinder); - FormatManager tableMgr = fac.build("STRING", formatLibrary); + FormatManager tableMgr = fac.build(Optional.empty(), Optional.of("STRING"), formatLibrary); vl.assertLegalVariableID("TableA", getGlobalScope(), tableMgr); VariableID tableID = vl.getVariableID(getGlobalScopeInst(), "TableA"); vs.put(tableID, tableMgr.convert("A")); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("STRING", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("STRING"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID columnID = @@ -213,7 +214,7 @@ public void testInvalidWrongFormat3() WriteableVariableStore vs = getVariableStore(); TableFormatFactory fac = new TableFormatFactory(tablefinder); - FormatManager tableMgr = fac.build("STRING", formatLibrary); + FormatManager tableMgr = fac.build(Optional.empty(), Optional.of("STRING"), formatLibrary); vl.assertLegalVariableID("TableA", getGlobalScope(), tableMgr); VariableID tableID = vl.getVariableID(getGlobalScopeInst(), "TableA"); @@ -236,7 +237,7 @@ public void testInvalidBadSemantics1() WriteableVariableStore vs = getVariableStore(); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("STRING", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("STRING"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID columnID = @@ -264,14 +265,14 @@ public void testInvalidBadSemantics2() WriteableVariableStore vs = getVariableStore(); TableFormatFactory fac = new TableFormatFactory(tablefinder); - FormatManager tableMgr = fac.build("STRING", formatLibrary); + FormatManager tableMgr = fac.build(Optional.empty(), Optional.of("STRING"), formatLibrary); vl.assertLegalVariableID("TableA", getGlobalScope(), tableMgr); VariableID tableID = vl.getVariableID(getGlobalScopeInst(), "TableA"); vs.put(tableID, tableMgr.convert("A")); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("STRING", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("STRING"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID columnID = @@ -299,7 +300,7 @@ public void testInvalidBadSemantics3() WriteableVariableStore vs = getVariableStore(); TableFormatFactory fac = new TableFormatFactory(tablefinder); - FormatManager tableMgr = fac.build("STRING", formatLibrary); + FormatManager tableMgr = fac.build(Optional.empty(), Optional.of("STRING"), formatLibrary); vl.assertLegalVariableID("TableA", getGlobalScope(), tableMgr); VariableID tableID = vl.getVariableID(getGlobalScopeInst(), "TableA"); @@ -326,11 +327,11 @@ public void testBasic() WriteableVariableStore vs = getVariableStore(); TableFormatFactory fac = new TableFormatFactory(tablefinder); - FormatManager tableMgr = fac.build("STRING", formatLibrary); + FormatManager tableMgr = fac.build(Optional.empty(), Optional.of("STRING"), formatLibrary); vl.assertLegalVariableID("TableA", getGlobalScope(), tableMgr); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("NUMBER", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("NUMBER"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID tableID = vl.getVariableID(getGlobalScopeInst(), "TableA"); @@ -365,7 +366,7 @@ public void testInvalidFormatDirect() WriteableVariableStore vs = getVariableStore(); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("NUMBER", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("NUMBER"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID columnID = @@ -402,7 +403,7 @@ public void testInvalidTableFormatDirect() WriteableVariableStore vs = getVariableStore(); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("NUMBER", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("NUMBER"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID columnID = @@ -439,7 +440,7 @@ public void testInvalidNameDirect() WriteableVariableStore vs = getVariableStore(); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("NUMBER", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("NUMBER"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID columnID = @@ -476,7 +477,7 @@ public void testDirect() WriteableVariableStore vs = getVariableStore(); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("NUMBER", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("NUMBER"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID columnID = @@ -512,7 +513,7 @@ public void testInDirectColumn() finder.map.put("Value", buildColumn("Value", numberManager)); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("NUMBER", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("NUMBER"), formatLibrary); VariableLibrary vl = getVariableLibrary(); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); @@ -543,7 +544,7 @@ public void testInvalidExtra() WriteableVariableStore vs = getVariableStore(); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("NUMBER", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("NUMBER"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID columnID = @@ -583,11 +584,11 @@ public void testNoColumn() WriteableVariableStore vs = getVariableStore(); TableFormatFactory fac = new TableFormatFactory(tablefinder); - FormatManager tableMgr = fac.build("STRING", formatLibrary); + FormatManager tableMgr = fac.build(Optional.empty(), Optional.of("STRING"), formatLibrary); vl.assertLegalVariableID("TableA", getGlobalScope(), tableMgr); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("NUMBER", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("NUMBER"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID tableID = vl.getVariableID(getGlobalScopeInst(), "TableA"); @@ -628,11 +629,11 @@ public void testNoLookup() WriteableVariableStore vs = getVariableStore(); TableFormatFactory fac = new TableFormatFactory(tablefinder); - FormatManager tableMgr = fac.build("STRING", formatLibrary); + FormatManager tableMgr = fac.build(Optional.empty(), Optional.of("STRING"), formatLibrary); vl.assertLegalVariableID("TableA", getGlobalScope(), tableMgr); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("NUMBER", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("NUMBER"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID tableID = vl.getVariableID(getGlobalScopeInst(), "TableA"); @@ -684,7 +685,7 @@ public void testLessThan() WriteableVariableStore vs = getVariableStore(); ColumnFormatFactory cfac = new ColumnFormatFactory(finder); - FormatManager columnMgr = cfac.build("NUMBER", formatLibrary); + FormatManager columnMgr = cfac.build(Optional.empty(), Optional.of("NUMBER"), formatLibrary); vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr); VariableID columnID = diff --git a/code/src/utest/plugin/lsttokens/ModifyLstTest.java b/code/src/utest/plugin/lsttokens/ModifyLstTest.java index 24b5af8a9e8..efaf79dc0ec 100644 --- a/code/src/utest/plugin/lsttokens/ModifyLstTest.java +++ b/code/src/utest/plugin/lsttokens/ModifyLstTest.java @@ -21,10 +21,10 @@ import java.net.URISyntaxException; -import pcgen.base.formula.base.LegalScope; import pcgen.base.util.FormatManager; import pcgen.cdom.base.VarContainer; import pcgen.cdom.base.VarHolder; +import pcgen.cdom.formula.scope.PCGenScope; import pcgen.core.PCTemplate; import pcgen.persistence.PersistenceLayerException; import pcgen.rules.context.LoadContext; @@ -245,7 +245,7 @@ protected void additionalSetup(LoadContext context) { super.additionalSetup(context); FormatManager formatManager = context.getReferenceContext().getFormatManager("NUMBER"); - LegalScope scope = context.getActiveScope(); + PCGenScope scope = context.getActiveScope(); context.getVariableContext().assertLegalVariableID("MyVar", scope, formatManager); context.getVariableContext().assertLegalVariableID("OtherVar", scope, formatManager); } diff --git a/code/src/utest/plugin/lsttokens/ModifyOtherLstTest.java b/code/src/utest/plugin/lsttokens/ModifyOtherLstTest.java index bad7a66f0b1..fb7247448ff 100644 --- a/code/src/utest/plugin/lsttokens/ModifyOtherLstTest.java +++ b/code/src/utest/plugin/lsttokens/ModifyOtherLstTest.java @@ -21,10 +21,10 @@ import java.net.URISyntaxException; -import pcgen.base.formula.base.LegalScope; import pcgen.base.util.FormatManager; import pcgen.cdom.base.VarContainer; import pcgen.cdom.base.VarHolder; +import pcgen.cdom.formula.scope.PCGenScope; import pcgen.core.PCTemplate; import pcgen.core.Skill; import pcgen.persistence.PersistenceLayerException; @@ -282,7 +282,7 @@ protected void additionalSetup(LoadContext context) { super.additionalSetup(context); FormatManager formatManager = context.getReferenceContext().getFormatManager("NUMBER"); - LegalScope scope = context.getActiveScope(); + PCGenScope scope = context.getActiveScope(); context.getVariableContext().assertLegalVariableID("MyVar", scope, formatManager); context.getVariableContext().assertLegalVariableID("OtherVar", scope, formatManager); context.getReferenceContext().constructCDOMObject(Skill.class, "Dummy"); From afb54fb733dd10d144b65a0fd72ef0da9bcb5370 Mon Sep 17 00:00:00 2001 From: Vest Date: Sat, 16 May 2026 17:16:36 +0200 Subject: [PATCH 04/29] Fix test compilation and runtime failures for JPMS API migration - Add equals/hashCode to GlobalPCVarScoped to fix ScopeInstance identity mismatches when multiple instances are created across test and production code - Fix scope getName() methods to return fully-qualified names (e.g. "PC.SKILL") matching the registration keys used by ImplementedScopeLibrary - Add getFunctionLibrary() and getOperatorLibrary() accessors to VariableContext for test infrastructure access - Rewrite AbstractFormulaTestCase to use ManagerFactory/ScopeInstanceFactory instead of removed FormulaManager - Update SimpleSolverManager.processSolver to preserve existing store values when no solver is built, preventing VariableChannel.set() from being overwritten by format defaults - Adapt tests to explicitly call processSolver after addModifier since SimpleSolverManager does not auto-evaluate like the old DynamicSolverManager --- .../base/solver/SimpleSolverManager.java | 16 +- .../formula/scope/EquipmentPartScope.java | 2 +- .../cdom/formula/scope/EquipmentScope.java | 2 +- .../cdom/formula/scope/GlobalPCVarScoped.java | 13 ++ .../pcgen/cdom/formula/scope/RaceScope.java | 2 +- .../pcgen/cdom/formula/scope/SaveScope.java | 2 +- .../pcgen/cdom/formula/scope/SizeScope.java | 2 +- .../pcgen/cdom/formula/scope/SkillScope.java | 2 +- .../pcgen/cdom/formula/scope/StatScope.java | 2 +- .../pcgen/rules/context/VariableContext.java | 10 ++ .../base/solver/SetSolverManagerTest.java | 158 ++++++------------ .../pcgen/cdom/base/FormulaFactoryTest.java | 66 ++++---- .../cdom/formula/VariableChannelTest.java | 30 ++-- .../plugin/function/GetFactFunctionTest.java | 11 +- .../plugin/function/GetOtherFunctionTest.java | 26 ++- .../plugin/function/InputFunctionTest.java | 9 +- .../testsupport/AbstractFormulaTestCase.java | 81 ++++----- .../number/SetNumberModifierTest.java | 25 +-- 18 files changed, 218 insertions(+), 241 deletions(-) diff --git a/PCGen-Formula/code/src/java/pcgen/base/solver/SimpleSolverManager.java b/PCGen-Formula/code/src/java/pcgen/base/solver/SimpleSolverManager.java index ae756cd397f..2160f1a1e6f 100644 --- a/PCGen-Formula/code/src/java/pcgen/base/solver/SimpleSolverManager.java +++ b/PCGen-Formula/code/src/java/pcgen/base/solver/SimpleSolverManager.java @@ -152,9 +152,19 @@ public void captureAllDependencies(VariableID varID, @Override public boolean processSolver(VariableID varID) { - T newValue = getBuiltSolver(varID) - .map(s -> s.process(managerFactory.generateEvaluationManager())) - .orElse(getDefault(varID.getFormatManager())); + Optional> solver = getBuiltSolver(varID); + if (solver.isEmpty()) + { + T existing = resultStore.get(varID); + if (existing != null) + { + return false; + } + T newValue = getDefault(varID.getFormatManager()); + resultStore.put(varID, newValue); + return true; + } + T newValue = solver.get().process(managerFactory.generateEvaluationManager()); Object oldValue = resultStore.put(varID, newValue); return !newValue.equals(oldValue); } diff --git a/code/src/java/pcgen/cdom/formula/scope/EquipmentPartScope.java b/code/src/java/pcgen/cdom/formula/scope/EquipmentPartScope.java index 3abc165f9d8..5990853bda4 100644 --- a/code/src/java/pcgen/cdom/formula/scope/EquipmentPartScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/EquipmentPartScope.java @@ -45,7 +45,7 @@ public class EquipmentPartScope implements PCGenScope @Override public String getName() { - return "PART"; + return "PC.EQUIPMENT.PART"; } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/EquipmentScope.java b/code/src/java/pcgen/cdom/formula/scope/EquipmentScope.java index 856638de6ae..bc343a4856f 100644 --- a/code/src/java/pcgen/cdom/formula/scope/EquipmentScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/EquipmentScope.java @@ -40,7 +40,7 @@ public class EquipmentScope implements PCGenScope @Override public String getName() { - return "EQUIPMENT"; + return "PC.EQUIPMENT"; } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/GlobalPCVarScoped.java b/code/src/java/pcgen/cdom/formula/scope/GlobalPCVarScoped.java index 4209638445f..2ff72395aef 100644 --- a/code/src/java/pcgen/cdom/formula/scope/GlobalPCVarScoped.java +++ b/code/src/java/pcgen/cdom/formula/scope/GlobalPCVarScoped.java @@ -54,4 +54,17 @@ public String toString() { return "PC Global Scope (" + name + ")"; } + + @Override + public boolean equals(Object obj) + { + return (obj instanceof GlobalPCVarScoped other) + && name.equals(other.name); + } + + @Override + public int hashCode() + { + return name.hashCode(); + } } diff --git a/code/src/java/pcgen/cdom/formula/scope/RaceScope.java b/code/src/java/pcgen/cdom/formula/scope/RaceScope.java index d8f69566600..a63d8a5d041 100644 --- a/code/src/java/pcgen/cdom/formula/scope/RaceScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/RaceScope.java @@ -40,7 +40,7 @@ public class RaceScope implements PCGenScope @Override public String getName() { - return "RACE"; + return "PC.RACE"; } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/SaveScope.java b/code/src/java/pcgen/cdom/formula/scope/SaveScope.java index 3998e974a6c..a92c95daf03 100644 --- a/code/src/java/pcgen/cdom/formula/scope/SaveScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/SaveScope.java @@ -40,7 +40,7 @@ public class SaveScope implements PCGenScope @Override public String getName() { - return "SAVE"; + return "PC.SAVE"; } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/SizeScope.java b/code/src/java/pcgen/cdom/formula/scope/SizeScope.java index f1e56c3803d..ce67bf0c1d6 100644 --- a/code/src/java/pcgen/cdom/formula/scope/SizeScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/SizeScope.java @@ -40,7 +40,7 @@ public class SizeScope implements PCGenScope @Override public String getName() { - return "SIZE"; + return "PC.SIZE"; } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/SkillScope.java b/code/src/java/pcgen/cdom/formula/scope/SkillScope.java index a32dd29eb55..1e838bff659 100644 --- a/code/src/java/pcgen/cdom/formula/scope/SkillScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/SkillScope.java @@ -40,7 +40,7 @@ public class SkillScope implements PCGenScope @Override public String getName() { - return "SKILL"; + return "PC.SKILL"; } @Override diff --git a/code/src/java/pcgen/cdom/formula/scope/StatScope.java b/code/src/java/pcgen/cdom/formula/scope/StatScope.java index a4aeb2177b8..c39bf60a938 100644 --- a/code/src/java/pcgen/cdom/formula/scope/StatScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/StatScope.java @@ -40,7 +40,7 @@ public class StatScope implements PCGenScope @Override public String getName() { - return "STAT"; + return "PC.STAT"; } @Override diff --git a/code/src/java/pcgen/rules/context/VariableContext.java b/code/src/java/pcgen/rules/context/VariableContext.java index 0acb327238b..87a76cab498 100644 --- a/code/src/java/pcgen/rules/context/VariableContext.java +++ b/code/src/java/pcgen/rules/context/VariableContext.java @@ -260,6 +260,16 @@ public void addFunction(FormulaFunction function) myFunctionLibrary.addFunction(function); } + public WriteableFunctionLibrary getFunctionLibrary() + { + return myFunctionLibrary; + } + + public OperatorLibrary getOperatorLibrary() + { + return operatorLibrary; + } + /** * Returns the PCGenScope for the given name. * diff --git a/code/src/utest/pcgen/base/solver/SetSolverManagerTest.java b/code/src/utest/pcgen/base/solver/SetSolverManagerTest.java index 20e7db0111e..332f9b2e004 100644 --- a/code/src/utest/pcgen/base/solver/SetSolverManagerTest.java +++ b/code/src/utest/pcgen/base/solver/SetSolverManagerTest.java @@ -1,14 +1,14 @@ /* * Copyright 2014 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License along with * this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, * Suite 330, Boston, MA 02111-1307 USA @@ -21,8 +21,6 @@ import java.util.Arrays; import java.util.List; -import java.util.Objects; -import java.util.Optional; import pcgen.cdom.calculation.BasicCalculation; import pcgen.cdom.calculation.CalculationModifier; @@ -30,30 +28,17 @@ import pcgen.cdom.calculation.NEPCalculation; import pcgen.base.format.ArrayFormatManager; import pcgen.base.formatmanager.FormatUtilities; -import pcgen.base.formula.base.DependencyManager; -import pcgen.base.formula.base.EvaluationManager; -import pcgen.base.formula.base.FormulaManager; -import pcgen.base.formula.base.FormulaSemantics; -import pcgen.base.formula.base.LegalScope; -import pcgen.base.formula.base.ManagerFactory; -import pcgen.base.formula.base.OperatorLibrary; import pcgen.base.formula.base.ScopeInstance; import pcgen.base.formula.base.ScopeInstanceFactory; import pcgen.base.formula.base.VariableID; -import pcgen.base.formula.base.WriteableFunctionLibrary; -import pcgen.base.formula.inst.ScopeManagerInst; -import pcgen.base.formula.inst.SimpleFormulaManager; -import pcgen.base.formula.inst.SimpleFunctionLibrary; -import pcgen.base.formula.inst.SimpleOperatorLibrary; -import pcgen.base.formula.inst.SimpleScopeInstanceFactory; -import pcgen.base.formula.inst.VariableManager; +import pcgen.base.formula.base.VariableLibrary; import pcgen.base.solver.testsupport.TrackingVariableCache; import pcgen.base.util.FormatManager; import pcgen.cdom.content.ProcessCalculation; -import pcgen.cdom.formula.ManagerKey; import pcgen.cdom.formula.local.ModifierDecoration; import pcgen.cdom.formula.scope.EquipmentScope; import pcgen.cdom.formula.scope.GlobalPCScope; +import pcgen.cdom.formula.scope.GlobalPCVarScoped; import pcgen.cdom.formula.scope.PCGenScope; import pcgen.cdom.formula.scope.SkillScope; import pcgen.core.Skill; @@ -61,9 +46,11 @@ import pcgen.rules.context.LoadContext; import pcgen.rules.context.RuntimeLoadContext; import pcgen.rules.context.RuntimeReferenceContext; +import pcgen.rules.context.VariableContext; import pcgen.rules.persistence.token.ModifierFactory; import plugin.function.GetOtherFunction; +import util.FormatSupport; import org.hamcrest.MatcherAssert; import org.junit.jupiter.api.BeforeEach; @@ -72,65 +59,55 @@ class SetSolverManagerTest { - private final PCGenScope globalScope = new GlobalPCScope(); private TrackingVariableCache vc; - private ScopeManagerInst vsLib; - private VariableManager sl; - private FormulaManager fm; - private DynamicSolverManager manager; + private SolverManager manager; private FormatManager skillManager; private ArrayFormatManager arrayManager; private ScopeInstanceFactory siFactory; private RuntimeLoadContext context; - private MyManagerFactory managerFactory; + private VariableLibrary sl; @BeforeEach void setUp() throws Exception { - SupplierValueStore mvs = new SupplierValueStore(); - WriteableFunctionLibrary fl = new SimpleFunctionLibrary(); - fl.addFunction(new GetOtherFunction()); - OperatorLibrary ol = new SimpleOperatorLibrary(); - vc = new TrackingVariableCache(); - vsLib = new ScopeManagerInst(); - vsLib.registerScope(globalScope); + context = new RuntimeLoadContext( + RuntimeReferenceContext.createRuntimeReferenceContext(), + new ConsolidatedListCommitStrategy()); + FormatSupport.addBasicDefaults(context); + VariableContext variableContext = context.getVariableContext(); + variableContext.addFunction(new GetOtherFunction()); + + PCGenScope globalScope = new GlobalPCScope(); + variableContext.registerScope(globalScope); EquipmentScope equipScope = new EquipmentScope(); equipScope.setParent(globalScope); - vsLib.registerScope(equipScope); + variableContext.registerScope(equipScope); SkillScope skillScope = new SkillScope(); skillScope.setParent(globalScope); - vsLib.registerScope(skillScope); - sl = new VariableManager(vsLib, mvs); + variableContext.registerScope(skillScope); + arrayManager = new ArrayFormatManager<>(FormatUtilities.STRING_MANAGER, '\n', ','); - context = new RuntimeLoadContext( - RuntimeReferenceContext.createRuntimeReferenceContext(), - new ConsolidatedListCommitStrategy()); + variableContext.addDefault(arrayManager, () -> new String[0]); skillManager = context.getReferenceContext().getManufacturer(Skill.class); - managerFactory = new MyManagerFactory(context); - siFactory = new SimpleScopeInstanceFactory(vsLib); - fm = new SimpleFormulaManager(ol, sl, siFactory, vc, mvs); - fm = fm.getWith(FormulaManager.FUNCTION, fl); - SolverFactory solverFactory = new SimpleSolverFactory(mvs); - solverFactory.addSolverFormat(arrayManager, () -> new String[0]); - Skill defaultSkill = new Skill(); - solverFactory.addSolverFormat(skillManager, () -> defaultSkill); + variableContext.addDefault(skillManager, () -> defaultSkill); - manager = new DynamicSolverManager(fm, managerFactory, solverFactory, vc); - solverFactory.addSolverFormat(FormatUtilities.NUMBER_MANAGER, () -> 0); - solverFactory.addSolverFormat(FormatUtilities.STRING_MANAGER, () -> ""); + sl = variableContext; + vc = new TrackingVariableCache(); + siFactory = variableContext.getScopeInstanceFactory(); + manager = variableContext.generateSolverManager(vc); } - //TODO Tear Down - @Test public void testProcessDependentSet() { + PCGenScope globalScope = context.getVariableContext().getScope(GlobalPCScope.GLOBAL_SCOPE_NAME); sl.assertLegalVariableID("Regions", globalScope, arrayManager); - ScopeInstance scopeInst = siFactory.getGlobalInstance(globalScope.getName()); + ScopeInstance scopeInst = siFactory.get(GlobalPCScope.GLOBAL_SCOPE_NAME, + new GlobalPCVarScoped(GlobalPCScope.GLOBAL_SCOPE_NAME)); VariableID regions = (VariableID) sl.getVariableID(scopeInst, "Regions"); - manager.createChannel(regions); + manager.processSolver(regions); Object[] array = vc.get(regions); List list; assertEquals(0, array.length); @@ -142,6 +119,7 @@ public void testProcessDependentSet() FormulaModifier mod = am1.getModifier("France,England", arrayManager); mod.addAssociation("PRIORITY=2000"); manager.addModifier(regions, new ModifierDecoration<>(mod), scopeInst); + manager.processSolver(regions); array = vc.get(regions); MatcherAssert.assertThat(2, is(array.length)); list = Arrays.asList(array); @@ -155,6 +133,7 @@ public void testProcessDependentSet() mod = am2.getModifier("Greece,England", arrayManager); mod.addAssociation("PRIORITY=3000"); manager.addModifier(regions, new ModifierDecoration<>(mod), scopeInst); + manager.processSolver(regions); array = vc.get(regions); MatcherAssert.assertThat(3, is(array.length)); list = Arrays.asList(array); @@ -169,7 +148,9 @@ public void testProcessDependentSet() @Test public void testProcessDynamicSet() { - LegalScope skillScope = vsLib.getScope("PC.SKILL"); + VariableContext variableContext = context.getVariableContext(); + PCGenScope globalScope = variableContext.getScope(GlobalPCScope.GLOBAL_SCOPE_NAME); + PCGenScope skillScope = variableContext.getScope("PC.SKILL"); sl.assertLegalVariableID("LocalVar", skillScope, FormatUtilities.NUMBER_MANAGER); sl.assertLegalVariableID("ResultVar", globalScope, FormatUtilities.NUMBER_MANAGER); sl.assertLegalVariableID("SkillVar", globalScope, skillManager); @@ -179,21 +160,21 @@ public void testProcessDynamicSet() Skill skillalt = new Skill(); skillalt.setName("SkillAlt"); - ScopeInstance scopeInste = siFactory.get("PC.SKILL", Optional.of(skill)); + ScopeInstance scopeInste = siFactory.get("PC.SKILL", skill); VariableID varIDe = sl.getVariableID(scopeInste, "LocalVar"); - manager.createChannel(varIDe); + manager.processSolver(varIDe); vc.put(varIDe, 2); - ScopeInstance scopeInsta = siFactory.get("PC.SKILL", Optional.of(skillalt)); + ScopeInstance scopeInsta = siFactory.get("PC.SKILL", skillalt); VariableID varIDa = sl.getVariableID(scopeInsta, "LocalVar"); - manager.createChannel(varIDa); + manager.processSolver(varIDa); vc.put(varIDa, 3); - ScopeInstance globalInst = - siFactory.getGlobalInstance(GlobalPCScope.GLOBAL_SCOPE_NAME); + ScopeInstance globalInst = siFactory.get(GlobalPCScope.GLOBAL_SCOPE_NAME, + new GlobalPCVarScoped(GlobalPCScope.GLOBAL_SCOPE_NAME)); VariableID varIDq = sl.getVariableID(globalInst, "SkillVar"); - manager.createChannel(varIDq); + manager.processSolver(varIDq); VariableID varIDr = sl.getVariableID(globalInst, "ResultVar"); - manager.createChannel(varIDr); - + manager.processSolver(varIDr); + ModifierFactory am1 = new plugin.modifier.number.SetModifierFactory(); ModifierFactory amString = new plugin.modifier.string.SetModifierFactory(); FormulaModifier mod2 = @@ -210,7 +191,7 @@ public void testProcessDynamicSet() context.getReferenceContext().importObject(skillalt); FormulaModifier modf = am1.getModifier(formula, FormatUtilities.NUMBER_MANAGER); modf.addAssociation("PRIORITY=2000"); - + NEPCalculation calc1 = new ProcessCalculation<>(skill, new BasicSet(), skillManager); CalculationModifier mods1 = new CalculationModifier<>(calc1, skillManager); @@ -221,18 +202,26 @@ public void testProcessDynamicSet() manager.addModifier(varIDe, new ModifierDecoration<>(mod2), scopeInste); manager.addModifier(varIDa, new ModifierDecoration<>(mod3), scopeInsta); + manager.processSolver(varIDe); + manager.processSolver(varIDa); assertEquals(2, vc.get(varIDe)); assertEquals(3, vc.get(varIDa)); assertEquals(0, vc.get(varIDr)); manager.addModifier(varIDq, new ModifierDecoration<>(mods1), globalInst); manager.addModifier(varIDr, new ModifierDecoration<>(modf), globalInst); + manager.processSolver(varIDq); + manager.processSolver(varIDr); assertEquals(2, vc.get(varIDr)); manager.addModifier(varIDq, new ModifierDecoration<>(mods2), globalInst); + manager.processSolver(varIDq); + manager.processSolver(varIDr); assertEquals(3, vc.get(varIDr)); manager.addModifier(varIDa, new ModifierDecoration<>(mod4), scopeInsta); + manager.processSolver(varIDa); + manager.processSolver(varIDr); assertEquals(4, vc.get(varIDr)); } @@ -256,43 +245,4 @@ public Object process(Object previousValue, Object argument) return argument; } } - - /** - * A custom ManagerFactory to inject the LoadContext. - */ - private static class MyManagerFactory implements ManagerFactory - { - private final LoadContext context; - - private MyManagerFactory(LoadContext context) - { - this.context = Objects.requireNonNull(context); - } - - @Override - public DependencyManager generateDependencyManager(FormulaManager formulaManager, - ScopeInstance scopeInst) - { - DependencyManager dm = ManagerFactory.super.generateDependencyManager( - formulaManager, scopeInst); - return dm.getWith(ManagerKey.CONTEXT, context); - } - - @Override - public FormulaSemantics generateFormulaSemantics(FormulaManager manager, - LegalScope legalScope) - { - FormulaSemantics fs = - ManagerFactory.super.generateFormulaSemantics(manager, legalScope); - return fs.getWith(ManagerKey.CONTEXT, context); - } - - @Override - public EvaluationManager generateEvaluationManager(FormulaManager formulaManager) - { - EvaluationManager em = - ManagerFactory.super.generateEvaluationManager(formulaManager); - return em.getWith(ManagerKey.CONTEXT, context); - } - } } diff --git a/code/src/utest/pcgen/cdom/base/FormulaFactoryTest.java b/code/src/utest/pcgen/cdom/base/FormulaFactoryTest.java index 669cdc5aba4..df2b353176b 100644 --- a/code/src/utest/pcgen/cdom/base/FormulaFactoryTest.java +++ b/code/src/utest/pcgen/cdom/base/FormulaFactoryTest.java @@ -4,13 +4,16 @@ import pcgen.base.format.ArrayFormatManager; import pcgen.base.formatmanager.FormatUtilities; -import pcgen.base.formula.base.FormulaManager; import pcgen.base.formula.base.ManagerFactory; import pcgen.base.formula.inst.NEPFormula; -import pcgen.base.formula.inst.ScopeManagerInst; -import pcgen.base.solver.FormulaSetupFactory; import pcgen.cdom.formula.scope.GlobalPCScope; import pcgen.cdom.formula.scope.PCGenScope; +import pcgen.rules.context.ConsolidatedListCommitStrategy; +import pcgen.rules.context.LoadContext; +import pcgen.rules.context.RuntimeLoadContext; +import pcgen.rules.context.RuntimeReferenceContext; + +import util.FormatSupport; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -21,71 +24,60 @@ class FormulaFactoryTest private ArrayFormatManager arrayManager; private PCGenScope varScope; - private FormulaManager formulaManager; + private LoadContext context; + private ManagerFactory managerFactory; @BeforeEach void setUp() throws Exception { arrayManager = new ArrayFormatManager<>(FormatUtilities.NUMBER_MANAGER, '\n', ','); - varScope = new GlobalPCScope(); - FormulaSetupFactory formulaSetupFactory = new FormulaSetupFactory(); - ScopeManagerInst legalScopeManager = new ScopeManagerInst(); - formulaSetupFactory - .setLegalScopeManagerSupplier(() -> legalScopeManager); - formulaManager = formulaSetupFactory.generate(); - legalScopeManager.registerScope(varScope); + context = new RuntimeLoadContext( + RuntimeReferenceContext.createRuntimeReferenceContext(), + new ConsolidatedListCommitStrategy()); + FormatSupport.addBasicDefaults(context); + varScope = context.getVariableContext().getScope(GlobalPCScope.GLOBAL_SCOPE_NAME); + managerFactory = context.getVariableContext().getManagerFactory(); } @AfterEach void tearDown() throws Exception { arrayManager = null; - formulaManager = null; + context = null; varScope = null; + managerFactory = null; } @Test void testNumberFormula() { - NEPFormula formula1 = - FormulaFactory.getValidFormula("3", new ManagerFactory() - { - }, formulaManager, varScope, FormatUtilities.NUMBER_MANAGER); - NEPFormula formula2 = - FormulaFactory.getValidFormula("3", new ManagerFactory() - { - }, formulaManager, varScope, FormatUtilities.NUMBER_MANAGER); + NEPFormula formula1 = FormulaFactory.getValidFormula("3", + managerFactory, varScope, FormatUtilities.NUMBER_MANAGER); + NEPFormula formula2 = FormulaFactory.getValidFormula("3", + managerFactory, varScope, FormatUtilities.NUMBER_MANAGER); assertEquals(formula1, formula2); } @Test void testComplexNumberFormula() { - formulaManager.getFactory().assertLegalVariableID("Arm", varScope, + context.getVariableContext().assertLegalVariableID("Arm", varScope, FormatUtilities.NUMBER_MANAGER); - NEPFormula formula1 = - FormulaFactory.getValidFormula("3+Arm", new ManagerFactory() - { - }, formulaManager, varScope, FormatUtilities.NUMBER_MANAGER); - NEPFormula formula2 = - FormulaFactory.getValidFormula("3+Arm", new ManagerFactory() - { - }, formulaManager, varScope, FormatUtilities.NUMBER_MANAGER); + NEPFormula formula1 = FormulaFactory.getValidFormula("3+Arm", + managerFactory, varScope, FormatUtilities.NUMBER_MANAGER); + NEPFormula formula2 = FormulaFactory.getValidFormula("3+Arm", + managerFactory, varScope, FormatUtilities.NUMBER_MANAGER); assertEquals(formula1, formula2); } @Test void testArrayFormula() { - NEPFormula formula1 = - FormulaFactory.getValidFormula("3,4,5", new ManagerFactory() - { - }, formulaManager, varScope, arrayManager); - NEPFormula formula2 = - FormulaFactory.getValidFormula("3,4,5", new ManagerFactory() - { - }, formulaManager, varScope, arrayManager); + NEPFormula formula1 = FormulaFactory.getValidFormula("3,4,5", + managerFactory, varScope, arrayManager); + NEPFormula formula2 = FormulaFactory.getValidFormula("3,4,5", + managerFactory, varScope, arrayManager); assertEquals(formula1, formula2); } diff --git a/code/src/utest/pcgen/cdom/formula/VariableChannelTest.java b/code/src/utest/pcgen/cdom/formula/VariableChannelTest.java index 5c4f2ec426e..6c106abf479 100644 --- a/code/src/utest/pcgen/cdom/formula/VariableChannelTest.java +++ b/code/src/utest/pcgen/cdom/formula/VariableChannelTest.java @@ -23,7 +23,6 @@ import pcgen.base.formatmanager.FormatUtilities; import pcgen.base.formula.base.ScopeInstance; -import pcgen.base.formula.base.ScopeInstanceFactory; import pcgen.base.formula.base.VariableID; import pcgen.base.formula.inst.ComplexNEPFormula; import pcgen.base.formula.inst.FormulaUtilities; @@ -59,8 +58,7 @@ public void setUp() throws Exception manager = context.getVariableContext().generateSolverManager(getVariableStore()); globalScope = context.getVariableContext().getScope(GlobalPCScope.GLOBAL_SCOPE_NAME); - ScopeInstanceFactory sif = getFormulaManager().getScopeInstanceFactory(); - globalInstance = sif.getGlobalInstance(globalScope.getName()); + globalInstance = getGlobalScopeInst(); } @AfterEach @@ -103,8 +101,11 @@ void testBadConstructionThirdArg() @Test void testGetSet() { - VariableID varID = new VariableID<>(globalInstance, - FormatUtilities.NUMBER_MANAGER, "MyNumber"); + getVariableLibrary().assertLegalVariableID("MyNumber", globalScope, + FormatUtilities.NUMBER_MANAGER); + @SuppressWarnings("unchecked") + VariableID varID = + (VariableID) getVariableLibrary().getVariableID(globalInstance, "MyNumber"); VariableChannel channel = VariableChannel.construct(manager, getVariableStore(), varID); assertEquals(0, channel.get()); @@ -117,8 +118,11 @@ void testGetSet() @Test void testGetSetEvents() { - VariableID varID = new VariableID<>(globalInstance, - FormatUtilities.NUMBER_MANAGER, "MyNumber"); + getVariableLibrary().assertLegalVariableID("MyNumber", globalScope, + FormatUtilities.NUMBER_MANAGER); + @SuppressWarnings("unchecked") + VariableID varID = + (VariableID) getVariableLibrary().getVariableID(globalInstance, "MyNumber"); VariableChannel channel = VariableChannel.construct(manager, getVariableStore(), varID); TestingReferenceListener listener = @@ -186,15 +190,18 @@ void testGetSetEffects() @SuppressWarnings("unchecked") VariableID limbs = (VariableID) getVariableLibrary().getVariableID(globalInstance, "Limbs"); - manager.addModifier(limbs, formulaMod, globalInstance); - @SuppressWarnings("unchecked") VariableID arms = (VariableID) getVariableLibrary().getVariableID(globalInstance, "Arms"); - @SuppressWarnings("unchecked") VariableID legs = (VariableID) getVariableLibrary().getVariableID(globalInstance, "Legs"); + + manager.processSolver(legs); + manager.processSolver(arms); + manager.addModifier(limbs, formulaMod, globalInstance); + manager.processSolver(limbs); + VariableChannel armsChannel = VariableChannel.construct(manager, getVariableStore(), arms); VariableChannel legsChannel = @@ -205,6 +212,7 @@ void testGetSetEffects() legsChannel.set(4); assertEquals(4, getVariableStore().get(legs)); assertEquals(4, legsChannel.get()); + manager.processSolver(limbs); assertEquals(4, getVariableStore().get(limbs)); assertEquals(0, armsChannel.get()); @@ -212,10 +220,12 @@ void testGetSetEffects() armsChannel.set(3); assertEquals(3, getVariableStore().get(arms)); assertEquals(3, armsChannel.get()); + manager.processSolver(limbs); assertEquals(7, getVariableStore().get(limbs)); armsChannel.set(6); assertEquals(6, getVariableStore().get(arms)); assertEquals(6, armsChannel.get()); + manager.processSolver(limbs); assertEquals(10, getVariableStore().get(limbs)); } diff --git a/code/src/utest/plugin/function/GetFactFunctionTest.java b/code/src/utest/plugin/function/GetFactFunctionTest.java index 0ee082a3ca1..1b165371a69 100644 --- a/code/src/utest/plugin/function/GetFactFunctionTest.java +++ b/code/src/utest/plugin/function/GetFactFunctionTest.java @@ -25,7 +25,6 @@ import pcgen.base.formatmanager.FormatUtilities; import pcgen.base.formatmanager.SimpleFormatManagerLibrary; import pcgen.base.formula.base.FormulaSemantics; -import pcgen.base.formula.base.LegalScope; import pcgen.base.formula.base.ScopeInstance; import pcgen.base.formula.base.VariableID; import pcgen.base.formula.base.VariableLibrary; @@ -39,6 +38,8 @@ import pcgen.cdom.enumeration.FactKey; import pcgen.cdom.formula.ManagerKey; import pcgen.cdom.formula.scope.GlobalPCScope; +import pcgen.cdom.formula.scope.GlobalPCVarScoped; +import pcgen.cdom.formula.scope.PCGenScope; import pcgen.core.Skill; import pcgen.rules.context.AbstractReferenceContext; import pcgen.util.enumeration.Visibility; @@ -81,7 +82,7 @@ public void testInvalidWrongArgCount() @Test public void testInvalidWrongArgType() { - LegalScope skillScope = context.getVariableContext().getScope("PC.SKILL"); + PCGenScope skillScope = context.getVariableContext().getScope("PC.SKILL"); getVariableLibrary().assertLegalVariableID("LocalVar", skillScope, numberManager); String s = "getFact(\"SKILL\",\"SkillKey\",LocalVar)"; SimpleNode simpleNode = doParse(s); @@ -159,7 +160,7 @@ public void testBasic() public void testDynamic() { VariableLibrary vl = getVariableLibrary(); - LegalScope globalScope = + PCGenScope globalScope = context.getVariableContext().getScope(GlobalPCScope.GLOBAL_SCOPE_NAME); vl.assertLegalVariableID("SkillVar", globalScope, context.getManufacturer("SKILL")); @@ -183,8 +184,8 @@ public void testDynamic() skill.setName("SkillKey"); Skill skillalt = new Skill(); skillalt.setName("SkillAlt"); - ScopeInstance globalInst = getFormulaManager().getScopeInstanceFactory() - .getGlobalInstance(GlobalPCScope.GLOBAL_SCOPE_NAME); + ScopeInstance globalInst = getScopeInstanceFactory().get( + GlobalPCScope.GLOBAL_SCOPE_NAME, new GlobalPCVarScoped(GlobalPCScope.GLOBAL_SCOPE_NAME)); VariableID varIDq = vl.getVariableID(globalInst, "SkillVar"); getVariableStore().put(varIDq, skill); context.getReferenceContext().importObject(skill); diff --git a/code/src/utest/plugin/function/GetOtherFunctionTest.java b/code/src/utest/plugin/function/GetOtherFunctionTest.java index 871f129f25b..d0564201adc 100644 --- a/code/src/utest/plugin/function/GetOtherFunctionTest.java +++ b/code/src/utest/plugin/function/GetOtherFunctionTest.java @@ -22,12 +22,9 @@ import static org.junit.jupiter.api.Assertions.fail; import static plugin.function.testsupport.TestUtilities.doParse; -import java.util.Optional; - import pcgen.base.formatmanager.FormatUtilities; import pcgen.base.formatmanager.SimpleFormatManagerLibrary; import pcgen.base.formula.base.FormulaSemantics; -import pcgen.base.formula.base.LegalScope; import pcgen.base.formula.base.ScopeInstance; import pcgen.base.formula.base.ScopeInstanceFactory; import pcgen.base.formula.base.VariableID; @@ -39,6 +36,8 @@ import pcgen.base.formula.visitor.SemanticsVisitor; import pcgen.cdom.formula.ManagerKey; import pcgen.cdom.formula.scope.GlobalPCScope; +import pcgen.cdom.formula.scope.GlobalPCVarScoped; +import pcgen.cdom.formula.scope.PCGenScope; import pcgen.core.Skill; import pcgen.rules.context.AbstractReferenceContext; import pcgen.rules.context.VariableContext; @@ -118,7 +117,7 @@ public void testInvalidWrongFormat3() public void testBasic() { VariableLibrary vl = getVariableLibrary(); - LegalScope skillScope = context.getVariableContext().getScope("PC.SKILL"); + PCGenScope skillScope = context.getVariableContext().getScope("PC.SKILL"); vl.assertLegalVariableID("LocalVar", skillScope, numberManager); String formula = @@ -130,8 +129,8 @@ public void testBasic() isStatic(formula, node, false); Skill skill = new Skill(); skill.setName("SkillKey"); - ScopeInstance scopeInst = - getFormulaManager().getScopeInstanceFactory().get("PC.SKILL", Optional.of(skill)); + ScopeInstanceFactory scopeInstanceFactory = getScopeInstanceFactory(); + ScopeInstance scopeInst = scopeInstanceFactory.get("PC.SKILL", skill); VariableID varID = vl.getVariableID(scopeInst, "LocalVar"); getVariableStore().put(varID, 2); context.getReferenceContext().importObject(skill); @@ -146,8 +145,8 @@ public void testDynamic() { VariableLibrary vl = getVariableLibrary(); VariableContext variableContext = context.getVariableContext(); - LegalScope skillScope = variableContext.getScope("PC.SKILL"); - LegalScope globalScope = variableContext.getScope(GlobalPCScope.GLOBAL_SCOPE_NAME); + PCGenScope skillScope = variableContext.getScope("PC.SKILL"); + PCGenScope globalScope = variableContext.getScope(GlobalPCScope.GLOBAL_SCOPE_NAME); vl.assertLegalVariableID("LocalVar", skillScope, numberManager); vl.assertLegalVariableID("SkillVar", globalScope, context.getManufacturer("SKILL")); @@ -162,16 +161,15 @@ public void testDynamic() skill.setName("SkillKey"); Skill skillalt = new Skill(); skillalt.setName("SkillAlt"); - ScopeInstanceFactory scopeInstanceFactory = - getFormulaManager().getScopeInstanceFactory(); - ScopeInstance scopeInste = scopeInstanceFactory.get("PC.SKILL", Optional.of(skill)); + ScopeInstanceFactory scopeInstanceFactory = getScopeInstanceFactory(); + ScopeInstance scopeInste = scopeInstanceFactory.get("PC.SKILL", skill); VariableID varIDe = vl.getVariableID(scopeInste, "LocalVar"); getVariableStore().put(varIDe, 2); - ScopeInstance scopeInsta = scopeInstanceFactory.get("PC.SKILL", Optional.of(skillalt)); + ScopeInstance scopeInsta = scopeInstanceFactory.get("PC.SKILL", skillalt); VariableID varIDa = vl.getVariableID(scopeInsta, "LocalVar"); getVariableStore().put(varIDa, 3); - ScopeInstance globalInst = - scopeInstanceFactory.getGlobalInstance(GlobalPCScope.GLOBAL_SCOPE_NAME); + ScopeInstance globalInst = scopeInstanceFactory.get(GlobalPCScope.GLOBAL_SCOPE_NAME, + new GlobalPCVarScoped(GlobalPCScope.GLOBAL_SCOPE_NAME)); VariableID varIDq = vl.getVariableID(globalInst, "SkillVar"); getVariableStore().put(varIDq, skill); context.getReferenceContext().importObject(skill); diff --git a/code/src/utest/plugin/function/InputFunctionTest.java b/code/src/utest/plugin/function/InputFunctionTest.java index 541f2a28dd2..94058eb4ab0 100644 --- a/code/src/utest/plugin/function/InputFunctionTest.java +++ b/code/src/utest/plugin/function/InputFunctionTest.java @@ -20,7 +20,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import pcgen.base.formula.base.ScopeInstance; -import pcgen.base.formula.base.ScopeInstanceFactory; import pcgen.base.formula.parse.SimpleNode; import pcgen.base.formula.visitor.ReconstructionVisitor; import pcgen.cdom.enumeration.CharID; @@ -54,7 +53,7 @@ public void setUp() throws Exception super.setUp(); getFunctionLibrary().addFunction(new InputFunction()); id = CharID.getID(context.getDataSetID()); - scopeFacet.set(id, getFormulaManager().getScopeInstanceFactory()); + scopeFacet.set(id, getScopeInstanceFactory()); variableStoreFacet.set(id, getVariableStore()); solverManagerFacet.set(id, context.getVariableContext().generateSolverManager(getVariableStore())); @@ -98,11 +97,9 @@ public void testNotValidNoChannel() @Test public void testGlobalChannelStrength() { - ScopeInstanceFactory instFactory = scopeFacet.get(id); - ScopeInstance globalInstance = - instFactory.getGlobalInstance(GlobalPCScope.GLOBAL_SCOPE_NAME); + ScopeInstance globalInstance = scopeFacet.getGlobalScope(id); context.getVariableContext().assertLegalVariableID(ChannelUtilities.createVarName("STR"), - globalInstance.getLegalScope(), numberManager); + getGlobalScope(), numberManager); VariableChannel strChannel = (VariableChannel) context .getVariableContext().getGlobalChannel(id, "STR"); String formula = "input(\"STR\")"; diff --git a/code/src/utest/plugin/function/testsupport/AbstractFormulaTestCase.java b/code/src/utest/plugin/function/testsupport/AbstractFormulaTestCase.java index 6ffcae1403d..7ecea0c74b2 100644 --- a/code/src/utest/plugin/function/testsupport/AbstractFormulaTestCase.java +++ b/code/src/utest/plugin/function/testsupport/AbstractFormulaTestCase.java @@ -1,14 +1,14 @@ /* * Copyright 2014 (C) Tom Parker - * + * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License along with * this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, * Suite 330, Boston, MA 02111-1307 USA @@ -24,11 +24,12 @@ import pcgen.base.format.StringManager; import pcgen.base.formatmanager.FormatUtilities; import pcgen.base.formula.base.EvaluationManager; -import pcgen.base.formula.base.FormulaManager; import pcgen.base.formula.base.FormulaSemantics; -import pcgen.base.formula.base.LegalScope; +import pcgen.base.formula.base.FunctionLibrary; +import pcgen.base.formula.base.ManagerFactory; import pcgen.base.formula.base.OperatorLibrary; import pcgen.base.formula.base.ScopeInstance; +import pcgen.base.formula.base.ScopeInstanceFactory; import pcgen.base.formula.base.VariableLibrary; import pcgen.base.formula.base.WriteableFunctionLibrary; import pcgen.base.formula.exception.SemanticsFailureException; @@ -39,9 +40,10 @@ import pcgen.base.util.FormatManager; import pcgen.cdom.facet.FacetLibrary; import pcgen.cdom.facet.LoadContextFacet; -import pcgen.cdom.formula.ManagerKey; import pcgen.cdom.formula.MonitorableVariableStore; import pcgen.cdom.formula.scope.GlobalPCScope; +import pcgen.cdom.formula.scope.GlobalPCVarScoped; +import pcgen.cdom.formula.scope.PCGenScope; import pcgen.rules.context.ConsolidatedListCommitStrategy; import pcgen.rules.context.LoadContext; import pcgen.rules.context.RuntimeLoadContext; @@ -56,7 +58,9 @@ public abstract class AbstractFormulaTestCase protected FormatManager stringManager = new StringManager(); protected LoadContext context; - private FormulaManager formulaManager; + private ManagerFactory managerFactory; + private MonitorableVariableStore varStore; + private ScopeInstance globalInstance; public void setUp() throws Exception { @@ -66,18 +70,13 @@ public void setUp() throws Exception FacetLibrary.getFacet(LoadContextFacet.class).set(context.getDataSetID(), new WeakReference<>(context)); FormatSupport.addBasicDefaults(context); + varStore = new MonitorableVariableStore(); + managerFactory = context.getVariableContext().getPCManagerFactory(varStore); + ScopeInstanceFactory siFactory = context.getVariableContext().getScopeInstanceFactory(); + globalInstance = siFactory.get(GlobalPCScope.GLOBAL_SCOPE_NAME, + new GlobalPCVarScoped(GlobalPCScope.GLOBAL_SCOPE_NAME)); } - /** - * Force a given formula to be valid. - * - * @param node - * The root node for processing the formula - * @param formatManager - * The FormatManager indicating the format of the result of the formula - * @param assertedFormat - * The asserted format - */ protected void isValid(SimpleNode node, FormatManager formatManager, FormatManager assertedFormat) { @@ -95,7 +94,7 @@ protected void isValid(SimpleNode node, FormatManager formatManager, protected void isStatic(String formula, SimpleNode node, boolean b) { StaticVisitor staticVisitor = - new StaticVisitor(getFormulaManager().get(FormulaManager.FUNCTION)); + new StaticVisitor(context.getVariableContext().getFunctionLibrary()); boolean isStat = (Boolean) staticVisitor.visit(node, null); if (isStat != b) { @@ -150,63 +149,57 @@ protected void isNotValid(String formula, SimpleNode node) protected WriteableFunctionLibrary getFunctionLibrary() { - return (WriteableFunctionLibrary) getFormulaManager() - .get(FormulaManager.FUNCTION); + return context.getVariableContext().getFunctionLibrary(); } protected OperatorLibrary getOperatorLibrary() { - return getFormulaManager().getOperatorLibrary(); + return context.getVariableContext().getOperatorLibrary(); } protected VariableLibrary getVariableLibrary() { - return getFormulaManager().getFactory(); + return context.getVariableContext(); } protected MonitorableVariableStore getVariableStore() { - return (MonitorableVariableStore) getFormulaManager().get(FormulaManager.RESULTS); + return varStore; } - protected LegalScope getGlobalScope() + protected PCGenScope getGlobalScope() { - return getGlobalScopeInst().getLegalScope(); + return context.getVariableContext().getScope(GlobalPCScope.GLOBAL_SCOPE_NAME); } protected ScopeInstance getGlobalScopeInst() { - return getFormulaManager().getScopeInstanceFactory() - .getGlobalInstance(GlobalPCScope.GLOBAL_SCOPE_NAME); + return globalInstance; } - protected FormulaManager getFormulaManager() + protected ManagerFactory getManagerFactory() { - if (formulaManager == null) - { - formulaManager = context.getVariableContext().getFormulaManager() - .getWith(FormulaManager.RESULTS, new MonitorableVariableStore()); - } - return formulaManager; + return managerFactory; + } + + protected ScopeInstanceFactory getScopeInstanceFactory() + { + return context.getVariableContext().getScopeInstanceFactory(); } protected FormulaSemantics generateFormulaSemantics(FormatManager assertedFormat) { Optional> format = (assertedFormat == null) ? Optional.empty() : Optional.of(assertedFormat); - return new FormulaSemantics() - .getWith(FormulaSemantics.FMANAGER, formulaManager) - .getWith(FormulaSemantics.SCOPE, getGlobalScope()) - .getWith(FormulaSemantics.ASSERTED, format) - .getWith(ManagerKey.CONTEXT, context); + FormulaSemantics semantics = managerFactory.generateFormulaSemantics( + context.getVariableContext().getScope(GlobalPCScope.GLOBAL_SCOPE_NAME)); + return semantics.getWith(FormulaSemantics.ASSERTED, format); } public EvaluationManager generateManager() { - return new EvaluationManager() - .getWith(EvaluationManager.FMANAGER, getFormulaManager()) - .getWith(EvaluationManager.INSTANCE, getGlobalScopeInst()) - .getWith(EvaluationManager.ASSERTED, Optional.of(FormatUtilities.NUMBER_MANAGER)) - .getWith(ManagerKey.CONTEXT, context); + EvaluationManager em = managerFactory.generateEvaluationManager(); + return em.getWith(EvaluationManager.INSTANCE, getGlobalScopeInst()) + .getWith(EvaluationManager.ASSERTED, Optional.of(FormatUtilities.NUMBER_MANAGER)); } } diff --git a/code/src/utest/plugin/modifier/number/SetNumberModifierTest.java b/code/src/utest/plugin/modifier/number/SetNumberModifierTest.java index 7f55a165d98..6e4402119d8 100644 --- a/code/src/utest/plugin/modifier/number/SetNumberModifierTest.java +++ b/code/src/utest/plugin/modifier/number/SetNumberModifierTest.java @@ -23,14 +23,17 @@ import pcgen.cdom.calculation.FormulaModifier; import pcgen.base.format.NumberManager; import pcgen.base.formula.base.EvaluationManager; -import pcgen.base.formula.base.FormulaManager; -import pcgen.base.formula.inst.ScopeManagerInst; -import pcgen.base.solver.FormulaSetupFactory; +import pcgen.base.formula.base.ManagerFactory; import pcgen.base.util.FormatManager; import pcgen.cdom.formula.scope.GlobalPCScope; import pcgen.cdom.formula.scope.PCGenScope; +import pcgen.rules.context.ConsolidatedListCommitStrategy; +import pcgen.rules.context.LoadContext; +import pcgen.rules.context.RuntimeLoadContext; +import pcgen.rules.context.RuntimeReferenceContext; import plugin.modifier.testsupport.EvalManagerUtilities; +import util.FormatSupport; import org.junit.jupiter.api.Test; @@ -211,18 +214,18 @@ public void testGetModifier() @Test public void testGetFormulaModifier() { - FormulaSetupFactory formulaSetupFactory = new FormulaSetupFactory(); - ScopeManagerInst legalScopeManager = new ScopeManagerInst(); - formulaSetupFactory.setLegalScopeManagerSupplier(() -> legalScopeManager); - FormulaManager formulaManager = formulaSetupFactory.generate(); - legalScopeManager.registerScope(varScope); + LoadContext context = new RuntimeLoadContext( + RuntimeReferenceContext.createRuntimeReferenceContext(), + new ConsolidatedListCommitStrategy()); + FormatSupport.addBasicDefaults(context); + ManagerFactory managerFactory = context.getVariableContext().getManagerFactory(); SetModifierFactory factory = new SetModifierFactory(); FormulaModifier modifier = factory.getModifier("6+5", numManager); modifier.addAssociation("PRIORITY=35"); assertEquals((35L<<32)+factory.getInherentPriority(), modifier.getPriority()); assertEquals(numManager, modifier.getVariableFormat()); - EvaluationManager evalManager = EvalManagerUtilities.getInputEM(4.3); - assertEquals(11, modifier.process( - evalManager.getWith(EvaluationManager.FMANAGER, formulaManager))); + EvaluationManager evalManager = managerFactory.generateEvaluationManager() + .getWith(EvaluationManager.INPUT, 4.3); + assertEquals(11, modifier.process(evalManager)); } } From a457367d4ba4f2891dd5822019af4b0ed0f09d12 Mon Sep 17 00:00:00 2001 From: Vest Date: Sat, 16 May 2026 17:21:36 +0200 Subject: [PATCH 05/29] Update Gradle wrapper to 9.5.1 --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f193d72905e..e74c8700b2a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-all.zip networkTimeout=10000 retries=0 retryBackOffMs=500 From 0330b171651497961c675a8276ba539556b4f6c8 Mon Sep 17 00:00:00 2001 From: Vest Date: Sat, 16 May 2026 19:59:22 +0200 Subject: [PATCH 06/29] Remove processSolver calls after user-input channel writes SimpleSolverManager.processSolver() writes the format default when no solver exists, which overwrites values set via VariableChannel.set() and ChannelUtilities.setGlobalChannel(). This was correct for the old DynamicSolverManager (which auto-cascaded), but incorrect for SimpleSolverManager where channel writes are the final value. - Revert SimpleSolverManager.processSolver() to original upstream logic - Remove processSolver() call from VariableChannel.set() - Remove processSolver() call from ChannelUtilities.setGlobalChannel() - Remove unused SolverManagerFacet field from ChannelUtilities --- .../pcgen/base/solver/SimpleSolverManager.java | 16 +++------------- .../java/pcgen/cdom/formula/VariableChannel.java | 1 - .../pcgen/output/channel/ChannelUtilities.java | 7 ------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/PCGen-Formula/code/src/java/pcgen/base/solver/SimpleSolverManager.java b/PCGen-Formula/code/src/java/pcgen/base/solver/SimpleSolverManager.java index 2160f1a1e6f..ae756cd397f 100644 --- a/PCGen-Formula/code/src/java/pcgen/base/solver/SimpleSolverManager.java +++ b/PCGen-Formula/code/src/java/pcgen/base/solver/SimpleSolverManager.java @@ -152,19 +152,9 @@ public void captureAllDependencies(VariableID varID, @Override public boolean processSolver(VariableID varID) { - Optional> solver = getBuiltSolver(varID); - if (solver.isEmpty()) - { - T existing = resultStore.get(varID); - if (existing != null) - { - return false; - } - T newValue = getDefault(varID.getFormatManager()); - resultStore.put(varID, newValue); - return true; - } - T newValue = solver.get().process(managerFactory.generateEvaluationManager()); + T newValue = getBuiltSolver(varID) + .map(s -> s.process(managerFactory.generateEvaluationManager())) + .orElse(getDefault(varID.getFormatManager())); Object oldValue = resultStore.put(varID, newValue); return !newValue.equals(oldValue); } diff --git a/code/src/java/pcgen/cdom/formula/VariableChannel.java b/code/src/java/pcgen/cdom/formula/VariableChannel.java index 39b7d1f19d7..226f24054e8 100644 --- a/code/src/java/pcgen/cdom/formula/VariableChannel.java +++ b/code/src/java/pcgen/cdom/formula/VariableChannel.java @@ -106,7 +106,6 @@ public void set(T object) if (!checkForVeto(object)) { varStore.put(varID, object); - manager.processSolver(varID); } } diff --git a/code/src/java/pcgen/output/channel/ChannelUtilities.java b/code/src/java/pcgen/output/channel/ChannelUtilities.java index 922b73a4b61..38ff524ce99 100644 --- a/code/src/java/pcgen/output/channel/ChannelUtilities.java +++ b/code/src/java/pcgen/output/channel/ChannelUtilities.java @@ -22,7 +22,6 @@ import pcgen.base.formula.base.VariableID; import pcgen.cdom.enumeration.CharID; import pcgen.cdom.facet.FacetLibrary; -import pcgen.cdom.facet.SolverManagerFacet; import pcgen.cdom.facet.VariableStoreFacet; import pcgen.cdom.facet.event.DataFacetChangeListener; import pcgen.cdom.formula.VariableListener; @@ -42,11 +41,6 @@ public final class ChannelUtilities * The VariableStoreFacet */ private static final VariableStoreFacet RESULT_FACET = FacetLibrary.getFacet(VariableStoreFacet.class); - - /** - * The SolverManagerFacet - */ - private static final SolverManagerFacet SOLVER_MANAGER_FACET = FacetLibrary.getFacet(SolverManagerFacet.class); private ChannelUtilities() { @@ -100,7 +94,6 @@ public static void setGlobalChannel(CharID id, String channelName, Object value) { VariableID varID = getChannelVariableID(id, channelName); RESULT_FACET.get(id).put(varID, value); - SOLVER_MANAGER_FACET.get(id).processSolver(varID); } /** From a22ace8155a7c43d48940305c92655e63422c53f Mon Sep 17 00:00:00 2001 From: Vest Date: Sat, 16 May 2026 23:52:34 +0200 Subject: [PATCH 07/29] Open pcgen.cdom.base to pcgen.base for StagingProxy reflection access PCGen-base's StagingProxy.applyTo() reflectively invokes methods on VarHolder (in pcgen.cdom.base). With proper module boundaries enforced, this requires an explicit opens directive. --- code/src/java/module-info.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/src/java/module-info.java b/code/src/java/module-info.java index eaf2fdba6c3..944ff5e6aec 100644 --- a/code/src/java/module-info.java +++ b/code/src/java/module-info.java @@ -50,6 +50,8 @@ exports pcgen.system; exports pcgen.util; + opens pcgen.cdom.base to pcgen.base; + opens pcgen.system; opens pcgen.pluginmgr; opens pcgen.core.bonus; From 62f37d5b62b22b4d54414670cc8006606743cbd8 Mon Sep 17 00:00:00 2001 From: Vest Date: Sun, 17 May 2026 08:51:16 +0200 Subject: [PATCH 08/29] Add JUnit Platform Launcher to subproject test dependencies JPMS modular projects with inferModulePath require the launcher artifact explicitly on the test runtime classpath. --- PCGen-Formula/build.gradle | 1 + PCGen-base/build.gradle | 1 + 2 files changed, 2 insertions(+) diff --git a/PCGen-Formula/build.gradle b/PCGen-Formula/build.gradle index 5206fcdf25c..7c5d10b354b 100644 --- a/PCGen-Formula/build.gradle +++ b/PCGen-Formula/build.gradle @@ -34,6 +34,7 @@ dependencies { testImplementation 'junit:junit:4.13.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } tasks.named('test') { diff --git a/PCGen-base/build.gradle b/PCGen-base/build.gradle index b1ad54f8020..1cc5deeb0b8 100644 --- a/PCGen-base/build.gradle +++ b/PCGen-base/build.gradle @@ -30,6 +30,7 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api' testImplementation 'org.junit.jupiter:junit-jupiter-params' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } tasks.named('test') { From febc907098be2e2feea96a236ca0b0fed175c482 Mon Sep 17 00:00:00 2001 From: Vest Date: Sun, 17 May 2026 09:13:12 +0200 Subject: [PATCH 09/29] Revert String equality branch in CaseInsensitiveString.equals() Reverts the change from a7e1952ed3 which added an `instanceof String` branch to equals(). This violates the equals symmetry contract: cis.equals("Foo") returned true but "Foo".equals(cis) always returns false since String is unaware of CaseInsensitiveString. The upstream pcgen-base repo never accepted this change, and the existing CaseInsensitiveStringTest.testString() explicitly asserts that this comparison must be false. Callers that need case-insensitive comparison with a raw String should wrap it in a CaseInsensitiveString first. --- .../code/src/java/pcgen/base/lang/CaseInsensitiveString.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/PCGen-base/code/src/java/pcgen/base/lang/CaseInsensitiveString.java b/PCGen-base/code/src/java/pcgen/base/lang/CaseInsensitiveString.java index 8544dd75faa..ce221778bf4 100644 --- a/PCGen-base/code/src/java/pcgen/base/lang/CaseInsensitiveString.java +++ b/PCGen-base/code/src/java/pcgen/base/lang/CaseInsensitiveString.java @@ -72,8 +72,6 @@ public boolean equals(Object obj) { CaseInsensitiveString cis = (CaseInsensitiveString) obj; return (string == cis.string) || string.equalsIgnoreCase(cis.string); - } else if (obj instanceof String) { - return string.equalsIgnoreCase(obj.toString()); } return false; } From 2ace84f0475fa597fb004512eef3071317154394 Mon Sep 17 00:00:00 2001 From: Vest Date: Sun, 17 May 2026 11:09:38 +0200 Subject: [PATCH 10/29] Restore processSolver after addModifier/removeModifier in SolverManagerFacet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Phase 6 API migration (094525dfc0) replaced addModifierAndSolve() with addModifier() but omitted the follow-up processSolver() call that recomputes the variable value. Without it, modifiers were registered but never evaluated, causing GlobalModifyTest to hang waiting for a value that was never computed. Also short-circuit global-scope resolution: when the target scope is global, call scopeFacet.getGlobalScope() directly instead of walking the VarScoped hierarchy — global variables have no meaningful scoped object to traverse. In GlobalModifyTest.targetFacetCount(), guard against an empty diagnose list (which is valid when no solver has been built yet) and remove a stale comment about a missing API method. --- .../src/itest/tokencontent/GlobalModifyTest.java | 3 +-- .../pcgen/cdom/facet/SolverManagerFacet.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/code/src/itest/tokencontent/GlobalModifyTest.java b/code/src/itest/tokencontent/GlobalModifyTest.java index c9524663dd8..b33e6fc5bda 100644 --- a/code/src/itest/tokencontent/GlobalModifyTest.java +++ b/code/src/itest/tokencontent/GlobalModifyTest.java @@ -98,11 +98,10 @@ protected int targetFacetCount() try { List list = sm.diagnose(varID); - size = list.size() - 1; + size = list.isEmpty() ? 0 : list.size() - 1; } catch (IllegalArgumentException e) { - //Really, SolverManager should have isChannel(varID) to avoid diagnose complaining if something doesn't exist size = 0; } return size; diff --git a/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java b/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java index 85f85f43b09..79d41b911d5 100644 --- a/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java +++ b/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java @@ -49,10 +49,14 @@ public List> diagnose(CharID id, VariableID varID) public boolean addModifier(CharID id, VarModifier vm, VarScoped thisValue, Modifier modifier, ScopeInstance source) { - ScopeInstance scope = scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue); + ScopeInstance scope = vm.getLegalScope().isGlobal() + ? scopeFacet.getGlobalScope(id) + : scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue); VariableID varID = (VariableID) loadContextFacet.get(id.getDatasetID()).get().getVariableContext() .getVariableID(scope, vm.getVarName()); - get(id).addModifier(varID, modifier, source); + SolverManager sm = get(id); + sm.addModifier(varID, modifier, source); + sm.processSolver(varID); return true; } @@ -62,10 +66,14 @@ public boolean addModifier(CharID id, VarModifier vm, VarScoped thisValue public void removeModifier(CharID id, VarModifier vm, VarScoped thisValue, Modifier modifier, ScopeInstance source) { - ScopeInstance scope = scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue); + ScopeInstance scope = vm.getLegalScope().isGlobal() + ? scopeFacet.getGlobalScope(id) + : scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue); VariableID varID = (VariableID) loadContextFacet.get(id.getDatasetID()).get().getVariableContext() .getVariableID(scope, vm.getVarName()); - get(id).removeModifier(varID, modifier, source); + SolverManager sm = get(id); + sm.removeModifier(varID, modifier, source); + sm.processSolver(varID); } public void setScopeFacet(ScopeFacet scopeFacet) From 9541b0e5cc8a28dcfee677d9e424c83e59434f57 Mon Sep 17 00:00:00 2001 From: Vest Date: Sun, 17 May 2026 21:32:59 +0200 Subject: [PATCH 11/29] Resolve global scope correctly in SolverManagerFacet When MODIFY is parsed inside a non-global scope (e.g., MODIFY:Face on a SIZE object), VarModifier.getLegalScope() reports the parsing scope, not the variable's actual scope. Following that path produced a ScopeInstance that did not match the one used when reading the variable, so modifiers were applied to a different VariableID than channels read from. Routine the scope through resolveScope(): if the parsed scope is global, or if the variable is legally defined at the global scope, use the global ScopeInstance. Otherwise fall back to the local scope as before. Fixes the Pathfinder FACE tests (which use MODIFY:Face on SIZE objects to set the global Face variable to "5,5") and the GlobalModifyTest identity-mismatch failures. --- .../pcgen/cdom/facet/SolverManagerFacet.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java b/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java index 79d41b911d5..cea4aa4bca3 100644 --- a/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java +++ b/code/src/java/pcgen/cdom/facet/SolverManagerFacet.java @@ -28,6 +28,7 @@ import pcgen.cdom.content.VarModifier; import pcgen.cdom.enumeration.CharID; import pcgen.cdom.facet.base.AbstractItemFacet; +import pcgen.rules.context.VariableContext; /** * This stores the SolverManager for each PlayerCharacter. @@ -49,11 +50,9 @@ public List> diagnose(CharID id, VariableID varID) public boolean addModifier(CharID id, VarModifier vm, VarScoped thisValue, Modifier modifier, ScopeInstance source) { - ScopeInstance scope = vm.getLegalScope().isGlobal() - ? scopeFacet.getGlobalScope(id) - : scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue); - VariableID varID = (VariableID) loadContextFacet.get(id.getDatasetID()).get().getVariableContext() - .getVariableID(scope, vm.getVarName()); + VariableContext varContext = loadContextFacet.get(id.getDatasetID()).get().getVariableContext(); + ScopeInstance scope = resolveScope(id, vm, thisValue, varContext); + VariableID varID = (VariableID) varContext.getVariableID(scope, vm.getVarName()); SolverManager sm = get(id); sm.addModifier(varID, modifier, source); sm.processSolver(varID); @@ -66,16 +65,25 @@ public boolean addModifier(CharID id, VarModifier vm, VarScoped thisValue public void removeModifier(CharID id, VarModifier vm, VarScoped thisValue, Modifier modifier, ScopeInstance source) { - ScopeInstance scope = vm.getLegalScope().isGlobal() - ? scopeFacet.getGlobalScope(id) - : scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue); - VariableID varID = (VariableID) loadContextFacet.get(id.getDatasetID()).get().getVariableContext() - .getVariableID(scope, vm.getVarName()); + VariableContext varContext = loadContextFacet.get(id.getDatasetID()).get().getVariableContext(); + ScopeInstance scope = resolveScope(id, vm, thisValue, varContext); + VariableID varID = (VariableID) varContext.getVariableID(scope, vm.getVarName()); SolverManager sm = get(id); sm.removeModifier(varID, modifier, source); sm.processSolver(varID); } + private ScopeInstance resolveScope(CharID id, VarModifier vm, VarScoped thisValue, + VariableContext varContext) + { + if (vm.getLegalScope().isGlobal() + || varContext.isLegalVariableID(scopeFacet.getGlobalScope(id).getImplementedScope(), vm.getVarName())) + { + return scopeFacet.getGlobalScope(id); + } + return scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue); + } + public void setScopeFacet(ScopeFacet scopeFacet) { this.scopeFacet = scopeFacet; From 2cb73bb1f316e75f579c72ea02d872cc64d15df0 Mon Sep 17 00:00:00 2001 From: Vest Date: Sun, 17 May 2026 21:33:05 +0200 Subject: [PATCH 12/29] Copy globalVarScopedMap entry on PlayerCharacter clone PlayerCharacter.clone() invokes bean.copyContents(id, aClone.id) on every facet, but AbstractItemFacet.copyContents() copies the underlying map directly without going through set(), so ScopeFacet.set()'s side effect of registering the GlobalPCVarScoped sentinel was skipped on the clone. The cloned character then had a null entry in globalVarScopedMap, and getGlobalScope() handed back a ScopeInstance whose owner was null, causing NullPointerExceptions in VarScoped.getProviderFor() during the 26 pcGenGUI*Test save/restore flows. Override copyContents() to also copy the globalVarScopedMap entry. --- code/src/java/pcgen/cdom/facet/ScopeFacet.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/code/src/java/pcgen/cdom/facet/ScopeFacet.java b/code/src/java/pcgen/cdom/facet/ScopeFacet.java index 1ece07a74ee..09d84371e2d 100644 --- a/code/src/java/pcgen/cdom/facet/ScopeFacet.java +++ b/code/src/java/pcgen/cdom/facet/ScopeFacet.java @@ -45,6 +45,17 @@ public boolean set(CharID id, ScopeInstanceFactory factory) return result; } + @Override + public void copyContents(CharID source, CharID copy) + { + super.copyContents(source, copy); + GlobalPCVarScoped globalVS = globalVarScopedMap.get(source); + if (globalVS != null) + { + globalVarScopedMap.put(copy, globalVS); + } + } + @Override public ScopeInstanceFactory remove(CharID id) { From 0eeccaa866c87b682872d93f453bf939f775adb1 Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 11:04:31 +0200 Subject: [PATCH 13/29] Fix CI release pipeline after JPMS subproject migration - jlink: add `addExtraDependencies('javafx')` so the merged module (which inherits `requires javafx.graphics` from controlsfx) can resolve JavaFX modules from `mods/lib` during merged-module compilation. - jlink: declare `prepareMergedJarsDir.dependsOn copyToLibs` to satisfy Gradle 9.5's implicit-dependency validation; both tasks read/write `build/libs/`. - Test config: move the JavaFX `--module-path mods/lib --add-modules javafx.*` JVM args out of `allprojects { tasks.withType(Test) }`. The pure-formula subprojects (PCGen-base, PCGen-Formula) have no `mods/lib` and don't depend on JavaFX, so applying those args to their tests crashed JVM startup with `FindException: Module javafx.web not found`. - Remove unused imports flagged by checkstyle after the JPMS API migration. --- build.gradle | 17 +++++++---------- .../java/pcgen/cdom/base/FormulaFactory.java | 1 - .../pcgen/cdom/formula/FixedSizeFormula.java | 1 - .../pcgen/cdom/formula/VariableUtilities.java | 1 - .../cdom/grouping/GroupingInfoFactory.java | 1 - .../cdom/grouping/GroupingScopeFilter.java | 1 - .../pcgen/rules/context/LoadContextInst.java | 1 - .../pcgen/rules/context/VariableContext.java | 1 - .../plugin/lsttokens/variable/LocalToken.java | 1 - 9 files changed, 7 insertions(+), 18 deletions(-) diff --git a/build.gradle b/build.gradle index e26dbd8e83a..50206b32d55 100644 --- a/build.gradle +++ b/build.gradle @@ -294,6 +294,7 @@ jar { */ jlink { options = ['--strip-debug', '--no-header-files', '--no-man-pages'] + addExtraDependencies('javafx') forceMerge('jep', 'fop', 'Saxon-HE', 'commons-lang3', 'commons-io', 'spring', 'freemarker', 'jdom2', 'argparse4j', 'xmlunit', 'controlsfx', @@ -471,6 +472,10 @@ tasks.register("copyToLibs", Copy) { // Fix implicit dependency issues with distribution tasks distZip.dependsOn copyToLibs distTar.dependsOn copyToLibs +// jlink's prepareMergedJarsDir reads from build/libs, which copyToLibs populates. +tasks.named("prepareMergedJarsDir").configure { + dependsOn copyToLibs +} tasks.register("copyToOutput", Copy) { dependsOn copyToLibs, converterJar, jar @@ -805,16 +810,6 @@ allprojects { exceptionFormat = 'full' events 'failed', 'skipped' } - jvmArgs += [ - '-Djava.awt.headless=true', - '-Djavafx.macosx.embedded=true', - '-Djava.security.manager=disallow', - - "--module-path", layout.projectDirectory.dir("mods/lib"), - "--add-modules", "javafx.controls,javafx.web,javafx.swing,javafx.fxml,javafx.graphics", - - '--enable-native-access=javafx.graphics', - ] } // https://youtrack.jetbrains.com/issue/KT-46165 @@ -826,6 +821,8 @@ allprojects { } } +// Root-project tests need JavaFX on the module path. Subproject tests +// (PCGen-base, PCGen-Formula) don't, and don't have a mods/lib dir. tasks.withType(Test).configureEach { jvmArgs += [ '-Djava.awt.headless=true', diff --git a/code/src/java/pcgen/cdom/base/FormulaFactory.java b/code/src/java/pcgen/cdom/base/FormulaFactory.java index abb83d09e73..cd94d705835 100644 --- a/code/src/java/pcgen/cdom/base/FormulaFactory.java +++ b/code/src/java/pcgen/cdom/base/FormulaFactory.java @@ -30,7 +30,6 @@ import pcgen.base.formula.inst.ComplexNEPFormula; import pcgen.base.formula.inst.NEPFormula; import pcgen.base.util.FormatManager; -import pcgen.cdom.formula.scope.PCGenScope; import pcgen.core.Equipment; import pcgen.core.PlayerCharacter; diff --git a/code/src/java/pcgen/cdom/formula/FixedSizeFormula.java b/code/src/java/pcgen/cdom/formula/FixedSizeFormula.java index 2b852b3e681..f11b755d960 100644 --- a/code/src/java/pcgen/cdom/formula/FixedSizeFormula.java +++ b/code/src/java/pcgen/cdom/formula/FixedSizeFormula.java @@ -19,7 +19,6 @@ import java.util.Objects; -import pcgen.cdom.formula.Formula; import pcgen.cdom.enumeration.IntegerKey; import pcgen.cdom.reference.CDOMSingleRef; import pcgen.core.Equipment; diff --git a/code/src/java/pcgen/cdom/formula/VariableUtilities.java b/code/src/java/pcgen/cdom/formula/VariableUtilities.java index 8187cf9142a..5b412ce9ba6 100644 --- a/code/src/java/pcgen/cdom/formula/VariableUtilities.java +++ b/code/src/java/pcgen/cdom/formula/VariableUtilities.java @@ -17,7 +17,6 @@ */ package pcgen.cdom.formula; -import java.util.Optional; import pcgen.base.formula.base.ScopeInstance; import pcgen.base.formula.base.ScopeInstanceFactory; diff --git a/code/src/java/pcgen/cdom/grouping/GroupingInfoFactory.java b/code/src/java/pcgen/cdom/grouping/GroupingInfoFactory.java index e4e7f80cd70..e1121da130f 100644 --- a/code/src/java/pcgen/cdom/grouping/GroupingInfoFactory.java +++ b/code/src/java/pcgen/cdom/grouping/GroupingInfoFactory.java @@ -18,7 +18,6 @@ import java.util.Arrays; import java.util.Stack; -import pcgen.base.formula.base.ImplementedScope; import pcgen.cdom.formula.scope.PCGenScope; /** diff --git a/code/src/java/pcgen/cdom/grouping/GroupingScopeFilter.java b/code/src/java/pcgen/cdom/grouping/GroupingScopeFilter.java index 777bb3bb9cc..15039d060c4 100644 --- a/code/src/java/pcgen/cdom/grouping/GroupingScopeFilter.java +++ b/code/src/java/pcgen/cdom/grouping/GroupingScopeFilter.java @@ -19,7 +19,6 @@ import java.util.Optional; import java.util.function.Consumer; -import pcgen.base.formula.base.ImplementedScope; import pcgen.cdom.formula.PCGenScoped; import pcgen.cdom.formula.scope.PCGenScope; diff --git a/code/src/java/pcgen/rules/context/LoadContextInst.java b/code/src/java/pcgen/rules/context/LoadContextInst.java index 540356c78cc..762f37d2824 100644 --- a/code/src/java/pcgen/rules/context/LoadContextInst.java +++ b/code/src/java/pcgen/rules/context/LoadContextInst.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.Optional; import java.util.logging.Logger; import java.util.logging.Level; diff --git a/code/src/java/pcgen/rules/context/VariableContext.java b/code/src/java/pcgen/rules/context/VariableContext.java index 87a76cab498..5dcce2ce1ed 100644 --- a/code/src/java/pcgen/rules/context/VariableContext.java +++ b/code/src/java/pcgen/rules/context/VariableContext.java @@ -66,7 +66,6 @@ import pcgen.cdom.helper.ReferenceDependency; import pcgen.rules.persistence.TokenLibrary; import pcgen.rules.persistence.token.ModifierFactory; -import pcgen.util.Logging; /** * A VariableContext is responsible for managing variable items during the load of data diff --git a/code/src/java/plugin/lsttokens/variable/LocalToken.java b/code/src/java/plugin/lsttokens/variable/LocalToken.java index b7870107baa..4231f827d09 100644 --- a/code/src/java/plugin/lsttokens/variable/LocalToken.java +++ b/code/src/java/plugin/lsttokens/variable/LocalToken.java @@ -17,7 +17,6 @@ */ package plugin.lsttokens.variable; -import pcgen.base.formula.base.ImplementedScope; import pcgen.base.formula.exception.LegalVariableException; import pcgen.base.util.FormatManager; import pcgen.cdom.base.Constants; From d8091eebd85d983a6ab84ff92ce2c98b39a5e530 Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 11:20:13 +0200 Subject: [PATCH 14/29] Generate PCGen-Formula parser at build time via JJTree+JavaCC The PCGen-Formula parse package gitignores seven JavaCC-generated files (FormulaParser, FormulaParserConstants, FormulaParserTokenManager, ParseException, Token, TokenMgrError, SimpleCharStream). They were previously produced by an Ant build that no longer runs after the JPMS subproject migration, so clean CI checkouts (including CodeQL's autobuild) failed compileJava with "cannot find symbol: FormulaParser". Add a javacc configuration and two JavaExec tasks (jjtree, javacc) to PCGen-Formula/build.gradle. JJTree converts formula.jjt into an annotated .jj under build/generated/jjtree, then JavaCC emits the seven parser/token classes into build/generated/sources/javacc, which is added as a secondary srcDir of the main source set. The hand-maintained AST/Visitor/Node/SimpleNode/Operator classes in code/src/java remain canonical because JJTree's auxiliary outputs land in a directory not on the source path. --- PCGen-Formula/build.gradle | 48 +++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/PCGen-Formula/build.gradle b/PCGen-Formula/build.gradle index 7c5d10b354b..1b662b2261a 100644 --- a/PCGen-Formula/build.gradle +++ b/PCGen-Formula/build.gradle @@ -12,9 +12,11 @@ java { modularity.inferModulePath = true } +def generatedJavaccDir = layout.buildDirectory.dir('generated/sources/javacc').get().asFile + sourceSets { main { - java { srcDirs = ['code/src/java'] } + java { srcDirs = ['code/src/java', generatedJavaccDir] } } test { java { srcDirs = ['code/src/test'] } @@ -25,9 +27,15 @@ repositories { mavenCentral() } +configurations { + javacc +} + dependencies { api project(':PCGen-base') + javacc 'net.java.dev.javacc:javacc:7.0.13' + testImplementation platform('org.junit:junit-bom:5.11.4') testImplementation 'org.junit.jupiter:junit-jupiter-api' testImplementation 'org.junit.jupiter:junit-jupiter-params' @@ -37,6 +45,44 @@ dependencies { testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } +// The hand-maintained AST classes, visitors, Node, SimpleNode, and Operator are checked +// into code/src/java. Only the pure-boilerplate JavaCC outputs (FormulaParser, +// FormulaParserConstants, FormulaParserTokenManager, ParseException, Token, TokenMgrError, +// SimpleCharStream) are generated at build time from formula.jjt. +def jjtreeOutDir = layout.buildDirectory.dir('generated/jjtree').get().asFile + +tasks.register('jjtree', JavaExec) { + def src = file('code/src/jjtree/pcgen/base/formula/parse/formula.jjt') + inputs.file(src) + outputs.dir(jjtreeOutDir) + classpath = configurations.javacc + mainClass = 'jjtree' + args "-OUTPUT_DIRECTORY=${jjtreeOutDir}", src.absolutePath + doFirst { + jjtreeOutDir.deleteDir() + jjtreeOutDir.mkdirs() + } +} + +tasks.register('javacc', JavaExec) { + dependsOn 'jjtree' + def jjFile = new File(jjtreeOutDir, 'formula.jj') + def outDir = new File(generatedJavaccDir, 'pcgen/base/formula/parse') + inputs.file(jjFile) + outputs.dir(generatedJavaccDir) + classpath = configurations.javacc + mainClass = 'javacc' + args "-OUTPUT_DIRECTORY=${outDir}", jjFile.absolutePath + doFirst { + generatedJavaccDir.deleteDir() + outDir.mkdirs() + } +} + +tasks.named('compileJava') { + dependsOn 'javacc' +} + tasks.named('test') { useJUnitPlatform() } From 76b69bddebc63c7942ffd17a181d91417588648a Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 11:37:46 +0200 Subject: [PATCH 15/29] Generate redundant JJTree outputs at build time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 16 AST classes plus Node, JJTFormulaParserState, FormulaParserTreeConstants, FormulaParserVisitor, and FormulaParserDefaultVisitor in PCGen-Formula/code/src/java/pcgen/base/formula/parse were byte-identical to JJTree's output from formula.jjt — pure boilerplate that didn't need to live in source control. Wire JJTree's output dir as a secondary srcDir of the main source set, drop JJTree's SimpleNode.java stub in a doLast (the hand-edited SimpleNode in code/src/java is canonical), and remove the 21 redundant files. The .gitignore in the parse package now covers all generated artifacts so they can't accidentally be re-added. Operator.java and SimpleNode.java are the only remaining hand-maintained files in that package. --- PCGen-Formula/build.gradle | 29 +++-- .../java/pcgen/base/formula/parse/.gitignore | 9 ++ .../base/formula/parse/ASTArithmetic.java | 23 ---- .../pcgen/base/formula/parse/ASTEquality.java | 23 ---- .../pcgen/base/formula/parse/ASTExpon.java | 23 ---- .../pcgen/base/formula/parse/ASTFParen.java | 23 ---- .../base/formula/parse/ASTGeometric.java | 23 ---- .../pcgen/base/formula/parse/ASTLogical.java | 23 ---- .../java/pcgen/base/formula/parse/ASTNum.java | 23 ---- .../base/formula/parse/ASTPCGenBracket.java | 23 ---- .../base/formula/parse/ASTPCGenLookup.java | 23 ---- .../formula/parse/ASTPCGenSingleWord.java | 23 ---- .../pcgen/base/formula/parse/ASTParen.java | 23 ---- .../base/formula/parse/ASTQuotString.java | 23 ---- .../base/formula/parse/ASTRelational.java | 23 ---- .../pcgen/base/formula/parse/ASTRoot.java | 23 ---- .../base/formula/parse/ASTUnaryMinus.java | 23 ---- .../pcgen/base/formula/parse/ASTUnaryNot.java | 23 ---- .../parse/FormulaParserDefaultVisitor.java | 61 --------- .../parse/FormulaParserTreeConstants.java | 45 ------- .../formula/parse/FormulaParserVisitor.java | 24 ---- .../formula/parse/JJTFormulaParserState.java | 123 ------------------ .../java/pcgen/base/formula/parse/Node.java | 41 ------ 23 files changed, 26 insertions(+), 674 deletions(-) delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTArithmetic.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTEquality.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTExpon.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTFParen.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTGeometric.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTLogical.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTNum.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenBracket.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenLookup.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenSingleWord.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTParen.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTQuotString.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRelational.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRoot.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryMinus.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryNot.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserDefaultVisitor.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserTreeConstants.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserVisitor.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/JJTFormulaParserState.java delete mode 100644 PCGen-Formula/code/src/java/pcgen/base/formula/parse/Node.java diff --git a/PCGen-Formula/build.gradle b/PCGen-Formula/build.gradle index 1b662b2261a..3181f872868 100644 --- a/PCGen-Formula/build.gradle +++ b/PCGen-Formula/build.gradle @@ -12,11 +12,12 @@ java { modularity.inferModulePath = true } +def generatedJjtreeDir = layout.buildDirectory.dir('generated/sources/jjtree').get().asFile def generatedJavaccDir = layout.buildDirectory.dir('generated/sources/javacc').get().asFile sourceSets { main { - java { srcDirs = ['code/src/java', generatedJavaccDir] } + java { srcDirs = ['code/src/java', generatedJjtreeDir, generatedJavaccDir] } } test { java { srcDirs = ['code/src/test'] } @@ -45,28 +46,32 @@ dependencies { testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } -// The hand-maintained AST classes, visitors, Node, SimpleNode, and Operator are checked -// into code/src/java. Only the pure-boilerplate JavaCC outputs (FormulaParser, -// FormulaParserConstants, FormulaParserTokenManager, ParseException, Token, TokenMgrError, -// SimpleCharStream) are generated at build time from formula.jjt. -def jjtreeOutDir = layout.buildDirectory.dir('generated/jjtree').get().asFile - +// SimpleNode.java and Operator.java in code/src/java are hand-maintained; everything +// else in pcgen/base/formula/parse is generated at build time. JJTree produces the AST +// classes, the visitor interfaces, and an annotated .jj grammar; JavaCC then turns the +// .jj into the parser and token classes. tasks.register('jjtree', JavaExec) { def src = file('code/src/jjtree/pcgen/base/formula/parse/formula.jjt') + def outDir = new File(generatedJjtreeDir, 'pcgen/base/formula/parse') inputs.file(src) - outputs.dir(jjtreeOutDir) + outputs.dir(generatedJjtreeDir) classpath = configurations.javacc mainClass = 'jjtree' - args "-OUTPUT_DIRECTORY=${jjtreeOutDir}", src.absolutePath + args "-OUTPUT_DIRECTORY=${outDir}", src.absolutePath doFirst { - jjtreeOutDir.deleteDir() - jjtreeOutDir.mkdirs() + generatedJjtreeDir.deleteDir() + outDir.mkdirs() + } + doLast { + // SimpleNode is hand-maintained in code/src/java; drop JJTree's stub so the + // two don't collide on the source path. + new File(outDir, 'SimpleNode.java').delete() } } tasks.register('javacc', JavaExec) { dependsOn 'jjtree' - def jjFile = new File(jjtreeOutDir, 'formula.jj') + def jjFile = new File(generatedJjtreeDir, 'pcgen/base/formula/parse/formula.jj') def outDir = new File(generatedJavaccDir, 'pcgen/base/formula/parse') inputs.file(jjFile) outputs.dir(generatedJavaccDir) diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/.gitignore b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/.gitignore index e741072ad3e..9fb4c6a7efc 100644 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/.gitignore +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/.gitignore @@ -1,3 +1,12 @@ +# Generated by JJTree from code/src/jjtree/.../formula.jjt at build time. +/AST*.java +/FormulaParserDefaultVisitor.java +/FormulaParserTreeConstants.java +/FormulaParserVisitor.java +/JJTFormulaParserState.java +/Node.java + +# Generated by JavaCC from the JJTree-produced .jj at build time. /formula.jj /FormulaParser.java /FormulaParserConstants.java diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTArithmetic.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTArithmetic.java deleted file mode 100644 index 2e6f6fae567..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTArithmetic.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTArithmetic.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTArithmetic extends SimpleNode { - public ASTArithmetic(int id) { - super(id); - } - - public ASTArithmetic(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=2d57b59bce9ef4b54fce0027dcc9f692 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTEquality.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTEquality.java deleted file mode 100644 index fe140ea847c..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTEquality.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTEquality.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTEquality extends SimpleNode { - public ASTEquality(int id) { - super(id); - } - - public ASTEquality(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=6b15c0d0d26194d6f19ca211da84876d (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTExpon.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTExpon.java deleted file mode 100644 index d0f7972939d..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTExpon.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTExpon.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTExpon extends SimpleNode { - public ASTExpon(int id) { - super(id); - } - - public ASTExpon(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=6185c1f4af5db16b1087742fe429c2e2 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTFParen.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTFParen.java deleted file mode 100644 index 4f890cbbfe8..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTFParen.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTFParen.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTFParen extends SimpleNode { - public ASTFParen(int id) { - super(id); - } - - public ASTFParen(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=8f3d619301c820763d7af3a2783c1eef (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTGeometric.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTGeometric.java deleted file mode 100644 index a8bbdf9aea7..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTGeometric.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTGeometric.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTGeometric extends SimpleNode { - public ASTGeometric(int id) { - super(id); - } - - public ASTGeometric(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=7a4828bcf98f617118060eb449338e23 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTLogical.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTLogical.java deleted file mode 100644 index 62bd89cb368..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTLogical.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTLogical.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTLogical extends SimpleNode { - public ASTLogical(int id) { - super(id); - } - - public ASTLogical(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=83279545290394d1779e2e528f4afcd0 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTNum.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTNum.java deleted file mode 100644 index de6eabdd4cd..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTNum.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTNum.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTNum extends SimpleNode { - public ASTNum(int id) { - super(id); - } - - public ASTNum(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=be2bb918925ae586e74cecab1a343ab8 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenBracket.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenBracket.java deleted file mode 100644 index 1a8234dc5b2..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenBracket.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTPCGenBracket.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTPCGenBracket extends SimpleNode { - public ASTPCGenBracket(int id) { - super(id); - } - - public ASTPCGenBracket(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=1f63e88d05343dc29c20300804c79465 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenLookup.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenLookup.java deleted file mode 100644 index b0841517486..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenLookup.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTPCGenLookup.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTPCGenLookup extends SimpleNode { - public ASTPCGenLookup(int id) { - super(id); - } - - public ASTPCGenLookup(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=d12904f08404654952d30a3216dd7866 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenSingleWord.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenSingleWord.java deleted file mode 100644 index 1f17202a026..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTPCGenSingleWord.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTPCGenSingleWord.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTPCGenSingleWord extends SimpleNode { - public ASTPCGenSingleWord(int id) { - super(id); - } - - public ASTPCGenSingleWord(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=d626bc36cd2aa53587e1116d6ff6df64 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTParen.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTParen.java deleted file mode 100644 index 5e29d9d74e3..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTParen.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTParen.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTParen extends SimpleNode { - public ASTParen(int id) { - super(id); - } - - public ASTParen(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=70762d05ebb34f6e3120781dbaab0d6c (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTQuotString.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTQuotString.java deleted file mode 100644 index 5d9400ab87d..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTQuotString.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTQuotString.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTQuotString extends SimpleNode { - public ASTQuotString(int id) { - super(id); - } - - public ASTQuotString(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=d734b4df84554414609b0bb72d2f014c (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRelational.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRelational.java deleted file mode 100644 index 9f28ba290ef..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRelational.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTRelational.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTRelational extends SimpleNode { - public ASTRelational(int id) { - super(id); - } - - public ASTRelational(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=85072a7adfcaf4cfcee127e887fb0c0a (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRoot.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRoot.java deleted file mode 100644 index c4a99dad487..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTRoot.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTRoot.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTRoot extends SimpleNode { - public ASTRoot(int id) { - super(id); - } - - public ASTRoot(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=fc5ceb4a982d63684ab851caf3f3cc0d (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryMinus.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryMinus.java deleted file mode 100644 index ccdebab5af4..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryMinus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTUnaryMinus.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTUnaryMinus extends SimpleNode { - public ASTUnaryMinus(int id) { - super(id); - } - - public ASTUnaryMinus(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=e41f6a1191e4fcd7112cf27ac19e3eda (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryNot.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryNot.java deleted file mode 100644 index 774f3a42a89..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/ASTUnaryNot.java +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. ASTUnaryNot.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -public -class ASTUnaryNot extends SimpleNode { - public ASTUnaryNot(int id) { - super(id); - } - - public ASTUnaryNot(FormulaParser p, int id) { - super(p, id); - } - - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data) { - - return - visitor.visit(this, data); - } -} -/* JavaCC - OriginalChecksum=c6a8fd33e361b3fed43d8221ef686f1c (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserDefaultVisitor.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserDefaultVisitor.java deleted file mode 100644 index cd66058885d..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserDefaultVisitor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. FormulaParserDefaultVisitor.java Version 7.0.13 */ -package pcgen.base.formula.parse; - -public class FormulaParserDefaultVisitor implements FormulaParserVisitor{ - public Object defaultVisit(SimpleNode node, Object data){ - node.childrenAccept(this, data); - return data; - } - public Object visit(SimpleNode node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTRoot node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTLogical node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTEquality node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTRelational node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTArithmetic node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTGeometric node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTUnaryMinus node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTUnaryNot node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTExpon node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTParen node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTNum node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTPCGenLookup node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTPCGenSingleWord node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTPCGenBracket node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTFParen node, Object data){ - return defaultVisit(node, data); - } - public Object visit(ASTQuotString node, Object data){ - return defaultVisit(node, data); - } -} -/* JavaCC - OriginalChecksum=ef6ff0786bb1f3018972ad2d72bd2057 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserTreeConstants.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserTreeConstants.java deleted file mode 100644 index 86bb61bcdd5..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserTreeConstants.java +++ /dev/null @@ -1,45 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. FormulaParserTreeConstants.java Version 7.0.13 */ -package pcgen.base.formula.parse; - -public interface FormulaParserTreeConstants -{ - public int JJTROOT = 0; - public int JJTVOID = 1; - public int JJTLOGICAL = 2; - public int JJTEQUALITY = 3; - public int JJTRELATIONAL = 4; - public int JJTARITHMETIC = 5; - public int JJTGEOMETRIC = 6; - public int JJTUNARYMINUS = 7; - public int JJTUNARYNOT = 8; - public int JJTEXPON = 9; - public int JJTPAREN = 10; - public int JJTNUM = 11; - public int JJTPCGENLOOKUP = 12; - public int JJTPCGENSINGLEWORD = 13; - public int JJTPCGENBRACKET = 14; - public int JJTFPAREN = 15; - public int JJTQUOTSTRING = 16; - - - public String[] jjtNodeName = { - "Root", - "void", - "Logical", - "Equality", - "Relational", - "Arithmetic", - "Geometric", - "UnaryMinus", - "UnaryNot", - "Expon", - "Paren", - "Num", - "PCGenLookup", - "PCGenSingleWord", - "PCGenBracket", - "FParen", - "QuotString", - }; -} -/* JavaCC - OriginalChecksum=b6023e47faca655aaa5937d5713ac8bb (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserVisitor.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserVisitor.java deleted file mode 100644 index 0a8e93e2323..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/FormulaParserVisitor.java +++ /dev/null @@ -1,24 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. FormulaParserVisitor.java Version 7.0.13 */ -package pcgen.base.formula.parse; - -public interface FormulaParserVisitor -{ - public Object visit(SimpleNode node, Object data); - public Object visit(ASTRoot node, Object data); - public Object visit(ASTLogical node, Object data); - public Object visit(ASTEquality node, Object data); - public Object visit(ASTRelational node, Object data); - public Object visit(ASTArithmetic node, Object data); - public Object visit(ASTGeometric node, Object data); - public Object visit(ASTUnaryMinus node, Object data); - public Object visit(ASTUnaryNot node, Object data); - public Object visit(ASTExpon node, Object data); - public Object visit(ASTParen node, Object data); - public Object visit(ASTNum node, Object data); - public Object visit(ASTPCGenLookup node, Object data); - public Object visit(ASTPCGenSingleWord node, Object data); - public Object visit(ASTPCGenBracket node, Object data); - public Object visit(ASTFParen node, Object data); - public Object visit(ASTQuotString node, Object data); -} -/* JavaCC - OriginalChecksum=d380ad9d2317a3447548ec484828a7ff (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/JJTFormulaParserState.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/JJTFormulaParserState.java deleted file mode 100644 index 9bd89b2ff9b..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/JJTFormulaParserState.java +++ /dev/null @@ -1,123 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. JJTFormulaParserState.java Version 7.0.13 */ -package pcgen.base.formula.parse; - -public class JJTFormulaParserState { - private java.util.List nodes; - private java.util.List marks; - - private int sp; // number of nodes on stack - private int mk; // current mark - private boolean node_created; - - public JJTFormulaParserState() { - nodes = new java.util.ArrayList(); - marks = new java.util.ArrayList(); - sp = 0; - mk = 0; - } - - /* Determines whether the current node was actually closed and - pushed. This should only be called in the final user action of a - node scope. */ - public boolean nodeCreated() { - return node_created; - } - - /* Call this to reinitialize the node stack. It is called - automatically by the parser's ReInit() method. */ - public void reset() { - nodes.clear(); - marks.clear(); - sp = 0; - mk = 0; - } - - /* Returns the root node of the AST. It only makes sense to call - this after a successful parse. */ - public Node rootNode() { - return nodes.get(0); - } - - /* Pushes a node on to the stack. */ - public void pushNode(Node n) { - nodes.add(n); - ++sp; - } - - /* Returns the node on the top of the stack, and remove it from the - stack. */ - public Node popNode() { - if (--sp < mk) { - mk = marks.remove(marks.size()-1); - } - return nodes.remove(nodes.size()-1); - } - - /* Returns the node currently on the top of the stack. */ - public Node peekNode() { - return nodes.get(nodes.size()-1); - } - - /* Returns the number of children on the stack in the current node - scope. */ - public int nodeArity() { - return sp - mk; - } - - - public void clearNodeScope(Node n) { - while (sp > mk) { - popNode(); - } - mk = marks.remove(marks.size()-1); - } - - - public void openNodeScope(Node n) { - marks.add(mk); - mk = sp; - n.jjtOpen(); - } - - - /* A definite node is constructed from a specified number of - children. That number of nodes are popped from the stack and - made the children of the definite node. Then the definite node - is pushed on to the stack. */ - public void closeNodeScope(Node n, int num) { - mk = marks.remove(marks.size()-1); - while (num-- > 0) { - Node c = popNode(); - c.jjtSetParent(n); - n.jjtAddChild(c, num); - } - n.jjtClose(); - pushNode(n); - node_created = true; - } - - - /* A conditional node is constructed if its condition is true. All - the nodes that have been pushed since the node was opened are - made children of the conditional node, which is then pushed - on to the stack. If the condition is false the node is not - constructed and they are left on the stack. */ - public void closeNodeScope(Node n, boolean condition) { - if (condition) { - int a = nodeArity(); - mk = marks.remove(marks.size()-1); - while (a-- > 0) { - Node c = popNode(); - c.jjtSetParent(n); - n.jjtAddChild(c, a); - } - n.jjtClose(); - pushNode(n); - node_created = true; - } else { - mk = marks.remove(marks.size()-1); - node_created = false; - } - } -} -/* JavaCC - OriginalChecksum=f86caf1856b37b54e22879b7eb7e5260 (do not edit this line) */ diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/Node.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/Node.java deleted file mode 100644 index 1db4d1639cb..00000000000 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/Node.java +++ /dev/null @@ -1,41 +0,0 @@ -/* Generated By:JJTree: Do not edit this line. Node.java Version 7.0 */ -/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package pcgen.base.formula.parse; - -/* All AST nodes must implement this interface. It provides basic - machinery for constructing the parent and child relationships - between nodes. */ - -public -interface Node { - - /** This method is called after the node has been made the current - node. It indicates that child nodes can now be added to it. */ - public void jjtOpen(); - - /** This method is called after all the child nodes have been - added. */ - public void jjtClose(); - - /** This pair of methods are used to inform the node of its - parent. */ - public void jjtSetParent(Node n); - public Node jjtGetParent(); - - /** This method tells the node to add its argument to the node's - list of children. */ - public void jjtAddChild(Node n, int i); - - /** This method returns a child node. The children are numbered - from zero, left to right. */ - public Node jjtGetChild(int i); - - /** Return the number of children the node has. */ - public int jjtGetNumChildren(); - - public int getId(); - - /** Accept the visitor. **/ - public Object jjtAccept(FormulaParserVisitor visitor, Object data); -} -/* JavaCC - OriginalChecksum=a3cc9e5f83b9a1a826f5a893dd258e12 (do not edit this line) */ From df818ee6ece96ca1549ce71317f46894a506d46a Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 11:54:34 +0200 Subject: [PATCH 16/29] Document why SimpleNode is hand-maintained Note the PCGen-specific Operator/text fields, the ~50 call sites that prevent a rename, and the NODE_CLASS=PCGenBaseNode alternative for any future cleanup. --- .../pcgen/base/formula/parse/SimpleNode.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/SimpleNode.java b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/SimpleNode.java index 221f7148921..db0ed3af9d0 100644 --- a/PCGen-Formula/code/src/java/pcgen/base/formula/parse/SimpleNode.java +++ b/PCGen-Formula/code/src/java/pcgen/base/formula/parse/SimpleNode.java @@ -20,6 +20,29 @@ package pcgen.base.formula.parse; +/** + * SimpleNode is the base AST node class for the formula parser. JJTree would + * normally generate this class itself from formula.jjt, but the PCGen formula + * domain needs every node to carry an Operator (for arithmetic/relational/ + * logical nodes) and a text token (for variables, function names, numeric + * literals, etc.). The fields and accessors for those — setOperator/getOperator, + * setToken/getText, and the getId override — are added below the standard + * JJTree boilerplate. + * + * Because these PCGen-specific accessors are called on receivers typed as + * SimpleNode from roughly fifty call sites across the formula visitors, + * library functions, the grammar actions in formula.jjt, and the main pcgen + * tree (UserFunction, InputFunction), they must live on a class literally + * named SimpleNode. JJTree's own SimpleNode generation is suppressed by the + * `jjtree` Gradle task, which deletes the generated stub before compileJava. + * + * The cleaner alternative would be to set NODE_CLASS=PCGenBaseNode in + * formula.jjt, move the PCGen-specific extensions into a new PCGenBaseNode + * class, let JJTree regenerate SimpleNode from scratch, and rename every + * external reference. That is the idiomatic JJTree pattern for this kind of + * customization, but it would touch around fifty call sites for no functional + * benefit, so the current shape is preserved. + */ public class SimpleNode implements Node { private Node parent; From d29929b26bcb493c3a6229864e9062d0ff6c380c Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 12:55:48 +0200 Subject: [PATCH 17/29] Fix DynamicScope.getName() to return fully-qualified scope name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ImplementedScopeLibrary (new API) keys scopes by scope.getName() directly, whereas the old ScopeManagerInst built the full dotted name from the scope hierarchy. All hardcoded PCGenScope implementations (SkillScope, StatScope, etc.) were updated to return their full name (e.g. "PC.SKILL"), but DynamicScope was missed — it still returned only the category's local name (e.g. "MOVEMENT" instead of "PC.MOVEMENT"). This caused MODIFYOTHER:PC.MOVEMENT|... and LOCAL:PC.MOVEMENT|... tokens to fail with "illegal variable scope" warnings at load time, breaking DataLoadTest for any source that uses dynamic scopes (e.g. Starfinder armor entries using MODIFYOTHER to apply movement penalties). --- code/src/java/pcgen/cdom/formula/scope/DynamicScope.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/src/java/pcgen/cdom/formula/scope/DynamicScope.java b/code/src/java/pcgen/cdom/formula/scope/DynamicScope.java index 31ad8b4579a..e0cd1fbdd04 100644 --- a/code/src/java/pcgen/cdom/formula/scope/DynamicScope.java +++ b/code/src/java/pcgen/cdom/formula/scope/DynamicScope.java @@ -66,7 +66,7 @@ public DynamicScope(DynamicCategory category, FormatManager formatManag @Override public String getName() { - return category.getName(); + return GlobalPCScope.GLOBAL_SCOPE_NAME + "." + category.getName(); } @Override From 65ac6ab28c49cd2ae10adacc990ffaeacf32f1a1 Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 14:05:52 +0200 Subject: [PATCH 18/29] Fix getLocalVariableID to use owner's local scope, not global PC scope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the Phase 6 API migration, the call: instFactory.get(localScopeName.get(), Optional.of(owner)) was replaced with: SCOPE_FACET.get(id, owner) ScopeFacet.get(CharID, VarScoped) always uses GlobalPCScope.GLOBAL_SCOPE_NAME ("PC"), so variables declared in child scopes (e.g. CHANNEL*STATSCORE in PC.STAT) could not be found — VariableManager.getActiveScope only walks drawsFrom() upward, not into child scopes. Restore the original intent: get the owner's proper local scope name via PCGenScoped.getLocalScopeName() and use the ScopeInstanceFactory directly. --- code/src/java/pcgen/cdom/formula/VariableUtilities.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/src/java/pcgen/cdom/formula/VariableUtilities.java b/code/src/java/pcgen/cdom/formula/VariableUtilities.java index 5b412ce9ba6..0272190c62a 100644 --- a/code/src/java/pcgen/cdom/formula/VariableUtilities.java +++ b/code/src/java/pcgen/cdom/formula/VariableUtilities.java @@ -179,7 +179,8 @@ public static VariableID getLocalVariableID(CharID id, VarScoped owner, String name) { ScopeInstanceFactory instFactory = SCOPE_FACET.get(id); - ScopeInstance scopeInst = SCOPE_FACET.get(id, owner); + PCGenScoped pcGenOwner = (PCGenScoped) owner; + ScopeInstance scopeInst = instFactory.get(pcGenOwner.getLocalScopeName().get(), owner); return VariableUtilities.getLocalVariableID(id, scopeInst, name); } } From beb7593208ab64ed79af5bb5f0e70ca2dfe57047 Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 14:22:34 +0200 Subject: [PATCH 19/29] Address Sonar issues in VariableUtilities Replace wildcard VariableID returns on getLocalVariableID with a generic parameter (S1452), matching the existing pattern on getGlobalVariableID. Replace the unguarded Optional.get() on the owner's local scope name with orElseThrow (S3655), carrying the variable name, owner class, and owner identity in the message so a misrouted call can be diagnosed from the log alone. --- .../java/pcgen/cdom/formula/VariableUtilities.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/code/src/java/pcgen/cdom/formula/VariableUtilities.java b/code/src/java/pcgen/cdom/formula/VariableUtilities.java index 0272190c62a..06c36b1fe32 100644 --- a/code/src/java/pcgen/cdom/formula/VariableUtilities.java +++ b/code/src/java/pcgen/cdom/formula/VariableUtilities.java @@ -155,11 +155,11 @@ public static void forwardVariableChangeToDFCL(CharID id, * @return The VariableID for the variable with the given name on the local object * represented by the given ScopeInstance */ - public static VariableID getLocalVariableID(CharID id, + public static VariableID getLocalVariableID(CharID id, ScopeInstance scopeInst, String name) { LoadContext loadContext = LOAD_CONTEXT_FACET.get(id.getDatasetID()).get(); - return loadContext.getVariableContext().getVariableID(scopeInst, name); + return (VariableID) loadContext.getVariableContext().getVariableID(scopeInst, name); } /** @@ -175,12 +175,17 @@ public static VariableID getLocalVariableID(CharID id, * The name of the variable for which the VariableID should be returned * @return The VariableID for the variable with the given name on the given object */ - public static VariableID getLocalVariableID(CharID id, VarScoped owner, + public static VariableID getLocalVariableID(CharID id, VarScoped owner, String name) { ScopeInstanceFactory instFactory = SCOPE_FACET.get(id); PCGenScoped pcGenOwner = (PCGenScoped) owner; - ScopeInstance scopeInst = instFactory.get(pcGenOwner.getLocalScopeName().get(), owner); + String localScopeName = pcGenOwner.getLocalScopeName().orElseThrow( + () -> new IllegalArgumentException( + "Cannot resolve local variable '" + name + "' on " + + owner.getClass().getSimpleName() + " '" + owner + + "': object has no local scope name")); + ScopeInstance scopeInst = instFactory.get(localScopeName, owner); return VariableUtilities.getLocalVariableID(id, scopeInst, name); } } From 137c116a4e5509b1adb336c5ce523183733220d6 Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 16:50:27 +0200 Subject: [PATCH 20/29] Fix stale links and git rebase command in README Replace defunct AdoptOpenJDK links with Eclipse Temurin (Adoptium). Correct git rebase command: fetch before checkout, and rebase from upstream/master. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 668778cdcc9..a2a292cce01 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ It supports numerous game systems, most notably: 1. Install Java. - JDK 11 is recommended and has long term support, later versions should also work. 10 and below are not supported. - To check if you have Java installed, see [Install Java](#install-java) - - If you don't have it already, you can get it from [AdoptOpenJDK](https://adoptopenjdk.net/installation.html?variant=openjdk11&jvmVariant=hotspot). + - If you don't have it already, you can get it from [Eclipse Temurin](https://adoptium.net/temurin/releases/?version=11). 2. Download and extract the full zip file from https://github.com/PCGen/pcgen/releases/latest. @@ -113,7 +113,7 @@ Check the installed version with: For 6.08 development you will want Java with a minimum version of 11. For 6.09 development you will want Java with a minimum version of 25. -You can install the latest version from [AdoptOpenJDK](https://adoptopenjdk.net) regardless of your OS, please see instructions there. +You can install the latest version from [Eclipse Temurin](https://adoptium.net) regardless of your OS, please see instructions there. ### Install Git Check the installed version with: @@ -150,7 +150,7 @@ Run the following command: This sets up the project for upstream rebasing to keep you level with changes. You can rebase the master with the latest changes with the following. It can be done from GUI as well. - git checkout master && git fetch upstream && git rebase master + git fetch upstream && git checkout master && git rebase upstream/master ### Get an IDE This step is optional. You are free to program in what you prefer, these are several popular IDEs for Java. From fcc45a86ea81271589c0929bd38599a6390a21ae Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 16:57:11 +0200 Subject: [PATCH 21/29] Include PCGen-base and PCGen-Formula test results in CI report After the JPMS subproject migration, subprojects produce their own test results under PCGen-base/ and PCGen-Formula/. Add those paths to the Publish Test Results step so they are not silently omitted. --- .github/workflows/gradle-test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/gradle-test.yml b/.github/workflows/gradle-test.yml index acc144d5617..5ec5a2d03f7 100644 --- a/.github/workflows/gradle-test.yml +++ b/.github/workflows/gradle-test.yml @@ -42,6 +42,12 @@ jobs: build/test-results/**/*.xml build/test-results/**/*.trx build/test-results/**/*.json + PCGen-base/build/test-results/**/*.xml + PCGen-base/build/test-results/**/*.trx + PCGen-base/build/test-results/**/*.json + PCGen-Formula/build/test-results/**/*.xml + PCGen-Formula/build/test-results/**/*.trx + PCGen-Formula/build/test-results/**/*.json - name: Run Coverage run: ./gradlew testCoverage From 69993f67bf76da0a0036ca71d142b83d762c617b Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 19:13:20 +0200 Subject: [PATCH 22/29] Drop unused orange-extensions compileOnly dependency com.yuvimasory:orange-extensions had no references in any source file. The library exposes Apple-specific eawt APIs that the project does not use; the dependency was carried by the build configuration alone. --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index 50206b32d55..de13270a1da 100644 --- a/build.gradle +++ b/build.gradle @@ -241,7 +241,6 @@ dependencies { implementation project(':PCGen-Formula') compileOnly 'org.jetbrains:annotations:26.1.0' - compileOnly 'com.yuvimasory:orange-extensions:1.3.0' compileOnly 'com.github.spotbugs:spotbugs-annotations:4.9.8' testImplementation platform('org.junit:junit-bom:6.0.3') From 2c15a069f156003763bde1575f4235e89d8db897 Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 19:29:55 +0200 Subject: [PATCH 23/29] Move xmlunit-core to testImplementation scope Only PcgenFtlTestCase referenced org.xmlunit.*; no production code did. Keeping it on the production module path forced a `requires org.xmlunit;` in module-info and pulled the jar into the runtime image for nothing. --- build.gradle | 2 +- code/src/java/module-info.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index de13270a1da..cc62a6cd0fd 100644 --- a/build.gradle +++ b/build.gradle @@ -235,7 +235,6 @@ dependencies { implementation 'org.freemarker:freemarker:2.3.34' implementation 'org.jdom:jdom2:2.0.6.1' implementation 'net.sourceforge.argparse4j:argparse4j:0.9.0' - implementation 'org.xmlunit:xmlunit-core:2.11.0' implementation 'org.controlsfx:controlsfx:11.2.3' implementation project(':PCGen-base') implementation project(':PCGen-Formula') @@ -258,6 +257,7 @@ dependencies { testImplementation 'org.testfx:openjfx-monocle:21.0.2' testImplementation 'org.xmlunit:xmlunit-matchers:2.11.0' + testImplementation 'org.xmlunit:xmlunit-core:2.11.0' spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0' diff --git a/code/src/java/module-info.java b/code/src/java/module-info.java index 944ff5e6aec..6a75e5bcbb1 100644 --- a/code/src/java/module-info.java +++ b/code/src/java/module-info.java @@ -28,7 +28,6 @@ requires org.jdom2; requires net.sourceforge.argparse4j; requires org.controlsfx.controls; - requires org.xmlunit; requires org.apache.xmlgraphics.fop.core; requires org.apache.xmlgraphics.fop.events; requires org.apache.xmlgraphics.commons; From ca9df42ac47a3d558bd5f85ff92b074f692e8668 Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 20:32:06 +0200 Subject: [PATCH 24/29] Add UNICODE_INPUT=true to suppress JavaCC non-ASCII warning The BASIC_LETTER token definition covers Unicode ranges beyond Latin. Without UNICODE_INPUT=true, JavaCC warns about non-ASCII characters in the generated regex. The option also ensures the parser handles Unicode input correctly when a non-default Reader is used. --- .../code/src/jjtree/pcgen/base/formula/parse/formula.jjt | 1 + 1 file changed, 1 insertion(+) diff --git a/PCGen-Formula/code/src/jjtree/pcgen/base/formula/parse/formula.jjt b/PCGen-Formula/code/src/jjtree/pcgen/base/formula/parse/formula.jjt index 9ab91a8bfbd..9b390955a99 100644 --- a/PCGen-Formula/code/src/jjtree/pcgen/base/formula/parse/formula.jjt +++ b/PCGen-Formula/code/src/jjtree/pcgen/base/formula/parse/formula.jjt @@ -20,6 +20,7 @@ options { STATIC=false; VISITOR=true; MULTI=true; + UNICODE_INPUT=true; } PARSER_BEGIN( FormulaParser ) From fa680c10a79574dddcd37f61256d02e671b11bc6 Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 21:39:07 +0200 Subject: [PATCH 25/29] Document fullJpackage as the correct native bundle task jpackageImage alone skips assembleJpackageImage, leaving data/plugins/ preview/outputsheets out of the bundle. fullJpackage runs the full chain. Also document the macOS .DS_Store workaround. --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index a2a292cce01..0af6a02d4e0 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,19 @@ This mirrors what GitHub Actions runs to verify a PR; if it fails locally your C ### Generate IntelliJ IDEA Project ./gradlew idea +### Build Native Application Bundle (jpackage) +Produces a self-contained native app with a bundled JVM for the current platform. +**Always use `fullJpackage`** — not `jpackageImage` directly. `jpackageImage` only builds +the JVM runtime; `fullJpackage` also copies the required `data`, `plugins`, `preview`, and +`outputsheets` folders into the bundle. + + ./gradlew fullJpackage + +The output is placed in `build/jpackage/`. + +> **macOS note:** If the build fails with `Unable to delete directory 'build/jpackage'` due +> to a `.DS_Store` file, run `rm -f build/jpackage/.DS_Store` and retry. + ## Troubleshooting #### If you have an error stating `Task :run FAILED Error: --module-path requires module path specification` in Intellij, From aa8da72f9b6d81131aab6e74901af437c9ee6f9f Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 22:46:43 +0200 Subject: [PATCH 26/29] Remove dead cross-platform build infrastructure from jlink/jpackage Pre-late-2024, PCGen used NSIS for the Windows installer. NSIS is script-driven and platform-agnostic, so a single host could produce installers for all five target platforms (linux x64/aarch64, mac x64/aarch64, windows x64). The all-platforms JDK download chain (downloadJDKs / extractJDKs / downloadJavaFXMods, plus the five-entry targetPlatform() block in jlink {}) was load-bearing for that workflow, and PCGEN_ALL_PLATFORMS=true was the switch that turned it on. NSIS was retired in commits 306cee4801..be48763530 in favor of jpackage. jpackage is not platform-agnostic: it shells out to native OS tooling (hdiutil/pkgbuild on macOS, WiX on Windows, dpkg-deb on Linux), and the Beryx jlink plugin's mergedModule step invokes the target JDK's native javac to synthesize a module-info. The moment NSIS left, cross-platform builds from a single host stopped working - verified 2026-05-19 on macOS aarch64, where PCGEN_ALL_PLATFORMS=true ./gradlew jlink fails with "jdk_linux_aarch64/bin/javac: cannot execute binary file". CI sidestepped this by moving to a per-OS matrix (.github/workflows/gradle-release.yml) where each runner builds only its own platform. PCGEN_ALL_PLATFORMS is never set in any workflow and would fail on every GitHub-hosted runner if it were. This commit removes the now-dead surface: - The PCGEN_ALL_PLATFORMS env-var branches in jlink {} and tasks.named("jlink"); registers only the host targetPlatform(). - Aggregator tasks downloadJDKs, extractJDKs, downloadJavaFXMods. - The unused 'jre' task (no callers). Per-platform downloadJdk_*, extractJdk_*, downloadJfxMods_*, and extractJfxMods_* tasks are kept - they back the host-only path and CI caches them by glob. AGENTS.md updated to point at the per-platform task names. --- AGENTS.md | 3 +- build.gradle | 83 +++++++++++++++++++++++----------------------------- 2 files changed, 37 insertions(+), 49 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 31e14aac133..b75da77d367 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -65,8 +65,7 @@ Always use the wrapper (./gradlew). Java 25 is required; Gradle will fetch depen - ./gradlew clean (also triggers cleanPlugins, cleanOutput, cleanJdks, cleanMods, cleanMasterSheets) Notes -- Some tasks trigger downloads of JDKs/JavaFX for all platforms (downloadJDKs, extractJDKs, downloadJavaFXMods) or host SDK (downloadJavaFXLocal/extractJavaFXLocal). CI caches build/jre and build/libs. -- The `jre` task prepares all platform JDKs with JavaFX modules for runtime image creation. +- jlink/jpackage build only the host platform. Per-platform tasks (downloadJdk__, extractJdk__, downloadJfxMods__, extractJfxMods__) are wired up automatically; the host SDK helper is downloadJavaFXLocal/extractJavaFXLocal. CI caches build/jre and build/libs. - Runtime bundles expect assets in data/, system/, outputsheets/, preview/, vendordata/, homebrewdata/. ## Running From Source diff --git a/build.gradle b/build.gradle index cc62a6cd0fd..6d56be769c7 100644 --- a/build.gradle +++ b/build.gradle @@ -326,39 +326,38 @@ jlink { excludeProvides(service: 'org.apache.fop.fo.FOEventHandler') } - // Cross-platform images: only register platforms whose JDK javac can run on this host. - // CI sets PCGEN_ALL_PLATFORMS=true to build all targets (using platform-specific runners). - def hostArch = System.getProperty("os.arch") - def allPlatforms = System.getenv("PCGEN_ALL_PLATFORMS") == "true" - - def platformDefs = [ - 'linux-x64' : jdksDir.dir("jdk_linux_x64").asFile.absolutePath, - 'linux-aarch64' : jdksDir.dir("jdk_linux_aarch64").asFile.absolutePath, - 'windows-x64' : jdksDir.dir("jdk_windows_x64").asFile.absolutePath, - 'mac-x64' : jdksDir.dir("jdk_mac_x64/Contents/Home").asFile.absolutePath, - 'mac-aarch64' : jdksDir.dir("jdk_mac_aarch64/Contents/Home").asFile.absolutePath, + // jpackage shells out to native OS tooling and the jlink mergedModule step + // invokes the target JDK's native javac, so cross-platform images cannot + // be built from a single host. Register only the host platform; CI builds + // each installer on its own per-OS runner. + def hostArch = (System.getProperty("os.arch") == "aarch64") ? "aarch64" : "x64" + def supportedHostOs = [ + (Os.FAMILY_MAC) : "mac", + (Os.FAMILY_UNIX) : "linux", + (Os.FAMILY_WINDOWS): "windows", ] - - if (allPlatforms) { - platformDefs.each { name, jdk -> targetPlatform(name, jdk) } - } else if (Os.isFamily(Os.FAMILY_MAC)) { - def macPlatform = (hostArch == "aarch64") ? 'mac-aarch64' : 'mac-x64' - targetPlatform(macPlatform, platformDefs[macPlatform]) - } else if (Os.isFamily(Os.FAMILY_UNIX)) { - def linuxPlatform = (hostArch == "aarch64") ? 'linux-aarch64' : 'linux-x64' - targetPlatform(linuxPlatform, platformDefs[linuxPlatform]) - } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { - targetPlatform('windows-x64', platformDefs['windows-x64']) + def hostOs = supportedHostOs.find { Os.isFamily(it.key) }?.value + if (hostOs == null) { + throw new GradleException("Unsupported host OS: '${System.getProperty("os.name")}'. Supported families: ${supportedHostOs.values().join(", ")}") } + def hostJdkPath = (hostOs == "mac") + ? jdksDir.dir("jdk_${hostOs}_${hostArch}/Contents/Home").asFile.absolutePath + : jdksDir.dir("jdk_${hostOs}_${hostArch}").asFile.absolutePath + targetPlatform("${hostOs}-${hostArch}", hostJdkPath) // Use the jpackage tool that comes with Java to build native installers jpackage { def licenseFile = layout.projectDirectory.file("code/LICENSE") def hostArchitecture = System.getProperty("os.arch") - def osFamily = - Os.isFamily(Os.FAMILY_MAC) ? "mac" : - Os.isFamily(Os.FAMILY_UNIX) ? "linux" : - Os.isFamily(Os.FAMILY_WINDOWS) ? "windows" : "unknown" + def supportedOsFamily = [ + (Os.FAMILY_MAC) : "mac", + (Os.FAMILY_UNIX) : "linux", + (Os.FAMILY_WINDOWS): "windows", + ] + def osFamily = supportedOsFamily.find { Os.isFamily(it.key) }?.value + if (osFamily == null) { + throw new GradleException("Unsupported host OS: '${System.getProperty("os.name")}'. Supported families: ${supportedOsFamily.values().join(", ")}") + } def targetPlatform = ["x86_64" : "x64", "amd64" : "x64", "aarch64" : "aarch64"] @@ -387,7 +386,17 @@ tasks.named("jpackageImage") { } tasks.named("jlink") { - dependsOn "downloadJavaFXMods" + def supportedHostOs = [ + (Os.FAMILY_MAC) : "mac", + (Os.FAMILY_UNIX) : "linux", + (Os.FAMILY_WINDOWS): "windows", + ] + def hostOs = supportedHostOs.find { Os.isFamily(it.key) }?.value + if (hostOs == null) { + throw new GradleException("Unsupported host OS: '${System.getProperty("os.name")}'. Supported families: ${supportedHostOs.values().join(", ")}") + } + def hostArch = (System.getProperty("os.arch") == "aarch64") ? "aarch64" : "x64" + dependsOn "extractJfxMods_${hostOs}_${hostArch}" } tasks.register("assembleJpackageImage", Copy) { @@ -566,11 +575,6 @@ platforms.each { p -> } } -tasks.register("downloadJDKs") { - description = "Downloads JDKs for all supported platforms" - dependsOn platforms.collect { "downloadJdk_${it.os}_${it.arch}" } -} - platforms.each { p -> tasks.register("extractJdk_${p.os}_${p.arch}", Copy) { description = "Extracts JDK archive for ${p.os} ${p.arch}" @@ -594,11 +598,6 @@ platforms.each { p -> } } -tasks.register("extractJDKs") { - description = "Extracts all downloaded JDK archives" - dependsOn platforms.collect { "extractJdk_${it.os}_${it.arch}" } -} - platforms.each { p -> def osPackage = (p.os == 'mac') ? 'osx' : p.os def archSuffix = (p.arch == 'x64') ? '-x64' : '-aarch64' @@ -634,11 +633,6 @@ platforms.each { p -> } } -tasks.register("downloadJavaFXMods") { - description = "Downloads and extracts JavaFX jmods into each platform JDK" - dependsOn platforms.collect { "extractJfxMods_${it.os}_${it.arch}" } -} - tasks.register("downloadJavaFXLocal", Download) { description = "Downloads the JavaFX modules for the current platform to the 'mods' directory for local testing" def supportedOS = [(Os.FAMILY_WINDOWS): "windows", @@ -698,11 +692,6 @@ tasks.named("compileJava") { dependsOn copyMasterSheets } -tasks.register("jre") { - description = "Prepares all platform JDKs with JavaFX modules for runtime image creation" - dependsOn downloadJavaFXMods -} - tasks.register("testCoverage", JacocoReport) { dependsOn test group = "Reporting" From 056aad4b5a895ed8c300a8281b0226f14fe22bb9 Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 23:11:17 +0200 Subject: [PATCH 27/29] Collapse per-platform JDK/JFX tasks to single host-targeted tasks Follow-up to "Remove dead cross-platform build infrastructure". The prior commit removed the all-platforms aggregator tasks and the five-entry targetPlatform() block, but the four platforms.each { } loops were left intact, registering 20 download/extract tasks of which only the host platform's 4 ever fire. Collapse the loops to single tasks: downloadJdk, extractJdk, downloadJfxMods, extractJfxMods. Filenames remain platform-stamped (jdks/jdk_${hostOs}_${hostArch}.${ext}) so the GitHub Actions cache glob in gradle-release.yml keeps working - per-runner cache keys already isolate the linux/mac/windows builds. Remove the platforms ext list, which existed only to drive the loops. Lift host-OS/arch detection to a single computation at script scope (above jlink {}) and reuse it from jlink {}, jpackage {}, and tasks.named("jlink") instead of recomputing in three places. Verified by running ./gradlew jlink end-to-end on macOS aarch64: build/image/pcgen-mac-aarch64/bin/java reports openjdk 25.0.3. Updates CI workflow comments and AGENTS.md to reference the new flat task names. --- .github/workflows/gradle-release-manual.yml | 6 +- .github/workflows/gradle-release.yml | 6 +- AGENTS.md | 2 +- build.gradle | 174 ++++++++------------ 4 files changed, 77 insertions(+), 111 deletions(-) diff --git a/.github/workflows/gradle-release-manual.yml b/.github/workflows/gradle-release-manual.yml index c9effb7c8a6..fb7294d2834 100644 --- a/.github/workflows/gradle-release-manual.yml +++ b/.github/workflows/gradle-release-manual.yml @@ -160,8 +160,10 @@ jobs: cache-read-only: false cache-overwrite-existing: true - # Cache cross-platform JDK and JavaFX jmod archives downloaded by - # downloadJdk_* / downloadJavaFXMods_* tasks. These are pinned by + # Cache the host-platform JDK and JavaFX jmod archives downloaded by + # the downloadJdk / downloadJfxMods tasks. Filenames are stamped with + # ${hostOs}_${hostArch}, so each runner OS gets its own cache bucket + # via the runner-keyed actions/cache key. These are pinned by # javaVersion (gradle.properties) and the URL templates (build.gradle), # so keying on those file hashes invalidates correctly when we bump # the JDK or JavaFX version. We cache only the archives (.tar.gz / .zip) diff --git a/.github/workflows/gradle-release.yml b/.github/workflows/gradle-release.yml index 704e4656018..5d92dcb5aac 100644 --- a/.github/workflows/gradle-release.yml +++ b/.github/workflows/gradle-release.yml @@ -130,8 +130,10 @@ jobs: cache-read-only: false cache-overwrite-existing: true - # Cache cross-platform JDK and JavaFX jmod archives downloaded by - # downloadJdk_* / downloadJavaFXMods_* tasks. These are pinned by + # Cache the host-platform JDK and JavaFX jmod archives downloaded by + # the downloadJdk / downloadJfxMods tasks. Filenames are stamped with + # ${hostOs}_${hostArch}, so each runner OS gets its own cache bucket + # via the runner-keyed actions/cache key. These are pinned by # javaVersion (gradle.properties) and the URL templates (build.gradle), # so keying on those file hashes invalidates correctly when we bump # the JDK or JavaFX version. We cache only the archives (.tar.gz / .zip) diff --git a/AGENTS.md b/AGENTS.md index b75da77d367..631746d751c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -65,7 +65,7 @@ Always use the wrapper (./gradlew). Java 25 is required; Gradle will fetch depen - ./gradlew clean (also triggers cleanPlugins, cleanOutput, cleanJdks, cleanMods, cleanMasterSheets) Notes -- jlink/jpackage build only the host platform. Per-platform tasks (downloadJdk__, extractJdk__, downloadJfxMods__, extractJfxMods__) are wired up automatically; the host SDK helper is downloadJavaFXLocal/extractJavaFXLocal. CI caches build/jre and build/libs. +- jlink/jpackage build only the host platform. The download/extract tasks (downloadJdk, extractJdk, downloadJfxMods, extractJfxMods) target the host OS/arch automatically; the host SDK helper for local dev is downloadJavaFXLocal/extractJavaFXLocal. CI caches build/jre and build/libs. - Runtime bundles expect assets in data/, system/, outputsheets/, preview/, vendordata/, homebrewdata/. ## Running From Source diff --git a/build.gradle b/build.gradle index 6d56be769c7..19901c69e6e 100644 --- a/build.gradle +++ b/build.gradle @@ -291,6 +291,24 @@ jar { /** * Create a Java runtime built from Java modules using jlink */ +// Host platform detection. jpackage shells out to native OS tooling and the +// jlink mergedModule step invokes the target JDK's native javac, so cross- +// platform images cannot be built from a single host. Compute host once and +// reuse from jlink {}, jpackage {}, and the JDK/JFX download tasks below. +def supportedHostOs = [ + (Os.FAMILY_MAC) : "mac", + (Os.FAMILY_UNIX) : "linux", + (Os.FAMILY_WINDOWS): "windows", +] +def hostOs = supportedHostOs.find { Os.isFamily(it.key) }?.value +if (hostOs == null) { + throw new GradleException("Unsupported host OS: '${System.getProperty("os.name")}'. Supported families: ${supportedHostOs.values().join(", ")}") +} +def hostArch = (System.getProperty("os.arch") == "aarch64") ? "aarch64" : "x64" +def hostJdkExt = (hostOs == "windows") ? "zip" : "tar.gz" +def hostJfxOsPackage = (hostOs == "mac") ? "osx" : hostOs +def hostJfxArchSuffix = (hostArch == "x64") ? "-x64" : "-aarch64" + jlink { options = ['--strip-debug', '--no-header-files', '--no-man-pages'] addExtraDependencies('javafx') @@ -326,20 +344,6 @@ jlink { excludeProvides(service: 'org.apache.fop.fo.FOEventHandler') } - // jpackage shells out to native OS tooling and the jlink mergedModule step - // invokes the target JDK's native javac, so cross-platform images cannot - // be built from a single host. Register only the host platform; CI builds - // each installer on its own per-OS runner. - def hostArch = (System.getProperty("os.arch") == "aarch64") ? "aarch64" : "x64" - def supportedHostOs = [ - (Os.FAMILY_MAC) : "mac", - (Os.FAMILY_UNIX) : "linux", - (Os.FAMILY_WINDOWS): "windows", - ] - def hostOs = supportedHostOs.find { Os.isFamily(it.key) }?.value - if (hostOs == null) { - throw new GradleException("Unsupported host OS: '${System.getProperty("os.name")}'. Supported families: ${supportedHostOs.values().join(", ")}") - } def hostJdkPath = (hostOs == "mac") ? jdksDir.dir("jdk_${hostOs}_${hostArch}/Contents/Home").asFile.absolutePath : jdksDir.dir("jdk_${hostOs}_${hostArch}").asFile.absolutePath @@ -348,30 +352,17 @@ jlink { // Use the jpackage tool that comes with Java to build native installers jpackage { def licenseFile = layout.projectDirectory.file("code/LICENSE") - def hostArchitecture = System.getProperty("os.arch") - def supportedOsFamily = [ - (Os.FAMILY_MAC) : "mac", - (Os.FAMILY_UNIX) : "linux", - (Os.FAMILY_WINDOWS): "windows", - ] - def osFamily = supportedOsFamily.find { Os.isFamily(it.key) }?.value - if (osFamily == null) { - throw new GradleException("Unsupported host OS: '${System.getProperty("os.name")}'. Supported families: ${supportedOsFamily.values().join(", ")}") - } - def targetPlatform = ["x86_64" : "x64", - "amd64" : "x64", - "aarch64" : "aarch64"] - targetPlatformName = "${osFamily}-${targetPlatform.get(hostArchitecture, "NOT SUPPORTED")}" + targetPlatformName = "${hostOs}-${hostArch}" def appVersionStr = version.replaceAll('-SNAPSHOT', '').replaceAll(/[^0-9.].*/, '').replaceAll(/\.$/, '') appVersion = appVersionStr def opts = ["--license-file", licenseFile.asFile.absolutePath] - if (osFamily == "mac") { + if (hostOs == "mac") { opts += ["--mac-package-identifier", "PcGen", "--mac-package-name", "PcGen"] resourceDir = layout.projectDirectory.dir("installers/mac-installer").asFile } - else if (osFamily == "linux") { + else if (hostOs == "linux") { opts += ['--linux-shortcut'] } @@ -386,17 +377,7 @@ tasks.named("jpackageImage") { } tasks.named("jlink") { - def supportedHostOs = [ - (Os.FAMILY_MAC) : "mac", - (Os.FAMILY_UNIX) : "linux", - (Os.FAMILY_WINDOWS): "windows", - ] - def hostOs = supportedHostOs.find { Os.isFamily(it.key) }?.value - if (hostOs == null) { - throw new GradleException("Unsupported host OS: '${System.getProperty("os.name")}'. Supported families: ${supportedHostOs.values().join(", ")}") - } - def hostArch = (System.getProperty("os.arch") == "aarch64") ? "aarch64" : "x64" - dependsOn "extractJfxMods_${hostOs}_${hostArch}" + dependsOn "extractJfxMods" } tasks.register("assembleJpackageImage", Copy) { @@ -553,84 +534,65 @@ tasks.named("build") { mustRunAfter clean } -ext { - platforms = [ - [os: 'linux', arch: 'x64', ext: 'tar.gz'], - [os: 'linux', arch: 'aarch64', ext: 'tar.gz'], - [os: 'mac', arch: 'x64', ext: 'tar.gz'], - [os: 'mac', arch: 'aarch64', ext: 'tar.gz'], - [os: 'windows', arch: 'x64', ext: 'zip'], - ] -} - -platforms.each { p -> - tasks.register("downloadJdk_${p.os}_${p.arch}", Download) { - description = "Downloads JDK for ${p.os} ${p.arch}" - src "https://api.adoptium.net/v3/binary/latest/${javaVersion}/ga/${p.os}/${p.arch}/jdk/hotspot/normal/eclipse" - dest jdksDir.file("jdk_${p.os}_${p.arch}.${p.ext}") - onlyIfModified true - overwrite false - useETag true - tempAndMove true - } +tasks.register("downloadJdk", Download) { + description = "Downloads JDK for the host platform (${hostOs} ${hostArch})" + src "https://api.adoptium.net/v3/binary/latest/${javaVersion}/ga/${hostOs}/${hostArch}/jdk/hotspot/normal/eclipse" + dest jdksDir.file("jdk_${hostOs}_${hostArch}.${hostJdkExt}") + onlyIfModified true + overwrite false + useETag true + tempAndMove true } -platforms.each { p -> - tasks.register("extractJdk_${p.os}_${p.arch}", Copy) { - description = "Extracts JDK archive for ${p.os} ${p.arch}" - dependsOn "downloadJdk_${p.os}_${p.arch}" +tasks.register("extractJdk", Copy) { + description = "Extracts the host-platform JDK archive" + dependsOn "downloadJdk" - def archiveFile = jdksDir.file("jdk_${p.os}_${p.arch}.${p.ext}") - def outDir = jdksDir.dir("jdk_${p.os}_${p.arch}") + def archiveFile = jdksDir.file("jdk_${hostOs}_${hostArch}.${hostJdkExt}") + def outDir = jdksDir.dir("jdk_${hostOs}_${hostArch}") - from(p.ext == 'zip' ? zipTree(archiveFile) : tarTree(archiveFile)) - into outDir + from(hostJdkExt == 'zip' ? zipTree(archiveFile) : tarTree(archiveFile)) + into outDir - eachFile { FileCopyDetails fcd -> - def segments = fcd.relativePath.segments - if (segments.length > 1) { - fcd.relativePath = new RelativePath(!fcd.isDirectory(), segments[1..-1] as String[]) - } + eachFile { FileCopyDetails fcd -> + def segments = fcd.relativePath.segments + if (segments.length > 1) { + fcd.relativePath = new RelativePath(!fcd.isDirectory(), segments[1..-1] as String[]) } - includeEmptyDirs = false - - onlyIf { !outDir.asFile.directory } } -} - -platforms.each { p -> - def osPackage = (p.os == 'mac') ? 'osx' : p.os - def archSuffix = (p.arch == 'x64') ? '-x64' : '-aarch64' - def fileName = "openjfx-${latestJavaVersion}_${osPackage}${archSuffix}_bin-jmods.zip" + includeEmptyDirs = false - tasks.register("downloadJfxMods_${p.os}_${p.arch}", Download) { - description = "Downloads JavaFX jmods for ${p.os} ${p.arch}" - dependsOn "extractJdk_${p.os}_${p.arch}" - src "https://download2.gluonhq.com/openjfx/${latestJavaVersion}/${fileName}" - dest jdksDir.file("jfx_jmods_${p.os}_${p.arch}.zip") - overwrite false - useETag true - tempAndMove true - } + onlyIf { !outDir.asFile.directory } +} - tasks.register("extractJfxMods_${p.os}_${p.arch}", Copy) { - description = "Extracts JavaFX jmods into JDK for ${p.os} ${p.arch}" - dependsOn "downloadJfxMods_${p.os}_${p.arch}" +tasks.register("downloadJfxMods", Download) { + description = "Downloads JavaFX jmods for the host platform" + dependsOn "extractJdk" + def fileName = "openjfx-${latestJavaVersion}_${hostJfxOsPackage}${hostJfxArchSuffix}_bin-jmods.zip" + src "https://download2.gluonhq.com/openjfx/${latestJavaVersion}/${fileName}" + dest jdksDir.file("jfx_jmods_${hostOs}_${hostArch}.zip") + overwrite false + useETag true + tempAndMove true +} - def jmodsTarget = (p.os == 'mac') - ? jdksDir.dir("jdk_${p.os}_${p.arch}/Contents/Home/jmods") - : jdksDir.dir("jdk_${p.os}_${p.arch}/jmods") +tasks.register("extractJfxMods", Copy) { + description = "Extracts JavaFX jmods into the host-platform JDK" + dependsOn "downloadJfxMods" - from zipTree(jdksDir.file("jfx_jmods_${p.os}_${p.arch}.zip")) - into jmodsTarget - eachFile { fcd -> - def segments = fcd.relativePath.segments - fcd.relativePath = new RelativePath(!fcd.isDirectory(), segments[1..-1] as String[]) - } - includeEmptyDirs = false + def jmodsTarget = (hostOs == 'mac') + ? jdksDir.dir("jdk_${hostOs}_${hostArch}/Contents/Home/jmods") + : jdksDir.dir("jdk_${hostOs}_${hostArch}/jmods") - onlyIf { !jmodsTarget.asFile.directory || jmodsTarget.asFile.list()?.length == 0 } + from zipTree(jdksDir.file("jfx_jmods_${hostOs}_${hostArch}.zip")) + into jmodsTarget + eachFile { fcd -> + def segments = fcd.relativePath.segments + fcd.relativePath = new RelativePath(!fcd.isDirectory(), segments[1..-1] as String[]) } + includeEmptyDirs = false + + onlyIf { !jmodsTarget.asFile.directory || jmodsTarget.asFile.list()?.length == 0 } } tasks.register("downloadJavaFXLocal", Download) { From a6fc5f1e4de17cddc69869dfa410b8be5b2bc7ad Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 23:39:27 +0200 Subject: [PATCH 28/29] Disable unused distZip/distTar tasks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The application plugin's distZip/distTar produce build/distributions/ archives containing the pcgen jar plus ~150 runtime dependency jars and the generated start scripts. Nothing in this project consumes them: - CI publishes the custom 5-zip layout from buildDist (data, docs, program, libs, image) plus jpackage native installers. The release pipeline never reads build/distributions/. - End users install via jpackage-produced .dmg/.pkg/.exe/.deb/.rpm with a bundled JRE, not a raw jar pile that needs a system JDK. - Local dev uses ./gradlew run / qbuild, which don't touch dist*. Disable both with enabled = false. They stay in the task graph (assemble depends on them) but skip their actions, so every build stops materializing ~150 jars into build/distributions/ for nobody to read. Drop distTar/distZip from sourcesJar's dependsOn — that was a stale workaround for a Gradle implicit-dependency warning between copyToLibs and the dist tasks, now moot. sourcesJar's content comes from sourceSets.main.allSource, which is independent of dist*. --- build.gradle | 9 ++++++--- code/gradle/release.gradle | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 19901c69e6e..cc97c28f91b 100644 --- a/build.gradle +++ b/build.gradle @@ -458,9 +458,12 @@ tasks.register("copyToLibs", Copy) { from configurations.runtimeClasspath } -// Fix implicit dependency issues with distribution tasks -distZip.dependsOn copyToLibs -distTar.dependsOn copyToLibs +// distZip/distTar are unused: CI publishes the custom buildDist zips +// (see code/gradle/distribution.gradle) and the jpackage native installers, +// not the built-in distribution-plugin archives. Disable them so they don't +// materialize ~150 runtime JARs into build/distributions/ on every build. +tasks.named("distZip") { enabled = false } +tasks.named("distTar") { enabled = false } // jlink's prepareMergedJarsDir reads from build/libs, which copyToLibs populates. tasks.named("prepareMergedJarsDir").configure { dependsOn copyToLibs diff --git a/code/gradle/release.gradle b/code/gradle/release.gradle index 8b1079210d6..b7a63a8c1d5 100644 --- a/code/gradle/release.gradle +++ b/code/gradle/release.gradle @@ -32,7 +32,7 @@ ext { } tasks.register("sourcesJar", Jar) { - dependsOn classes, copyToOutput, distTar, distZip, startScripts + dependsOn classes, copyToOutput, startScripts duplicatesStrategy = DuplicatesStrategy.INCLUDE description = "build source jar file" archiveClassifier.set('sources') From 6eb013233f0813d83bcd66fd6f422a7379e8e0db Mon Sep 17 00:00:00 2001 From: Vest Date: Tue, 19 May 2026 23:48:23 +0200 Subject: [PATCH 29/29] Remove dead build tasks and stale debug prints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - buildonly: registered in 2014, never referenced anywhere in the repo (no CI, docs, scripts). Functionally a worse qbuild — same dependency on copyToOutput but missing the actual copy logic that makes qbuild useful. Pure dead weight. - quickbuild: same story, never referenced. "build runnable output and run tests" is just `./gradlew qbuild test` — no dedicated task needed. - println("IN copyToOutput") / println("IN buildonly"): debug prints left over from the 2014 Gradle conversion (commit f00f99c). They spammed stdout on every build with no useful info. - Stale TODO + commented-out `dependsOn copyToOutput` in the build task: documenting a non-change from 18 months ago. The decision to not have build populate output/ is permanent — qbuild fills that role for devs who want it. Kept mustRunAfter clean (load-bearing) with a clearer comment. - Dropped the now-orphan "// Alias tasks" comment. --- build.gradle | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index cc97c28f91b..108be993871 100644 --- a/build.gradle +++ b/build.gradle @@ -472,10 +472,6 @@ tasks.named("prepareMergedJarsDir").configure { tasks.register("copyToOutput", Copy) { dependsOn copyToLibs, converterJar, jar - doFirst { - println("IN copyToOutput") - } - from layout.buildDirectory.file("libs/pcgen-${version}.jar"), layout.buildDirectory.file("libs/pcgen-${version}-batch-convert.jar"), layout.projectDirectory.file("code/pcgen.bat") @@ -516,24 +512,9 @@ tasks.register("cleanMods", Delete) { delete modsDir } -// Alias tasks -tasks.register("buildonly") { - doFirst { - println("IN buildonly") - } - dependsOn copyToOutput -} - -tasks.register("quickbuild") { - dependsOn copyToOutput, test -} - tasks.named("build") { - // TODO reverts the commit f00f99c, because we don't have to generate all artifacts during the build - // dependsOn copyToOutput - - // Ensures that clean is never run after build and when clean is called it is - // run before build so it doesn't delete the new build folder. + // Ensures clean runs before build (not after) when both are invoked, + // so it doesn't delete the freshly-built artifacts. mustRunAfter clean }