Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 162320 - wrong formatting of comments
wrong formatting of comments
Status: VERIFIED FIXED
Product: php
Classification: Unclassified
Component: Formatting & Indentation
6.x
All All
: P2 with 1 vote (vote)
: 6.x
Assigned To: Tomasz Slota
issues@php
:
: 158921 166399 167907 171254 172116 172123 173333 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-04-09 15:41 UTC by Filip Zamboj
Modified: 2009-10-09 22:54 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Zamboj 2009-04-09 15:41:04 UTC
Product Version: NetBeans IDE Dev (Build 2009-04-09_09-05-02 )
Java: 1.6.0_13; Java HotSpot(TM) 64-Bit Server VM 11.3-b02

**Example

initial: 
<?
// If done processing a 'param', append it to the 'params' array. -> manually added
if (!strcmp($name, 'param')) {
$this->record['params'][] = array_pop($this->stack);
}
// If done with the 'record' parsing, dump it. -> manually added
elseif (!strcmp($name, 'record')) {
// TODO: replace with DB INSERT --> manually added
//    print_r($this->record); --> ctrl+/
$this->normalizeRecord();
//comment(); --> manually added
$this->storeRecord();
array_pop($this->stack);
}
?>


result:  
<?
// If done processing a 'param', append it to the 'params' array. -> manually added
if (!strcmp($name, 'param')) {
    $this->record['params'][] = array_pop($this->stack);
}
// If done with the 'record' parsing, dump it. -> manually added
    elseif (!strcmp($name, 'record')) { -> WRONG! Already reported
    // TODO: replace with DB INSERT --> WRONG
    //    print_r($this->record); --> WRONG
        $this->normalizeRecord();
        //comment(); --> OK
        $this->storeRecord();
        array_pop($this->stack);
    }
?>

expected result: 
// If done processing a 'param', append it to the 'params' array. -> manually added
if (!strcmp($name, 'param')) {
    $this->record['params'][] = array_pop($this->stack);
}
// If done with the 'record' parsing, dump it. -> manually added
elseif (!strcmp($name, 'record')) {
    // TODO: replace with DB INSERT --> manually added
//    print_r($this->record); --> ctrl+/
    $this->normalizeRecord();
    //comment(); --> manually added
    $this->storeRecord();
    array_pop($this->stack);
}
Comment 1 Filip Zamboj 2009-04-09 15:42:18 UTC
included into unit tests php.editor/test/unit/data/testfiles/formatting/real_life/comments_in_statements.php
Comment 2 Tomasz Slota 2009-04-09 15:51:22 UTC
confirmed, a minimal test case:

<?php
if (1) {
//comment
    echo 1;
}
?>
Comment 3 Filip Zamboj 2009-04-21 00:56:08 UTC
one more example: 

function encounterPageName() {
        
//            comment   <- this one is correct behaviour after pressing ctrl+//
            calSomeDummyFunction 
}
result after pressing alt+shift+f to format source 
function encounterPageName() {
        
             //            comment   <- INCORRECT
            calSomeDummyFunction 
}
expected result: 
function encounterPageName() {
        
//            comment   <- CORRECT
            calSomeDummyFunction 
}
Comment 4 Tomasz Slota 2009-06-02 13:53:11 UTC
*** Issue 166399 has been marked as a duplicate of this issue. ***
Comment 5 Filip Zamboj 2009-06-02 14:04:51 UTC
keep it p2 - this issue is here too long and nothing is going on. it's not going to disappear between other formatting
issues, at least. 
Comment 6 Tomas Mysik 2009-06-02 16:15:06 UTC
Another example:
(the first line in the method - comment - is not indented)

----- %< -----
class Jobeet {
    static public function slugify($text) {
    // replace all non letters or digits by -
    $text = preg_replace('/\W+/', '-', $text);

    // trim and lowercase
    $text = strtolower(trim($text, '-'));

    return $text;
    }
}
----- %< -----
Comment 7 Filip Zamboj 2009-06-02 19:00:43 UTC
one more. After I used hint to implement all abstract methods I realized indentation is wrong so i used formatting and
comment was incorrectly formatted.

initial state: 
class PageLogin extends Page {
    //put your code here
        public function setPageTitle() {
        }
        public function setPageVariables() {
        }
        public function setPageContentDescription() {
        }
        public function getPageContentVars() {
        }
    }


after format: 
class PageLogin extends Page {
//put your code here  <-- wrong 
    public function setPageKeywords() {
    }
    public function setPageTitle() {
    }
    public function setPageVariables() {
    }
    public function setPageContentDescription() {
    }
    public function getPageContentVars() {
    }
}
Comment 8 Filip Zamboj 2009-06-30 12:54:38 UTC
*** Issue 158921 has been marked as a duplicate of this issue. ***
Comment 9 Petr Blaha 2009-07-02 13:50:14 UTC
Will you be able to fix&verify the issue till Fr 3-July when is cut-off-day for Patch1. thanks petr
Comment 10 Tomasz Slota 2009-07-02 14:08:09 UTC
No. The fix will depend on other post-67 changes, so it is not a good candidate for a patch
Comment 11 Tomasz Slota 2009-08-10 10:35:59 UTC
http://hg.netbeans.org/web-main/rev/cfd834b95566 - partial fix
Comment 12 Tomasz Slota 2009-08-10 15:56:41 UTC
*** Issue 167907 has been marked as a duplicate of this issue. ***
Comment 13 Tomasz Slota 2009-08-10 15:59:24 UTC
The remaining part of problems described in this report is covered by issue 162586. I am closing this issue and upgrading 162586 to P2 for more clarity
Comment 14 Quality Engineering 2009-08-10 18:03:41 UTC
Integrated into 'main-golden', will be available in build *200908101401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/cfd834b95566
User: Tomasz Slota <tslota@netbeans.org>
Log: #162320: wrong formatting of comments (part 1)
Comment 15 Tomasz Slota 2009-09-01 13:30:57 UTC
*** Issue 171254 has been marked as a duplicate of this issue. ***
Comment 16 Tomasz Slota 2009-09-14 10:40:39 UTC
*** Issue 172123 has been marked as a duplicate of this issue. ***
Comment 17 Tomasz Slota 2009-09-14 10:43:00 UTC
*** Issue 172116 has been marked as a duplicate of this issue. ***
Comment 18 Tomasz Slota 2009-09-30 11:57:43 UTC
*** Issue 173333 has been marked as a duplicate of this issue. ***
Comment 19 Filip Zamboj 2009-10-06 18:09:22 UTC
unit test added 
Comment 20 Quality Engineering 2009-10-09 22:54:35 UTC
Integrated into 'main-golden', will be available in build *200910091401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/5108cdf6c4d7
User: Filip Zamboj <fzamboj@netbeans.org>
Log: unit tests for #160996 and #162320 fixed


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo