diff --git a/.gitignore b/.gitignore index d3f04a5e4c..b63096a951 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,6 @@ dependency-reduced-pom.xml # Built libraries *.kpar + +# Sysand JAR +org.omg.sysml.xtext/lib/sysand.jar diff --git a/org.omg.kerml.xtext/src/org/omg/kerml/xtext/util/KerMLIndexUtil.java b/org.omg.kerml.xtext/src/org/omg/kerml/xtext/util/KerMLIndexUtil.java new file mode 100644 index 0000000000..4102b568c2 --- /dev/null +++ b/org.omg.kerml.xtext/src/org/omg/kerml/xtext/util/KerMLIndexUtil.java @@ -0,0 +1,106 @@ +/******************************************************************************* + * 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 . + * + * @license LGPL-3.0-or-later + * + *******************************************************************************/ + +package org.omg.kerml.xtext.util; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.ecore.resource.Resource; +import org.omg.kerml.xtext.KerMLStandaloneSetup; +import org.omg.sysml.lang.sysml.Membership; +import org.omg.sysml.lang.sysml.Namespace; +import org.omg.sysml.util.SysMLUtil; + +public class KerMLIndexUtil extends SysMLUtil { + + public KerMLIndexUtil() { + super(); + KerMLStandaloneSetup.doSetup(); + addExtension(".kerml"); + } + + protected static String formatEntry(String elementName, String resourcePath) { + return " \"" + elementName + "\": \"" + resourcePath + "\""; + } + + public String index(String inputPath) { + java.util.LinkedHashMap map = indexAsMap(inputPath); + List entries = new ArrayList<>(); + for (var entry : map.entrySet()) { + entries.add(formatEntry(entry.getKey(), entry.getValue())); + } + return String.join("\n", entries); + } + + public java.util.LinkedHashMap indexAsMap(String inputPath) { + read(inputPath); + File inputFile = new File(inputPath); + String inputDir = inputPath; + if (!inputFile.isDirectory()) { + inputDir = inputFile.getParent(); + if (inputDir == null) inputDir = ""; + } + java.util.TreeMap sorted = new java.util.TreeMap<>(); + for (Resource resource : getInputResources()) { + String resourcePath = resource.getURI().toFileString().replace(inputDir + "/", ""); + Namespace rootNamespace = (Namespace) resource.getContents().get(0); + List memberships = rootNamespace.visibleMemberships(new BasicEList<>(), false, false); + for (Membership m : memberships) { + if (m.getMemberName() != null) sorted.put(m.getMemberName(), resourcePath); + if (m.getMemberShortName() != null) sorted.put(m.getMemberShortName(), resourcePath); + } + } + return new java.util.LinkedHashMap<>(sorted); + } + + public void writeIndex(String inputPath, String outputPath) throws IOException { + String index = index(inputPath); + System.out.println("Writing " + outputPath + "..."); + Files.writeString(Path.of(outputPath), index); + } + + /** + *

Usage: + * + *

KerMLIndexUtil input-path output-path + * + *

where: + * + *

    + *
  • input-path is a path for reading input resources (file or directory)
  • + *
  • output-path is a path for an output file
  • + *
