forked from apache/netbeans
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- apache#7546 - Compare segments of namespace names to avoid adding incorrect items - Add a unit test
- Loading branch information
Showing
5 changed files
with
175 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
php/php.editor/test/unit/data/testfiles/actions/testGH7546/testGH7546.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
namespace NS1; | ||
|
||
class TestClass {} | ||
class TestClass2TestClass {} | ||
interface TestInterface {} | ||
interface TestInterface2TestInterface {} | ||
trait TestTrait {} | ||
trait TestTrait2TestTrait {} | ||
enum TestEnum { | ||
case Test; | ||
} | ||
enum TestEnum2TestEnum { | ||
case Test; | ||
} | ||
|
||
const CONSTANT = 1; | ||
const CONSTANT2CONSTANT = 2; | ||
|
||
function func(): void {} | ||
function func2func(): void {} | ||
|
||
namespace NS1\Sub1\Sub2\Sub3; | ||
|
||
class TestClass {} | ||
class TestClass2TestClass {} | ||
interface TestInterface {} | ||
interface TestInterface2TestInterface {} | ||
trait TestTrait {} | ||
trait TestTrait2TestTrait {} | ||
enum TestEnum { | ||
case Test; | ||
} | ||
enum TestEnum2TestEnum { | ||
case Test; | ||
} | ||
|
||
const CONSTANT = 1; | ||
const CONSTANT2CONSTANT = 2; | ||
|
||
function func(): void {} | ||
function func2func(): void {} |
36 changes: 36 additions & 0 deletions
36
php/php.editor/test/unit/data/testfiles/actions/testGH7546/testGH7546_01.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
namespace Test; | ||
|
||
class GH7546 { | ||
private TestClass $testClass1; | ||
private NS1\Sub1\TestClass $testClass2; | ||
private TestInterface $testInterface; | ||
private \NS1\Sub1\Sub2\Sub3\TestInterface $testInterface2; | ||
|
||
public const CONSTANT = TestEnum::Test; | ||
public const int CONSTANT2 = CONSTANT; | ||
|
||
use TestTrait; | ||
|
||
public function test(): void { | ||
func(); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
php/php.editor/test/unit/data/testfiles/actions/testGH7546/testGH7546_01.php.importData
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Caret position: 844 | ||
Should show uses panel: true | ||
Defaults: | ||
\NS1\Sub1\Sub2\Sub3\CONSTANT | ||
<html><font color='#FF0000'><cannot be resolved> | ||
\NS1\TestClass | ||
\NS1\TestEnum | ||
\NS1\TestInterface | ||
\NS1\TestTrait | ||
\NS1\Sub1\Sub2\Sub3\TestInterface | ||
\NS1\Sub1\Sub2\Sub3\func | ||
|
||
Names: | ||
CONSTANT | ||
NS1\Sub1\TestClass | ||
TestClass | ||
TestEnum | ||
TestInterface | ||
TestTrait | ||
\NS1\Sub1\Sub2\Sub3\TestInterface | ||
func | ||
|
||
Variants: | ||
\NS1\CONSTANT | ||
\NS1\Sub1\Sub2\Sub3\CONSTANT | ||
Don't import. | ||
|
||
<html><font color='#FF0000'><cannot be resolved> | ||
|
||
\NS1\Sub1\Sub2\Sub3\TestClass | ||
\NS1\TestClass | ||
Don't import. | ||
|
||
\NS1\Sub1\Sub2\Sub3\TestEnum | ||
\NS1\TestEnum | ||
Don't import. | ||
|
||
\NS1\Sub1\Sub2\Sub3\TestInterface | ||
\NS1\TestInterface | ||
Don't import. | ||
|
||
\NS1\Sub1\Sub2\Sub3\TestTrait | ||
\NS1\TestTrait | ||
Don't import. | ||
|
||
\NS1\Sub1\Sub2\Sub3\TestInterface | ||
Don't import. | ||
|
||
\NS1\func | ||
\NS1\Sub1\Sub2\Sub3\func | ||
Don't import. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters