-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Bugfix for issue: #569 Plugin doesn't reassign extension if it has already been associated with text
- Loading branch information
Showing
5 changed files
with
78 additions
and
9 deletions.
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
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
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
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
50 changes: 50 additions & 0 deletions
50
src/test/java/org/antlr/intellij/plugin/editor/Issue569Test.java
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,50 @@ | ||
package org.antlr.intellij.plugin.editor; | ||
|
||
import com.intellij.openapi.command.WriteCommandAction; | ||
import com.intellij.openapi.editor.EditorFactory; | ||
import com.intellij.openapi.fileTypes.FileTypeManager; | ||
import com.intellij.openapi.fileTypes.FileTypes; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.intellij.testFramework.fixtures.BasePlatformTestCase; | ||
import org.antlr.intellij.plugin.ANTLRv4FileType; | ||
import org.antlr.intellij.plugin.ANTLRv4PluginController; | ||
import org.antlr.intellij.plugin.TestUtils; | ||
import org.junit.Test; | ||
|
||
public class Issue569Test extends BasePlatformTestCase { | ||
|
||
@Test | ||
public void test_shouldReassignExtensionType() { | ||
|
||
// Reassign extension temporarily | ||
WriteCommandAction.runWriteCommandAction(getProject(), () -> | ||
FileTypeManager.getInstance().associateExtension(FileTypes.PLAIN_TEXT, "g4")); | ||
|
||
// Test File | ||
VirtualFile file = myFixture.configureByFile("FooParser.g4").getVirtualFile(); | ||
assertEquals(file.getFileType(), FileTypes.PLAIN_TEXT); | ||
|
||
// Create controller and initialize it | ||
ANTLRv4PluginController controller = ANTLRv4PluginController.getInstance(getProject()); | ||
assertNotNull(controller); | ||
controller.initComponent(); | ||
|
||
// Check if file type is reassigned | ||
assertEquals(file.getFileType(), ANTLRv4FileType.INSTANCE); | ||
|
||
} | ||
|
||
@Override | ||
protected String getTestDataPath() { | ||
return "src/test/resources/references"; | ||
} | ||
|
||
@Override | ||
protected void tearDown() throws Exception { | ||
TestUtils.tearDownIgnoringObjectNotDisposedException(() -> { | ||
EditorFactory.getInstance().releaseEditor(myFixture.getEditor()); | ||
super.tearDown(); | ||
}); | ||
} | ||
|
||
} |