+ */ + public static void main(String[] args) { + try { + new KerMLIndexUtil().writeIndex(args[0], args[1]); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/org.omg.sysml.interactive/pom.xml b/org.omg.sysml.interactive/pom.xml index 9d02d7a425..85ec20e88d 100644 --- a/org.omg.sysml.interactive/pom.xml +++ b/org.omg.sysml.interactive/pom.xml @@ -96,6 +96,12 @@ exec-maven-plugin ${exec-maven-plugin.version} + + + sysand-index + none + package diff --git a/org.omg.sysml.xtext/.classpath b/org.omg.sysml.xtext/.classpath index 5a652ad974..36359f1f1b 100644 --- a/org.omg.sysml.xtext/.classpath +++ b/org.omg.sysml.xtext/.classpath @@ -8,6 +8,7 @@ + diff --git a/org.omg.sysml.xtext/.project b/org.omg.sysml.xtext/.project index d817e75768..cf1aabed07 100644 --- a/org.omg.sysml.xtext/.project +++ b/org.omg.sysml.xtext/.project @@ -25,8 +25,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.xtext.ui.shared.xtextNature org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature diff --git a/org.omg.sysml.xtext/.settings/org.eclipse.m2e.core.prefs b/org.omg.sysml.xtext/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000000..f897a7f1cb --- /dev/null +++ b/org.omg.sysml.xtext/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/org.omg.sysml.xtext/META-INF/MANIFEST.MF b/org.omg.sysml.xtext/META-INF/MANIFEST.MF index 7d2a344b7b..306e1fb80d 100644 --- a/org.omg.sysml.xtext/META-INF/MANIFEST.MF +++ b/org.omg.sysml.xtext/META-INF/MANIFEST.MF @@ -7,6 +7,8 @@ Bundle-Vendor: SysML v2 Submission Team Bundle-Version: 0.59.0.qualifier Bundle-SymbolicName: org.omg.sysml.xtext; singleton:=true Bundle-ActivationPolicy: lazy +Bundle-ClassPath: ., + lib/sysand.jar Require-Bundle: org.eclipse.xtext, org.eclipse.xtext.xbase, org.eclipse.equinox.common;bundle-version="3.5.0", diff --git a/org.omg.sysml.xtext/build.properties b/org.omg.sysml.xtext/build.properties index 0bcbfe4fbe..abbd8af676 100644 --- a/org.omg.sysml.xtext/build.properties +++ b/org.omg.sysml.xtext/build.properties @@ -2,7 +2,8 @@ source.. = src/,\ src-gen/,\ xtend-gen/ bin.includes = .,\ - META-INF/ + META-INF/,\ + lib/ bin.excludes = **/*.mwe2,\ **/*.xtend additional.bundles = org.eclipse.xtext.xbase,\ diff --git a/org.omg.sysml.xtext/pom.xml b/org.omg.sysml.xtext/pom.xml index 8808de0dbf..f11b058762 100644 --- a/org.omg.sysml.xtext/pom.xml +++ b/org.omg.sysml.xtext/pom.xml @@ -13,6 +13,14 @@ org.omg.sysml.xtext eclipse-plugin + + + com.sensmetry + sysand + ${sysand.version} + + + @@ -25,6 +33,34 @@ + + maven-dependency-plugin + + + copy-sysand + generate-resources + + copy + + + + + com.sensmetry + sysand + ${sysand.version} + + ${project.basedir}/lib + sysand.jar + + + + + + + + org.codehaus.mojo + exec-maven-plugin + org.eclipse.xtend xtend-maven-plugin diff --git a/org.omg.sysml.xtext/src/org/omg/sysml/xtext/util/SysMLIndexUtil.java b/org.omg.sysml.xtext/src/org/omg/sysml/xtext/util/SysMLIndexUtil.java new file mode 100644 index 0000000000..3b29122820 --- /dev/null +++ b/org.omg.sysml.xtext/src/org/omg/sysml/xtext/util/SysMLIndexUtil.java @@ -0,0 +1,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 . + * + * @license 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 index = util.indexAsMap(projectPath); + com.sensmetry.sysand.Sysand.setProjectIndex( + java.nio.file.Paths.get(projectPath), index); + System.out.println(" Updated " + index.size() + " index entries"); + } + } + + /** + *

Usage: + * + *

Workspace mode: SysMLIndexUtil workspace-path + *

Single-file mode: SysMLIndexUtil input-path output-path + * + *

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); + } + } + +} diff --git a/pom.xml b/pom.xml index e6d467e4d8..dbd769d4eb 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 3.5.3 3.2.0 2.3.19 - 0.0.6 + 0.0.11 4.0.0 @@ -298,7 +298,7 @@ com.sensmetry sysand-maven-plugin - ${sysand-maven-plugin.version} + ${sysand.version} @@ -329,14 +329,14 @@ xtend-gen - @@ -356,6 +356,27 @@ true + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + + sysand-index + prepare-package + + java + + + org.omg.sysml.xtext.util.SysMLIndexUtil + + ${maven.multiModuleProjectDirectory}/sysml.library + + compile + + + + org.apache.maven.plugins maven-clean-plugin @@ -377,6 +398,34 @@ + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [1.0,) + + copy + + + + + false + + + + + + + diff --git a/sysml.library/Domain Libraries/Analysis/.meta.json b/sysml.library/Domain Libraries/Analysis/.meta.json index c3172ae072..c3e575cd35 100644 --- a/sysml.library/Domain Libraries/Analysis/.meta.json +++ b/sysml.library/Domain Libraries/Analysis/.meta.json @@ -7,4 +7,4 @@ }, "created": "2025-03-13T00:00:00Z", "metamodel": "https://www.omg.org/spec/SysML/20250201" -} \ No newline at end of file +} diff --git a/sysml.library/Domain Libraries/Cause and Effect/.meta.json b/sysml.library/Domain Libraries/Cause and Effect/.meta.json index 1f04aee4c2..e65446b3a6 100644 --- a/sysml.library/Domain Libraries/Cause and Effect/.meta.json +++ b/sysml.library/Domain Libraries/Cause and Effect/.meta.json @@ -5,4 +5,4 @@ }, "created": "2025-03-13T00:00:00Z", "metamodel": "https://www.omg.org/spec/SysML/20250201" -} \ No newline at end of file +} diff --git a/sysml.library/Domain Libraries/Geometry/.meta.json b/sysml.library/Domain Libraries/Geometry/.meta.json index 273413c06f..afe0509878 100644 --- a/sysml.library/Domain Libraries/Geometry/.meta.json +++ b/sysml.library/Domain Libraries/Geometry/.meta.json @@ -5,4 +5,4 @@ }, "created": "2025-03-13T00:00:00Z", "metamodel": "https://www.omg.org/spec/SysML/20250201" -} \ No newline at end of file +} diff --git a/sysml.library/Domain Libraries/Metadata/.meta.json b/sysml.library/Domain Libraries/Metadata/.meta.json index d77df66cfc..27df7d24bd 100644 --- a/sysml.library/Domain Libraries/Metadata/.meta.json +++ b/sysml.library/Domain Libraries/Metadata/.meta.json @@ -7,4 +7,4 @@ }, "created": "2025-03-13T00:00:00Z", "metamodel": "https://www.omg.org/spec/SysML/20250201" -} \ No newline at end of file +} diff --git a/sysml.library/Domain Libraries/Quantities and Units/.meta.json b/sysml.library/Domain Libraries/Quantities and Units/.meta.json index 51a21dc43d..21e0278f3b 100644 --- a/sysml.library/Domain Libraries/Quantities and Units/.meta.json +++ b/sysml.library/Domain Libraries/Quantities and Units/.meta.json @@ -21,9 +21,10 @@ "SIPrefixes": "SIPrefixes.sysml", "TensorCalculations": "TensorCalculations.sysml", "Time": "Time.sysml", + "USCU": "USCustomaryUnits.sysml", "USCustomaryUnits": "USCustomaryUnits.sysml", "VectorCalculations": "VectorCalculations.sysml" }, "created": "2025-03-13T00:00:00Z", "metamodel": "https://www.omg.org/spec/SysML/20250201" -} \ No newline at end of file +} diff --git a/sysml.library/Domain Libraries/Requirement Derivation/.meta.json b/sysml.library/Domain Libraries/Requirement Derivation/.meta.json index 54b3311d22..bd80a7df84 100644 --- a/sysml.library/Domain Libraries/Requirement Derivation/.meta.json +++ b/sysml.library/Domain Libraries/Requirement Derivation/.meta.json @@ -5,4 +5,4 @@ }, "created": "2025-03-13T00:00:00Z", "metamodel": "https://www.omg.org/spec/SysML/20250201" -} \ No newline at end of file +} diff --git a/sysml.library/Kernel Libraries/Kernel Data Type Library/.meta.json b/sysml.library/Kernel Libraries/Kernel Data Type Library/.meta.json index ce884075ae..98d293b8fe 100644 --- a/sysml.library/Kernel Libraries/Kernel Data Type Library/.meta.json +++ b/sysml.library/Kernel Libraries/Kernel Data Type Library/.meta.json @@ -6,4 +6,4 @@ }, "created": "2025-03-13T00:00:00Z", "metamodel": "https://www.omg.org/spec/KerML/20250201" -} \ No newline at end of file +} diff --git a/sysml.library/Kernel Libraries/Kernel Function Library/.meta.json b/sysml.library/Kernel Libraries/Kernel Function Library/.meta.json index 72ac7e62a5..93167e0ec7 100644 --- a/sysml.library/Kernel Libraries/Kernel Function Library/.meta.json +++ b/sysml.library/Kernel Libraries/Kernel Function Library/.meta.json @@ -20,4 +20,4 @@ }, "created": "2025-03-13T00:00:00Z", "metamodel": "https://www.omg.org/spec/KerML/20250201" -} \ No newline at end of file +} diff --git a/sysml.library/Kernel Libraries/Kernel Semantic Library/.meta.json b/sysml.library/Kernel Libraries/Kernel Semantic Library/.meta.json index 3a2662377b..9043e8eae4 100644 --- a/sysml.library/Kernel Libraries/Kernel Semantic Library/.meta.json +++ b/sysml.library/Kernel Libraries/Kernel Semantic Library/.meta.json @@ -19,4 +19,4 @@ }, "created": "2025-03-13T00:00:00Z", "metamodel": "https://www.omg.org/spec/KerML/20250201" -} \ No newline at end of file +} diff --git a/sysml.library/Systems Library/.meta.json b/sysml.library/Systems Library/.meta.json index d670a67301..d19381e0bc 100644 --- a/sysml.library/Systems Library/.meta.json +++ b/sysml.library/Systems Library/.meta.json @@ -24,4 +24,4 @@ }, "created": "2025-03-13T00:00:00Z", "metamodel": "https://www.omg.org/spec/SysML/20250201" -} \ No newline at end of file +}