JetBrains / JetBrains/Grammar-Kit
Inconsistent output when generating parser code (Type vs. List<Type>)
- Dominant language
- Java
- Stars
- 771
- Forks
- 137
- Avg merge
- 11h 14m
- Merged PRs (30d)
- 1
Description
Using IDEA versions 13.1.5, 13.1.6, 14.
JDK: 1.6, 1.7, and 1.8 (Using default options; aggressive options appear to make it worse).
Grammar-Kit versions: 1.2.0, 1.2.0.1 (Did not occur on 1.1.x versions.)
OS: Windows 8.1, Linux (Ubuntu 14.04, CentOS 6.5)
The Intellij-haxe project is seeing an inconsistency in output when generating code from within the Intellij IDE (Ctrl+Shift+G). Sometimes the (consistent with v1.1.x) output looks like:
`HaxeFunctionType getFunctionType();`
and sometimes:
`List getFunctionTypeList();`
We say "sometimes" because the bug exhibits itself intermittently: at times you can regenerate for hours and not see the bug, and other times, you will hit it the first time you generate. (The recovery mechanism is to exit and restart IDEA and /usually/ you get the expected result.)
We've been trying to automate generation, so that we don't have to check in the gen/\* files, but command-line generations always give the second (unexpected) result. If you want to try using our scripts, you can find them in the [tivo repository](https://github.com/tivo/intellij-haxe).
The relevant BNF is [here](https://github.com/JetBrains/intellij-haxe/blob/master/grammar/haxe.bnf). Since the bug is intermittent, it will be very difficult to create a minimal example.
The output diff is:
```
diff --git a/gen/com/intellij/plugins/haxe/lang/psi/HaxeTypeTag.java b/gen/com/intellij/plugins/haxe
index 8309947..3bf6410 100644
--- a/gen/com/intellij/plugins/haxe/lang/psi/HaxeTypeTag.java
+++ b/gen/com/intellij/plugins/haxe/lang/psi/HaxeTypeTag.java
@@ -25,10 +25,10 @@ import com.intellij.psi.PsiElement;
public interface HaxeTypeTag extends HaxePsiCompositeElement {
- @Nullable
- HaxeFunctionType getFunctionType();
+ @NotNull
+ List getFunctionTypeList();
- @Nullable
- HaxeTypeOrAnonymous getTypeOrAnonymous();
+ @NotNull
+ List getTypeOrAnonymousList();
}
diff --git a/gen/com/intellij/plugins/haxe/lang/psi/impl/HaxeTypeTagImpl.java b/gen/com/intellij/plu
index 8e20f0e..4580244 100644
--- a/gen/com/intellij/plugins/haxe/lang/psi/impl/HaxeTypeTagImpl.java
+++ b/gen/com/intellij/plugins/haxe/lang/psi/impl/HaxeTypeTagImpl.java
@@ -40,15 +40,15 @@ public class HaxeTypeTagImpl extends HaxePsiCompositeElementImpl implements Haxe
}
@Override
- @Nullable
- public HaxeFunctionType getFunctionType() {
- return findChildByClass(HaxeFunctionType.class);
+ @NotNull
+ public List getFunctionTypeList() {
+ return PsiTreeUtil.getChildrenOfTypeAsList(this, HaxeFunctionType.class);
}
@Override
- @Nullable
- public HaxeTypeOrAnonymous getTypeOrAnonymous() {
- return findChildByClass(HaxeTypeOrAnonymous.class);
+ @NotNull
+ public List getTypeOrAnonymousList() {
+ return PsiTreeUtil.getChildrenOfTypeAsList(this, HaxeTypeOrAnonymous.class);
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with grammar/haxe.bnf and the Ctrl+Shift+G generation path, then compare it with the command-line scripts in the linked tivo/intellij-haxe repository. Use the generated HaxeTypeTag.java and HaxeTypeTagImpl.java diff as the observable result; done means generation consistently produces the expected singular Type accessors rather than List accessors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100