Skip to content

Commit

Permalink
Generator no longer crashes (but still not correct outpu)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronanquillevere committed May 21, 2015
1 parent 70f0d75 commit 699074d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,26 @@ public static String getEventNamePrefix(Option option)

// GaugeClickEvent
String eventName = v2 + option.getTitle().substring(0, 1).toUpperCase() + option.getTitle().substring(1);
eventName = removeLt(eventName);
eventName = removeGt(eventName);
return eventName;
}

public static String removeLt(String name)
{
int lt = name.indexOf("<");
if (lt > -1)
name = name.substring(0,lt) + name.substring(lt+1,lt+2).toUpperCase() + name.substring(lt+2, name.length());
return name;
}

public static String removeGt(String name)
{
int lt = name.indexOf(">");
if (lt > -1)
name = name.substring(0,lt) + name.substring(lt+1, name.length());
return name;
}

public static String paramName(String eventName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.github.highcharts4gwt.generator.option.OptionTree;
import com.github.highcharts4gwt.generator.option.OptionUtils;
import com.github.highcharts4gwt.generator.option.field.BaseFieldWriter;
import com.github.highcharts4gwt.generator.option.field.EventHelper;
import com.github.highcharts4gwt.generator.option.field.GenericFieldWriter;
import com.sun.codemodel.ClassType;
import com.sun.codemodel.JClass;
Expand Down Expand Up @@ -56,7 +57,7 @@ public BaseClassWriter(String rootDirectory) throws JClassAlreadyExistsException
fieldWriter = new BaseFieldWriter();
genericFieldWritter = new GenericFieldWriter();
}

@Override
public void write() throws IOException, JClassAlreadyExistsException
{
Expand Down Expand Up @@ -140,6 +141,15 @@ public OptionClassWriter setTree(OptionTree tree)
this.tree = tree;
return this;
}

protected String getFullyQualifiedName()
{
String fullyqualifiedName = getPackageName() + "." + getPrefix() + getShortClassName();

fullyqualifiedName = EventHelper.removeLt(fullyqualifiedName);
fullyqualifiedName = EventHelper.removeGt(fullyqualifiedName);
return fullyqualifiedName;
}

protected abstract String getPrefix();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public ConcreteClassWriter(String rootDirectory) throws JClassAlreadyExistsExcep
@Override
protected JDefinedClass createJClass() throws JClassAlreadyExistsException
{
String fullyqualifiedName = getPackageName() + "." + getPrefix() + getShortClassName();
return getCodeModel()._class(fullyqualifiedName, getClassType())._implements(getInterface());
return getCodeModel()._class(getFullyQualifiedName(), getClassType())._implements(getInterface());
}

protected JClass getInterface()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ public String getPrefix()
@Override
protected JDefinedClass createJClass() throws JClassAlreadyExistsException
{
String fullyqualifiedName = getPackageName() + "." + getPrefix() + getShortClassName();
String fullyqualifiedName = getFullyQualifiedName();

return getCodeModel()._class(fullyqualifiedName, getClassType());
}



@Override
protected ClassType getClassType()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public JsoClassWriter(String rootDirectory) throws JClassAlreadyExistsException
@Override
protected JDefinedClass createJClass() throws JClassAlreadyExistsException
{
String fullyqualifiedName = getPackageName() + "." + getPrefix() + getShortClassName();
JDefinedClass jClass = getCodeModel()._class(fullyqualifiedName, getClassType())._implements(getInterface())._extends(JavaScriptObject.class);
JDefinedClass jClass = getCodeModel()._class(getFullyQualifiedName(), getClassType())._implements(getInterface())._extends(JavaScriptObject.class);
jClass.constructor(JMod.PROTECTED);
return jClass;
}
Expand Down

0 comments on commit 699074d

Please sign in to comment.