aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/language/src/main/java/tools/refinery/language/serializer/ProblemTransientValueService.java
blob: 269e12435b0af000d1c065d12f15e934f417f418 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * SPDX-FileCopyrightText: 2024 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.language.serializer;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.xtext.parsetree.reconstr.impl.DefaultTransientValueService;
import tools.refinery.language.model.problem.Problem;
import tools.refinery.language.model.problem.ProblemPackage;
import tools.refinery.language.utils.ProblemUtil;

public class ProblemTransientValueService extends DefaultTransientValueService {
	@Override
	public boolean isTransient(EObject owner, EStructuralFeature feature, int index) {
		if (owner instanceof Problem problem && feature == ProblemPackage.Literals.PROBLEM__KIND) {
			return problem.getName() == null && problem.getKind() == ProblemUtil.getDefaultModuleKind(problem) &&
					!problem.isExplicitKind();
		}
		return super.isTransient(owner, feature, index);
	}
}