Package net.mcreator.blockly
Class BlocklyToCode
java.lang.Object
net.mcreator.blockly.BlocklyToCode
- All Implemented Interfaces:
IGeneratorProvider,IWorkspaceProvider
- Direct Known Subclasses:
BlocklyToJava,BlocklyToJSONTrigger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<IBlockGenerator> protected final BlocklyEditorTypeprotected String -
Constructor Summary
ConstructorsConstructorDescriptionBlocklyToCode(Workspace workspace, ModElement parent, BlocklyEditorType editorType, TemplateGenerator templateGenerator, IBlockGenerator... externalGenerators) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddCompileNote(BlocklyCompileNote compileNote) final voidaddDependency(Dependency dependency) final voidaddTemplate(String template) final BlocklyToCodebooleancheckIfDepProviderInputsProvide(Dependency dependency) final voidvoidstatic StringdirectProcessOutputBlock(BlocklyToCode master, Element element) Helper method to get the code of an output block and remove surrounding parentheses if possiblestatic StringdirectProcessStatementBlock(BlocklyToCode master, Element element) intReturns the count of blocks currently processed from the block arrangement.final List<BlocklyCompileNote> final List<Dependency> final Stringfinal StringgetStatementInputsMatching(Predicate<StatementInput> predicate) final TemplateGeneratorThis method returns collection of machine names of all blocks that are present in the provided Blockly arrangementfinal Workspacefinal voidfinal voidprocessBlockProcedure(List<Element> blocks) final voidprocessOutputBlock(Element condition) final voidprocessOutputBlockToInt(Element element) Helper method to process an output block and cast to int when neededfinal voidHelper method to process an output block and remove surrounding parentheses if possiblefinal voidprocessOutputBlockWithoutParentheses(Element element, String blacklist) Helper method to process an output block and remove surrounding parentheses if possiblefinal voidpushDepProviderInputStack(DependencyProviderInput statementInput) voidsetHeadSection(String headSection) voidsetTailSection(String tailSection) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.mcreator.generator.IGeneratorProvider
getGenerator, getGeneratorConfiguration, getGeneratorStatsMethods inherited from interface net.mcreator.workspace.IWorkspaceProvider
getFileManager, getFolderManager, getModElementManager, getWorkspaceFolder, getWorkspaceSettings, getWorkspaceUserSettings
-
Field Details
-
blockGenerators
-
editorType
-
lastProceduralBlockType
-
-
Constructor Details
-
BlocklyToCode
public BlocklyToCode(Workspace workspace, ModElement parent, BlocklyEditorType editorType, @Nullable TemplateGenerator templateGenerator, IBlockGenerator... externalGenerators)
-
-
Method Details
-
getGeneratedCode
-
getExtraTemplatesCode
- Throws:
TemplateGeneratorException
-
getCompileNotes
-
getParent
-
getEditorType
-
getDependencies
-
append
-
clearCodeGeneratorBuffer
public final void clearCodeGeneratorBuffer() -
addCompileNote
-
addDependency
-
getTemplateGenerator
-
getWorkspace
- Specified by:
getWorkspacein interfaceIWorkspaceProvider
-
pushDepProviderInputStack
-
popDepProviderInputStack
public final void popDepProviderInputStack() -
checkIfDepProviderInputsProvide
-
getStatementInputsMatching
-
addTemplate
-
processBlockProcedure
- Throws:
TemplateGeneratorException
-
processOutputBlock
- Throws:
TemplateGeneratorException
-
directProcessOutputBlock
public static String directProcessOutputBlock(BlocklyToCode master, Element element) throws TemplateGeneratorException - Throws:
TemplateGeneratorException
-
directProcessStatementBlock
public static String directProcessStatementBlock(BlocklyToCode master, Element element) throws TemplateGeneratorException - Throws:
TemplateGeneratorException
-
processOutputBlockWithoutParentheses
public final void processOutputBlockWithoutParentheses(Element element) throws TemplateGeneratorException Helper method to process an output block and remove surrounding parentheses if possible- Parameters:
element- The element to process- Throws:
TemplateGeneratorException- If the template can't be generated
-
processOutputBlockWithoutParentheses
public final void processOutputBlockWithoutParentheses(Element element, String blacklist) throws TemplateGeneratorException Helper method to process an output block and remove surrounding parentheses if possible- Parameters:
element- The element to processblacklist- The characters that can't be contained at the top nesting level when optimizing the element- Throws:
TemplateGeneratorException- If the template can't be generated
-
directProcessOutputBlockWithoutParentheses
public String directProcessOutputBlockWithoutParentheses(Element element) throws TemplateGeneratorException Helper method to get the code of an output block and remove surrounding parentheses if possible- Parameters:
element- The element to process- Returns:
- The generated code of the element with parentheses optimization
- Throws:
TemplateGeneratorException- If the template can't be generated
-
processOutputBlockToInt
Helper method to process an output block and cast to int when needed- Parameters:
element- The element to process- Throws:
TemplateGeneratorException- If the template can't be generated
-
getUsedBlocks
This method returns collection of machine names of all blocks that are present in the provided Blockly arrangement- Returns:
- Unmodifiable collection of machine names of all blocks that are present in the provided Blockly arrangement
-
setHeadSection
-
setTailSection
-
clearSections
public void clearSections() -
getHeadSection
-
getTailSection
-
getBlockCount
public int getBlockCount()Returns the count of blocks currently processed from the block arrangement.- Returns:
- The total number of blocks.
-