-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix indentation to cfset, add cfthread, cftimer, cftrace #37
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably should have been more than one PR.
} | ||
return converter; | ||
} | ||
|
||
public function getIdentLevel() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is supposed to be getIndentLevel
.
|
||
public string function toScript(tag) { | ||
if( !tag.hasInnerContent() ) { | ||
throw(message="cftimer tag have a start and end tag"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "tag has" or "tags have".
@@ -1,6 +1,9 @@ | |||
component extends="BaseConverter" { | |||
|
|||
public string function toScript(tag) { | |||
if( !tag.hasInnerContent() ) { | |||
throw(message="cflock tag have a start and end tag"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "tag has" or "tags have".
@@ -1,6 +1,6 @@ | |||
component { | |||
variables.indentLevel = 0; | |||
variables.options = {indentChars=Chr(9)}; | |||
variables.options = {indentChars=Chr(9),cleanTypes=true}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why default this new option to true
? Also, if you're introducing a new option, it should be added to the README.
@@ -47,6 +47,18 @@ component extends="BaseConverter" { | |||
s = s & "++"; | |||
} | |||
s = s & " ) {"; | |||
} else if (structKeyExists(attr, "query")) { | |||
s = "cfloop( query= " & attr.query; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you extend BaseBlockTagConverter
for this component instead, I think you can just use super.toScript(tag)
here.
} else if (structKeyExists(attr, "query")) { | ||
s = "cfloop( query= " & attr.query; | ||
if (structKeyExists(attr, "startrow")) { | ||
s = s & " startRow= " & unPound(attr.startrow); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACF requires commas to separate script attributes, but I would recommend using something generic and already implemented as I suggested above.
@@ -40,7 +40,9 @@ component extends="BaseConverter" { | |||
s = s & "public "; | |||
} | |||
if (structKeyExists(attr, "returntype")) { | |||
s = s & attr.returntype & " "; | |||
if( !variables.options.cleanTypes || ( attr.returntype != "VOID" && attr.returntype != "any" ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since any
is the default, it's fine to optionally exclude, but removing void
changes the semantics. Also, it's unnecessary to nest another if
here.
@@ -56,7 +58,9 @@ component extends="BaseConverter" { | |||
s = s & "required "; | |||
} | |||
if (structKeyExists(childAttr, "type")) { | |||
s = s & childAttr.type & " "; | |||
if( !variables.options.cleanTypes || ( childAttr.type != "VOID" && childAttr.type != "any" ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issues as returntype
This pull will re-indent multiline cfset content. It was necessary to pass the toscript object to the converter and add a public method to get the current ident level.
For example the tags:
Would previously result in:
After this pull it will be: