-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathSysMLIndexUtil.java
More file actions
76 lines (69 loc) · 2.72 KB
/
SysMLIndexUtil.java
File metadata and controls
76 lines (69 loc) · 2.72 KB
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
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2026 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
*******************************************************************************/
package org.omg.sysml.xtext.util;
import org.omg.kerml.xtext.util.KerMLIndexUtil;
import org.omg.sysml.xtext.SysMLStandaloneSetup;
public class SysMLIndexUtil extends KerMLIndexUtil {
public SysMLIndexUtil() {
super();
SysMLStandaloneSetup.doSetup();
addExtension(".sysml");
}
/**
* Index all projects in a sysand workspace. For each project, parses SysML/KerML
* files, computes symbol-to-file index, and updates the project's {@code .meta.json}.
*
* @param workspacePath path to the workspace directory containing {@code .workspace.json}
*/
public void indexWorkspace(String workspacePath) throws com.sensmetry.sysand.exceptions.SysandException {
String[] projectPaths = com.sensmetry.sysand.Sysand.workspaceProjectPaths(
java.nio.file.Paths.get(workspacePath));
for (String projectPath : projectPaths) {
System.out.println("Indexing project: " + projectPath);
SysMLIndexUtil util = new SysMLIndexUtil();
java.util.LinkedHashMap<String, String> index = util.indexAsMap(projectPath);
com.sensmetry.sysand.Sysand.setProjectIndex(
java.nio.file.Paths.get(projectPath), index);
System.out.println(" Updated " + index.size() + " index entries");
}
}
/**
* <p>Usage:
*
* <p>Workspace mode: SysMLIndexUtil workspace-path
* <p>Single-file mode: SysMLIndexUtil input-path output-path
*
* <p>Workspace mode is detected when the first argument is a directory
* containing {@code .workspace.json}.
*/
public static void main(String[] args) {
try {
if (new java.io.File(args[0], ".workspace.json").exists()) {
new SysMLIndexUtil().indexWorkspace(args[0]);
} else {
new SysMLIndexUtil().writeIndex(args[0], args[1]);
}
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}