Skip to content

Commit 6aaaf2b

Browse files
author
Vitaliy Boyko
committed
464: fixed reference navigation for classes under directories with underscores
1 parent 73b5292 commit 6aaaf2b

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

src/com/magento/idea/magento2plugin/util/RegExUtil.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ public class PhpRegex {
7575
public static final String CLASS_NAME
7676
= "[A-Z][a-zA-Z0-9_\\x7f-\\xff]*";
7777

78+
public static final String DIR_NAME
79+
= "[a-zA-Z0-9_\\x7f-\\xff]*";
80+
7881
public static final String FQN
79-
= CLASS_NAME + "(\\\\" + CLASS_NAME + ")*";
82+
= CLASS_NAME + "(\\\\" + DIR_NAME + ")*" + CLASS_NAME;
8083
}
8184

8285
public static class XmlRegex {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\test_event;
8+
9+
use Magento\Framework\Event\ObserverInterface;
10+
11+
class TestObserver implements ObserverInterface
12+
{
13+
public function execute()
14+
{
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
10+
<event name="test_event">
11+
<observer name="test_observer" instance="Magento\Catalog\test_event\TestObserver<caret>" />
12+
</event>
13+
</config>

tests/com/magento/idea/magento2plugin/reference/xml/ObserverReferenceRegistrarTest.java

+9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ public void testObserverInstanceMustHaveReference() {
1818
assertHasReferencePhpClass("Magento\\Catalog\\Observer\\TestObserver");
1919
}
2020

21+
/**
22+
* Tests for observer instance with snake case reference in events.xml.
23+
*/
24+
public void testObserverInstanceDirectorySnakeCaseMustHaveReference() {
25+
myFixture.configureByFile(this.getFixturePath(ModuleEventsXml.FILE_NAME));
26+
27+
assertHasReferencePhpClass("Magento\\Catalog\\test_event\\TestObserver");
28+
}
29+
2130
/**
2231
* Tests for event name reference in events.xml.
2332
*/

0 commit comments

Comments
 (0)