The API Level
Please, become acquainted with the three levels of customization used by Freon. This section explains the 3rd of these three levels where you can customize Freon in TypeScript.
Customize a Pi-tool
Third level full adaptability per concept is currently possible for:
To add third level adaptability for the scoper, parser and unparser is one of the entries in our wish list.
Adding your Own Files
As a convenience, Freon generates templates for
your customization in the files ~/picode/editor/Custom<yourLanguageName>Projection.ts
, ~/picode/editor/Custom<yourLanguageName>Actions.ts
, etc
(<yourLanguageName>
is a placeholder for the name of the language as defined in your .ast file). You can use
these files to add your own special elements.
The custom files can be renamed and/or
put it in another location, or you can create your own set of custom projection files.
In that case, you need to adjust the file ~/picode/config/FreonConfiguration
.
// docu-project/config/ProjectitConfiguration.ts
/ Generated by the ProjectIt Language Generator.
import { PiProjection, PiActions, PiTyperPart, PiStdlib } from "@projectit/core";
import { CustomDocuProjectActions, CustomDocuProjectProjection } from "../editor";
import { CustomDocuProjectTyperPart } from "../typer";
import { CustomDocuProjectValidator } from "../validator";
import { CustomDocuProjectStdlib } from "../stdlib";
import { DocuProjectCheckerInterface } from "../validator/gen";
/**
* Class ProjectitConfiguration is the place where you can add all your customisations.
* These will be used through the 'projectitConfiguration' constant by any generated
* part of your language environment.
*/
class ProjectitConfiguration {
// add your custom editor projections here
customProjection: PiProjection[] = [new CustomDocuProjectProjection("manual")];
// add your custom editor actions here
customActions: PiActions[] = [new CustomDocuProjectActions()];
// add your custom validations here
customValidations: DocuProjectCheckerInterface[] = [new CustomDocuProjectValidator()];
// add your custom type-providers here
customTypers: PiTyperPart[] = [new CustomDocuProjectTyperPart()];
// add extra predefined instances here
customStdLibs: PiStdlib[] = [new CustomDocuProjectStdlib()];
}
export const projectitConfiguration = new ProjectitConfiguration();
Replacing a Pi-tool
All parts can be completely replaced at the 3rd level, thereby completely disregarding the default and definition levels. This is done by implementing their respective interfaces.
For the scoper, parser and unparser this is currently the only way to customize.
Pi-tool Interfaces
More information on the interfaces can be found here: