mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
[#269] Ensure no unnecessary import is generated for GrammarAccess.
- Modify the GrammarAccessFragment2 to use JavaFileAccess.DONT_IMPORT_NESTED_TYPES flag in order to avoid the generation of unnecessary import and warnings. Signed-off-by: Tamas Miklossy <miklossy@itemis.de>
This commit is contained in:
parent
59d0234347
commit
33983ec2ba
2 changed files with 6 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2016 itemis AG (http://www.itemis.eu) and others.
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
|
@ -42,6 +42,7 @@ import org.eclipse.xtext.xtext.generator.AbstractXtextGeneratorFragment
|
|||
import org.eclipse.xtext.xtext.generator.XtextGeneratorNaming
|
||||
import org.eclipse.xtext.xtext.generator.model.FileAccessFactory
|
||||
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess
|
||||
import org.eclipse.xtext.xtext.generator.model.JavaFileAccess
|
||||
import org.eclipse.xtext.xtext.generator.model.annotations.SingletonClassAnnotation
|
||||
|
||||
import static extension org.eclipse.xtext.GrammarUtil.*
|
||||
|
@ -175,6 +176,7 @@ class GrammarAccessFragment2 extends AbstractXtextGeneratorFragment {
|
|||
|
||||
protected def doGenerateGrammarAccess() {
|
||||
val javaFile = fileAccessFactory.createGeneratedJavaFile(grammar.grammarAccess)
|
||||
javaFile.importNestedTypeThreshold = JavaFileAccess.DONT_IMPORT_NESTED_TYPES
|
||||
javaFile.annotations += new SingletonClassAnnotation
|
||||
javaFile.content = '''
|
||||
public class «language.grammar.grammarAccess.simpleName» extends «AbstractGrammarElementFinder» {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2016 itemis AG (http://www.itemis.eu) and others.
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
|
@ -59,6 +59,7 @@ import org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessExtensions;
|
|||
import org.eclipse.xtext.xtext.generator.model.FileAccessFactory;
|
||||
import org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.JavaFileAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.ManifestAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
||||
import org.eclipse.xtext.xtext.generator.model.annotations.IClassAnnotation;
|
||||
|
@ -252,6 +253,7 @@ public class GrammarAccessFragment2 extends AbstractXtextGeneratorFragment {
|
|||
|
||||
protected void doGenerateGrammarAccess() {
|
||||
final GeneratedJavaFileAccess javaFile = this.fileAccessFactory.createGeneratedJavaFile(this._grammarAccessExtensions.getGrammarAccess(this.getGrammar()));
|
||||
javaFile.setImportNestedTypeThreshold(JavaFileAccess.DONT_IMPORT_NESTED_TYPES);
|
||||
List<IClassAnnotation> _annotations = javaFile.getAnnotations();
|
||||
SingletonClassAnnotation _singletonClassAnnotation = new SingletonClassAnnotation();
|
||||
_annotations.add(_singletonClassAnnotation);
|
||||
|
|
Loading…
Reference in a new issue