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

Support new snake_case templates #1389

Merged
merged 1 commit into from
Nov 9, 2019
Merged

Conversation

ruudk
Copy link
Contributor

@ruudk ruudk commented Nov 7, 2019

This was introduced in SensioFrameworkExtraBundle 4.0.

https://github.com/sensiolabs/SensioFrameworkExtraBundle/blob/master/CHANGELOG.md#40

Fixes #1082 #1296 #1138

This is my first try to do something in Java, so I don't expect this PR to be pixel perfect yet. Please tell me how to improve, and I will :)

@ruudk
Copy link
Contributor Author

ruudk commented Nov 7, 2019

Somehow, the testTemplateOverwriteNavigation test is failing while running it in my IntelliJ IDEA Ultimate.

Stacktrace

log4j:WARN No appenders could be found for logger (#com.intellij.application.impl.ApplicationImpl). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

10:45:42,895 DEBUG .intellij.openapi.command.impl - executeCommand: com.intellij.openapi.command.WriteCommandAction$$Lambda$1047/0x000000080194b840@e87082a, name = Undefined, groupId = null, in command = false, in transparent action = false 
10:45:42,896 DEBUG i.vfs.newvfs.AsyncEventSupport - Processing [VfsEvent[create file temp:///src/aaa.twig]] 
10:45:42,896 DEBUG newvfs.persistent.PersistentFS - Applying VfsEvent[create file temp:///src/aaa.twig] 
10:45:42,896 DEBUG fs.impl.VirtualFileManagerImpl - fileCreated: file = temp:///src/aaa.twig, requestor = com.intellij.testFramework.fixtures.impl.JavaCodeInsightTestFixtureImpl@56ceed71 
10:45:42,897 DEBUG tellij.psi.impl.PsiManagerImpl - beforeChildAddition: event = PsiTreeChangeEventImpl{BEFORE_CHILD_ADDITION} 
10:45:42,897 DEBUG tellij.psi.impl.PsiManagerImpl - childAdded: child = com.jetbrains.twig.TwigFile, parent = com.intellij.psi.impl.file.PsiJavaDirectoryImpl 
10:45:42,897 DEBUG i.vfs.newvfs.AsyncEventSupport - Processing [VfsEvent[update: temp:///src/aaa.twig]] 
10:45:42,897 DEBUG fs.impl.VirtualFileManagerImpl - beforeContentsChange: file = temp:///src/aaa.twig, requestor = temp:///src/aaa.twig 
10:45:42,897 DEBUG fs.impl.VirtualFileManagerImpl - contentsChanged: file = temp:///src/aaa.twig, requestor = temp:///src/aaa.twig 
10:45:42,898 DEBUG tellij.psi.impl.PsiManagerImpl - beforeChildrenChange: parent = com.jetbrains.twig.TwigFile 
10:45:42,898 DEBUG ight.daemon.impl.FileStatusMap - [Mark dirty file defensively: , aaa.twig, PsiTreeChangeEventImpl{BEFORE_CHILDREN_CHANGE (generic) in file aaa.twig}] 

10:45:42,898 DEBUG tellij.psi.impl.PsiManagerImpl - beforeChildrenChange: parent = com.jetbrains.twig.TwigFile 
10:45:42,898 DEBUG ight.daemon.impl.FileStatusMap - [Mark dirty file defensively: , aaa.twig, PsiTreeChangeEventImpl{BEFORE_CHILDREN_CHANGE in file aaa.twig}] 

10:45:42,898 DEBUG tellij.psi.impl.PsiManagerImpl - childrenChanged: parent = com.jetbrains.twig.TwigFile 
10:45:42,898 DEBUG tellij.psi.impl.PsiManagerImpl - childrenChanged: parent = com.jetbrains.twig.TwigFile 
10:45:42,898 DEBUG mand.impl.UndoRedoStacksHolder - Adding to undo stacks: UndoableGroup[project=Project '/private/var/folders/_b/k77rqmjj55v9yfbfwqjjlfkr0000gn/T/unitTest_templateOverwriteNavigation5/light_temp.ipr' light_temp, name=Undefined, global=true, transparent=false, stamp=4, policy=DO_NOT_REQUEST_CONFIRMATION, temporary=false, valid=true, actions=[com.intellij.openapi.command.impl.FileUndoProvider$MyUndoableAction@7eb3ef35, com.intellij.openapi.command.impl.FileUndoProvider$MyUndoableAction@5f3720f7], documents=[temp:///src/app/Resources/TwigUtilIntegrationBundle/views/Foo/Bar, temp:///src/app/Resources/TwigUtilIntegrationBundle/views/Foo/Bar/layout.html.twig]] 
10:45:42,908 DEBUG .intellij.openapi.command.impl - executeCommand: com.intellij.openapi.command.WriteCommandAction$$Lambda$1047/0x000000080194b840@541c324f, name = Undefined, groupId = null, in command = false, in transparent action = false 
10:45:42,915 DEBUG enapi.editor.impl.DocumentImpl - DocumentEventImpl[myOffset=12, myOldLength=7, myNewLength=0, myOldString='', myNewString='']. 
10:45:42,916 DEBUG command.undo.NonUndoableAction - global=false; doc={% extends 'TwigUtilIntegrationBundle:layout.html.twig' %} 
10:45:42,919 DEBUG mand.impl.UndoRedoStacksHolder - Adding to undo stacks: UndoableGroup[project=Project '/private/var/folders/_b/k77rqmjj55v9yfbfwqjjlfkr0000gn/T/unitTest_templateOverwriteNavigation5/light_temp.ipr' light_temp, name=Undefined, global=true, transparent=false, stamp=5, policy=DO_NOT_REQUEST_CONFIRMATION, temporary=false, valid=true, actions=[com.intellij.openapi.command.impl.FileUndoProvider$MyUndoableAction@56e227ce], documents=[temp:///src/aaa.twig]] 
10:45:42,920 DEBUG i.vfs.newvfs.AsyncEventSupport - Processing [VfsEvent[update: temp:///src/aaa.twig]] 
10:45:42,920 DEBUG fs.impl.VirtualFileManagerImpl - beforeContentsChange: file = temp:///src/aaa.twig, requestor = temp:///src/aaa.twig 
10:45:42,920 DEBUG fs.impl.VirtualFileManagerImpl - contentsChanged: file = temp:///src/aaa.twig, requestor = temp:///src/aaa.twig 
10:45:42,921 DEBUG tellij.psi.impl.PsiManagerImpl - beforeChildrenChange: parent = com.jetbrains.twig.TwigFile 
10:45:42,921 DEBUG ight.daemon.impl.FileStatusMap - [Mark dirty file defensively: , aaa.twig, PsiTreeChangeEventImpl{BEFORE_CHILDREN_CHANGE (generic) in file aaa.twig}] 

10:45:42,921 DEBUG tellij.psi.impl.PsiManagerImpl - beforeChildrenChange: parent = com.jetbrains.twig.TwigFile 
10:45:42,921 DEBUG ight.daemon.impl.FileStatusMap - [Mark dirty file defensively: , aaa.twig, PsiTreeChangeEventImpl{BEFORE_CHILDREN_CHANGE in file aaa.twig}] 

10:45:42,921 DEBUG tellij.psi.impl.PsiManagerImpl - childrenChanged: parent = com.jetbrains.twig.TwigFile 
10:45:42,921 DEBUG tellij.psi.impl.PsiManagerImpl - childrenChanged: parent = com.jetbrains.twig.TwigFile 
10:45:42,922 DEBUG .intellij.openapi.command.impl - executeCommand: com.intellij.openapi.fileEditor.impl.TestEditorManagerImpl$$Lambda$1093/0x000000080197ec40@17a8eb10, name = , groupId = null, in command = false, in transparent action = false 
10:45:42,955 DEBUG j.ui.components.MacScrollBarUI - initialize scroll bar style 
10:45:42,958 DEBUG j.ui.components.MacScrollBarUI - scroll bar style Overlay from 1 
10:45:43,064 DEBUG n.options.CodeStyleCachingUtil - File: aaa.twig (2e4e215b), cached: com.intellij.psi.codeStyle.CodeStyleSettings@39234dd8, tracker: 0 
10:45:43,109 DEBUG ht.daemon.impl.DaemonListeners - Not worth bothering about editor created for : TwigFile:aaa.twig because editor isShowing(): false; project is open and file is mine: true 
10:45:43,112 DEBUG .editor.impl.EditorFactoryImpl - number of Editors after create: 1 
10:45:43,134 DEBUG pi.editor.impl.view.LineLayout - Text layout for null (0-58) 
10:45:43,152 DEBUG pi.editor.impl.view.LineLayout - Text layout for temp:///src/aaa.twig (0-58) 
10:45:43,199 DEBUG mand.impl.UndoRedoStacksHolder - Adding to undo stacks: UndoableGroup[project=null, name=Undefined, global=false, transparent=false, stamp=2, policy=DO_NOT_REQUEST_CONFIRMATION, temporary=false, valid=true, actions=[editor change: '' to '' at: 12], documents=[{% extends 'TwigUtilIntegrationBundle:layout.html.twig' %}]] 
10:45:43,199 DEBUG mand.impl.UndoRedoStacksHolder - Adding to undo stacks: UndoableGroup[project=Project '/private/var/folders/_b/k77rqmjj55v9yfbfwqjjlfkr0000gn/T/unitTest_templateOverwriteNavigation5/light_temp.ipr' light_temp, name=Undefined, global=false, transparent=false, stamp=6, policy=DO_NOT_REQUEST_CONFIRMATION, temporary=false, valid=true, actions=[com.intellij.openapi.command.impl.NonUndoableAction@19b4f66d], documents=[{% extends 'TwigUtilIntegrationBundle:layout.html.twig' %}]] 
10:45:43,214 DEBUG ij.psi.impl.source.PsiFileImpl - Loaded text for file /src/aaa.twig 
10:45:43,239 DEBUG ij.psi.impl.source.PsiFileImpl - Loaded text for file /src/aaa.twig 
10:45:43,262 DEBUG il.indexing.FileBasedIndexImpl - 320 files iterated in 1 ms 
10:45:43,358 INFO Symfony-Plugin - new instance: fr.adrienbrault.idea.symfony2plugin.templating.path.TwigPathServiceParser 
10:45:43,359 INFO Symfony-Plugin - update: fr.adrienbrault.idea.symfony2plugin.templating.path.TwigPathServiceParser 
10:45:43,363 DEBUG ij.psi.stubs.StubUpdatingIndex - Indexing temp:///src/app/Resources/TwigUtilIntegrationBundle/views/Foo/Bar/layout.html.twig; byte size = 0, char size = 0 
10:45:43,367 DEBUG ij.psi.stubs.StubUpdatingIndex - Indexing temp:///src/aaa.twig; byte size = 58, char size = 58 
10:45:43,370 DEBUG ij.psi.stubs.StubUpdatingIndex - Indexing temp:///src/app/Resources/TwigUtilIntegrationBundle/views/layout.html.twig; byte size = 0, char size = 0 
10:45:43,371 DEBUG ij.psi.stubs.StubUpdatingIndex - Indexing temp:///src/app/Resources/TwigUtilIntegrationBundle/views/Foo/layout.html.twig; byte size = 0, char size = 0 

failed that PsiElement (PsiElement(STRING_TEXT)) navigate to file /views/layout.html.twig
junit.framework.AssertionFailedError: failed that PsiElement (PsiElement(STRING_TEXT)) navigate to file /views/layout.html.twig
at junit.framework.Assert.fail(Assert.java:57)
at junit.framework.TestCase.fail(TestCase.java:227)
at fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase.assertNavigationContainsFile(SymfonyLightCodeInsightFixtureTestCase.java:260)
at fr.adrienbrault.idea.symfony2plugin.tests.templating.util.TwigUtilTest.testTemplateOverwriteNavigation(TwigUtilTest.java:54)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at junit.framework.TestCase.runTest(TestCase.java:176)
at com.intellij.testFramework.UsefulTestCase.lambda$runTest$12(UsefulTestCase.java:338)
at com.intellij.testFramework.UsefulTestCase.lambda$invokeTestRunnable$13(UsefulTestCase.java:375)
at com.intellij.testFramework.EdtTestUtilKt.runInEdtAndWait(EdtTestUtil.kt:44)
at com.intellij.testFramework.UsefulTestCase.invokeTestRunnable(UsefulTestCase.java:374)
at com.intellij.testFramework.UsefulTestCase.runTest(UsefulTestCase.java:357)
at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:392)
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:18)
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:13)
at com.intellij.testFramework.EdtTestUtilKt$runInEdtAndWait$3.run(EdtTestUtil.kt:67)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:303)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:433)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)2

@ruudk
Copy link
Contributor Author

ruudk commented Nov 7, 2019

With this change, we basically stop supporting the old < 4.0 syntax. I think it's not worth to add a configuration option to support both. Since the new format is the way forward, I think it's acceptable.

@@ -159,17 +161,17 @@
shortcutName = String.format(
"%s::%s%s",
symfonyBundle.getName(),
templateFolderName,
templateName
underscore(templateFolderName),
Copy link
Owner

Choose a reason for hiding this comment

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

With this change, we basically stop supporting the old < 4.0 syntax

Yes its just what i was think of, but i still see lot of projects having older versions. i think they can be easily supported as the method already supports multiple template names. I guess just adding the old naming to the end of the array will avoid this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's clever! Gonna try that out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it, tested it and it works. Tests are also green. Not sure if I need to add more test cases to also guard the old ones? How to do that?

Copy link
Owner

Choose a reason for hiding this comment

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

would be nice, but not needed for merging ;)

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.

Template name generation changed in SensioFrameworkExtraBundle
2 participants