Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

jordanclark
Copy link

@jordanclark jordanclark commented Apr 24, 2019

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:

<cffunction>
	<cfset var foo = {
		success = false
	,	something = ""
	}>
</cffunction>

Would previously result in:

function {
	foo = {
	success = false
,	something = ""
};
}

After this pull it will be:

function {
	foo = {
		success = false
	,	something = ""
	};
}

Copy link

@KamasamaK KamasamaK left a 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() {

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");

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");

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};

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;

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);

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" ) ) {

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" ) ) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issues as returntype

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants