Skip to content

Commit

Permalink
push the minor version to 2.7.0:
Browse files Browse the repository at this point in the history
- OML ids can now have characters % and ~ as well
- OML formatter now indents strings on 2nd of higher lines
- Better exception handling in OmlBuilder
  • Loading branch information
melaasar committed Apr 25, 2024
1 parent 6f911bf commit 87076aa
Show file tree
Hide file tree
Showing 34 changed files with 79 additions and 71 deletions.
2 changes: 1 addition & 1 deletion io.opencaesar.oml.api.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="io.opencaesar.oml.api.feature"
label="%featureName"
version="2.6.0"
version="2.7.0"
provider-name="%providerName">

<description>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.api.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml.api.feature</artifactId>
<packaging>eclipse-feature</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.dsl.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="io.opencaesar.oml.dsl.feature"
label="%featureName"
version="2.6.0"
version="2.7.0"
provider-name="%providerName">

<description>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.dsl.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml.dsl.feature</artifactId>
<packaging>eclipse-feature</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.dsl.ide/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Automatic-Module-Name: io.opencaesar.oml.dsl.ide
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Version: 2.6.0
Bundle-Version: 2.7.0
Bundle-SymbolicName: io.opencaesar.oml.dsl.ide; singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.dsl.ide/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml.dsl.ide</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.dsl.ui.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Automatic-Module-Name: io.opencaesar.oml.dsl.ui.tests
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Version: 2.6.0
Bundle-Version: 2.7.0
Bundle-SymbolicName: io.opencaesar.oml.dsl.ui.tests; singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.dsl.ui.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml.dsl.ui.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.dsl.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Automatic-Module-Name: io.opencaesar.oml.dsl.ui
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Version: 2.6.0
Bundle-Version: 2.7.0
Bundle-SymbolicName: io.opencaesar.oml.dsl.ui; singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.dsl.ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml.dsl.ui</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.dsl/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Automatic-Module-Name: io.opencaesar.oml.dsl
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Version: 2.6.0
Bundle-Version: 2.7.0
Bundle-SymbolicName: io.opencaesar.oml.dsl; singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.dsl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml.dsl</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
14 changes: 8 additions & 6 deletions io.opencaesar.oml.dsl/src/io/opencaesar/oml/dsl/Oml.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,13 @@ Double returns Double: DOUBLE_STR;

terminal BOOLEAN_STR: 'false'|'true';

terminal UNSIGNED_INTEGER_STR: DIGIT+;
terminal UNSIGNED_INTEGER_STR: NUMERIC+;

terminal INTEGER_STR: ('+'|'-')? DIGIT+;
terminal INTEGER_STR: ('+'|'-')? NUMERIC+;

terminal DECIMAL_STR: ('+'|'-')? (DIGIT+('.'DIGIT*)? | ('.'DIGIT+));
terminal DECIMAL_STR: ('+'|'-')? (NUMERIC+('.'NUMERIC*)? | ('.'NUMERIC+));

terminal DOUBLE_STR: ('+'|'-')? (DIGIT+('.'DIGIT*)? | ('.'DIGIT+)) ('e'|'E') ('+'|'-')? DIGIT+;
terminal DOUBLE_STR: ('+'|'-')? (NUMERIC+('.'NUMERIC*)? | ('.'NUMERIC+)) ('e'|'E') ('+'|'-')? NUMERIC+;

terminal STRING: ('"' (!('"'|'\\') | '\\'.)* '"') | ("'" (!("'"|'\\') | '\\'.)* "'") | ("'''" -> "'''") | '"""' -> '"""';

Expand All @@ -441,8 +441,10 @@ terminal WS: (' '|'\t'|'\r'|'\n')+;

//----------------------------

terminal fragment IDFRAG: '^'? (ALPHA|DIGIT|'_') (ALPHA|DIGIT|'_'|'-'|'.'|'$')*;
terminal fragment IDFRAG: '^'? (ALPHA|NUMERIC|SPECIAL) (ALPHA|NUMERIC|SPECIAL|'$')*;

terminal fragment ALPHA: 'a'..'z'| 'A'..'Z';

terminal fragment DIGIT: '0'..'9';
terminal fragment NUMERIC: '0'..'9';

