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

Replace Guava's ImmutableMap in XtextAntlrGeneratorFragment2 #2990

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*******************************************************************************/
package org.eclipse.xtext.builder.tests.ide.contentassist.antlr;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.xtext.AbstractElement;
import org.eclipse.xtext.builder.tests.ide.contentassist.antlr.internal.InternalBuilderTestLanguageParser;
Expand All @@ -26,33 +26,33 @@ public static final class NameMappings {

@Inject
public NameMappings(BuilderTestLanguageGrammarAccess grammarAccess) {
ImmutableMap.Builder<AbstractElement, String> builder = ImmutableMap.builder();
init(builder, grammarAccess);
this.mappings = builder.build();
Map<AbstractElement, String> mappings = new HashMap<>();
init(mappings, grammarAccess);
this.mappings = Map.copyOf(mappings);
}

public String getRuleName(AbstractElement element) {
return mappings.get(element);
}

private static void init(ImmutableMap.Builder<AbstractElement, String> builder, BuilderTestLanguageGrammarAccess grammarAccess) {
builder.put(grammarAccess.getNamedElementAccess().getAlternatives(), "rule__NamedElement__Alternatives");
builder.put(grammarAccess.getNamespaceAccess().getGroup(), "rule__Namespace__Group__0");
builder.put(grammarAccess.getImportAccess().getGroup(), "rule__Import__Group__0");
builder.put(grammarAccess.getElementAccess().getGroup(), "rule__Element__Group__0");
builder.put(grammarAccess.getElementAccess().getGroup_2(), "rule__Element__Group_2__0");
builder.put(grammarAccess.getElementAccess().getGroup_3(), "rule__Element__Group_3__0");
builder.put(grammarAccess.getElementAccess().getGroup_3_2(), "rule__Element__Group_3_2__0");
builder.put(grammarAccess.getQualifiedNameAccess().getGroup(), "rule__QualifiedName__Group__0");
builder.put(grammarAccess.getQualifiedNameAccess().getGroup_1(), "rule__QualifiedName__Group_1__0");
builder.put(grammarAccess.getNamespaceAccess().getNameAssignment_1(), "rule__Namespace__NameAssignment_1");
builder.put(grammarAccess.getNamespaceAccess().getImportsAssignment_3(), "rule__Namespace__ImportsAssignment_3");
builder.put(grammarAccess.getNamespaceAccess().getElementsAssignment_4(), "rule__Namespace__ElementsAssignment_4");
builder.put(grammarAccess.getImportAccess().getImportedNamespaceAssignment_1(), "rule__Import__ImportedNamespaceAssignment_1");
builder.put(grammarAccess.getElementAccess().getNameAssignment_1(), "rule__Element__NameAssignment_1");
builder.put(grammarAccess.getElementAccess().getReferencesAssignment_2_1(), "rule__Element__ReferencesAssignment_2_1");
builder.put(grammarAccess.getElementAccess().getOtherRefsAssignment_3_1(), "rule__Element__OtherRefsAssignment_3_1");
builder.put(grammarAccess.getElementAccess().getOtherRefsAssignment_3_2_1(), "rule__Element__OtherRefsAssignment_3_2_1");
private static void init(Map<AbstractElement, String> mappings, BuilderTestLanguageGrammarAccess grammarAccess) {
mappings.put(grammarAccess.getNamedElementAccess().getAlternatives(), "rule__NamedElement__Alternatives");
mappings.put(grammarAccess.getNamespaceAccess().getGroup(), "rule__Namespace__Group__0");
mappings.put(grammarAccess.getImportAccess().getGroup(), "rule__Import__Group__0");
mappings.put(grammarAccess.getElementAccess().getGroup(), "rule__Element__Group__0");
mappings.put(grammarAccess.getElementAccess().getGroup_2(), "rule__Element__Group_2__0");
mappings.put(grammarAccess.getElementAccess().getGroup_3(), "rule__Element__Group_3__0");
mappings.put(grammarAccess.getElementAccess().getGroup_3_2(), "rule__Element__Group_3_2__0");
mappings.put(grammarAccess.getQualifiedNameAccess().getGroup(), "rule__QualifiedName__Group__0");
mappings.put(grammarAccess.getQualifiedNameAccess().getGroup_1(), "rule__QualifiedName__Group_1__0");
mappings.put(grammarAccess.getNamespaceAccess().getNameAssignment_1(), "rule__Namespace__NameAssignment_1");
mappings.put(grammarAccess.getNamespaceAccess().getImportsAssignment_3(), "rule__Namespace__ImportsAssignment_3");
mappings.put(grammarAccess.getNamespaceAccess().getElementsAssignment_4(), "rule__Namespace__ElementsAssignment_4");
mappings.put(grammarAccess.getImportAccess().getImportedNamespaceAssignment_1(), "rule__Import__ImportedNamespaceAssignment_1");
mappings.put(grammarAccess.getElementAccess().getNameAssignment_1(), "rule__Element__NameAssignment_1");
mappings.put(grammarAccess.getElementAccess().getReferencesAssignment_2_1(), "rule__Element__ReferencesAssignment_2_1");
mappings.put(grammarAccess.getElementAccess().getOtherRefsAssignment_3_1(), "rule__Element__OtherRefsAssignment_3_1");
mappings.put(grammarAccess.getElementAccess().getOtherRefsAssignment_3_2_1(), "rule__Element__OtherRefsAssignment_3_2_1");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*******************************************************************************/
package org.eclipse.xtext.common.types.xtext.ui.ide.contentassist.antlr;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.xtext.AbstractElement;
import org.eclipse.xtext.common.types.xtext.ui.ide.contentassist.antlr.internal.InternalContentAssistTestLanguageParser;
Expand All @@ -26,36 +26,36 @@ public static final class NameMappings {

@Inject
public NameMappings(ContentAssistTestLanguageGrammarAccess grammarAccess) {
ImmutableMap.Builder<AbstractElement, String> builder = ImmutableMap.builder();
init(builder, grammarAccess);
this.mappings = builder.build();
Map<AbstractElement, String> mappings = new HashMap<>();
init(mappings, grammarAccess);
this.mappings = Map.copyOf(mappings);
}

public String getRuleName(AbstractElement element) {
return mappings.get(element);
}

private static void init(ImmutableMap.Builder<AbstractElement, String> builder, ContentAssistTestLanguageGrammarAccess grammarAccess) {
builder.put(grammarAccess.getReferenceHolderAccess().getAlternatives(), "rule__ReferenceHolder__Alternatives");
builder.put(grammarAccess.getModelAccess().getGroup(), "rule__Model__Group__0");
builder.put(grammarAccess.getReferenceHolderAccess().getGroup_0(), "rule__ReferenceHolder__Group_0__0");
builder.put(grammarAccess.getReferenceHolderAccess().getGroup_1(), "rule__ReferenceHolder__Group_1__0");
builder.put(grammarAccess.getReferenceHolderAccess().getGroup_2(), "rule__ReferenceHolder__Group_2__0");
builder.put(grammarAccess.getGenerateDirectiveAccess().getGroup(), "rule__GenerateDirective__Group__0");
builder.put(grammarAccess.getImportAccess().getGroup(), "rule__Import__Group__0");
builder.put(grammarAccess.getImportedFQNAccess().getGroup(), "rule__ImportedFQN__Group__0");
builder.put(grammarAccess.getFQNAccess().getGroup(), "rule__FQN__Group__0");
builder.put(grammarAccess.getFQNAccess().getGroup_1(), "rule__FQN__Group_1__0");
builder.put(grammarAccess.getQNAccess().getGroup(), "rule__QN__Group__0");
builder.put(grammarAccess.getQNAccess().getGroup_1(), "rule__QN__Group_1__0");
builder.put(grammarAccess.getModelAccess().getImportsAssignment_0(), "rule__Model__ImportsAssignment_0");
builder.put(grammarAccess.getModelAccess().getGenerateDirectiveAssignment_1(), "rule__Model__GenerateDirectiveAssignment_1");
builder.put(grammarAccess.getModelAccess().getReferenceHolderAssignment_2(), "rule__Model__ReferenceHolderAssignment_2");
builder.put(grammarAccess.getReferenceHolderAccess().getDefaultReferenceAssignment_0_1(), "rule__ReferenceHolder__DefaultReferenceAssignment_0_1");
builder.put(grammarAccess.getReferenceHolderAccess().getCustomizedReferenceAssignment_1_1(), "rule__ReferenceHolder__CustomizedReferenceAssignment_1_1");
builder.put(grammarAccess.getReferenceHolderAccess().getSubtypeReferenceAssignment_2_1(), "rule__ReferenceHolder__SubtypeReferenceAssignment_2_1");
builder.put(grammarAccess.getGenerateDirectiveAccess().getTypeNameAssignment_1(), "rule__GenerateDirective__TypeNameAssignment_1");
builder.put(grammarAccess.getImportAccess().getImportedNamespaceAssignment_1(), "rule__Import__ImportedNamespaceAssignment_1");
private static void init(Map<AbstractElement, String> mappings, ContentAssistTestLanguageGrammarAccess grammarAccess) {
mappings.put(grammarAccess.getReferenceHolderAccess().getAlternatives(), "rule__ReferenceHolder__Alternatives");
mappings.put(grammarAccess.getModelAccess().getGroup(), "rule__Model__Group__0");
mappings.put(grammarAccess.getReferenceHolderAccess().getGroup_0(), "rule__ReferenceHolder__Group_0__0");
mappings.put(grammarAccess.getReferenceHolderAccess().getGroup_1(), "rule__ReferenceHolder__Group_1__0");
mappings.put(grammarAccess.getReferenceHolderAccess().getGroup_2(), "rule__ReferenceHolder__Group_2__0");
mappings.put(grammarAccess.getGenerateDirectiveAccess().getGroup(), "rule__GenerateDirective__Group__0");
mappings.put(grammarAccess.getImportAccess().getGroup(), "rule__Import__Group__0");
mappings.put(grammarAccess.getImportedFQNAccess().getGroup(), "rule__ImportedFQN__Group__0");
mappings.put(grammarAccess.getFQNAccess().getGroup(), "rule__FQN__Group__0");
mappings.put(grammarAccess.getFQNAccess().getGroup_1(), "rule__FQN__Group_1__0");
mappings.put(grammarAccess.getQNAccess().getGroup(), "rule__QN__Group__0");
mappings.put(grammarAccess.getQNAccess().getGroup_1(), "rule__QN__Group_1__0");
mappings.put(grammarAccess.getModelAccess().getImportsAssignment_0(), "rule__Model__ImportsAssignment_0");
mappings.put(grammarAccess.getModelAccess().getGenerateDirectiveAssignment_1(), "rule__Model__GenerateDirectiveAssignment_1");
mappings.put(grammarAccess.getModelAccess().getReferenceHolderAssignment_2(), "rule__Model__ReferenceHolderAssignment_2");
mappings.put(grammarAccess.getReferenceHolderAccess().getDefaultReferenceAssignment_0_1(), "rule__ReferenceHolder__DefaultReferenceAssignment_0_1");
mappings.put(grammarAccess.getReferenceHolderAccess().getCustomizedReferenceAssignment_1_1(), "rule__ReferenceHolder__CustomizedReferenceAssignment_1_1");
mappings.put(grammarAccess.getReferenceHolderAccess().getSubtypeReferenceAssignment_2_1(), "rule__ReferenceHolder__SubtypeReferenceAssignment_2_1");
mappings.put(grammarAccess.getGenerateDirectiveAccess().getTypeNameAssignment_1(), "rule__GenerateDirective__TypeNameAssignment_1");
mappings.put(grammarAccess.getImportAccess().getImportedNamespaceAssignment_1(), "rule__Import__ImportedNamespaceAssignment_1");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*******************************************************************************/
package org.eclipse.xtext.common.types.xtext.ui.ide.contentassist.antlr;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.xtext.AbstractElement;
import org.eclipse.xtext.common.types.xtext.ui.ide.contentassist.antlr.internal.InternalRefactoringTestLanguage1Parser;
Expand All @@ -26,23 +26,23 @@ public static final class NameMappings {

@Inject
public NameMappings(RefactoringTestLanguage1GrammarAccess grammarAccess) {
ImmutableMap.Builder<AbstractElement, String> builder = ImmutableMap.builder();
init(builder, grammarAccess);
this.mappings = builder.build();
Map<AbstractElement, String> mappings = new HashMap<>();
init(mappings, grammarAccess);
this.mappings = Map.copyOf(mappings);
}

public String getRuleName(AbstractElement element) {
return mappings.get(element);
}

private static void init(ImmutableMap.Builder<AbstractElement, String> builder, RefactoringTestLanguage1GrammarAccess grammarAccess) {
builder.put(grammarAccess.getReferenceHolderAccess().getGroup(), "rule__ReferenceHolder__Group__0");
builder.put(grammarAccess.getFQNAccess().getGroup(), "rule__FQN__Group__0");
builder.put(grammarAccess.getFQNAccess().getGroup_1(), "rule__FQN__Group_1__0");
builder.put(grammarAccess.getFQNAccess().getGroup_2(), "rule__FQN__Group_2__0");
builder.put(grammarAccess.getModelAccess().getReferenceHolderAssignment(), "rule__Model__ReferenceHolderAssignment");
builder.put(grammarAccess.getReferenceHolderAccess().getNameAssignment_0(), "rule__ReferenceHolder__NameAssignment_0");
builder.put(grammarAccess.getReferenceHolderAccess().getDefaultReferenceAssignment_1(), "rule__ReferenceHolder__DefaultReferenceAssignment_1");
private static void init(Map<AbstractElement, String> mappings, RefactoringTestLanguage1GrammarAccess grammarAccess) {
mappings.put(grammarAccess.getReferenceHolderAccess().getGroup(), "rule__ReferenceHolder__Group__0");
mappings.put(grammarAccess.getFQNAccess().getGroup(), "rule__FQN__Group__0");
mappings.put(grammarAccess.getFQNAccess().getGroup_1(), "rule__FQN__Group_1__0");
mappings.put(grammarAccess.getFQNAccess().getGroup_2(), "rule__FQN__Group_2__0");
mappings.put(grammarAccess.getModelAccess().getReferenceHolderAssignment(), "rule__Model__ReferenceHolderAssignment");
mappings.put(grammarAccess.getReferenceHolderAccess().getNameAssignment_0(), "rule__ReferenceHolder__NameAssignment_0");
mappings.put(grammarAccess.getReferenceHolderAccess().getDefaultReferenceAssignment_1(), "rule__ReferenceHolder__DefaultReferenceAssignment_1");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*******************************************************************************/
package org.eclipse.xtext.common.types.xtext.ui.ide.contentassist.antlr;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.xtext.AbstractElement;
import org.eclipse.xtext.common.types.xtext.ui.ide.contentassist.antlr.internal.InternalRefactoringTestLanguage2Parser;
Expand All @@ -26,23 +26,23 @@ public static final class NameMappings {

@Inject
public NameMappings(RefactoringTestLanguage2GrammarAccess grammarAccess) {
ImmutableMap.Builder<AbstractElement, String> builder = ImmutableMap.builder();
init(builder, grammarAccess);
this.mappings = builder.build();
Map<AbstractElement, String> mappings = new HashMap<>();
init(mappings, grammarAccess);
this.mappings = Map.copyOf(mappings);
}

public String getRuleName(AbstractElement element) {
return mappings.get(element);
}

private static void init(ImmutableMap.Builder<AbstractElement, String> builder, RefactoringTestLanguage2GrammarAccess grammarAccess) {
builder.put(grammarAccess.getReferenceHolderAccess().getGroup(), "rule__ReferenceHolder__Group__0");
builder.put(grammarAccess.getFQNAccess().getGroup(), "rule__FQN__Group__0");
builder.put(grammarAccess.getFQNAccess().getGroup_1(), "rule__FQN__Group_1__0");
builder.put(grammarAccess.getFQNAccess().getGroup_2(), "rule__FQN__Group_2__0");
builder.put(grammarAccess.getModelAccess().getReferenceHolderAssignment(), "rule__Model__ReferenceHolderAssignment");
builder.put(grammarAccess.getReferenceHolderAccess().getNameAssignment_0(), "rule__ReferenceHolder__NameAssignment_0");
builder.put(grammarAccess.getReferenceHolderAccess().getDefaultReferenceAssignment_1(), "rule__ReferenceHolder__DefaultReferenceAssignment_1");
private static void init(Map<AbstractElement, String> mappings, RefactoringTestLanguage2GrammarAccess grammarAccess) {
mappings.put(grammarAccess.getReferenceHolderAccess().getGroup(), "rule__ReferenceHolder__Group__0");
mappings.put(grammarAccess.getFQNAccess().getGroup(), "rule__FQN__Group__0");
mappings.put(grammarAccess.getFQNAccess().getGroup_1(), "rule__FQN__Group_1__0");
mappings.put(grammarAccess.getFQNAccess().getGroup_2(), "rule__FQN__Group_2__0");
mappings.put(grammarAccess.getModelAccess().getReferenceHolderAssignment(), "rule__Model__ReferenceHolderAssignment");
mappings.put(grammarAccess.getReferenceHolderAccess().getNameAssignment_0(), "rule__ReferenceHolder__NameAssignment_0");
mappings.put(grammarAccess.getReferenceHolderAccess().getDefaultReferenceAssignment_1(), "rule__ReferenceHolder__DefaultReferenceAssignment_1");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*******************************************************************************/
package org.eclipse.xtext.common.types.xtext.ui.ide.contentassist.antlr;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.xtext.AbstractElement;
import org.eclipse.xtext.common.types.xtext.ui.ide.contentassist.antlr.internal.InternalRefactoringTestLanguageParser;
Expand All @@ -26,23 +26,23 @@ public static final class NameMappings {

@Inject
public NameMappings(RefactoringTestLanguageGrammarAccess grammarAccess) {
ImmutableMap.Builder<AbstractElement, String> builder = ImmutableMap.builder();
init(builder, grammarAccess);
this.mappings = builder.build();
Map<AbstractElement, String> mappings = new HashMap<>();
init(mappings, grammarAccess);
this.mappings = Map.copyOf(mappings);
}

public String getRuleName(AbstractElement element) {
return mappings.get(element);
}

private static void init(ImmutableMap.Builder<AbstractElement, String> builder, RefactoringTestLanguageGrammarAccess grammarAccess) {
builder.put(grammarAccess.getReferenceHolderAccess().getGroup(), "rule__ReferenceHolder__Group__0");
builder.put(grammarAccess.getFQNAccess().getGroup(), "rule__FQN__Group__0");
builder.put(grammarAccess.getFQNAccess().getGroup_1(), "rule__FQN__Group_1__0");
builder.put(grammarAccess.getFQNAccess().getGroup_2(), "rule__FQN__Group_2__0");
builder.put(grammarAccess.getModelAccess().getReferenceHolderAssignment(), "rule__Model__ReferenceHolderAssignment");
builder.put(grammarAccess.getReferenceHolderAccess().getNameAssignment_0(), "rule__ReferenceHolder__NameAssignment_0");
builder.put(grammarAccess.getReferenceHolderAccess().getDefaultReferenceAssignment_1(), "rule__ReferenceHolder__DefaultReferenceAssignment_1");
private static void init(Map<AbstractElement, String> mappings, RefactoringTestLanguageGrammarAccess grammarAccess) {
mappings.put(grammarAccess.getReferenceHolderAccess().getGroup(), "rule__ReferenceHolder__Group__0");
mappings.put(grammarAccess.getFQNAccess().getGroup(), "rule__FQN__Group__0");
mappings.put(grammarAccess.getFQNAccess().getGroup_1(), "rule__FQN__Group_1__0");
mappings.put(grammarAccess.getFQNAccess().getGroup_2(), "rule__FQN__Group_2__0");
mappings.put(grammarAccess.getModelAccess().getReferenceHolderAssignment(), "rule__Model__ReferenceHolderAssignment");
mappings.put(grammarAccess.getReferenceHolderAccess().getNameAssignment_0(), "rule__ReferenceHolder__NameAssignment_0");
mappings.put(grammarAccess.getReferenceHolderAccess().getDefaultReferenceAssignment_1(), "rule__ReferenceHolder__DefaultReferenceAssignment_1");
}
}

Expand Down
Loading
Loading