-
Notifications
You must be signed in to change notification settings - Fork 9
Fix indentation to cfset, add cfthread, cftimer, cftrace #37
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
base: master
Are you sure you want to change the base?
Changes from all commits
012e5a9
119b2cd
b4ba3cf
730c31a
2cd8574
a15e61d
bb84c88
642be81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
component { | ||
variables.indentLevel = 0; | ||
variables.options = {indentChars=Chr(9)}; | ||
variables.options = {indentChars=Chr(9),cleanTypes=true}; | ||
|
||
public struct function toScript(filePath="", options={}, fileContent="") { | ||
var codeFile = new cfmlparser.File(filePath=filePath,fileContent=fileContent); | ||
|
@@ -146,17 +146,21 @@ component { | |
public function getTagConverter(tagName) { | ||
var converter = ""; | ||
try { | ||
converter = createObject("component", "converters." & trim(lCase(tagName))).init(options); | ||
converter = createObject("component", "converters." & trim(lCase(tagName))).init(options,this); | ||
} catch(any e) { | ||
if (e.type == "Template") { | ||
//due to compiler error of the CFC | ||
rethrow; | ||
} | ||
converter = createObject("component", "converters.BaseConverter").init(options); | ||
converter = createObject("component", "converters.BaseConverter").init(options,this); | ||
} | ||
return converter; | ||
} | ||
|
||
public function getIdentLevel() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is supposed to be |
||
return variables.indentLevel; | ||
} | ||
|
||
private function lineBreak(sb) { | ||
sb.append(Chr(13)); | ||
sb.append(Chr(10)); | ||
|
@@ -197,4 +201,4 @@ component { | |
outputBuffer.setLength(0); | ||
} | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
s = s & attr.returntype & " "; | ||
} | ||
} | ||
s = s & "function " & attr.name & "("; | ||
|
||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Same issues as |
||
s = s & childAttr.type & " "; | ||
} | ||
} | ||
s = s & childAttr.name; | ||
if (structKeyExists(childAttr, "default")) { | ||
|
@@ -85,4 +89,4 @@ component extends="BaseConverter" { | |
return "}"; | ||
} | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Should be "tag has" or "tags have". |
||
} | ||
var s = "lock "; | ||
var attr = tag.getAttributes(); | ||
s = s & trim(tag.getAttributeContent(stripTrailingSlash=true)); | ||
|
@@ -16,4 +19,4 @@ component extends="BaseConverter" { | |
public string function toScriptEndTag(tag) { | ||
return "}"; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. If you extend |
||
if (structKeyExists(attr, "startrow")) { | ||
s = s & " startRow= " & unPound(attr.startrow); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
if (structKeyExists(attr, "endrow")) { | ||
s = s & " endRow= " & unPound(attr.endrow); | ||
} | ||
if (structKeyExists(attr, "maxrows")) { | ||
s = s & " maxRows= " & unPound(attr.maxrows); | ||
} | ||
s = s & " ) {"; | ||
} else { | ||
throw(message="Unimplemented cfloop condition: #tag.getAttributeContent()# "); | ||
} | ||
|
@@ -62,4 +74,4 @@ component extends="BaseConverter" { | |
return "}"; | ||
} | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
component extends="BaseConverter" { | ||
|
||
public string function toScript(tag) { | ||
return trim(convertOperators(tag.getAttributeContent(stripTrailingSlash=true))) & ";"; | ||
var i = variables.toscript.getIdentLevel(); | ||
return reReplace( trim(convertOperators(tag.getAttributeContent(stripTrailingSlash=true))) & ";", "\n\t", chr(10) & repeatString( variables.options.indentChars, i ), "all" ); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
component extends="BaseBlockTagConverter" { | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Should be "tag has" or "tags have". |
||
} | ||
return super.toScript(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.
Why default this new option to
true
? Also, if you're introducing a new option, it should be added to the README.