PCGen Code Exploration Almanac

From PCGen Wiki
Revision as of 12:17, 18 October 2013 by James (talk | contribs) (Initial page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

This guide is a collection of strategies and ways to tackle tasks in the PCGen code. It doesn’t try to be an architectural guide, for that I would start with Explanation_of_the_Code_Base , which is a good document to be familiar with. There is also some good info at Architecture

Lst Tokens as an Entry Point

Quite often you will know the data that is associated with a problem or request. An important tip to remember is that almost all LST tokens are processed by a class which starts with the same name. e.g. the kit EQUIPBUY token is processed by the class plugin.lsttokens.kit.startpack.EquipBuyToken

All token classes then have a parse and unparsed method (sometimes it is in a parent class). You can look at these to find out how the token is interpreted and where the value is stored. Generally the token value is stored in a map in the rules object with a specific constant as a key (e.g. Objectkey.EQUIP_BUY). You can use this key to trace where the token value is processed, thus quickly getting to the code you want to look at.

So, typically in Eclipse I will

  1. Search for a class starting with the token name
  2. Read through the parse method to see the key used to store the value (or relevant part of the value).
  3. Open the Call hierarchy for the key to identify where the token’s value is processed.