package jetbrains.mps.baseLanguage.pluginSolution.plugin;
/*Generated by MPS */
import jetbrains.mps.smodel.structure.Extension;
import jetbrains.mps.refactoring.participant.MoveNodeRefactoringParticipant;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import java.util.List;
import jetbrains.mps.refactoring.participant.RefactoringParticipant;
import org.jetbrains.mps.openapi.module.SRepository;
import org.jetbrains.mps.openapi.language.SReferenceLink;
import jetbrains.mps.lang.core.plugin.UpdateReferencesParticipantBase;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SConceptOperations;
public class StaticFieldRefactoringParticipant extends StaticMemberRefactoringParticipant {
public static class StaticFieldRefactoringParticipant_extension extends Extension.Default<MoveNodeRefactoringParticipant<?, ?>> {
public StaticFieldRefactoringParticipant_extension() {
super("jetbrains.mps.refactoring.participant.MoveNodeParticipantEP");
}
public MoveNodeRefactoringParticipant<?, ?> get() {
return new StaticFieldRefactoringParticipant();
}
}
public String getId() {
return "moveNode.moveStaticField";
}
public boolean isApplicable(SNode nodeToMove) {
return SNodeOperations.isInstanceOf(nodeToMove, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf93c84351fL, "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration"));
}
@Override
protected void doUpdateReference(List<RefactoringParticipant.Option> selectedOptions, SRepository repository, final SNode containingNode, final SReferenceLink role, UpdateReferencesParticipantBase.NodeData<UpdateReferencesParticipantBase.NamedNodeReference> newTarget, final String resolveInfo) {
if (!((SNodeOperations.isInstanceOf(containingNode, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c77f1e98L, "jetbrains.mps.baseLanguage.structure.VariableReference")) || SNodeOperations.isInstanceOf(containingNode, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf940c80846L, "jetbrains.mps.baseLanguage.structure.StaticFieldReference")))) || newTarget.other() == null) {
super.doUpdateReference(selectedOptions, repository, containingNode, role, newTarget, resolveInfo);
} else {
@Nullable SNode tryToResolveNewTarget = newTarget.baseData().reference().resolve(repository);
if (tryToResolveNewTarget != null && SNodeOperations.getNodeAncestor(containingNode, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101d9d3ca30L, "jetbrains.mps.baseLanguage.structure.Classifier"), false, false) == SNodeOperations.getNodeAncestor(tryToResolveNewTarget, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101d9d3ca30L, "jetbrains.mps.baseLanguage.structure.Classifier"), false, false)) {
SNode replacement = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c77f1e98L, "jetbrains.mps.baseLanguage.structure.VariableReference"));
SNodeOperations.replaceWithAnother(containingNode, replacement);
super.doUpdateReference(selectedOptions, repository, replacement, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c77f1e98L, 0xf8cc6bf960L, "variableDeclaration"), newTarget, resolveInfo);
} else {
SNode replacement = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf940c80846L, "jetbrains.mps.baseLanguage.structure.StaticFieldReference"));
SNodeOperations.replaceWithAnother(containingNode, replacement);
super.doUpdateReference(selectedOptions, repository, replacement, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c77f1e98L, 0xf8cc6bf960L, "variableDeclaration"), newTarget, resolveInfo);
super.doUpdateReference(selectedOptions, repository, replacement, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf940c80846L, 0x10a75869f9bL, "classifier"), new NodeData<UpdateReferencesParticipantBase.NamedNodeReference>(newTarget.other(), ((UpdateReferencesParticipantBase.NamedNodeReference) null)), newTarget.other().name());
}
}
}
}