blob: 4ff9cb5574ed98f9c75b0eb2dac7381ea5bb2864 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*****************************************************************************
* Copyright (c) 2021 Christian W. Damus, CEA LIST, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christian W. Damus - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.toolsmiths.validation.architecture.internal.checkers;
import static org.eclipse.papyrus.toolsmiths.validation.architecture.constants.ArchitecturePluginValidationConstants.ARCHITECTURE_PLUGIN_VALIDATION_MARKER_TYPE;
import static org.eclipse.papyrus.toolsmiths.validation.architecture.internal.checkers.ArchitecturePluginChecker.ARCHITECTURE_EXTENSION;
import static org.eclipse.papyrus.toolsmiths.validation.common.utils.ModelResourceMapper.byExtension;
import static org.eclipse.papyrus.toolsmiths.validation.common.utils.ModelResourceMapper.resourceSets;
import static org.eclipse.papyrus.toolsmiths.validation.common.utils.ModelResourceMapper.rootsOfType;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.emf.common.util.URI;
import org.eclipse.papyrus.infra.core.architecture.ArchitectureDomain;
import org.eclipse.papyrus.infra.emf.utils.ResourceUtils;
import org.eclipse.papyrus.toolsmiths.plugin.builder.AbstractPapyrusBuilder;
import org.eclipse.papyrus.toolsmiths.plugin.builder.IPapyrusBuilderProvider;
import org.eclipse.papyrus.toolsmiths.plugin.builder.PapyrusBuilderKind;
import org.eclipse.papyrus.toolsmiths.plugin.builder.PluginCheckerBuilder;
import org.eclipse.papyrus.toolsmiths.validation.common.utils.ModelResourceMapper;
import org.osgi.service.component.annotations.Component;
import com.google.common.collect.ListMultimap;
/**
* Builder provider for <em>Architecture Domain</em> models.
*/
@Component
public class ArchitectureBuilderProvider implements IPapyrusBuilderProvider {
@Override
public String getProblemMarkerType(PapyrusBuilderKind builderKind) {
return ARCHITECTURE_PLUGIN_VALIDATION_MARKER_TYPE;
}
@Override
public boolean providesBuilder(PapyrusBuilderKind builderKind, URI resourceURI) {
return ARCHITECTURE_EXTENSION.equals(resourceURI.fileExtension());
}
@Override
public AbstractPapyrusBuilder getBuilder(PapyrusBuilderKind builderKind, IProject project) {
PluginCheckerBuilder result = new PluginCheckerBuilder(ARCHITECTURE_PLUGIN_VALIDATION_MARKER_TYPE, this::mapArchitectureResources);
switch (builderKind) {
case MODEL_RESOURCE:
result = result.withChecker(ArchitecturePluginChecker.modelValidationCheckerFactory())
.withChecker(ArchitecturePluginChecker.customModelCheckerFactory());
break;
case BUNDLE_MANIFEST:
result = result.withChecker(ArchitecturePluginChecker.buildPropertiesCheckerFactory())
.withChecker(ArchitecturePluginChecker.modelDependenciesCheckerFactory());
break;
case PLUGIN_MANIFEST:
result = result.withChecker(ArchitecturePluginChecker.extensionsCheckerFactory());
break;
}
return result;
}
private ListMultimap<IFile, ArchitectureDomain> mapArchitectureResources(IProject project) {
ModelResourceMapper<ArchitectureDomain> mapper = new ModelResourceMapper<>(project);
return mapper.map(byExtension(ARCHITECTURE_EXTENSION),
resourceSets(ResourceUtils.createWorkspaceAwarePackageRegistry()),
rootsOfType(ArchitectureDomain.class));
}
}
|