1 package org.simantics.scl.compiler.compilation;
3 import java.util.ArrayList;
5 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
6 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
7 import org.simantics.scl.compiler.elaboration.modules.TypeClassInstance;
8 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
9 import org.simantics.scl.compiler.internal.parsing.declarations.DDocumentationAst;
10 import org.simantics.scl.compiler.module.ConcreteModule;
11 import org.simantics.scl.compiler.types.TCon;
13 import gnu.trove.map.hash.THashMap;
14 import gnu.trove.set.hash.THashSet;
16 public class DocumentationGeneration {
17 THashMap<String, DDocumentationAst> valueDocumentation;
18 THashMap<String, DDocumentationAst> typeDocumentation;
19 THashMap<String, DDocumentationAst> classDocumentation;
20 ConcreteModule module;
22 THashSet<String> mentionedInDocumentation = new THashSet<String>();
23 THashMap<TCon, ArrayList<TypeClassInstance>> dataToInstance =
24 new THashMap<TCon, ArrayList<TypeClassInstance>>();
26 public DocumentationGeneration(/*StringBuilder moduleDocumentation,*/
27 THashMap<String, DDocumentationAst> valueDocumentation,
28 THashMap<String, DDocumentationAst> typeDocumentation,
29 THashMap<String, DDocumentationAst> classDocumentation,
30 ConcreteModule module) {
31 this.valueDocumentation = valueDocumentation;
32 this.typeDocumentation = typeDocumentation;
33 this.classDocumentation = classDocumentation;
37 public void generateDocumentation() {
38 for(String name : classDocumentation.keySet()) {
39 TypeClass typeClass = module.getTypeClass(name);
40 DDocumentationAst doc = classDocumentation.get(name);
41 if(typeClass != null && doc != null)
42 typeClass.setDocumentation(doc.documentation);
44 for(String name : valueDocumentation.keySet()) {
45 SCLValue value = module.getValue(name);
46 DDocumentationAst doc = valueDocumentation.get(name);
47 if(value != null && doc != null)
48 value.setDocumentation(doc.documentation);
50 for(String name : typeDocumentation.keySet()) {
51 TypeConstructor typeConstructor = module.getTypeConstructor(name);
52 DDocumentationAst doc = typeDocumentation.get(name);
53 if(typeConstructor != null && doc != null)
54 typeConstructor.setDocumentation(doc.documentation);