Bug 438715 - Code formatter's add whitespace options missing for concatenation operator
Summary: Code formatter's add whitespace options missing for concatenation operator
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-02 07:06 EDT by Sanjay Rakholiya CLA
Modified: 2020-05-14 11:18 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sanjay Rakholiya CLA 2014-07-02 07:06:58 EDT
Hi,

I have used Toshihiro Izumi's code formatter plugin PDT Tools: Formatter 1.5.1.v20131008

Its having seperate options for binary & string concatination operator for add whitespace

PHP Development Tools (PDT)	3.3.0.201406110111 default code formatter has problem like,   

White Space >> Expressions >> Operators >> before & after binary operators.

Problem     : Its also put spaces on string concat
Correct     : $a = 4 + 9;
Incorrect   : echo $elm . "\n"; instead of echo $elm."\n";
Comment 1 Dawid Pakula CLA 2014-07-18 11:12:24 EDT
This is not critical

Space for concat operator is hardcoded, I'm marking this bug as enhancement.
Comment 2 Jonh Doe CLA 2019-11-29 16:18:30 EST
I would like to remind about the problem.

Relevant Code:

https://github.com/eclipse/pdt/blob/80f4bdc9b25197cb75dd5dda7310146802babcad/plugins/org.eclipse.php.formatter.core/src/org/eclipse/php/formatter/core/CodeFormatterVisitor.java#L4419

I think you can add a check for

operator == InfixExpression.OP_CONCAT

And if the condition is true, then do not add a space.

The ideal option is to add another setting, which will determine the addition of a space only in this case.

But this requires more code changes.
Comment 3 Eclipse Genie CLA 2019-12-25 14:49:16 EST
New Gerrit change created: https://git.eclipse.org/r/155031
Comment 5 Thierry BLIND CLA 2019-12-25 17:45:23 EST
Fixed.

There are 2 new options: White Space >> Expressions >> Operators >> before & after concatenation operators

Note that this patch also fixes a bug found when unchecking the "before & after binary operators" options, code like:

$a instanceof MyClass;

would have been formatted as:

$ainstanceofMyClass;


Thierry.