[jira] [Commented] (GROOVY-9577) Order of ModuleNode#getImports() is expected but not guaranteed
[ https://issues.apache.org/jira/browse/GROOVY-9577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17119640#comment-17119640 ] Eric Milles commented on GROOVY-9577: - Yes, code editor needs the duplicates to generate warnings and correctly provide for de-duplication. > Order of ModuleNode#getImports() is expected but not guaranteed > --- > > Key: GROOVY-9577 > URL: https://issues.apache.org/jira/browse/GROOVY-9577 > Project: Groovy > Issue Type: Bug > Components: ast builder >Affects Versions: 3.0.4 >Reporter: Damir Murat >Assignee: Eric Milles >Priority: Major > > One of last statements in AstBuilder.visitImportDeclaration() are > {code:java} > moduleNode.addImport(alias, classNode, annotationNodeList); > importNode = last(moduleNode.getImports()); > {code} > Since ModuleNode.imports is a HashMap, last() method return unpredictable > result. > I guess this can be fixed by changing the implementation of > ModuleNode.imports into LinkedHashMap instead of HashMap as is currently. > I stumbled on this while trying to use CodeNarc with the latest Groovy. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9577) Order of ModuleNode#getImports() is expected but not guaranteed
[ https://issues.apache.org/jira/browse/GROOVY-9577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17119608#comment-17119608 ] Damir Murat commented on GROOVY-9577: - If of any help, here is related CodeNarc issue: [https://github.com/CodeNarc/CodeNarc/issues/506] > Order of ModuleNode#getImports() is expected but not guaranteed > --- > > Key: GROOVY-9577 > URL: https://issues.apache.org/jira/browse/GROOVY-9577 > Project: Groovy > Issue Type: Bug > Components: ast builder >Affects Versions: 3.0.4 >Reporter: Damir Murat >Assignee: Eric Milles >Priority: Major > > One of last statements in AstBuilder.visitImportDeclaration() are > {code:java} > moduleNode.addImport(alias, classNode, annotationNodeList); > importNode = last(moduleNode.getImports()); > {code} > Since ModuleNode.imports is a HashMap, last() method return unpredictable > result. > I guess this can be fixed by changing the implementation of > ModuleNode.imports into LinkedHashMap instead of HashMap as is currently. > I stumbled on this while trying to use CodeNarc with the latest Groovy. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9577) Order of ModuleNode#getImports() is expected but not guaranteed
[ https://issues.apache.org/jira/browse/GROOVY-9577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17119496#comment-17119496 ] Paul King commented on GROOVY-9577: --- At first glance I would say +1 for LinkedHashMap but that wouldn't cater for duplicates. The duplicated imports part wouldn't necessarily be relevant to Groovy but needed if you wanted a codenarc rule to check for duplicates? Would also be useful for Eclipse I guess and then there'd be no need for the raw imports? > Order of ModuleNode#getImports() is expected but not guaranteed > --- > > Key: GROOVY-9577 > URL: https://issues.apache.org/jira/browse/GROOVY-9577 > Project: Groovy > Issue Type: Bug > Components: ast builder >Affects Versions: 3.0.4 >Reporter: Damir Murat >Assignee: Eric Milles >Priority: Major > > One of last statements in AstBuilder.visitImportDeclaration() are > {code:java} > moduleNode.addImport(alias, classNode, annotationNodeList); > importNode = last(moduleNode.getImports()); > {code} > Since ModuleNode.imports is a HashMap, last() method return unpredictable > result. > I guess this can be fixed by changing the implementation of > ModuleNode.imports into LinkedHashMap instead of HashMap as is currently. > I stumbled on this while trying to use CodeNarc with the latest Groovy. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (GROOVY-9577) Order of ModuleNode#getImports() is expected but not guaranteed
[ https://issues.apache.org/jira/browse/GROOVY-9577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17119497#comment-17119497 ] Paul King commented on GROOVY-9577: --- At first glance I would say +1 for LinkedHashMap but that wouldn't cater for duplicates. The duplicated imports part wouldn't necessarily be relevant to Groovy but needed if you wanted a codenarc rule to check for duplicates? Would also be useful for Eclipse I guess and then there'd be no need for the raw imports? > Order of ModuleNode#getImports() is expected but not guaranteed > --- > > Key: GROOVY-9577 > URL: https://issues.apache.org/jira/browse/GROOVY-9577 > Project: Groovy > Issue Type: Bug > Components: ast builder >Affects Versions: 3.0.4 >Reporter: Damir Murat >Assignee: Eric Milles >Priority: Major > > One of last statements in AstBuilder.visitImportDeclaration() are > {code:java} > moduleNode.addImport(alias, classNode, annotationNodeList); > importNode = last(moduleNode.getImports()); > {code} > Since ModuleNode.imports is a HashMap, last() method return unpredictable > result. > I guess this can be fixed by changing the implementation of > ModuleNode.imports into LinkedHashMap instead of HashMap as is currently. > I stumbled on this while trying to use CodeNarc with the latest Groovy. -- This message was sent by Atlassian Jira (v8.3.4#803005)