public <T> T createParameters(Class<T> cls, T copyFrom) { T t = createParameters(cls); if (t != null) { ((Tuples._2) t).assign((Tuples._2) copyFrom); } return t; }
public void populate(IPropertiesPool ppool) { Tuples._2<MakeSession, Boolean> vars = (Tuples._2<MakeSession, Boolean>) ppool.properties( new ITarget.Name("jetbrains.mps.lang.core.Generate.checkParameters"), Object.class); if (vars != null) { vars._0(mySession); vars._1(myCleanMake); } if (myGenOptions != null) { Tuples._2<Boolean, GenerationOptions.OptionsBuilder> params = (Tuples._2<Boolean, GenerationOptions.OptionsBuilder>) ppool.properties( new ITarget.Name("jetbrains.mps.lang.core.Generate.configure"), Object.class); if (params != null) { params._1(myGenOptions); } } }
public List< RefactoringParticipant.Change<Tuples._2<I, SNodeReference>, Tuples._2<F, SNodeReference>>> getChanges( final Tuples._2<I, SNodeReference> initialState, SRepository repository, List<RefactoringParticipant.Option> selectedOptions, SearchScope searchScope) { if (initialState == null || !(ListSequence.fromList(selectedOptions).contains(OPTION))) { return ListSequence.fromList( new ArrayList< RefactoringParticipant.Change< Tuples._2<I, SNodeReference>, Tuples._2<F, SNodeReference>>>()); } Collection<SNode> instances = myStructureSpecialization.findInstances(initialState._0(), searchScope); return CollectionSequence.fromCollection(instances) .select( new ISelector< SNode, RefactoringParticipant.Change< Tuples._2<I, SNodeReference>, Tuples._2<F, SNodeReference>>>() { public RefactoringParticipant.Change< Tuples._2<I, SNodeReference>, Tuples._2<F, SNodeReference>> select(SNode instance) { final SNodeReference nodeRef = instance.getReference(); final SearchResults searchResults = new SearchResults(); searchResults.add(new SearchResult<SNode>(instance, "instance")); RefactoringParticipant.Change< Tuples._2<I, SNodeReference>, Tuples._2<F, SNodeReference>> change = new MoveNodeRefactoringParticipant.ChangeBase< Tuples._2<I, SNodeReference>, Tuples._2<F, SNodeReference>>() { public MoveNodeRefactoringParticipant< Tuples._2<I, SNodeReference>, Tuples._2<F, SNodeReference>> getParticipant() { return UpdateLocalInstancesParticipant.this; } public SearchResults getSearchResults() { return searchResults; } public void confirm( final Tuples._2<F, SNodeReference> finalState, final SRepository repository, final RefactoringSession refactoringSession) { refactoringSession.registerChange( new Runnable() { public void run() { SNode node = nodeRef.resolve(repository); NodeCopyTracker copyMap = NodeCopyTracker.get(refactoringSession); if (node == null || MapSequence.fromMap(copyMap.getCopyMap()) .containsKey(node)) { myStructureSpecialization.doReplaceInstance( MapSequence.fromMap(copyMap.getCopyMap()).get(node), initialState._0(), finalState._0()); } myStructureSpecialization.doReplaceInstance( node, initialState._0(), finalState._0()); } }); } }; return change; } }) .toListSequence(); }