terminal fragment SPECIAL: '_'|'-'|'.'|'~'|'%';
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ protected String toEscapedString(final String value) {

@Override
public String toValue(final String string, final INode node) {
if (string.contains("\"\"\"")) {
return string.replaceAll("\"\"\"", "");
} else if (string.contains("'''")) {
return string.replaceAll("'''", "");
if (string.startsWith("\"\"\"") && string.endsWith("\"\"\"")) {
return string.substring(3, string.length()-3);
} else if (string.startsWith("'''") && string.endsWith("'''")) {
return string.substring(3, string.length()-3);
}
return string.substring(1, string.length() - 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.eclipse.xtext.formatting2.FormatterRequest;
import org.eclipse.xtext.formatting2.IFormattableDocument;
import org.eclipse.xtext.formatting2.IHiddenRegionFormatter;
import org.eclipse.xtext.formatting2.ITextReplacerContext;
import org.eclipse.xtext.formatting2.internal.AbstractTextReplacer;
import org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion;
import org.eclipse.xtext.preferences.MapBasedPreferenceValues;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
Expand Down Expand Up @@ -515,41 +517,36 @@ protected void _format(BuiltInPredicate predicate, IFormattableDocument doc) {
protected void _format(QuotedLiteral literal, IFormattableDocument doc) {
doc.surround(keyword(literal, oml.getQuotedLiteralAccess().getCircumflexAccentCircumflexAccentKeyword_1_0_0()), noSpace());
doc.surround(keyword(literal, oml.getQuotedLiteralAccess().getDollarSignKeyword_1_1_0()), noSpace());
/*var region = textRegionExtensions.regionFor(literal).feature(OmlPackage.Literals.QUOTED_LITERAL__VALUE);
var region = textRegionExtensions.regionFor(literal).feature(OmlPackage.Literals.QUOTED_LITERAL__VALUE);
if (region != null) {
var r = new AbstractTextReplacer(doc, region) {
@Override
public ITextReplacerContext createReplacements(ITextReplacerContext context) {
String text = region.getText();
int length = text.length();
int offset = region.getOffset();
int indentation = context.getIndentation();

String[] lines = text.split("\n");

// Find the minimum number of leading whitespace characters
int minWhitespaceCount = Integer.MAX_VALUE;
for (int i = 1; i < lines.length; i++) {
String line = lines[i];
int whitespaceCount = line.length() - line.trim().length();
minWhitespaceCount = Math.min(minWhitespaceCount, whitespaceCount);
}
// Remove the common number of leading whitespace characters from each line
for (int i = 1; i < lines.length; i++) {
lines[i] = "\t" + lines[i].substring(minWhitespaceCount);
StringBuffer b = new StringBuffer();
for (int j=0; j<indentation; j++) {
b.append("\t");
}
lines[i] = b.toString()+lines[i].trim();
}

String newText = String.join("\n", lines);

if (!newText.equals(text)) {
context.addReplacement(region.getTextRegionAccess().getRewriter().createReplacement(offset, text.length(), newText));
context.addReplacement(region.getTextRegionAccess().getRewriter().createReplacement(region.getOffset(), text.length(), newText));
}
return context;
}

};
doc.addReplacer(r);
}*/
}
}

/************** UTILITIES **************/
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.edit/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: io.opencaesar.oml.edit;singleton:=true
Automatic-Module-Name: io.opencaesar.oml.edit
Bundle-Version: 2.6.0
Bundle-Version: 2.7.0
Bundle-ClassPath: .
Bundle-Activator: io.opencaesar.oml.provider.OmlEditPlugin$Implementation
Bundle-Vendor: %providerName
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.edit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml.edit</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.editor/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: io.opencaesar.oml.editor;singleton:=true
Automatic-Module-Name: io.opencaesar.oml.editor
Bundle-Version: 2.6.0
Bundle-Version: 2.7.0
Bundle-ClassPath: .
Bundle-Activator: io.opencaesar.oml.presentation.OmlEditorPlugin$Implementation
Bundle-Vendor: %providerName
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.editor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml.editor</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml.repository</artifactId>
<packaging>eclipse-repository</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.sdk.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="io.opencaesar.oml.sdk.feature"
label="%featureName"
version="2.6.0"
version="2.7.0"
provider-name="%providerName">

<description>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml.sdk.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml.sdk.feature</artifactId>
<packaging>eclipse-feature</packaging>
Expand Down
15 changes: 9 additions & 6 deletions io.opencaesar.oml.specification/src/main/textual-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,16 @@
`false` | `true`

&lt;<span id="UNSIGNED_INTEGER_STR-Syntax">UNSIGNED_INTEGER_STR</span>&gt;:
DIGIT+
NUMERIC+

&lt;<span id="INTEGER_STR-Syntax">INTEGER_STR</span>&gt;:
(`+`|`-`)? DIGIT+
(`+`|`-`)? NUMERIC+

&lt;<span id="DECIMAL_STR-Syntax">DECIMAL_STR</span>&gt;:
(`+`|`-`)? (DIGIT+(`.`DIGIT*)? | (`.`DIGIT+))
(`+`|`-`)? (NUMERIC+(`.`NUMERIC*)? | (`.`NUMERIC+))

&lt;<span id="DOUBLE_STR-Syntax">DOUBLE_STR</span>&gt;:
(`+`|`-`)? (DIGIT+(`.`DIGIT*)? | (`.`DIGIT+)) ((`e`|`E`) (`+`|`-`)? DIGIT+)?
(`+`|`-`)? (NUMERIC+(`.`NUMERIC*)? | (`.`NUMERIC+)) ((`e`|`E`) (`+`|`-`)? NUMERIC+)?

&lt;<span id="STRING-Syntax">STRING</span>&gt;:
(`"` -> `"`) | (`'` -> `'`) | (`'''` -> `'''`) | (`"""` -> `"""`)
Expand All @@ -444,12 +444,15 @@
ID `:` ID

&lt;<span id="ID-Syntax">ID</span>&gt;:
`^`? (ALPHA|DIGIT|`_`) (ALPHA|DIGIT|`_`|`-`|`.`|`$`)*
`^`? (ALPHA|NUMERIC|SPECIAL) (ALPHA|NUMERIC|SPECIAL|`$`)*

&lt;<span id="ALPHA-Syntax">ALPHA</span>&gt;:
`a`..`z` | `A`..`Z`

&lt;<span id="DIGIT-Syntax">DIGIT</span>&gt;:
&lt;<span id="NUMERIC-Syntax">NUMERIC</span>&gt;:
`0`..`9`

&lt;<span id="SPECIAL-Syntax">SPECIAL</span>&gt;:
`_`|`-`|`.`|`~`|`%`

</pre>
2 changes: 1 addition & 1 deletion io.opencaesar.oml.target/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml.target</artifactId>
<packaging>eclipse-target-definition</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: io.opencaesar.oml;singleton:=true
Automatic-Module-Name: io.opencaesar.oml
Bundle-Version: 2.6.0
Bundle-Version: 2.7.0
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.oml</groupId>
<artifactId>io.opencaesar.oml.parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>
<artifactId>io.opencaesar.oml</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12681,7 +12681,7 @@ public interface OmlPackage extends EPackage {
* @return the meta object for data type '<em>ID</em>'.
* @see java.lang.String
* @model instanceClass="java.lang.String"
* extendedMetaData="pattern='[a-zA-Z0-9_]([a-zA-Z0-9_\\-.$])*'"
* extendedMetaData="pattern='[a-zA-Z0-9_\\-.%~]([a-zA-Z0-9_\\-.%~$])*'"
* @generated
*/
EDataType getID();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5586,7 +5586,7 @@ protected void createExtendedMetaDataAnnotations() {
(idEDataType,
source,
new String[] {
"pattern", "[a-zA-Z0-9_]([a-zA-Z0-9_\\-.$])*"
"pattern", "[a-zA-Z0-9_\\-.%~]([a-zA-Z0-9_\\-.%~$])*"
});
addAnnotation
(namespaceEDataType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ public boolean validateID(String id, DiagnosticChain diagnostics, Map<Object, Ob
public static final PatternMatcher [][] ID__PATTERN__VALUES =
new PatternMatcher [][] {
new PatternMatcher [] {
XMLTypeUtil.createPatternMatcher("[a-zA-Z0-9_]([a-zA-Z0-9_\\-.$])*")
XMLTypeUtil.createPatternMatcher("[a-zA-Z0-9_\\-.%~]([a-zA-Z0-9_\\-.%~$])*")
}
};

Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.oml/src/io/opencaesar/oml/Oml.xcore
Original file line number Diff line number Diff line change
Expand Up @@ -1919,7 +1919,7 @@ convert {
String.format("%.2E", it)
}

@ExtendedMetaData(pattern="[a-zA-Z0-9_]([a-zA-Z0-9_\\-.$])*")
@ExtendedMetaData(pattern="[a-zA-Z0-9_\\-.%~]([a-zA-Z0-9_\\-.%~$])*")
type ID wraps String

@ExtendedMetaData(pattern="([^\\s#])*(#|/)", minLength="2")
Expand Down
6 changes: 5 additions & 1 deletion io.opencaesar.oml/src/io/opencaesar/oml/util/OmlBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ protected <T extends Member> T resolve(Class<T> type, Ontology context, String i
}
cache.put(context, iri, member);
}
return type.cast(member);
if (type.isInstance(member)) {
return type.cast(member);
} else {
throw new RuntimeException("resolved iri "+iri+" in context of "+context.getIri()+" to element of type "+member.getClass().getName()+" instead of expected type "+type.getName());
}
}

// ------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 87076aa

Please sign in to comment.