diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/.classpath b/plugins/org.eclipse.fordiac.ide.contractspec.ide/.classpath new file mode 100644 index 0000000000..7994b69384 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/.project b/plugins/org.eclipse.fordiac.ide.contractspec.ide/.project new file mode 100644 index 0000000000..238bdc76cd --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/.project @@ -0,0 +1,34 @@ + + + org.eclipse.fordiac.ide.contractspec.ide + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.xtext.ui.shared.xtextNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.fordiac.ide.contractspec.ide/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.fordiac.ide.contractspec.ide/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..cc4eaa539c --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 +org.eclipse.jdt.core.compiler.compliance=21 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=21 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/META-INF/MANIFEST.MF b/plugins/org.eclipse.fordiac.ide.contractspec.ide/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..c4dd22b93c --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Automatic-Module-Name: org.eclipse.fordiac.ide.contractspec.ide +Bundle-ManifestVersion: 2 +Bundle-Name: org.eclipse.fordiac.ide.contractspec.ide +Bundle-Vendor: Eclipse 4diac +Bundle-Version: 1.0.0.qualifier +Bundle-SymbolicName: org.eclipse.fordiac.ide.contractspec.ide; singleton:=true +Bundle-ActivationPolicy: lazy +Require-Bundle: org.eclipse.fordiac.ide.contractspec, + org.eclipse.xtext.ide, + org.eclipse.xtext.xbase.ide, + org.antlr.runtime;bundle-version="[3.2.0,3.2.1)" +Bundle-RequiredExecutionEnvironment: JavaSE-21 +Export-Package: org.eclipse.fordiac.ide.ide.contentassist.antlr, + org.eclipse.fordiac.ide.ide.contentassist.antlr.internal diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/build.properties b/plugins/org.eclipse.fordiac.ide.contractspec.ide/build.properties new file mode 100644 index 0000000000..5c6bbf99f0 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/build.properties @@ -0,0 +1,6 @@ +source.. = src/,\ + src-gen/,\ + xtend-gen/ +bin.includes = .,\ + META-INF/ +bin.excludes = **/*.xtend diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/META-INF/services/org.eclipse.xtext.ISetup b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/META-INF/services/org.eclipse.xtext.ISetup new file mode 100644 index 0000000000..f0211a06b0 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/META-INF/services/org.eclipse.xtext.ISetup @@ -0,0 +1 @@ +org.eclipse.fordiac.ide.ide.ContractSpecIdeSetup diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/AbstractContractSpecIdeModule.java b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/AbstractContractSpecIdeModule.java new file mode 100644 index 0000000000..efc3883b0a --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/AbstractContractSpecIdeModule.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ide; + +import com.google.inject.Binder; +import com.google.inject.name.Names; +import org.eclipse.fordiac.ide.ide.contentassist.antlr.ContractSpecParser; +import org.eclipse.fordiac.ide.ide.contentassist.antlr.internal.InternalContractSpecLexer; +import org.eclipse.xtext.ide.DefaultIdeModule; +import org.eclipse.xtext.ide.LexerIdeBindings; +import org.eclipse.xtext.ide.editor.contentassist.FQNPrefixMatcher; +import org.eclipse.xtext.ide.editor.contentassist.IPrefixMatcher; +import org.eclipse.xtext.ide.editor.contentassist.IProposalConflictHelper; +import org.eclipse.xtext.ide.editor.contentassist.antlr.AntlrProposalConflictHelper; +import org.eclipse.xtext.ide.editor.contentassist.antlr.IContentAssistParser; +import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer; +import org.eclipse.xtext.ide.refactoring.IRenameStrategy2; +import org.eclipse.xtext.ide.server.rename.IRenameService2; +import org.eclipse.xtext.ide.server.rename.RenameService2; + +/** + * Manual modifications go to {@link ContractSpecIdeModule}. + */ +@SuppressWarnings("all") +public abstract class AbstractContractSpecIdeModule extends DefaultIdeModule { + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public void configureContentAssistLexer(Binder binder) { + binder.bind(Lexer.class) + .annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST)) + .to(InternalContractSpecLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIContentAssistParser() { + return ContractSpecParser.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIProposalConflictHelper() { + return AntlrProposalConflictHelper.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.exporting.QualifiedNamesFragment2 + public Class bindIPrefixMatcher() { + return FQNPrefixMatcher.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.refactoring.RefactorElementNameFragment2 + public Class bindIRenameService2() { + return RenameService2.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.refactoring.RefactorElementNameFragment2 + public Class bindIRenameStrategy2() { + return IRenameStrategy2.DefaultImpl.class; + } + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/ContractSpecParser.java b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/ContractSpecParser.java new file mode 100644 index 0000000000..80dcd7533f --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/ContractSpecParser.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ide.contentassist.antlr; + +import com.google.common.collect.ImmutableMap; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.util.Map; +import org.eclipse.fordiac.ide.ide.contentassist.antlr.internal.InternalContractSpecParser; +import org.eclipse.fordiac.ide.services.ContractSpecGrammarAccess; +import org.eclipse.xtext.AbstractElement; +import org.eclipse.xtext.ide.editor.contentassist.antlr.AbstractContentAssistParser; + +public class ContractSpecParser extends AbstractContentAssistParser { + + @Singleton + public static final class NameMappings { + + private final Map mappings; + + @Inject + public NameMappings(ContractSpecGrammarAccess grammarAccess) { + ImmutableMap.Builder builder = ImmutableMap.builder(); + init(builder, grammarAccess); + this.mappings = builder.build(); + } + + public String getRuleName(AbstractElement element) { + return mappings.get(element); + } + + private static void init(ImmutableMap.Builder builder, ContractSpecGrammarAccess grammarAccess) { + builder.put(grammarAccess.getModelAccess().getTimeSpecAssignment(), "rule__Model__TimeSpecAssignment"); + } + } + + @Inject + private NameMappings nameMappings; + + @Inject + private ContractSpecGrammarAccess grammarAccess; + + @Override + protected InternalContractSpecParser createParser() { + InternalContractSpecParser result = new InternalContractSpecParser(null); + result.setGrammarAccess(grammarAccess); + return result; + } + + @Override + protected String getRuleName(AbstractElement element) { + return nameMappings.getRuleName(element); + } + + @Override + protected String[] getInitialHiddenTokens() { + return new String[] { "RULE_WS", "RULE_ML_COMMENT", "RULE_SL_COMMENT" }; + } + + public ContractSpecGrammarAccess getGrammarAccess() { + return this.grammarAccess; + } + + public void setGrammarAccess(ContractSpecGrammarAccess grammarAccess) { + this.grammarAccess = grammarAccess; + } + + public NameMappings getNameMappings() { + return nameMappings; + } + + public void setNameMappings(NameMappings nameMappings) { + this.nameMappings = nameMappings; + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/PartialContractSpecContentAssistParser.java b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/PartialContractSpecContentAssistParser.java new file mode 100644 index 0000000000..ff242198d1 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/PartialContractSpecContentAssistParser.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ide.contentassist.antlr; + +import java.util.Collection; +import java.util.Collections; +import org.eclipse.xtext.AbstractRule; +import org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement; +import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.AbstractInternalContentAssistParser; +import org.eclipse.xtext.util.PolymorphicDispatcher; + +public class PartialContractSpecContentAssistParser extends ContractSpecParser { + + private AbstractRule rule; + + @Override + public void initializeFor(AbstractRule rule) { + this.rule = rule; + } + + @Override + protected Collection getFollowElements(AbstractInternalContentAssistParser parser) { + if (rule == null || rule.eIsProxy()) + return Collections.emptyList(); + String methodName = "entryRule" + rule.getName(); + PolymorphicDispatcher> dispatcher = + new PolymorphicDispatcher>(methodName, 0, 0, Collections.singletonList(parser)); + dispatcher.invoke(); + return parser.getFollowElements(); + } + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpec.g b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpec.g new file mode 100644 index 0000000000..c55567d381 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpec.g @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +grammar InternalContractSpec; + +options { + superClass=AbstractInternalContentAssistParser; +} + +@lexer::header { +package org.eclipse.fordiac.ide.ide.contentassist.antlr.internal; + +// Hack: Use our own Lexer superclass by means of import. +// Currently there is no other way to specify the superclass for the lexer. +import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer; +} + +@parser::header { +package org.eclipse.fordiac.ide.ide.contentassist.antlr.internal; + +import java.io.InputStream; +import org.eclipse.xtext.*; +import org.eclipse.xtext.parser.*; +import org.eclipse.xtext.parser.impl.*; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; +import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.AbstractInternalContentAssistParser; +import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.DFA; +import org.eclipse.fordiac.ide.services.ContractSpecGrammarAccess; + +} +@parser::members { + private ContractSpecGrammarAccess grammarAccess; + + public void setGrammarAccess(ContractSpecGrammarAccess grammarAccess) { + this.grammarAccess = grammarAccess; + } + + @Override + protected Grammar getGrammar() { + return grammarAccess.getGrammar(); + } + + @Override + protected String getValueForTokenName(String tokenName) { + return tokenName; + } +} + +// Entry rule entryRuleModel +entryRuleModel +: +{ before(grammarAccess.getModelRule()); } + ruleModel +{ after(grammarAccess.getModelRule()); } + EOF +; + +// Rule Model +ruleModel + @init { + int stackSize = keepStackSize(); + } + : + ( + { before(grammarAccess.getModelAccess().getTimeSpecAssignment()); } + (rule__Model__TimeSpecAssignment)* + { after(grammarAccess.getModelAccess().getTimeSpecAssignment()); } + ) +; +finally { + restoreStackSize(stackSize); +} + +// Entry rule entryRuleTimeSpec +entryRuleTimeSpec +: +{ before(grammarAccess.getTimeSpecRule()); } + ruleTimeSpec +{ after(grammarAccess.getTimeSpecRule()); } + EOF +; + +// Rule TimeSpec +ruleTimeSpec + @init { + int stackSize = keepStackSize(); + } + : + ( + { before(grammarAccess.getTimeSpecAccess().getDummy_ruleKeyword()); } + 'dummy_rule' + { after(grammarAccess.getTimeSpecAccess().getDummy_ruleKeyword()); } + ) +; +finally { + restoreStackSize(stackSize); +} + +rule__Model__TimeSpecAssignment + @init { + int stackSize = keepStackSize(); + } +: + ( + { before(grammarAccess.getModelAccess().getTimeSpecTimeSpecParserRuleCall_0()); } + ruleTimeSpec + { after(grammarAccess.getModelAccess().getTimeSpecTimeSpecParserRuleCall_0()); } + ) +; +finally { + restoreStackSize(stackSize); +} + +RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; + +RULE_INT : ('0'..'9')+; + +RULE_STRING : ('"' ('\\' .|~(('\\'|'"')))* '"'|'\'' ('\\' .|~(('\\'|'\'')))* '\''); + +RULE_ML_COMMENT : '/*' ( options {greedy=false;} : . )*'*/'; + +RULE_SL_COMMENT : '//' ~(('\n'|'\r'))* ('\r'? '\n')?; + +RULE_WS : (' '|'\t'|'\r'|'\n')+; + +RULE_ANY_OTHER : .; diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpec.tokens b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpec.tokens new file mode 100644 index 0000000000..78bfe28563 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpec.tokens @@ -0,0 +1,9 @@ +'dummy_rule'=11 +RULE_ANY_OTHER=10 +RULE_ID=4 +RULE_INT=5 +RULE_ML_COMMENT=7 +RULE_SL_COMMENT=8 +RULE_STRING=6 +RULE_WS=9 +T__11=11 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpecLexer.java b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpecLexer.java new file mode 100644 index 0000000000..c6f717e50f --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpecLexer.java @@ -0,0 +1,755 @@ +package org.eclipse.fordiac.ide.ide.contentassist.antlr.internal; + +// Hack: Use our own Lexer superclass by means of import. +// Currently there is no other way to specify the superclass for the lexer. +import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer; + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +@SuppressWarnings("all") +public class InternalContractSpecLexer extends Lexer { + public static final int RULE_ID=4; + public static final int RULE_WS=9; + public static final int RULE_STRING=6; + public static final int RULE_ANY_OTHER=10; + public static final int RULE_SL_COMMENT=8; + public static final int RULE_INT=5; + public static final int T__11=11; + public static final int RULE_ML_COMMENT=7; + public static final int EOF=-1; + + // delegates + // delegators + + public InternalContractSpecLexer() {;} + public InternalContractSpecLexer(CharStream input) { + this(input, new RecognizerSharedState()); + } + public InternalContractSpecLexer(CharStream input, RecognizerSharedState state) { + super(input,state); + + } + public String getGrammarFileName() { return "InternalContractSpec.g"; } + + // $ANTLR start "T__11" + public final void mT__11() throws RecognitionException { + try { + int _type = T__11; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:11:7: ( 'dummy_rule' ) + // InternalContractSpec.g:11:9: 'dummy_rule' + { + match("dummy_rule"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__11" + + // $ANTLR start "RULE_ID" + public final void mRULE_ID() throws RecognitionException { + try { + int _type = RULE_ID; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:127:9: ( ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* ) + // InternalContractSpec.g:127:11: ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + { + // InternalContractSpec.g:127:11: ( '^' )? + int alt1=2; + int LA1_0 = input.LA(1); + + if ( (LA1_0=='^') ) { + alt1=1; + } + switch (alt1) { + case 1 : + // InternalContractSpec.g:127:11: '^' + { + match('^'); + + } + break; + + } + + if ( (input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + // InternalContractSpec.g:127:40: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + loop2: + do { + int alt2=2; + int LA2_0 = input.LA(1); + + if ( ((LA2_0>='0' && LA2_0<='9')||(LA2_0>='A' && LA2_0<='Z')||LA2_0=='_'||(LA2_0>='a' && LA2_0<='z')) ) { + alt2=1; + } + + + switch (alt2) { + case 1 : + // InternalContractSpec.g: + { + if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop2; + } + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ID" + + // $ANTLR start "RULE_INT" + public final void mRULE_INT() throws RecognitionException { + try { + int _type = RULE_INT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:129:10: ( ( '0' .. '9' )+ ) + // InternalContractSpec.g:129:12: ( '0' .. '9' )+ + { + // InternalContractSpec.g:129:12: ( '0' .. '9' )+ + int cnt3=0; + loop3: + do { + int alt3=2; + int LA3_0 = input.LA(1); + + if ( ((LA3_0>='0' && LA3_0<='9')) ) { + alt3=1; + } + + + switch (alt3) { + case 1 : + // InternalContractSpec.g:129:13: '0' .. '9' + { + matchRange('0','9'); + + } + break; + + default : + if ( cnt3 >= 1 ) break loop3; + EarlyExitException eee = + new EarlyExitException(3, input); + throw eee; + } + cnt3++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_INT" + + // $ANTLR start "RULE_STRING" + public final void mRULE_STRING() throws RecognitionException { + try { + int _type = RULE_STRING; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:131:13: ( ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) ) + // InternalContractSpec.g:131:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) + { + // InternalContractSpec.g:131:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) + int alt6=2; + int LA6_0 = input.LA(1); + + if ( (LA6_0=='\"') ) { + alt6=1; + } + else if ( (LA6_0=='\'') ) { + alt6=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 6, 0, input); + + throw nvae; + } + switch (alt6) { + case 1 : + // InternalContractSpec.g:131:16: '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' + { + match('\"'); + // InternalContractSpec.g:131:20: ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* + loop4: + do { + int alt4=3; + int LA4_0 = input.LA(1); + + if ( (LA4_0=='\\') ) { + alt4=1; + } + else if ( ((LA4_0>='\u0000' && LA4_0<='!')||(LA4_0>='#' && LA4_0<='[')||(LA4_0>=']' && LA4_0<='\uFFFF')) ) { + alt4=2; + } + + + switch (alt4) { + case 1 : + // InternalContractSpec.g:131:21: '\\\\' . + { + match('\\'); + matchAny(); + + } + break; + case 2 : + // InternalContractSpec.g:131:28: ~ ( ( '\\\\' | '\"' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='!')||(input.LA(1)>='#' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop4; + } + } while (true); + + match('\"'); + + } + break; + case 2 : + // InternalContractSpec.g:131:48: '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' + { + match('\''); + // InternalContractSpec.g:131:53: ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* + loop5: + do { + int alt5=3; + int LA5_0 = input.LA(1); + + if ( (LA5_0=='\\') ) { + alt5=1; + } + else if ( ((LA5_0>='\u0000' && LA5_0<='&')||(LA5_0>='(' && LA5_0<='[')||(LA5_0>=']' && LA5_0<='\uFFFF')) ) { + alt5=2; + } + + + switch (alt5) { + case 1 : + // InternalContractSpec.g:131:54: '\\\\' . + { + match('\\'); + matchAny(); + + } + break; + case 2 : + // InternalContractSpec.g:131:61: ~ ( ( '\\\\' | '\\'' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='&')||(input.LA(1)>='(' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop5; + } + } while (true); + + match('\''); + + } + break; + + } + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_STRING" + + // $ANTLR start "RULE_ML_COMMENT" + public final void mRULE_ML_COMMENT() throws RecognitionException { + try { + int _type = RULE_ML_COMMENT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:133:17: ( '/*' ( options {greedy=false; } : . )* '*/' ) + // InternalContractSpec.g:133:19: '/*' ( options {greedy=false; } : . )* '*/' + { + match("/*"); + + // InternalContractSpec.g:133:24: ( options {greedy=false; } : . )* + loop7: + do { + int alt7=2; + int LA7_0 = input.LA(1); + + if ( (LA7_0=='*') ) { + int LA7_1 = input.LA(2); + + if ( (LA7_1=='/') ) { + alt7=2; + } + else if ( ((LA7_1>='\u0000' && LA7_1<='.')||(LA7_1>='0' && LA7_1<='\uFFFF')) ) { + alt7=1; + } + + + } + else if ( ((LA7_0>='\u0000' && LA7_0<=')')||(LA7_0>='+' && LA7_0<='\uFFFF')) ) { + alt7=1; + } + + + switch (alt7) { + case 1 : + // InternalContractSpec.g:133:52: . + { + matchAny(); + + } + break; + + default : + break loop7; + } + } while (true); + + match("*/"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ML_COMMENT" + + // $ANTLR start "RULE_SL_COMMENT" + public final void mRULE_SL_COMMENT() throws RecognitionException { + try { + int _type = RULE_SL_COMMENT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:135:17: ( '//' (~ ( ( '\\n' | '\\r' ) ) )* ( ( '\\r' )? '\\n' )? ) + // InternalContractSpec.g:135:19: '//' (~ ( ( '\\n' | '\\r' ) ) )* ( ( '\\r' )? '\\n' )? + { + match("//"); + + // InternalContractSpec.g:135:24: (~ ( ( '\\n' | '\\r' ) ) )* + loop8: + do { + int alt8=2; + int LA8_0 = input.LA(1); + + if ( ((LA8_0>='\u0000' && LA8_0<='\t')||(LA8_0>='\u000B' && LA8_0<='\f')||(LA8_0>='\u000E' && LA8_0<='\uFFFF')) ) { + alt8=1; + } + + + switch (alt8) { + case 1 : + // InternalContractSpec.g:135:24: ~ ( ( '\\n' | '\\r' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='\t')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop8; + } + } while (true); + + // InternalContractSpec.g:135:40: ( ( '\\r' )? '\\n' )? + int alt10=2; + int LA10_0 = input.LA(1); + + if ( (LA10_0=='\n'||LA10_0=='\r') ) { + alt10=1; + } + switch (alt10) { + case 1 : + // InternalContractSpec.g:135:41: ( '\\r' )? '\\n' + { + // InternalContractSpec.g:135:41: ( '\\r' )? + int alt9=2; + int LA9_0 = input.LA(1); + + if ( (LA9_0=='\r') ) { + alt9=1; + } + switch (alt9) { + case 1 : + // InternalContractSpec.g:135:41: '\\r' + { + match('\r'); + + } + break; + + } + + match('\n'); + + } + break; + + } + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_SL_COMMENT" + + // $ANTLR start "RULE_WS" + public final void mRULE_WS() throws RecognitionException { + try { + int _type = RULE_WS; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:137:9: ( ( ' ' | '\\t' | '\\r' | '\\n' )+ ) + // InternalContractSpec.g:137:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ + { + // InternalContractSpec.g:137:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ + int cnt11=0; + loop11: + do { + int alt11=2; + int LA11_0 = input.LA(1); + + if ( ((LA11_0>='\t' && LA11_0<='\n')||LA11_0=='\r'||LA11_0==' ') ) { + alt11=1; + } + + + switch (alt11) { + case 1 : + // InternalContractSpec.g: + { + if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + if ( cnt11 >= 1 ) break loop11; + EarlyExitException eee = + new EarlyExitException(11, input); + throw eee; + } + cnt11++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_WS" + + // $ANTLR start "RULE_ANY_OTHER" + public final void mRULE_ANY_OTHER() throws RecognitionException { + try { + int _type = RULE_ANY_OTHER; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:139:16: ( . ) + // InternalContractSpec.g:139:18: . + { + matchAny(); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ANY_OTHER" + + public void mTokens() throws RecognitionException { + // InternalContractSpec.g:1:8: ( T__11 | RULE_ID | RULE_INT | RULE_STRING | RULE_ML_COMMENT | RULE_SL_COMMENT | RULE_WS | RULE_ANY_OTHER ) + int alt12=8; + alt12 = dfa12.predict(input); + switch (alt12) { + case 1 : + // InternalContractSpec.g:1:10: T__11 + { + mT__11(); + + } + break; + case 2 : + // InternalContractSpec.g:1:16: RULE_ID + { + mRULE_ID(); + + } + break; + case 3 : + // InternalContractSpec.g:1:24: RULE_INT + { + mRULE_INT(); + + } + break; + case 4 : + // InternalContractSpec.g:1:33: RULE_STRING + { + mRULE_STRING(); + + } + break; + case 5 : + // InternalContractSpec.g:1:45: RULE_ML_COMMENT + { + mRULE_ML_COMMENT(); + + } + break; + case 6 : + // InternalContractSpec.g:1:61: RULE_SL_COMMENT + { + mRULE_SL_COMMENT(); + + } + break; + case 7 : + // InternalContractSpec.g:1:77: RULE_WS + { + mRULE_WS(); + + } + break; + case 8 : + // InternalContractSpec.g:1:85: RULE_ANY_OTHER + { + mRULE_ANY_OTHER(); + + } + break; + + } + + } + + + protected DFA12 dfa12 = new DFA12(this); + static final String DFA12_eotS = + "\1\uffff\1\13\1\11\2\uffff\3\11\2\uffff\1\13\6\uffff\7\13\1\31\1\uffff"; + static final String DFA12_eofS = + "\32\uffff"; + static final String DFA12_minS = + "\1\0\1\165\1\101\2\uffff\2\0\1\52\2\uffff\1\155\6\uffff\1\155\1\171\1\137\1\162\1\165\1\154\1\145\1\60\1\uffff"; + static final String DFA12_maxS = + "\1\uffff\1\165\1\172\2\uffff\2\uffff\1\57\2\uffff\1\155\6\uffff\1\155\1\171\1\137\1\162\1\165\1\154\1\145\1\172\1\uffff"; + static final String DFA12_acceptS = + "\3\uffff\1\2\1\3\3\uffff\1\7\1\10\1\uffff\1\2\1\3\1\4\1\5\1\6\1\7\10\uffff\1\1"; + static final String DFA12_specialS = + "\1\0\4\uffff\1\1\1\2\23\uffff}>"; + static final String[] DFA12_transitionS = { + "\11\11\2\10\2\11\1\10\22\11\1\10\1\11\1\5\4\11\1\6\7\11\1\7\12\4\7\11\32\3\3\11\1\2\1\3\1\11\3\3\1\1\26\3\uff85\11", + "\1\12", + "\32\13\4\uffff\1\13\1\uffff\32\13", + "", + "", + "\0\15", + "\0\15", + "\1\16\4\uffff\1\17", + "", + "", + "\1\21", + "", + "", + "", + "", + "", + "", + "\1\22", + "\1\23", + "\1\24", + "\1\25", + "\1\26", + "\1\27", + "\1\30", + "\12\13\7\uffff\32\13\4\uffff\1\13\1\uffff\32\13", + "" + }; + + static final short[] DFA12_eot = DFA.unpackEncodedString(DFA12_eotS); + static final short[] DFA12_eof = DFA.unpackEncodedString(DFA12_eofS); + static final char[] DFA12_min = DFA.unpackEncodedStringToUnsignedChars(DFA12_minS); + static final char[] DFA12_max = DFA.unpackEncodedStringToUnsignedChars(DFA12_maxS); + static final short[] DFA12_accept = DFA.unpackEncodedString(DFA12_acceptS); + static final short[] DFA12_special = DFA.unpackEncodedString(DFA12_specialS); + static final short[][] DFA12_transition; + + static { + int numStates = DFA12_transitionS.length; + DFA12_transition = new short[numStates][]; + for (int i=0; i='A' && LA12_0<='Z')||LA12_0=='_'||(LA12_0>='a' && LA12_0<='c')||(LA12_0>='e' && LA12_0<='z')) ) {s = 3;} + + else if ( ((LA12_0>='0' && LA12_0<='9')) ) {s = 4;} + + else if ( (LA12_0=='\"') ) {s = 5;} + + else if ( (LA12_0=='\'') ) {s = 6;} + + else if ( (LA12_0=='/') ) {s = 7;} + + else if ( ((LA12_0>='\t' && LA12_0<='\n')||LA12_0=='\r'||LA12_0==' ') ) {s = 8;} + + else if ( ((LA12_0>='\u0000' && LA12_0<='\b')||(LA12_0>='\u000B' && LA12_0<='\f')||(LA12_0>='\u000E' && LA12_0<='\u001F')||LA12_0=='!'||(LA12_0>='#' && LA12_0<='&')||(LA12_0>='(' && LA12_0<='.')||(LA12_0>=':' && LA12_0<='@')||(LA12_0>='[' && LA12_0<=']')||LA12_0=='`'||(LA12_0>='{' && LA12_0<='\uFFFF')) ) {s = 9;} + + if ( s>=0 ) return s; + break; + case 1 : + int LA12_5 = input.LA(1); + + s = -1; + if ( ((LA12_5>='\u0000' && LA12_5<='\uFFFF')) ) {s = 13;} + + else s = 9; + + if ( s>=0 ) return s; + break; + case 2 : + int LA12_6 = input.LA(1); + + s = -1; + if ( ((LA12_6>='\u0000' && LA12_6<='\uFFFF')) ) {s = 13;} + + else s = 9; + + if ( s>=0 ) return s; + break; + } + NoViableAltException nvae = + new NoViableAltException(getDescription(), 12, _s, input); + error(nvae); + throw nvae; + } + } + + +} \ No newline at end of file diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpecParser.java b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpecParser.java new file mode 100644 index 0000000000..59ec35c552 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src-gen/org/eclipse/fordiac/ide/ide/contentassist/antlr/internal/InternalContractSpecParser.java @@ -0,0 +1,296 @@ +package org.eclipse.fordiac.ide.ide.contentassist.antlr.internal; + +import java.io.InputStream; +import org.eclipse.xtext.*; +import org.eclipse.xtext.parser.*; +import org.eclipse.xtext.parser.impl.*; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; +import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.AbstractInternalContentAssistParser; +import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.DFA; +import org.eclipse.fordiac.ide.services.ContractSpecGrammarAccess; + + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +@SuppressWarnings("all") +public class InternalContractSpecParser extends AbstractInternalContentAssistParser { + public static final String[] tokenNames = new String[] { + "", "", "", "", "RULE_ID", "RULE_INT", "RULE_STRING", "RULE_ML_COMMENT", "RULE_SL_COMMENT", "RULE_WS", "RULE_ANY_OTHER", "'dummy_rule'" + }; + public static final int RULE_ID=4; + public static final int RULE_WS=9; + public static final int RULE_STRING=6; + public static final int RULE_ANY_OTHER=10; + public static final int RULE_SL_COMMENT=8; + public static final int RULE_INT=5; + public static final int T__11=11; + public static final int RULE_ML_COMMENT=7; + public static final int EOF=-1; + + // delegates + // delegators + + + public InternalContractSpecParser(TokenStream input) { + this(input, new RecognizerSharedState()); + } + public InternalContractSpecParser(TokenStream input, RecognizerSharedState state) { + super(input, state); + + } + + + public String[] getTokenNames() { return InternalContractSpecParser.tokenNames; } + public String getGrammarFileName() { return "InternalContractSpec.g"; } + + + private ContractSpecGrammarAccess grammarAccess; + + public void setGrammarAccess(ContractSpecGrammarAccess grammarAccess) { + this.grammarAccess = grammarAccess; + } + + @Override + protected Grammar getGrammar() { + return grammarAccess.getGrammar(); + } + + @Override + protected String getValueForTokenName(String tokenName) { + return tokenName; + } + + + + // $ANTLR start "entryRuleModel" + // InternalContractSpec.g:63:1: entryRuleModel : ruleModel EOF ; + public final void entryRuleModel() throws RecognitionException { + try { + // InternalContractSpec.g:64:1: ( ruleModel EOF ) + // InternalContractSpec.g:65:1: ruleModel EOF + { + before(grammarAccess.getModelRule()); + pushFollow(FOLLOW_1); + ruleModel(); + + state._fsp--; + + after(grammarAccess.getModelRule()); + match(input,EOF,FOLLOW_2); + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + } + return ; + } + // $ANTLR end "entryRuleModel" + + + // $ANTLR start "ruleModel" + // InternalContractSpec.g:72:1: ruleModel : ( ( rule__Model__TimeSpecAssignment )* ) ; + public final void ruleModel() throws RecognitionException { + + int stackSize = keepStackSize(); + + try { + // InternalContractSpec.g:76:2: ( ( ( rule__Model__TimeSpecAssignment )* ) ) + // InternalContractSpec.g:77:2: ( ( rule__Model__TimeSpecAssignment )* ) + { + // InternalContractSpec.g:77:2: ( ( rule__Model__TimeSpecAssignment )* ) + // InternalContractSpec.g:78:3: ( rule__Model__TimeSpecAssignment )* + { + before(grammarAccess.getModelAccess().getTimeSpecAssignment()); + // InternalContractSpec.g:79:3: ( rule__Model__TimeSpecAssignment )* + loop1: + do { + int alt1=2; + int LA1_0 = input.LA(1); + + if ( (LA1_0==11) ) { + alt1=1; + } + + + switch (alt1) { + case 1 : + // InternalContractSpec.g:79:4: rule__Model__TimeSpecAssignment + { + pushFollow(FOLLOW_3); + rule__Model__TimeSpecAssignment(); + + state._fsp--; + + + } + break; + + default : + break loop1; + } + } while (true); + + after(grammarAccess.getModelAccess().getTimeSpecAssignment()); + + } + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + + restoreStackSize(stackSize); + + } + return ; + } + // $ANTLR end "ruleModel" + + + // $ANTLR start "entryRuleTimeSpec" + // InternalContractSpec.g:88:1: entryRuleTimeSpec : ruleTimeSpec EOF ; + public final void entryRuleTimeSpec() throws RecognitionException { + try { + // InternalContractSpec.g:89:1: ( ruleTimeSpec EOF ) + // InternalContractSpec.g:90:1: ruleTimeSpec EOF + { + before(grammarAccess.getTimeSpecRule()); + pushFollow(FOLLOW_1); + ruleTimeSpec(); + + state._fsp--; + + after(grammarAccess.getTimeSpecRule()); + match(input,EOF,FOLLOW_2); + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + } + return ; + } + // $ANTLR end "entryRuleTimeSpec" + + + // $ANTLR start "ruleTimeSpec" + // InternalContractSpec.g:97:1: ruleTimeSpec : ( 'dummy_rule' ) ; + public final void ruleTimeSpec() throws RecognitionException { + + int stackSize = keepStackSize(); + + try { + // InternalContractSpec.g:101:2: ( ( 'dummy_rule' ) ) + // InternalContractSpec.g:102:2: ( 'dummy_rule' ) + { + // InternalContractSpec.g:102:2: ( 'dummy_rule' ) + // InternalContractSpec.g:103:3: 'dummy_rule' + { + before(grammarAccess.getTimeSpecAccess().getDummy_ruleKeyword()); + match(input,11,FOLLOW_2); + after(grammarAccess.getTimeSpecAccess().getDummy_ruleKeyword()); + + } + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + + restoreStackSize(stackSize); + + } + return ; + } + // $ANTLR end "ruleTimeSpec" + + + // $ANTLR start "rule__Model__TimeSpecAssignment" + // InternalContractSpec.g:112:1: rule__Model__TimeSpecAssignment : ( ruleTimeSpec ) ; + public final void rule__Model__TimeSpecAssignment() throws RecognitionException { + + int stackSize = keepStackSize(); + + try { + // InternalContractSpec.g:116:1: ( ( ruleTimeSpec ) ) + // InternalContractSpec.g:117:2: ( ruleTimeSpec ) + { + // InternalContractSpec.g:117:2: ( ruleTimeSpec ) + // InternalContractSpec.g:118:3: ruleTimeSpec + { + before(grammarAccess.getModelAccess().getTimeSpecTimeSpecParserRuleCall_0()); + pushFollow(FOLLOW_2); + ruleTimeSpec(); + + state._fsp--; + + after(grammarAccess.getModelAccess().getTimeSpecTimeSpecParserRuleCall_0()); + + } + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + + restoreStackSize(stackSize); + + } + return ; + } + // $ANTLR end "rule__Model__TimeSpecAssignment" + + // Delegated rules + + + + + public static final BitSet FOLLOW_1 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_2 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_3 = new BitSet(new long[]{0x0000000000000802L}); + +} \ No newline at end of file diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/src/org/eclipse/fordiac/ide/ide/ContractSpecIdeModule.java b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src/org/eclipse/fordiac/ide/ide/ContractSpecIdeModule.java new file mode 100644 index 0000000000..d0b3a65b37 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src/org/eclipse/fordiac/ide/ide/ContractSpecIdeModule.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ide; + + +/** + * Use this class to register ide components. + */ +public class ContractSpecIdeModule extends AbstractContractSpecIdeModule { +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ide/src/org/eclipse/fordiac/ide/ide/ContractSpecIdeSetup.java b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src/org/eclipse/fordiac/ide/ide/ContractSpecIdeSetup.java new file mode 100644 index 0000000000..ed45e1a4ed --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ide/src/org/eclipse/fordiac/ide/ide/ContractSpecIdeSetup.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ide; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.eclipse.fordiac.ide.ContractSpecRuntimeModule; +import org.eclipse.fordiac.ide.ContractSpecStandaloneSetup; +import org.eclipse.xtext.util.Modules2; + +/** + * Initialization support for running Xtext languages as language servers. + */ +public class ContractSpecIdeSetup extends ContractSpecStandaloneSetup { + + @Override + public Injector createInjector() { + return Guice.createInjector(Modules2.mixin(new ContractSpecRuntimeModule(), new ContractSpecIdeModule())); + } + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.tests/.classpath b/plugins/org.eclipse.fordiac.ide.contractspec.tests/.classpath new file mode 100644 index 0000000000..8ee4cf1d89 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.tests/.classpath @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.tests/.gitignore b/plugins/org.eclipse.fordiac.ide.contractspec.tests/.gitignore new file mode 100644 index 0000000000..e75a396d4b --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.tests/.gitignore @@ -0,0 +1 @@ +/test-bin/ diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.tests/.project b/plugins/org.eclipse.fordiac.ide.contractspec.tests/.project new file mode 100644 index 0000000000..e146d4475d --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.tests/.project @@ -0,0 +1,34 @@ + + + org.eclipse.fordiac.ide.contractspec.tests + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.xtext.ui.shared.xtextNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.tests/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.fordiac.ide.contractspec.tests/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.tests/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.tests/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.fordiac.ide.contractspec.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..cc4eaa539c --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 +org.eclipse.jdt.core.compiler.compliance=21 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=21 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.fordiac.ide.contractspec.tests/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..911202f29f --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.tests/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Automatic-Module-Name: org.eclipse.fordiac.ide.contractspec.tests +Bundle-ManifestVersion: 2 +Bundle-Name: org.eclipse.fordiac.ide.contractspec.tests +Bundle-Vendor: Eclipse 4diac +Bundle-Version: 1.0.0.qualifier +Bundle-SymbolicName: org.eclipse.fordiac.ide.contractspec.tests; singleton:=true +Bundle-ActivationPolicy: lazy +Require-Bundle: org.eclipse.fordiac.ide.contractspec, + org.eclipse.xtext.testing, + org.eclipse.xtext.xbase.testing, + org.eclipse.xtext.xbase.lib;bundle-version="2.37.0" +Import-Package: org.junit.jupiter.api;version="[5.1.0,6.0.0)", + org.junit.jupiter.api.extension;version="[5.1.0,6.0.0)" +Bundle-RequiredExecutionEnvironment: JavaSE-21 +Export-Package: org.eclipse.fordiac.ide.tests;x-internal=true diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.tests/build.properties b/plugins/org.eclipse.fordiac.ide.contractspec.tests/build.properties new file mode 100644 index 0000000000..5c6bbf99f0 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.tests/build.properties @@ -0,0 +1,6 @@ +source.. = src/,\ + src-gen/,\ + xtend-gen/ +bin.includes = .,\ + META-INF/ +bin.excludes = **/*.xtend diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.tests/src-gen/org/eclipse/fordiac/ide/tests/ContractSpecInjectorProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec.tests/src-gen/org/eclipse/fordiac/ide/tests/ContractSpecInjectorProvider.java new file mode 100644 index 0000000000..90c2fdc362 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.tests/src-gen/org/eclipse/fordiac/ide/tests/ContractSpecInjectorProvider.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.tests; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.eclipse.fordiac.ide.ContractSpecRuntimeModule; +import org.eclipse.fordiac.ide.ContractSpecStandaloneSetup; +import org.eclipse.xtext.testing.GlobalRegistries; +import org.eclipse.xtext.testing.GlobalRegistries.GlobalStateMemento; +import org.eclipse.xtext.testing.IInjectorProvider; +import org.eclipse.xtext.testing.IRegistryConfigurator; + +public class ContractSpecInjectorProvider implements IInjectorProvider, IRegistryConfigurator { + + protected GlobalStateMemento stateBeforeInjectorCreation; + protected GlobalStateMemento stateAfterInjectorCreation; + protected Injector injector; + + static { + GlobalRegistries.initializeDefaults(); + } + + @Override + public Injector getInjector() { + if (injector == null) { + this.injector = internalCreateInjector(); + stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); + } + return injector; + } + + protected Injector internalCreateInjector() { + return new ContractSpecStandaloneSetup() { + @Override + public Injector createInjector() { + return Guice.createInjector(createRuntimeModule()); + } + }.createInjectorAndDoEMFRegistration(); + } + + protected ContractSpecRuntimeModule createRuntimeModule() { + // make it work also with Maven/Tycho and OSGI + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=493672 + // allows for bindClassLoaderToInstance to get the class loader of the bundle + // containing the instance of the injector provider (possibly inherited) + return new ContractSpecRuntimeModule() { + @Override + public ClassLoader bindClassLoaderToInstance() { + return ContractSpecInjectorProvider.this.getClass() + .getClassLoader(); + } + }; + } + + @Override + public void restoreRegistry() { + stateBeforeInjectorCreation.restoreGlobalState(); + stateBeforeInjectorCreation = null; + } + + @Override + public void setupRegistry() { + stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); + if (injector == null) { + getInjector(); + } + stateAfterInjectorCreation.restoreGlobalState(); + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.tests/src/org/eclipse/fordiac/ide/tests/ContractSpecParsingTest.xtend b/plugins/org.eclipse.fordiac.ide.contractspec.tests/src/org/eclipse/fordiac/ide/tests/ContractSpecParsingTest.xtend new file mode 100644 index 0000000000..007f422c69 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.tests/src/org/eclipse/fordiac/ide/tests/ContractSpecParsingTest.xtend @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.tests + +import com.google.inject.Inject +import org.eclipse.fordiac.ide.contractSpec.Model +import org.eclipse.xtext.testing.InjectWith +import org.eclipse.xtext.testing.extensions.InjectionExtension +import org.eclipse.xtext.testing.util.ParseHelper +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.^extension.ExtendWith + +@ExtendWith(InjectionExtension) +@InjectWith(ContractSpecInjectorProvider) +class ContractSpecParsingTest { + @Inject + ParseHelper parseHelper + + @Test + def void loadModel() { + val result = parseHelper.parse(''' + dummy_rule + ''') + Assertions.assertNotNull(result) + val errors = result.eResource.errors + Assertions.assertTrue(errors.isEmpty, '''Unexpected errors: «errors.join(", ")»''') + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.classpath b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.classpath new file mode 100644 index 0000000000..8ee4cf1d89 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.classpath @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.gitignore b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.gitignore new file mode 100644 index 0000000000..e75a396d4b --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.gitignore @@ -0,0 +1 @@ +/test-bin/ diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.project b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.project new file mode 100644 index 0000000000..8947b974d4 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.project @@ -0,0 +1,34 @@ + + + org.eclipse.fordiac.ide.contractspec.ui.tests + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.xtext.ui.shared.xtextNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..cc4eaa539c --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 +org.eclipse.jdt.core.compiler.compliance=21 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=21 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..91fb3852d6 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/META-INF/MANIFEST.MF @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Automatic-Module-Name: org.eclipse.fordiac.ide.contractspec.ui.tests +Bundle-ManifestVersion: 2 +Bundle-Name: org.eclipse.fordiac.ide.contractspec.ui.tests +Bundle-Vendor: Eclipse 4diac +Bundle-Version: 1.0.0.qualifier +Bundle-SymbolicName: org.eclipse.fordiac.ide.contractspec.ui.tests; singleton:=true +Bundle-ActivationPolicy: lazy +Require-Bundle: org.eclipse.fordiac.ide.contractspec.ui, + org.eclipse.xtext.testing, + org.eclipse.xtext.ui.testing, + org.eclipse.xtext.xbase.testing, + org.eclipse.xtext.xbase.ui.testing, + org.eclipse.core.runtime, + org.eclipse.ui.workbench;resolution:=optional +Import-Package: org.junit.jupiter.api;version="[5.1.0,6.0.0)", + org.junit.jupiter.api.extension;version="[5.1.0,6.0.0)" +Bundle-RequiredExecutionEnvironment: JavaSE-21 +Export-Package: org.eclipse.fordiac.ide.ui.tests;x-internal=true diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/build.properties b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/build.properties new file mode 100644 index 0000000000..5c6bbf99f0 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/build.properties @@ -0,0 +1,6 @@ +source.. = src/,\ + src-gen/,\ + xtend-gen/ +bin.includes = .,\ + META-INF/ +bin.excludes = **/*.xtend diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/src-gen/org/eclipse/fordiac/ide/ui/tests/ContractSpecUiInjectorProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/src-gen/org/eclipse/fordiac/ide/ui/tests/ContractSpecUiInjectorProvider.java new file mode 100644 index 0000000000..cec46f9ea8 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/src-gen/org/eclipse/fordiac/ide/ui/tests/ContractSpecUiInjectorProvider.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ui.tests; + +import com.google.inject.Injector; +import org.eclipse.fordiac.ide.contractspec.ui.internal.ContractspecActivator; +import org.eclipse.xtext.testing.IInjectorProvider; + +public class ContractSpecUiInjectorProvider implements IInjectorProvider { + + @Override + public Injector getInjector() { + return ContractspecActivator.getInstance().getInjector("org.eclipse.fordiac.ide.ContractSpec"); + } + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/src/org/eclipse/fordiac/ide/contractspec/ui/tests/DummyTest.xtend b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/src/org/eclipse/fordiac/ide/contractspec/ui/tests/DummyTest.xtend new file mode 100644 index 0000000000..a4f62f6269 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui.tests/src/org/eclipse/fordiac/ide/contractspec/ui/tests/DummyTest.xtend @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - fix automatic build not working + *******************************************************************************/ +package org.eclipse.fordiac.ide.contractspec.ui.tests + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Assertions + +/* At least one test is needed, otherwise the automatic build does not work. + * (maven build error: No tests found) + */ +class DummyTest { + + @Test + def void dummyTest() { + Assertions.assertEquals(true, true); + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/.classpath b/plugins/org.eclipse.fordiac.ide.contractspec.ui/.classpath new file mode 100644 index 0000000000..7994b69384 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/.project b/plugins/org.eclipse.fordiac.ide.contractspec.ui/.project new file mode 100644 index 0000000000..758059dfb5 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/.project @@ -0,0 +1,34 @@ + + + org.eclipse.fordiac.ide.contractspec.ui + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.xtext.ui.shared.xtextNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.fordiac.ide.contractspec.ui/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.fordiac.ide.contractspec.ui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..cc4eaa539c --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 +org.eclipse.jdt.core.compiler.compliance=21 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=21 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.fordiac.ide.contractspec.ui/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..caa697f64d --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/META-INF/MANIFEST.MF @@ -0,0 +1,24 @@ +Manifest-Version: 1.0 +Automatic-Module-Name: org.eclipse.fordiac.ide.contractspec.ui +Bundle-ManifestVersion: 2 +Bundle-Name: org.eclipse.fordiac.ide.contractspec.ui +Bundle-Vendor: Eclipse 4diac +Bundle-Version: 1.0.0.qualifier +Bundle-SymbolicName: org.eclipse.fordiac.ide.contractspec.ui; singleton:=true +Bundle-ActivationPolicy: lazy +Require-Bundle: org.eclipse.fordiac.ide.contractspec, + org.eclipse.fordiac.ide.contractspec.ide, + org.eclipse.xtext.ui, + org.eclipse.xtext.ui.shared, + org.eclipse.xtext.ui.codetemplates.ui, + org.eclipse.ui.editors;bundle-version="3.14.300", + org.eclipse.ui.ide;bundle-version="3.18.500", + org.eclipse.ui, + org.eclipse.compare, + org.eclipse.xtext.builder +Import-Package: org.apache.log4j +Bundle-RequiredExecutionEnvironment: JavaSE-21 +Export-Package: org.eclipse.fordiac.ide.contractspec.ui.internal, + org.eclipse.fordiac.ide.ui.contentassist, + org.eclipse.fordiac.ide.ui.quickfix +Bundle-Activator: org.eclipse.fordiac.ide.contractspec.ui.internal.ContractspecActivator diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/build.properties b/plugins/org.eclipse.fordiac.ide.contractspec.ui/build.properties new file mode 100644 index 0000000000..323f56c513 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/build.properties @@ -0,0 +1,7 @@ +source.. = src/,\ + src-gen/,\ + xtend-gen/ +bin.includes = .,\ + META-INF/,\ + plugin.xml +bin.excludes = **/*.xtend diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/plugin.xml b/plugins/org.eclipse.fordiac.ide.contractspec.ui/plugin.xml new file mode 100644 index 0000000000..9f2747e06c --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/plugin.xml @@ -0,0 +1,434 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/contractspec/ui/internal/ContractspecActivator.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/contractspec/ui/internal/ContractspecActivator.java new file mode 100644 index 0000000000..9c17a7a6da --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/contractspec/ui/internal/ContractspecActivator.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.contractspec.ui.internal; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.apache.log4j.Logger; +import org.eclipse.fordiac.ide.ContractSpecRuntimeModule; +import org.eclipse.fordiac.ide.ui.ContractSpecUiModule; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.xtext.ui.shared.SharedStateModule; +import org.eclipse.xtext.util.Modules2; +import org.osgi.framework.BundleContext; + +/** + * This class was generated. Customizations should only happen in a newly + * introduced subclass. + */ +public class ContractspecActivator extends AbstractUIPlugin { + + public static final String PLUGIN_ID = "org.eclipse.fordiac.ide.contractspec.ui"; + public static final String ORG_ECLIPSE_FORDIAC_IDE_CONTRACTSPEC = "org.eclipse.fordiac.ide.ContractSpec"; + + private static final Logger logger = Logger.getLogger(ContractspecActivator.class); + + private static ContractspecActivator INSTANCE; + + private Map injectors = Collections.synchronizedMap(new HashMap<>(2)); + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + INSTANCE = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + injectors.clear(); + INSTANCE = null; + super.stop(context); + } + + public static ContractspecActivator getInstance() { + return INSTANCE; + } + + public Injector getInjector(String language) { + synchronized (injectors) { + Injector injector = injectors.get(language); + if (injector == null) { + injectors.put(language, injector = createInjector(language)); + } + return injector; + } + } + + protected Injector createInjector(String language) { + try { + com.google.inject.Module runtimeModule = getRuntimeModule(language); + com.google.inject.Module sharedStateModule = getSharedStateModule(); + com.google.inject.Module uiModule = getUiModule(language); + com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule); + return Guice.createInjector(mergedModule); + } catch (Exception e) { + logger.error("Failed to create injector for " + language); + logger.error(e.getMessage(), e); + throw new RuntimeException("Failed to create injector for " + language, e); + } + } + + protected com.google.inject.Module getRuntimeModule(String grammar) { + if (ORG_ECLIPSE_FORDIAC_IDE_CONTRACTSPEC.equals(grammar)) { + return new ContractSpecRuntimeModule(); + } + throw new IllegalArgumentException(grammar); + } + + protected com.google.inject.Module getUiModule(String grammar) { + if (ORG_ECLIPSE_FORDIAC_IDE_CONTRACTSPEC.equals(grammar)) { + return new ContractSpecUiModule(this); + } + throw new IllegalArgumentException(grammar); + } + + protected com.google.inject.Module getSharedStateModule() { + return new SharedStateModule(); + } + + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/ui/AbstractContractSpecUiModule.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/ui/AbstractContractSpecUiModule.java new file mode 100644 index 0000000000..1be714d0e1 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/ui/AbstractContractSpecUiModule.java @@ -0,0 +1,303 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ui; + +import com.google.inject.Binder; +import com.google.inject.Provider; +import com.google.inject.name.Names; +import org.eclipse.compare.IViewerCreator; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.fordiac.ide.ide.contentassist.antlr.ContractSpecParser; +import org.eclipse.fordiac.ide.ide.contentassist.antlr.PartialContractSpecContentAssistParser; +import org.eclipse.fordiac.ide.ide.contentassist.antlr.internal.InternalContractSpecLexer; +import org.eclipse.fordiac.ide.ui.contentassist.ContractSpecProposalProvider; +import org.eclipse.fordiac.ide.ui.labeling.ContractSpecDescriptionLabelProvider; +import org.eclipse.fordiac.ide.ui.labeling.ContractSpecLabelProvider; +import org.eclipse.fordiac.ide.ui.outline.ContractSpecOutlineTreeProvider; +import org.eclipse.fordiac.ide.ui.quickfix.ContractSpecQuickfixProvider; +import org.eclipse.fordiac.ide.validation.ContractSpecValidatorConfigurationBlock; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.xtext.builder.BuilderParticipant; +import org.eclipse.xtext.builder.EclipseOutputConfigurationProvider; +import org.eclipse.xtext.builder.IXtextBuilderParticipant; +import org.eclipse.xtext.builder.builderState.IBuilderState; +import org.eclipse.xtext.builder.clustering.CurrentDescriptions; +import org.eclipse.xtext.builder.impl.PersistentDataAwareDirtyResource; +import org.eclipse.xtext.builder.nature.NatureAddingEditorCallback; +import org.eclipse.xtext.builder.preferences.BuilderPreferenceAccess; +import org.eclipse.xtext.generator.IContextualOutputConfigurationProvider; +import org.eclipse.xtext.ide.LexerIdeBindings; +import org.eclipse.xtext.ide.editor.contentassist.antlr.IContentAssistParser; +import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer; +import org.eclipse.xtext.ide.editor.partialEditing.IPartialEditingContentAssistParser; +import org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider; +import org.eclipse.xtext.parser.antlr.ITokenDefProvider; +import org.eclipse.xtext.parser.antlr.LexerProvider; +import org.eclipse.xtext.resource.IResourceDescriptions; +import org.eclipse.xtext.resource.containers.IAllContainersState; +import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider; +import org.eclipse.xtext.service.SingletonBinding; +import org.eclipse.xtext.ui.DefaultUiModule; +import org.eclipse.xtext.ui.UIBindings; +import org.eclipse.xtext.ui.codetemplates.ui.AccessibleCodetemplatesActivator; +import org.eclipse.xtext.ui.codetemplates.ui.partialEditing.IPartialEditingContentAssistContextFactory; +import org.eclipse.xtext.ui.codetemplates.ui.partialEditing.PartialEditingContentAssistContextFactory; +import org.eclipse.xtext.ui.codetemplates.ui.preferences.AdvancedTemplatesPreferencePage; +import org.eclipse.xtext.ui.codetemplates.ui.preferences.TemplatesLanguageConfiguration; +import org.eclipse.xtext.ui.codetemplates.ui.registry.LanguageRegistrar; +import org.eclipse.xtext.ui.codetemplates.ui.registry.LanguageRegistry; +import org.eclipse.xtext.ui.compare.DefaultViewerCreator; +import org.eclipse.xtext.ui.editor.DocumentBasedDirtyResource; +import org.eclipse.xtext.ui.editor.IXtextEditorCallback; +import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext; +import org.eclipse.xtext.ui.editor.contentassist.FQNPrefixMatcher; +import org.eclipse.xtext.ui.editor.contentassist.IContentProposalProvider; +import org.eclipse.xtext.ui.editor.contentassist.IProposalConflictHelper; +import org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher; +import org.eclipse.xtext.ui.editor.contentassist.antlr.AntlrProposalConflictHelper; +import org.eclipse.xtext.ui.editor.contentassist.antlr.DelegatingContentAssistContextFactory; +import org.eclipse.xtext.ui.editor.outline.IOutlineTreeProvider; +import org.eclipse.xtext.ui.editor.outline.impl.IOutlineTreeStructureProvider; +import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreInitializer; +import org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider; +import org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage; +import org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator; +import org.eclipse.xtext.ui.refactoring.IReferenceUpdater; +import org.eclipse.xtext.ui.refactoring.IRenameRefactoringProvider; +import org.eclipse.xtext.ui.refactoring.IRenameStrategy; +import org.eclipse.xtext.ui.refactoring.impl.DefaultDependentElementsCalculator; +import org.eclipse.xtext.ui.refactoring.impl.DefaultReferenceUpdater; +import org.eclipse.xtext.ui.refactoring.impl.DefaultRenameRefactoringProvider; +import org.eclipse.xtext.ui.refactoring.impl.DefaultRenameStrategy; +import org.eclipse.xtext.ui.refactoring.ui.DefaultRenameSupport; +import org.eclipse.xtext.ui.refactoring.ui.IRenameSupport; +import org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferences; +import org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider; +import org.eclipse.xtext.ui.shared.Access; +import org.eclipse.xtext.ui.validation.AbstractValidatorConfigurationBlock; + +/** + * Manual modifications go to {@link ContractSpecUiModule}. + */ +@SuppressWarnings("all") +public abstract class AbstractContractSpecUiModule extends DefaultUiModule { + + public AbstractContractSpecUiModule(AbstractUIPlugin plugin) { + super(plugin); + } + + // contributed by org.eclipse.xtext.xtext.generator.ImplicitFragment + public Provider provideIAllContainersState() { + return Access.getJavaProjectsState(); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIProposalConflictHelper() { + return AntlrProposalConflictHelper.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public void configureContentAssistLexer(Binder binder) { + binder.bind(Lexer.class) + .annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST)) + .to(InternalContractSpecLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public void configureHighlightingLexer(Binder binder) { + binder.bind(org.eclipse.xtext.parser.antlr.Lexer.class) + .annotatedWith(Names.named(LexerIdeBindings.HIGHLIGHTING)) + .to(org.eclipse.fordiac.ide.parser.antlr.internal.InternalContractSpecLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public void configureHighlightingTokenDefProvider(Binder binder) { + binder.bind(ITokenDefProvider.class) + .annotatedWith(Names.named(LexerIdeBindings.HIGHLIGHTING)) + .to(AntlrTokenDefProvider.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindContentAssistContext$Factory() { + return DelegatingContentAssistContextFactory.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIContentAssistParser() { + return ContractSpecParser.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public void configureContentAssistLexerProvider(Binder binder) { + binder.bind(InternalContractSpecLexer.class).toProvider(LexerProvider.create(InternalContractSpecLexer.class)); + } + + // contributed by org.eclipse.xtext.xtext.generator.validation.ValidatorFragment2 + public Class bindAbstractValidatorConfigurationBlock() { + return ContractSpecValidatorConfigurationBlock.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.exporting.QualifiedNamesFragment2 + public Class bindPrefixMatcher() { + return FQNPrefixMatcher.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.exporting.QualifiedNamesFragment2 + public Class bindIDependentElementsCalculator() { + return DefaultDependentElementsCalculator.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public void configureIResourceDescriptionsBuilderScope(Binder binder) { + binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE)).to(CurrentDescriptions.ResourceSetAware.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public Class bindIXtextEditorCallback() { + return NatureAddingEditorCallback.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public Class bindIContextualOutputConfigurationProvider() { + return EclipseOutputConfigurationProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public void configureIResourceDescriptionsPersisted(Binder binder) { + binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public Class bindDocumentBasedDirtyResource() { + return PersistentDataAwareDirtyResource.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.generator.GeneratorFragment2 + public Class bindIXtextBuilderParticipant() { + return BuilderParticipant.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.generator.GeneratorFragment2 + public IWorkspaceRoot bindIWorkspaceRootToInstance() { + return ResourcesPlugin.getWorkspace().getRoot(); + } + + // contributed by org.eclipse.xtext.xtext.generator.generator.GeneratorFragment2 + public void configureBuilderPreferenceStoreInitializer(Binder binder) { + binder.bind(IPreferenceStoreInitializer.class) + .annotatedWith(Names.named("builderPreferenceInitializer")) + .to(BuilderPreferenceAccess.Initializer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.labeling.LabelProviderFragment2 + public Class bindILabelProvider() { + return ContractSpecLabelProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.labeling.LabelProviderFragment2 + public void configureResourceUIServiceLabelProvider(Binder binder) { + binder.bind(ILabelProvider.class).annotatedWith(ResourceServiceDescriptionLabelProvider.class).to(ContractSpecDescriptionLabelProvider.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.outline.OutlineTreeProviderFragment2 + public Class bindIOutlineTreeProvider() { + return ContractSpecOutlineTreeProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.outline.OutlineTreeProviderFragment2 + public Class bindIOutlineTreeStructureProvider() { + return ContractSpecOutlineTreeProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.quickfix.QuickfixProviderFragment2 + public Class bindIssueResolutionProvider() { + return ContractSpecQuickfixProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.contentAssist.ContentAssistFragment2 + public Class bindIContentProposalProvider() { + return ContractSpecProposalProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.refactoring.RefactorElementNameFragment2 + public void configureIPreferenceStoreInitializer(Binder binder) { + binder.bind(IPreferenceStoreInitializer.class) + .annotatedWith(Names.named("RefactoringPreferences")) + .to(RefactoringPreferences.Initializer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.refactoring.RefactorElementNameFragment2 + public Class bindIRenameStrategy() { + return DefaultRenameStrategy.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.refactoring.RefactorElementNameFragment2 + public Class bindIReferenceUpdater() { + return DefaultReferenceUpdater.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.refactoring.RefactorElementNameFragment2 + public Class bindIRenameRefactoringProvider() { + return DefaultRenameRefactoringProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.refactoring.RefactorElementNameFragment2 + public Class bindIRenameSupport$Factory() { + return DefaultRenameSupport.Factory.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.templates.CodetemplatesGeneratorFragment2 + public Provider provideTemplatesLanguageConfiguration() { + return AccessibleCodetemplatesActivator.getTemplatesLanguageConfigurationProvider(); + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.templates.CodetemplatesGeneratorFragment2 + public Provider provideLanguageRegistry() { + return AccessibleCodetemplatesActivator.getLanguageRegistry(); + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.templates.CodetemplatesGeneratorFragment2 + @SingletonBinding(eager=true) + public Class bindLanguageRegistrar() { + return LanguageRegistrar.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.templates.CodetemplatesGeneratorFragment2 + public Class bindXtextTemplatePreferencePage() { + return AdvancedTemplatesPreferencePage.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.templates.CodetemplatesGeneratorFragment2 + public Class bindIPartialEditingContentAssistParser() { + return PartialContractSpecContentAssistParser.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.templates.CodetemplatesGeneratorFragment2 + public Class bindIPartialEditingContentAssistContextFactory() { + return PartialEditingContentAssistContextFactory.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.compare.CompareFragment2 + public Class bindIViewerCreator() { + return DefaultViewerCreator.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.ui.compare.CompareFragment2 + public void configureCompareViewerTitle(Binder binder) { + binder.bind(String.class).annotatedWith(Names.named(UIBindings.COMPARE_VIEWER_TITLE)).toInstance("ContractSpec Compare"); + } + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/ui/ContractSpecExecutableExtensionFactory.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/ui/ContractSpecExecutableExtensionFactory.java new file mode 100644 index 0000000000..bd82ee2b46 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/ui/ContractSpecExecutableExtensionFactory.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ui; + +import com.google.inject.Injector; +import org.eclipse.fordiac.ide.contractspec.ui.internal.ContractspecActivator; +import org.eclipse.xtext.ui.guice.AbstractGuiceAwareExecutableExtensionFactory; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +/** + * This class was generated. Customizations should only happen in a newly + * introduced subclass. + */ +public class ContractSpecExecutableExtensionFactory extends AbstractGuiceAwareExecutableExtensionFactory { + + @Override + protected Bundle getBundle() { + return FrameworkUtil.getBundle(ContractspecActivator.class); + } + + @Override + protected Injector getInjector() { + ContractspecActivator activator = ContractspecActivator.getInstance(); + return activator != null ? activator.getInjector(ContractspecActivator.ORG_ECLIPSE_FORDIAC_IDE_CONTRACTSPEC) : null; + } + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/ui/contentassist/AbstractContractSpecProposalProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/ui/contentassist/AbstractContractSpecProposalProvider.java new file mode 100644 index 0000000000..ee2b100c8a --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/ui/contentassist/AbstractContractSpecProposalProvider.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ui.contentassist; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.Assignment; +import org.eclipse.xtext.RuleCall; +import org.eclipse.xtext.common.ui.contentassist.TerminalsProposalProvider; +import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext; +import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor; + +/** + * Represents a generated, default implementation of superclass {@link TerminalsProposalProvider}. + * Methods are dynamically dispatched on the first parameter, i.e., you can override them + * with a more concrete subtype. + */ +public abstract class AbstractContractSpecProposalProvider extends TerminalsProposalProvider { + + public void completeModel_TimeSpec(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { + completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor); + } + + public void complete_Model(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { + // subclasses may override + } + public void complete_TimeSpec(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { + // subclasses may override + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/validation/ContractSpecValidatorConfigurationBlock.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/validation/ContractSpecValidatorConfigurationBlock.java new file mode 100644 index 0000000000..55717ae75e --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src-gen/org/eclipse/fordiac/ide/validation/ContractSpecValidatorConfigurationBlock.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.validation; + +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.xtext.ui.validation.AbstractValidatorConfigurationBlock; + +@SuppressWarnings("restriction") +public class ContractSpecValidatorConfigurationBlock extends AbstractValidatorConfigurationBlock { + + protected static final String SETTINGS_SECTION_NAME = "ContractSpec"; + + @Override + protected void fillSettingsPage(Composite composite, int nColumns, int defaultIndent) { + addComboBox(ContractSpecConfigurableIssueCodesProvider.DEPRECATED_MODEL_PART, "Deprecated Model Part", composite, defaultIndent); + } + + @Override + public void dispose() { + storeSectionExpansionStates(getDialogSettings()); + super.dispose(); + } + + @Override + protected IDialogSettings getDialogSettings() { + IDialogSettings dialogSettings = super.getDialogSettings(); + IDialogSettings section = dialogSettings.getSection(SETTINGS_SECTION_NAME); + if (section == null) { + return dialogSettings.addNewSection(SETTINGS_SECTION_NAME); + } + return section; + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/ContractSpecUiModule.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/ContractSpecUiModule.java new file mode 100644 index 0000000000..ec88204fac --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/ContractSpecUiModule.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ui; + +import org.eclipse.ui.plugin.AbstractUIPlugin; + +/** + * Use this class to register components to be used within the Eclipse IDE. + */ +public class ContractSpecUiModule extends AbstractContractSpecUiModule { + + public ContractSpecUiModule(AbstractUIPlugin plugin) { + super(plugin); + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/contentassist/ContractSpecProposalProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/contentassist/ContractSpecProposalProvider.java new file mode 100644 index 0000000000..3f79e2cf66 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/contentassist/ContractSpecProposalProvider.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ui.contentassist; + + +/** + * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#content-assist + * on how to customize the content assistant. + */ +public class ContractSpecProposalProvider extends AbstractContractSpecProposalProvider { +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/labeling/ContractSpecDescriptionLabelProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/labeling/ContractSpecDescriptionLabelProvider.java new file mode 100644 index 0000000000..a23c0f5f61 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/labeling/ContractSpecDescriptionLabelProvider.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ui.labeling; + +import org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider; + +/** + * Provides labels for IEObjectDescriptions and IResourceDescriptions. + * + * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#label-provider + */ +public class ContractSpecDescriptionLabelProvider extends DefaultDescriptionLabelProvider { + + // Labels and icons can be computed like this: +// @Override +// public String text(IEObjectDescription ele) { +// return ele.getName().toString(); +// } +// +// @Override +// public String image(IEObjectDescription ele) { +// return ele.getEClass().getName() + ".gif"; +// } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/labeling/ContractSpecLabelProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/labeling/ContractSpecLabelProvider.java new file mode 100644 index 0000000000..01ff1d64a2 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/labeling/ContractSpecLabelProvider.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ui.labeling; + +import com.google.inject.Inject; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; +import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider; + +/** + * Provides labels for EObjects. + * + * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#label-provider + */ +public class ContractSpecLabelProvider extends DefaultEObjectLabelProvider { + + @Inject + public ContractSpecLabelProvider(AdapterFactoryLabelProvider delegate) { + super(delegate); + } + + // Labels and icons can be computed like this: + +// String text(Greeting ele) { +// return "A greeting to " + ele.getName(); +// } +// +// String image(Greeting ele) { +// return "Greeting.gif"; +// } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/outline/ContractSpecOutlineTreeProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/outline/ContractSpecOutlineTreeProvider.java new file mode 100644 index 0000000000..03a2f9a913 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/outline/ContractSpecOutlineTreeProvider.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ui.outline; + +import org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider; + +/** + * Customization of the default outline structure. + * + * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#outline + */ +public class ContractSpecOutlineTreeProvider extends DefaultOutlineTreeProvider { + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/quickfix/ContractSpecQuickfixProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/quickfix/ContractSpecQuickfixProvider.java new file mode 100644 index 0000000000..f0943ac7c9 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec.ui/src/org/eclipse/fordiac/ide/ui/quickfix/ContractSpecQuickfixProvider.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.ui.quickfix; + +import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider; + +/** + * Custom quickfixes. + * + * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#quick-fixes + */ +public class ContractSpecQuickfixProvider extends DefaultQuickfixProvider { + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/.classpath b/plugins/org.eclipse.fordiac.ide.contractspec/.classpath new file mode 100644 index 0000000000..7994b69384 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/.launch/Generate ContractSpec (contract) Language Infrastructure.launch b/plugins/org.eclipse.fordiac.ide.contractspec/.launch/Generate ContractSpec (contract) Language Infrastructure.launch new file mode 100644 index 0000000000..30a5e0d287 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/.launch/Generate ContractSpec (contract) Language Infrastructure.launch @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/.launch/Launch Runtime Eclipse.launch b/plugins/org.eclipse.fordiac.ide.contractspec/.launch/Launch Runtime Eclipse.launch new file mode 100644 index 0000000000..67a8eb6932 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/.launch/Launch Runtime Eclipse.launch @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/.project b/plugins/org.eclipse.fordiac.ide.contractspec/.project new file mode 100644 index 0000000000..fcde91a17c --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/.project @@ -0,0 +1,34 @@ + + + org.eclipse.fordiac.ide.contractspec + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.xtext.ui.shared.xtextNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.fordiac.ide.contractspec/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.fordiac.ide.contractspec/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..cc4eaa539c --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 +org.eclipse.jdt.core.compiler.compliance=21 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=21 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/META-INF/MANIFEST.MF b/plugins/org.eclipse.fordiac.ide.contractspec/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..ea1728e399 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/META-INF/MANIFEST.MF @@ -0,0 +1,28 @@ +Manifest-Version: 1.0 +Automatic-Module-Name: org.eclipse.fordiac.ide.contractspec +Bundle-ManifestVersion: 2 +Bundle-Name: org.eclipse.fordiac.ide.contractspec +Bundle-Vendor: Eclipse 4diac +Bundle-Version: 1.0.0.qualifier +Bundle-SymbolicName: org.eclipse.fordiac.ide.contractspec; singleton:=true +Bundle-ActivationPolicy: lazy +Require-Bundle: org.eclipse.xtext, + org.eclipse.xtext.xbase, + org.eclipse.equinox.common;bundle-version="3.16.0", + org.eclipse.emf.ecore, + org.eclipse.xtext.xbase.lib;bundle-version="2.37.0", + org.eclipse.emf.common, + org.antlr.runtime;bundle-version="[3.2.0,3.2.1)" +Bundle-RequiredExecutionEnvironment: JavaSE-21 +Export-Package: org.eclipse.fordiac.ide.services, + org.eclipse.fordiac.ide.scoping, + org.eclipse.fordiac.ide.contractSpec.util, + org.eclipse.fordiac.ide.parser.antlr, + org.eclipse.fordiac.ide.validation, + org.eclipse.fordiac.ide, + org.eclipse.fordiac.ide.contractSpec, + org.eclipse.fordiac.ide.parser.antlr.internal, + org.eclipse.fordiac.ide.generator, + org.eclipse.fordiac.ide.contractSpec.impl, + org.eclipse.fordiac.ide.serializer +Import-Package: org.apache.log4j diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/build.properties b/plugins/org.eclipse.fordiac.ide.contractspec/build.properties new file mode 100644 index 0000000000..ad37eb74e9 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/build.properties @@ -0,0 +1,19 @@ +source.. = src/,\ + src-gen/,\ + xtend-gen/ +bin.includes = model/generated/,\ + .,\ + META-INF/,\ + plugin.xml +bin.excludes = **/*.mwe2,\ + **/*.xtend +additional.bundles = org.eclipse.xtext.xbase,\ + org.eclipse.xtext.common.types,\ + org.eclipse.xtext.xtext.generator,\ + org.eclipse.emf.codegen.ecore,\ + org.eclipse.emf.mwe.utils,\ + org.eclipse.emf.mwe2.launch,\ + org.eclipse.emf.mwe2.lib,\ + org.objectweb.asm,\ + org.apache.commons.commons-logging,\ + org.apache.log4j diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/model/generated/ContractSpec.ecore b/plugins/org.eclipse.fordiac.ide.contractspec/model/generated/ContractSpec.ecore new file mode 100644 index 0000000000..c2e90b5a71 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/model/generated/ContractSpec.ecore @@ -0,0 +1,9 @@ + + + + + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/model/generated/ContractSpec.genmodel b/plugins/org.eclipse.fordiac.ide.contractspec/model/generated/ContractSpec.genmodel new file mode 100644 index 0000000000..39b9b9aa3f --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/model/generated/ContractSpec.genmodel @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/plugin.xml b/plugins/org.eclipse.fordiac.ide.contractspec/plugin.xml new file mode 100644 index 0000000000..a63833db87 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/plugin.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/AbstractContractSpecRuntimeModule.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/AbstractContractSpecRuntimeModule.java new file mode 100644 index 0000000000..6a5b3a393a --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/AbstractContractSpecRuntimeModule.java @@ -0,0 +1,211 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide; + +import com.google.inject.Binder; +import com.google.inject.Provider; +import com.google.inject.name.Names; +import java.util.Properties; +import org.eclipse.fordiac.ide.generator.ContractSpecGenerator; +import org.eclipse.fordiac.ide.parser.antlr.ContractSpecAntlrTokenFileProvider; +import org.eclipse.fordiac.ide.parser.antlr.ContractSpecParser; +import org.eclipse.fordiac.ide.parser.antlr.internal.InternalContractSpecLexer; +import org.eclipse.fordiac.ide.scoping.ContractSpecScopeProvider; +import org.eclipse.fordiac.ide.serializer.ContractSpecSemanticSequencer; +import org.eclipse.fordiac.ide.serializer.ContractSpecSyntacticSequencer; +import org.eclipse.fordiac.ide.services.ContractSpecGrammarAccess; +import org.eclipse.fordiac.ide.validation.ContractSpecConfigurableIssueCodesProvider; +import org.eclipse.fordiac.ide.validation.ContractSpecValidator; +import org.eclipse.xtext.Constants; +import org.eclipse.xtext.IGrammarAccess; +import org.eclipse.xtext.generator.IGenerator2; +import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider; +import org.eclipse.xtext.naming.IQualifiedNameProvider; +import org.eclipse.xtext.parser.IParser; +import org.eclipse.xtext.parser.ITokenToStringConverter; +import org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider; +import org.eclipse.xtext.parser.antlr.AntlrTokenToStringConverter; +import org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider; +import org.eclipse.xtext.parser.antlr.ITokenDefProvider; +import org.eclipse.xtext.parser.antlr.Lexer; +import org.eclipse.xtext.parser.antlr.LexerBindings; +import org.eclipse.xtext.parser.antlr.LexerProvider; +import org.eclipse.xtext.resource.IContainer; +import org.eclipse.xtext.resource.IResourceDescriptions; +import org.eclipse.xtext.resource.containers.IAllContainersState; +import org.eclipse.xtext.resource.containers.ResourceSetBasedAllContainersStateProvider; +import org.eclipse.xtext.resource.containers.StateBasedContainerManager; +import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider; +import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions; +import org.eclipse.xtext.scoping.IGlobalScopeProvider; +import org.eclipse.xtext.scoping.IScopeProvider; +import org.eclipse.xtext.scoping.IgnoreCaseLinking; +import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider; +import org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider; +import org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider; +import org.eclipse.xtext.serializer.ISerializer; +import org.eclipse.xtext.serializer.impl.Serializer; +import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer; +import org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer; +import org.eclipse.xtext.service.DefaultRuntimeModule; +import org.eclipse.xtext.service.SingletonBinding; +import org.eclipse.xtext.validation.ConfigurableIssueCodesProvider; + +/** + * Manual modifications go to {@link ContractSpecRuntimeModule}. + */ +@SuppressWarnings("all") +public abstract class AbstractContractSpecRuntimeModule extends DefaultRuntimeModule { + + protected Properties properties = null; + + @Override + public void configure(Binder binder) { + properties = tryBindProperties(binder, "org/eclipse/fordiac/ide/ContractSpec.properties"); + super.configure(binder); + } + + public void configureLanguageName(Binder binder) { + binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.fordiac.ide.ContractSpec"); + } + + public void configureFileExtensions(Binder binder) { + if (properties == null || properties.getProperty(Constants.FILE_EXTENSIONS) == null) + binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("contract"); + } + + // contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2 + public ClassLoader bindClassLoaderToInstance() { + return getClass().getClassLoader(); + } + + // contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2 + public Class bindIGrammarAccess() { + return ContractSpecGrammarAccess.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISemanticSequencer() { + return ContractSpecSemanticSequencer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISyntacticSequencer() { + return ContractSpecSyntacticSequencer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISerializer() { + return Serializer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIParser() { + return ContractSpecParser.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindITokenToStringConverter() { + return AntlrTokenToStringConverter.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIAntlrTokenFileProvider() { + return ContractSpecAntlrTokenFileProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindLexer() { + return InternalContractSpecLexer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindITokenDefProvider() { + return AntlrTokenDefProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Provider provideInternalContractSpecLexer() { + return LexerProvider.create(InternalContractSpecLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public void configureRuntimeLexer(Binder binder) { + binder.bind(Lexer.class) + .annotatedWith(Names.named(LexerBindings.RUNTIME)) + .to(InternalContractSpecLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.validation.ValidatorFragment2 + @SingletonBinding(eager=true) + public Class bindContractSpecValidator() { + return ContractSpecValidator.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.validation.ValidatorFragment2 + public Class bindConfigurableIssueCodesProvider() { + return ContractSpecConfigurableIssueCodesProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2 + public Class bindIScopeProvider() { + return ContractSpecScopeProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2 + public void configureIScopeProviderDelegate(Binder binder) { + binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(ImportedNamespaceAwareLocalScopeProvider.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2 + public Class bindIGlobalScopeProvider() { + return DefaultGlobalScopeProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2 + public void configureIgnoreCaseLinking(Binder binder) { + binder.bindConstant().annotatedWith(IgnoreCaseLinking.class).to(false); + } + + // contributed by org.eclipse.xtext.xtext.generator.exporting.QualifiedNamesFragment2 + public Class bindIQualifiedNameProvider() { + return DefaultDeclarativeQualifiedNameProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public Class bindIContainer$Manager() { + return StateBasedContainerManager.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public Class bindIAllContainersState$Provider() { + return ResourceSetBasedAllContainersStateProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public void configureIResourceDescriptions(Binder binder) { + binder.bind(IResourceDescriptions.class).to(ResourceSetBasedResourceDescriptions.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public void configureIResourceDescriptionsPersisted(Binder binder) { + binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.generator.GeneratorFragment2 + public Class bindIGenerator2() { + return ContractSpecGenerator.class; + } + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/ContractSpec.xtextbin b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/ContractSpec.xtextbin new file mode 100644 index 0000000000..5db9c378c5 Binary files /dev/null and b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/ContractSpec.xtextbin differ diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/ContractSpecStandaloneSetupGenerated.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/ContractSpecStandaloneSetupGenerated.java new file mode 100644 index 0000000000..6fee2a5683 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/ContractSpecStandaloneSetupGenerated.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.fordiac.ide.contractSpec.ContractSpecPackage; +import org.eclipse.xtext.ISetup; +import org.eclipse.xtext.common.TerminalsStandaloneSetup; +import org.eclipse.xtext.resource.IResourceFactory; +import org.eclipse.xtext.resource.IResourceServiceProvider; + +@SuppressWarnings("all") +public class ContractSpecStandaloneSetupGenerated implements ISetup { + + @Override + public Injector createInjectorAndDoEMFRegistration() { + TerminalsStandaloneSetup.doSetup(); + + Injector injector = createInjector(); + register(injector); + return injector; + } + + public Injector createInjector() { + return Guice.createInjector(new ContractSpecRuntimeModule()); + } + + public void register(Injector injector) { + if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/fordiac/ide/ContractSpec")) { + EPackage.Registry.INSTANCE.put("http://www.eclipse.org/fordiac/ide/ContractSpec", ContractSpecPackage.eINSTANCE); + } + IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class); + IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class); + + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("contract", resourceFactory); + IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("contract", serviceProvider); + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/ContractSpecFactory.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/ContractSpecFactory.java new file mode 100644 index 0000000000..5fd3429404 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/ContractSpecFactory.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + */ +package org.eclipse.fordiac.ide.contractSpec; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see org.eclipse.fordiac.ide.contractSpec.ContractSpecPackage + * @generated + */ +public interface ContractSpecFactory extends EFactory +{ + /** + * The singleton instance of the factory. + * + * + * @generated + */ + ContractSpecFactory eINSTANCE = org.eclipse.fordiac.ide.contractSpec.impl.ContractSpecFactoryImpl.init(); + + /** + * Returns a new object of class 'Model'. + * + * + * @return a new object of class 'Model'. + * @generated + */ + Model createModel(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + ContractSpecPackage getContractSpecPackage(); + +} //ContractSpecFactory diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/ContractSpecPackage.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/ContractSpecPackage.java new file mode 100644 index 0000000000..9644d3066c --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/ContractSpecPackage.java @@ -0,0 +1,162 @@ +/** + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + */ +package org.eclipse.fordiac.ide.contractSpec; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see org.eclipse.fordiac.ide.contractSpec.ContractSpecFactory + * @model kind="package" + * @generated + */ +public interface ContractSpecPackage extends EPackage +{ + /** + * The package name. + * + * + * @generated + */ + String eNAME = "contractSpec"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.eclipse.org/fordiac/ide/ContractSpec"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "contractSpec"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + ContractSpecPackage eINSTANCE = org.eclipse.fordiac.ide.contractSpec.impl.ContractSpecPackageImpl.init(); + + /** + * The meta object id for the '{@link org.eclipse.fordiac.ide.contractSpec.impl.ModelImpl Model}' class. + * + * + * @see org.eclipse.fordiac.ide.contractSpec.impl.ModelImpl + * @see org.eclipse.fordiac.ide.contractSpec.impl.ContractSpecPackageImpl#getModel() + * @generated + */ + int MODEL = 0; + + /** + * The feature id for the 'Time Spec' attribute list. + * + * + * @generated + * @ordered + */ + int MODEL__TIME_SPEC = 0; + + /** + * The number of structural features of the 'Model' class. + * + * + * @generated + * @ordered + */ + int MODEL_FEATURE_COUNT = 1; + + + /** + * Returns the meta object for class '{@link org.eclipse.fordiac.ide.contractSpec.Model Model}'. + * + * + * @return the meta object for class 'Model'. + * @see org.eclipse.fordiac.ide.contractSpec.Model + * @generated + */ + EClass getModel(); + + /** + * Returns the meta object for the attribute list '{@link org.eclipse.fordiac.ide.contractSpec.Model#getTimeSpec Time Spec}'. + * + * + * @return the meta object for the attribute list 'Time Spec'. + * @see org.eclipse.fordiac.ide.contractSpec.Model#getTimeSpec() + * @see #getModel() + * @generated + */ + EAttribute getModel_TimeSpec(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + ContractSpecFactory getContractSpecFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals + { + /** + * The meta object literal for the '{@link org.eclipse.fordiac.ide.contractSpec.impl.ModelImpl Model}' class. + * + * + * @see org.eclipse.fordiac.ide.contractSpec.impl.ModelImpl + * @see org.eclipse.fordiac.ide.contractSpec.impl.ContractSpecPackageImpl#getModel() + * @generated + */ + EClass MODEL = eINSTANCE.getModel(); + + /** + * The meta object literal for the 'Time Spec' attribute list feature. + * + * + * @generated + */ + EAttribute MODEL__TIME_SPEC = eINSTANCE.getModel_TimeSpec(); + + } + +} //ContractSpecPackage diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/Model.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/Model.java new file mode 100644 index 0000000000..11ef366e5e --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/Model.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + */ +package org.eclipse.fordiac.ide.contractSpec; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Model'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.fordiac.ide.contractSpec.Model#getTimeSpec Time Spec}
  • + *
+ * + * @see org.eclipse.fordiac.ide.contractSpec.ContractSpecPackage#getModel() + * @model + * @generated + */ +public interface Model extends EObject +{ + /** + * Returns the value of the 'Time Spec' attribute list. + * The list contents are of type {@link java.lang.String}. + * + * + * @return the value of the 'Time Spec' attribute list. + * @see org.eclipse.fordiac.ide.contractSpec.ContractSpecPackage#getModel_TimeSpec() + * @model unique="false" + * @generated + */ + EList getTimeSpec(); + +} // Model diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/impl/ContractSpecFactoryImpl.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/impl/ContractSpecFactoryImpl.java new file mode 100644 index 0000000000..bb1c0ff32f --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/impl/ContractSpecFactoryImpl.java @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + */ +package org.eclipse.fordiac.ide.contractSpec.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +import org.eclipse.fordiac.ide.contractSpec.*; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class ContractSpecFactoryImpl extends EFactoryImpl implements ContractSpecFactory +{ + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static ContractSpecFactory init() + { + try + { + ContractSpecFactory theContractSpecFactory = (ContractSpecFactory)EPackage.Registry.INSTANCE.getEFactory(ContractSpecPackage.eNS_URI); + if (theContractSpecFactory != null) + { + return theContractSpecFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new ContractSpecFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public ContractSpecFactoryImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case ContractSpecPackage.MODEL: return createModel(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + @Override + public Model createModel() + { + ModelImpl model = new ModelImpl(); + return model; + } + + /** + * + * + * @generated + */ + @Override + public ContractSpecPackage getContractSpecPackage() + { + return (ContractSpecPackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static ContractSpecPackage getPackage() + { + return ContractSpecPackage.eINSTANCE; + } + +} //ContractSpecFactoryImpl diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/impl/ContractSpecPackageImpl.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/impl/ContractSpecPackageImpl.java new file mode 100644 index 0000000000..478b10241b --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/impl/ContractSpecPackageImpl.java @@ -0,0 +1,198 @@ +/** + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + */ +package org.eclipse.fordiac.ide.contractSpec.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import org.eclipse.fordiac.ide.contractSpec.ContractSpecFactory; +import org.eclipse.fordiac.ide.contractSpec.ContractSpecPackage; +import org.eclipse.fordiac.ide.contractSpec.Model; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class ContractSpecPackageImpl extends EPackageImpl implements ContractSpecPackage +{ + /** + * + * + * @generated + */ + private EClass modelEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.fordiac.ide.contractSpec.ContractSpecPackage#eNS_URI + * @see #init() + * @generated + */ + private ContractSpecPackageImpl() + { + super(eNS_URI, ContractSpecFactory.eINSTANCE); + } + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link ContractSpecPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static ContractSpecPackage init() + { + if (isInited) return (ContractSpecPackage)EPackage.Registry.INSTANCE.getEPackage(ContractSpecPackage.eNS_URI); + + // Obtain or create and register package + Object registeredContractSpecPackage = EPackage.Registry.INSTANCE.get(eNS_URI); + ContractSpecPackageImpl theContractSpecPackage = registeredContractSpecPackage instanceof ContractSpecPackageImpl ? (ContractSpecPackageImpl)registeredContractSpecPackage : new ContractSpecPackageImpl(); + + isInited = true; + + // Create package meta-data objects + theContractSpecPackage.createPackageContents(); + + // Initialize created meta-data + theContractSpecPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theContractSpecPackage.freeze(); + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(ContractSpecPackage.eNS_URI, theContractSpecPackage); + return theContractSpecPackage; + } + + /** + * + * + * @generated + */ + @Override + public EClass getModel() + { + return modelEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getModel_TimeSpec() + { + return (EAttribute)modelEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public ContractSpecFactory getContractSpecFactory() + { + return (ContractSpecFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + modelEClass = createEClass(MODEL); + createEAttribute(modelEClass, MODEL__TIME_SPEC); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initEClass(modelEClass, Model.class, "Model", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getModel_TimeSpec(), ecorePackage.getEString(), "timeSpec", null, 0, -1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //ContractSpecPackageImpl diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/impl/ModelImpl.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/impl/ModelImpl.java new file mode 100644 index 0000000000..3e5cef147e --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/impl/ModelImpl.java @@ -0,0 +1,175 @@ +/** + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + */ +package org.eclipse.fordiac.ide.contractSpec.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EDataTypeEList; + +import org.eclipse.fordiac.ide.contractSpec.ContractSpecPackage; +import org.eclipse.fordiac.ide.contractSpec.Model; + +/** + * + * An implementation of the model object 'Model'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.eclipse.fordiac.ide.contractSpec.impl.ModelImpl#getTimeSpec Time Spec}
  • + *
+ * + * @generated + */ +public class ModelImpl extends MinimalEObjectImpl.Container implements Model +{ + /** + * The cached value of the '{@link #getTimeSpec() Time Spec}' attribute list. + * + * + * @see #getTimeSpec() + * @generated + * @ordered + */ + protected EList timeSpec; + + /** + * + * + * @generated + */ + protected ModelImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return ContractSpecPackage.Literals.MODEL; + } + + /** + * + * + * @generated + */ + @Override + public EList getTimeSpec() + { + if (timeSpec == null) + { + timeSpec = new EDataTypeEList(String.class, this, ContractSpecPackage.MODEL__TIME_SPEC); + } + return timeSpec; + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ContractSpecPackage.MODEL__TIME_SPEC: + return getTimeSpec(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ContractSpecPackage.MODEL__TIME_SPEC: + getTimeSpec().clear(); + getTimeSpec().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case ContractSpecPackage.MODEL__TIME_SPEC: + getTimeSpec().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ContractSpecPackage.MODEL__TIME_SPEC: + return timeSpec != null && !timeSpec.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (timeSpec: "); + result.append(timeSpec); + result.append(')'); + return result.toString(); + } + +} //ModelImpl diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/util/ContractSpecAdapterFactory.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/util/ContractSpecAdapterFactory.java new file mode 100644 index 0000000000..397d71dead --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/util/ContractSpecAdapterFactory.java @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + */ +package org.eclipse.fordiac.ide.contractSpec.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.fordiac.ide.contractSpec.*; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see org.eclipse.fordiac.ide.contractSpec.ContractSpecPackage + * @generated + */ +public class ContractSpecAdapterFactory extends AdapterFactoryImpl +{ + /** + * The cached model package. + * + * + * @generated + */ + protected static ContractSpecPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public ContractSpecAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = ContractSpecPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) + { + if (object == modelPackage) + { + return true; + } + if (object instanceof EObject) + { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected ContractSpecSwitch modelSwitch = + new ContractSpecSwitch() + { + @Override + public Adapter caseModel(Model object) + { + return createModelAdapter(); + } + @Override + public Adapter defaultCase(EObject object) + { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) + { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.fordiac.ide.contractSpec.Model Model}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.fordiac.ide.contractSpec.Model + * @generated + */ + public Adapter createModelAdapter() + { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() + { + return null; + } + +} //ContractSpecAdapterFactory diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/util/ContractSpecSwitch.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/util/ContractSpecSwitch.java new file mode 100644 index 0000000000..443b2bf602 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/contractSpec/util/ContractSpecSwitch.java @@ -0,0 +1,130 @@ +/** + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + */ +package org.eclipse.fordiac.ide.contractSpec.util; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +import org.eclipse.fordiac.ide.contractSpec.*; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see org.eclipse.fordiac.ide.contractSpec.ContractSpecPackage + * @generated + */ +public class ContractSpecSwitch extends Switch +{ + /** + * The cached model package + * + * + * @generated + */ + protected static ContractSpecPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public ContractSpecSwitch() + { + if (modelPackage == null) + { + modelPackage = ContractSpecPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) + { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case ContractSpecPackage.MODEL: + { + Model model = (Model)theEObject; + T result = caseModel(model); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Model'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Model'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseModel(Model object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) + { + return null; + } + +} //ContractSpecSwitch diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/ContractSpecAntlrTokenFileProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/ContractSpecAntlrTokenFileProvider.java new file mode 100644 index 0000000000..a7bbe9fc26 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/ContractSpecAntlrTokenFileProvider.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.parser.antlr; + +import java.io.InputStream; +import org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider; + +public class ContractSpecAntlrTokenFileProvider implements IAntlrTokenFileProvider { + + @Override + public InputStream getAntlrTokenFile() { + ClassLoader classLoader = getClass().getClassLoader(); + return classLoader.getResourceAsStream("org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpec.tokens"); + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/ContractSpecParser.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/ContractSpecParser.java new file mode 100644 index 0000000000..bc5f5a5f3c --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/ContractSpecParser.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.parser.antlr; + +import com.google.inject.Inject; +import org.eclipse.fordiac.ide.parser.antlr.internal.InternalContractSpecParser; +import org.eclipse.fordiac.ide.services.ContractSpecGrammarAccess; +import org.eclipse.xtext.parser.antlr.AbstractAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; + +public class ContractSpecParser extends AbstractAntlrParser { + + @Inject + private ContractSpecGrammarAccess grammarAccess; + + @Override + protected void setInitialHiddenTokens(XtextTokenStream tokenStream) { + tokenStream.setInitialHiddenTokens("RULE_WS", "RULE_ML_COMMENT", "RULE_SL_COMMENT"); + } + + + @Override + protected InternalContractSpecParser createParser(XtextTokenStream stream) { + return new InternalContractSpecParser(stream, getGrammarAccess()); + } + + @Override + protected String getDefaultRuleName() { + return "Model"; + } + + public ContractSpecGrammarAccess getGrammarAccess() { + return this.grammarAccess; + } + + public void setGrammarAccess(ContractSpecGrammarAccess grammarAccess) { + this.grammarAccess = grammarAccess; + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpec.g b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpec.g new file mode 100644 index 0000000000..d5fa7dd283 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpec.g @@ -0,0 +1,143 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +grammar InternalContractSpec; + +options { + superClass=AbstractInternalAntlrParser; +} + +@lexer::header { +package org.eclipse.fordiac.ide.parser.antlr.internal; + +// Hack: Use our own Lexer superclass by means of import. +// Currently there is no other way to specify the superclass for the lexer. +import org.eclipse.xtext.parser.antlr.Lexer; +} + +@parser::header { +package org.eclipse.fordiac.ide.parser.antlr.internal; + +import org.eclipse.xtext.*; +import org.eclipse.xtext.parser.*; +import org.eclipse.xtext.parser.impl.*; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; +import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken; +import org.eclipse.fordiac.ide.services.ContractSpecGrammarAccess; + +} + +@parser::members { + + private ContractSpecGrammarAccess grammarAccess; + + public InternalContractSpecParser(TokenStream input, ContractSpecGrammarAccess grammarAccess) { + this(input); + this.grammarAccess = grammarAccess; + registerRules(grammarAccess.getGrammar()); + } + + @Override + protected String getFirstRuleName() { + return "Model"; + } + + @Override + protected ContractSpecGrammarAccess getGrammarAccess() { + return grammarAccess; + } + +} + +@rulecatch { + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } +} + +// Entry rule entryRuleModel +entryRuleModel returns [EObject current=null]: + { newCompositeNode(grammarAccess.getModelRule()); } + iv_ruleModel=ruleModel + { $current=$iv_ruleModel.current; } + EOF; + +// Rule Model +ruleModel returns [EObject current=null] +@init { + enterRule(); +} +@after { + leaveRule(); +}: + ( + ( + { + newCompositeNode(grammarAccess.getModelAccess().getTimeSpecTimeSpecParserRuleCall_0()); + } + lv_timeSpec_0_0=ruleTimeSpec + { + if ($current==null) { + $current = createModelElementForParent(grammarAccess.getModelRule()); + } + add( + $current, + "timeSpec", + lv_timeSpec_0_0, + "org.eclipse.fordiac.ide.ContractSpec.TimeSpec"); + afterParserOrEnumRuleCall(); + } + ) + )* +; + +// Entry rule entryRuleTimeSpec +entryRuleTimeSpec returns [String current=null]: + { newCompositeNode(grammarAccess.getTimeSpecRule()); } + iv_ruleTimeSpec=ruleTimeSpec + { $current=$iv_ruleTimeSpec.current.getText(); } + EOF; + +// Rule TimeSpec +ruleTimeSpec returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()] +@init { + enterRule(); +} +@after { + leaveRule(); +}: + kw='dummy_rule' + { + $current.merge(kw); + newLeafNode(kw, grammarAccess.getTimeSpecAccess().getDummy_ruleKeyword()); + } +; + +RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; + +RULE_INT : ('0'..'9')+; + +RULE_STRING : ('"' ('\\' .|~(('\\'|'"')))* '"'|'\'' ('\\' .|~(('\\'|'\'')))* '\''); + +RULE_ML_COMMENT : '/*' ( options {greedy=false;} : . )*'*/'; + +RULE_SL_COMMENT : '//' ~(('\n'|'\r'))* ('\r'? '\n')?; + +RULE_WS : (' '|'\t'|'\r'|'\n')+; + +RULE_ANY_OTHER : .; diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpec.tokens b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpec.tokens new file mode 100644 index 0000000000..78bfe28563 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpec.tokens @@ -0,0 +1,9 @@ +'dummy_rule'=11 +RULE_ANY_OTHER=10 +RULE_ID=4 +RULE_INT=5 +RULE_ML_COMMENT=7 +RULE_SL_COMMENT=8 +RULE_STRING=6 +RULE_WS=9 +T__11=11 diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpecLexer.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpecLexer.java new file mode 100644 index 0000000000..4b6927bc33 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpecLexer.java @@ -0,0 +1,755 @@ +package org.eclipse.fordiac.ide.parser.antlr.internal; + +// Hack: Use our own Lexer superclass by means of import. +// Currently there is no other way to specify the superclass for the lexer. +import org.eclipse.xtext.parser.antlr.Lexer; + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +@SuppressWarnings("all") +public class InternalContractSpecLexer extends Lexer { + public static final int RULE_ID=4; + public static final int RULE_WS=9; + public static final int RULE_STRING=6; + public static final int RULE_ANY_OTHER=10; + public static final int RULE_SL_COMMENT=8; + public static final int RULE_INT=5; + public static final int T__11=11; + public static final int RULE_ML_COMMENT=7; + public static final int EOF=-1; + + // delegates + // delegators + + public InternalContractSpecLexer() {;} + public InternalContractSpecLexer(CharStream input) { + this(input, new RecognizerSharedState()); + } + public InternalContractSpecLexer(CharStream input, RecognizerSharedState state) { + super(input,state); + + } + public String getGrammarFileName() { return "InternalContractSpec.g"; } + + // $ANTLR start "T__11" + public final void mT__11() throws RecognitionException { + try { + int _type = T__11; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:11:7: ( 'dummy_rule' ) + // InternalContractSpec.g:11:9: 'dummy_rule' + { + match("dummy_rule"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__11" + + // $ANTLR start "RULE_ID" + public final void mRULE_ID() throws RecognitionException { + try { + int _type = RULE_ID; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:131:9: ( ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* ) + // InternalContractSpec.g:131:11: ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + { + // InternalContractSpec.g:131:11: ( '^' )? + int alt1=2; + int LA1_0 = input.LA(1); + + if ( (LA1_0=='^') ) { + alt1=1; + } + switch (alt1) { + case 1 : + // InternalContractSpec.g:131:11: '^' + { + match('^'); + + } + break; + + } + + if ( (input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + // InternalContractSpec.g:131:40: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + loop2: + do { + int alt2=2; + int LA2_0 = input.LA(1); + + if ( ((LA2_0>='0' && LA2_0<='9')||(LA2_0>='A' && LA2_0<='Z')||LA2_0=='_'||(LA2_0>='a' && LA2_0<='z')) ) { + alt2=1; + } + + + switch (alt2) { + case 1 : + // InternalContractSpec.g: + { + if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop2; + } + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ID" + + // $ANTLR start "RULE_INT" + public final void mRULE_INT() throws RecognitionException { + try { + int _type = RULE_INT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:133:10: ( ( '0' .. '9' )+ ) + // InternalContractSpec.g:133:12: ( '0' .. '9' )+ + { + // InternalContractSpec.g:133:12: ( '0' .. '9' )+ + int cnt3=0; + loop3: + do { + int alt3=2; + int LA3_0 = input.LA(1); + + if ( ((LA3_0>='0' && LA3_0<='9')) ) { + alt3=1; + } + + + switch (alt3) { + case 1 : + // InternalContractSpec.g:133:13: '0' .. '9' + { + matchRange('0','9'); + + } + break; + + default : + if ( cnt3 >= 1 ) break loop3; + EarlyExitException eee = + new EarlyExitException(3, input); + throw eee; + } + cnt3++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_INT" + + // $ANTLR start "RULE_STRING" + public final void mRULE_STRING() throws RecognitionException { + try { + int _type = RULE_STRING; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:135:13: ( ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) ) + // InternalContractSpec.g:135:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) + { + // InternalContractSpec.g:135:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) + int alt6=2; + int LA6_0 = input.LA(1); + + if ( (LA6_0=='\"') ) { + alt6=1; + } + else if ( (LA6_0=='\'') ) { + alt6=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 6, 0, input); + + throw nvae; + } + switch (alt6) { + case 1 : + // InternalContractSpec.g:135:16: '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' + { + match('\"'); + // InternalContractSpec.g:135:20: ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* + loop4: + do { + int alt4=3; + int LA4_0 = input.LA(1); + + if ( (LA4_0=='\\') ) { + alt4=1; + } + else if ( ((LA4_0>='\u0000' && LA4_0<='!')||(LA4_0>='#' && LA4_0<='[')||(LA4_0>=']' && LA4_0<='\uFFFF')) ) { + alt4=2; + } + + + switch (alt4) { + case 1 : + // InternalContractSpec.g:135:21: '\\\\' . + { + match('\\'); + matchAny(); + + } + break; + case 2 : + // InternalContractSpec.g:135:28: ~ ( ( '\\\\' | '\"' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='!')||(input.LA(1)>='#' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop4; + } + } while (true); + + match('\"'); + + } + break; + case 2 : + // InternalContractSpec.g:135:48: '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' + { + match('\''); + // InternalContractSpec.g:135:53: ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* + loop5: + do { + int alt5=3; + int LA5_0 = input.LA(1); + + if ( (LA5_0=='\\') ) { + alt5=1; + } + else if ( ((LA5_0>='\u0000' && LA5_0<='&')||(LA5_0>='(' && LA5_0<='[')||(LA5_0>=']' && LA5_0<='\uFFFF')) ) { + alt5=2; + } + + + switch (alt5) { + case 1 : + // InternalContractSpec.g:135:54: '\\\\' . + { + match('\\'); + matchAny(); + + } + break; + case 2 : + // InternalContractSpec.g:135:61: ~ ( ( '\\\\' | '\\'' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='&')||(input.LA(1)>='(' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop5; + } + } while (true); + + match('\''); + + } + break; + + } + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_STRING" + + // $ANTLR start "RULE_ML_COMMENT" + public final void mRULE_ML_COMMENT() throws RecognitionException { + try { + int _type = RULE_ML_COMMENT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:137:17: ( '/*' ( options {greedy=false; } : . )* '*/' ) + // InternalContractSpec.g:137:19: '/*' ( options {greedy=false; } : . )* '*/' + { + match("/*"); + + // InternalContractSpec.g:137:24: ( options {greedy=false; } : . )* + loop7: + do { + int alt7=2; + int LA7_0 = input.LA(1); + + if ( (LA7_0=='*') ) { + int LA7_1 = input.LA(2); + + if ( (LA7_1=='/') ) { + alt7=2; + } + else if ( ((LA7_1>='\u0000' && LA7_1<='.')||(LA7_1>='0' && LA7_1<='\uFFFF')) ) { + alt7=1; + } + + + } + else if ( ((LA7_0>='\u0000' && LA7_0<=')')||(LA7_0>='+' && LA7_0<='\uFFFF')) ) { + alt7=1; + } + + + switch (alt7) { + case 1 : + // InternalContractSpec.g:137:52: . + { + matchAny(); + + } + break; + + default : + break loop7; + } + } while (true); + + match("*/"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ML_COMMENT" + + // $ANTLR start "RULE_SL_COMMENT" + public final void mRULE_SL_COMMENT() throws RecognitionException { + try { + int _type = RULE_SL_COMMENT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:139:17: ( '//' (~ ( ( '\\n' | '\\r' ) ) )* ( ( '\\r' )? '\\n' )? ) + // InternalContractSpec.g:139:19: '//' (~ ( ( '\\n' | '\\r' ) ) )* ( ( '\\r' )? '\\n' )? + { + match("//"); + + // InternalContractSpec.g:139:24: (~ ( ( '\\n' | '\\r' ) ) )* + loop8: + do { + int alt8=2; + int LA8_0 = input.LA(1); + + if ( ((LA8_0>='\u0000' && LA8_0<='\t')||(LA8_0>='\u000B' && LA8_0<='\f')||(LA8_0>='\u000E' && LA8_0<='\uFFFF')) ) { + alt8=1; + } + + + switch (alt8) { + case 1 : + // InternalContractSpec.g:139:24: ~ ( ( '\\n' | '\\r' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='\t')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop8; + } + } while (true); + + // InternalContractSpec.g:139:40: ( ( '\\r' )? '\\n' )? + int alt10=2; + int LA10_0 = input.LA(1); + + if ( (LA10_0=='\n'||LA10_0=='\r') ) { + alt10=1; + } + switch (alt10) { + case 1 : + // InternalContractSpec.g:139:41: ( '\\r' )? '\\n' + { + // InternalContractSpec.g:139:41: ( '\\r' )? + int alt9=2; + int LA9_0 = input.LA(1); + + if ( (LA9_0=='\r') ) { + alt9=1; + } + switch (alt9) { + case 1 : + // InternalContractSpec.g:139:41: '\\r' + { + match('\r'); + + } + break; + + } + + match('\n'); + + } + break; + + } + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_SL_COMMENT" + + // $ANTLR start "RULE_WS" + public final void mRULE_WS() throws RecognitionException { + try { + int _type = RULE_WS; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:141:9: ( ( ' ' | '\\t' | '\\r' | '\\n' )+ ) + // InternalContractSpec.g:141:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ + { + // InternalContractSpec.g:141:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ + int cnt11=0; + loop11: + do { + int alt11=2; + int LA11_0 = input.LA(1); + + if ( ((LA11_0>='\t' && LA11_0<='\n')||LA11_0=='\r'||LA11_0==' ') ) { + alt11=1; + } + + + switch (alt11) { + case 1 : + // InternalContractSpec.g: + { + if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + if ( cnt11 >= 1 ) break loop11; + EarlyExitException eee = + new EarlyExitException(11, input); + throw eee; + } + cnt11++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_WS" + + // $ANTLR start "RULE_ANY_OTHER" + public final void mRULE_ANY_OTHER() throws RecognitionException { + try { + int _type = RULE_ANY_OTHER; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalContractSpec.g:143:16: ( . ) + // InternalContractSpec.g:143:18: . + { + matchAny(); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ANY_OTHER" + + public void mTokens() throws RecognitionException { + // InternalContractSpec.g:1:8: ( T__11 | RULE_ID | RULE_INT | RULE_STRING | RULE_ML_COMMENT | RULE_SL_COMMENT | RULE_WS | RULE_ANY_OTHER ) + int alt12=8; + alt12 = dfa12.predict(input); + switch (alt12) { + case 1 : + // InternalContractSpec.g:1:10: T__11 + { + mT__11(); + + } + break; + case 2 : + // InternalContractSpec.g:1:16: RULE_ID + { + mRULE_ID(); + + } + break; + case 3 : + // InternalContractSpec.g:1:24: RULE_INT + { + mRULE_INT(); + + } + break; + case 4 : + // InternalContractSpec.g:1:33: RULE_STRING + { + mRULE_STRING(); + + } + break; + case 5 : + // InternalContractSpec.g:1:45: RULE_ML_COMMENT + { + mRULE_ML_COMMENT(); + + } + break; + case 6 : + // InternalContractSpec.g:1:61: RULE_SL_COMMENT + { + mRULE_SL_COMMENT(); + + } + break; + case 7 : + // InternalContractSpec.g:1:77: RULE_WS + { + mRULE_WS(); + + } + break; + case 8 : + // InternalContractSpec.g:1:85: RULE_ANY_OTHER + { + mRULE_ANY_OTHER(); + + } + break; + + } + + } + + + protected DFA12 dfa12 = new DFA12(this); + static final String DFA12_eotS = + "\1\uffff\1\13\1\11\2\uffff\3\11\2\uffff\1\13\6\uffff\7\13\1\31\1\uffff"; + static final String DFA12_eofS = + "\32\uffff"; + static final String DFA12_minS = + "\1\0\1\165\1\101\2\uffff\2\0\1\52\2\uffff\1\155\6\uffff\1\155\1\171\1\137\1\162\1\165\1\154\1\145\1\60\1\uffff"; + static final String DFA12_maxS = + "\1\uffff\1\165\1\172\2\uffff\2\uffff\1\57\2\uffff\1\155\6\uffff\1\155\1\171\1\137\1\162\1\165\1\154\1\145\1\172\1\uffff"; + static final String DFA12_acceptS = + "\3\uffff\1\2\1\3\3\uffff\1\7\1\10\1\uffff\1\2\1\3\1\4\1\5\1\6\1\7\10\uffff\1\1"; + static final String DFA12_specialS = + "\1\0\4\uffff\1\1\1\2\23\uffff}>"; + static final String[] DFA12_transitionS = { + "\11\11\2\10\2\11\1\10\22\11\1\10\1\11\1\5\4\11\1\6\7\11\1\7\12\4\7\11\32\3\3\11\1\2\1\3\1\11\3\3\1\1\26\3\uff85\11", + "\1\12", + "\32\13\4\uffff\1\13\1\uffff\32\13", + "", + "", + "\0\15", + "\0\15", + "\1\16\4\uffff\1\17", + "", + "", + "\1\21", + "", + "", + "", + "", + "", + "", + "\1\22", + "\1\23", + "\1\24", + "\1\25", + "\1\26", + "\1\27", + "\1\30", + "\12\13\7\uffff\32\13\4\uffff\1\13\1\uffff\32\13", + "" + }; + + static final short[] DFA12_eot = DFA.unpackEncodedString(DFA12_eotS); + static final short[] DFA12_eof = DFA.unpackEncodedString(DFA12_eofS); + static final char[] DFA12_min = DFA.unpackEncodedStringToUnsignedChars(DFA12_minS); + static final char[] DFA12_max = DFA.unpackEncodedStringToUnsignedChars(DFA12_maxS); + static final short[] DFA12_accept = DFA.unpackEncodedString(DFA12_acceptS); + static final short[] DFA12_special = DFA.unpackEncodedString(DFA12_specialS); + static final short[][] DFA12_transition; + + static { + int numStates = DFA12_transitionS.length; + DFA12_transition = new short[numStates][]; + for (int i=0; i='A' && LA12_0<='Z')||LA12_0=='_'||(LA12_0>='a' && LA12_0<='c')||(LA12_0>='e' && LA12_0<='z')) ) {s = 3;} + + else if ( ((LA12_0>='0' && LA12_0<='9')) ) {s = 4;} + + else if ( (LA12_0=='\"') ) {s = 5;} + + else if ( (LA12_0=='\'') ) {s = 6;} + + else if ( (LA12_0=='/') ) {s = 7;} + + else if ( ((LA12_0>='\t' && LA12_0<='\n')||LA12_0=='\r'||LA12_0==' ') ) {s = 8;} + + else if ( ((LA12_0>='\u0000' && LA12_0<='\b')||(LA12_0>='\u000B' && LA12_0<='\f')||(LA12_0>='\u000E' && LA12_0<='\u001F')||LA12_0=='!'||(LA12_0>='#' && LA12_0<='&')||(LA12_0>='(' && LA12_0<='.')||(LA12_0>=':' && LA12_0<='@')||(LA12_0>='[' && LA12_0<=']')||LA12_0=='`'||(LA12_0>='{' && LA12_0<='\uFFFF')) ) {s = 9;} + + if ( s>=0 ) return s; + break; + case 1 : + int LA12_5 = input.LA(1); + + s = -1; + if ( ((LA12_5>='\u0000' && LA12_5<='\uFFFF')) ) {s = 13;} + + else s = 9; + + if ( s>=0 ) return s; + break; + case 2 : + int LA12_6 = input.LA(1); + + s = -1; + if ( ((LA12_6>='\u0000' && LA12_6<='\uFFFF')) ) {s = 13;} + + else s = 9; + + if ( s>=0 ) return s; + break; + } + NoViableAltException nvae = + new NoViableAltException(getDescription(), 12, _s, input); + error(nvae); + throw nvae; + } + } + + +} \ No newline at end of file diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpecParser.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpecParser.java new file mode 100644 index 0000000000..bbb9b11d7e --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/parser/antlr/internal/InternalContractSpecParser.java @@ -0,0 +1,289 @@ +package org.eclipse.fordiac.ide.parser.antlr.internal; + +import org.eclipse.xtext.*; +import org.eclipse.xtext.parser.*; +import org.eclipse.xtext.parser.impl.*; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; +import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken; +import org.eclipse.fordiac.ide.services.ContractSpecGrammarAccess; + + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +@SuppressWarnings("all") +public class InternalContractSpecParser extends AbstractInternalAntlrParser { + public static final String[] tokenNames = new String[] { + "", "", "", "", "RULE_ID", "RULE_INT", "RULE_STRING", "RULE_ML_COMMENT", "RULE_SL_COMMENT", "RULE_WS", "RULE_ANY_OTHER", "'dummy_rule'" + }; + public static final int RULE_ID=4; + public static final int RULE_WS=9; + public static final int RULE_STRING=6; + public static final int RULE_ANY_OTHER=10; + public static final int RULE_SL_COMMENT=8; + public static final int RULE_INT=5; + public static final int T__11=11; + public static final int RULE_ML_COMMENT=7; + public static final int EOF=-1; + + // delegates + // delegators + + + public InternalContractSpecParser(TokenStream input) { + this(input, new RecognizerSharedState()); + } + public InternalContractSpecParser(TokenStream input, RecognizerSharedState state) { + super(input, state); + + } + + + public String[] getTokenNames() { return InternalContractSpecParser.tokenNames; } + public String getGrammarFileName() { return "InternalContractSpec.g"; } + + + + private ContractSpecGrammarAccess grammarAccess; + + public InternalContractSpecParser(TokenStream input, ContractSpecGrammarAccess grammarAccess) { + this(input); + this.grammarAccess = grammarAccess; + registerRules(grammarAccess.getGrammar()); + } + + @Override + protected String getFirstRuleName() { + return "Model"; + } + + @Override + protected ContractSpecGrammarAccess getGrammarAccess() { + return grammarAccess; + } + + + + + // $ANTLR start "entryRuleModel" + // InternalContractSpec.g:74:1: entryRuleModel returns [EObject current=null] : iv_ruleModel= ruleModel EOF ; + public final EObject entryRuleModel() throws RecognitionException { + EObject current = null; + + EObject iv_ruleModel = null; + + + try { + // InternalContractSpec.g:74:46: (iv_ruleModel= ruleModel EOF ) + // InternalContractSpec.g:75:2: iv_ruleModel= ruleModel EOF + { + newCompositeNode(grammarAccess.getModelRule()); + pushFollow(FOLLOW_1); + iv_ruleModel=ruleModel(); + + state._fsp--; + + current =iv_ruleModel; + match(input,EOF,FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleModel" + + + // $ANTLR start "ruleModel" + // InternalContractSpec.g:81:1: ruleModel returns [EObject current=null] : ( (lv_timeSpec_0_0= ruleTimeSpec ) )* ; + public final EObject ruleModel() throws RecognitionException { + EObject current = null; + + AntlrDatatypeRuleToken lv_timeSpec_0_0 = null; + + + + enterRule(); + + try { + // InternalContractSpec.g:87:2: ( ( (lv_timeSpec_0_0= ruleTimeSpec ) )* ) + // InternalContractSpec.g:88:2: ( (lv_timeSpec_0_0= ruleTimeSpec ) )* + { + // InternalContractSpec.g:88:2: ( (lv_timeSpec_0_0= ruleTimeSpec ) )* + loop1: + do { + int alt1=2; + int LA1_0 = input.LA(1); + + if ( (LA1_0==11) ) { + alt1=1; + } + + + switch (alt1) { + case 1 : + // InternalContractSpec.g:89:3: (lv_timeSpec_0_0= ruleTimeSpec ) + { + // InternalContractSpec.g:89:3: (lv_timeSpec_0_0= ruleTimeSpec ) + // InternalContractSpec.g:90:4: lv_timeSpec_0_0= ruleTimeSpec + { + + newCompositeNode(grammarAccess.getModelAccess().getTimeSpecTimeSpecParserRuleCall_0()); + + pushFollow(FOLLOW_3); + lv_timeSpec_0_0=ruleTimeSpec(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getModelRule()); + } + add( + current, + "timeSpec", + lv_timeSpec_0_0, + "org.eclipse.fordiac.ide.ContractSpec.TimeSpec"); + afterParserOrEnumRuleCall(); + + + } + + + } + break; + + default : + break loop1; + } + } while (true); + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleModel" + + + // $ANTLR start "entryRuleTimeSpec" + // InternalContractSpec.g:110:1: entryRuleTimeSpec returns [String current=null] : iv_ruleTimeSpec= ruleTimeSpec EOF ; + public final String entryRuleTimeSpec() throws RecognitionException { + String current = null; + + AntlrDatatypeRuleToken iv_ruleTimeSpec = null; + + + try { + // InternalContractSpec.g:110:48: (iv_ruleTimeSpec= ruleTimeSpec EOF ) + // InternalContractSpec.g:111:2: iv_ruleTimeSpec= ruleTimeSpec EOF + { + newCompositeNode(grammarAccess.getTimeSpecRule()); + pushFollow(FOLLOW_1); + iv_ruleTimeSpec=ruleTimeSpec(); + + state._fsp--; + + current =iv_ruleTimeSpec.getText(); + match(input,EOF,FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleTimeSpec" + + + // $ANTLR start "ruleTimeSpec" + // InternalContractSpec.g:117:1: ruleTimeSpec returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()] : kw= 'dummy_rule' ; + public final AntlrDatatypeRuleToken ruleTimeSpec() throws RecognitionException { + AntlrDatatypeRuleToken current = new AntlrDatatypeRuleToken(); + + Token kw=null; + + + enterRule(); + + try { + // InternalContractSpec.g:123:2: (kw= 'dummy_rule' ) + // InternalContractSpec.g:124:2: kw= 'dummy_rule' + { + kw=(Token)match(input,11,FOLLOW_2); + + current.merge(kw); + newLeafNode(kw, grammarAccess.getTimeSpecAccess().getDummy_ruleKeyword()); + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleTimeSpec" + + // Delegated rules + + + + + public static final BitSet FOLLOW_1 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_2 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_3 = new BitSet(new long[]{0x0000000000000802L}); + +} \ No newline at end of file diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/scoping/AbstractContractSpecScopeProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/scoping/AbstractContractSpecScopeProvider.java new file mode 100644 index 0000000000..15a811ee9d --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/scoping/AbstractContractSpecScopeProvider.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.scoping; + +import org.eclipse.xtext.scoping.impl.DelegatingScopeProvider; + +public abstract class AbstractContractSpecScopeProvider extends DelegatingScopeProvider { +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/serializer/ContractSpecSemanticSequencer.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/serializer/ContractSpecSemanticSequencer.java new file mode 100644 index 0000000000..6e1c3cffff --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/serializer/ContractSpecSemanticSequencer.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.serializer; + +import com.google.inject.Inject; +import java.util.Set; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.fordiac.ide.contractSpec.ContractSpecPackage; +import org.eclipse.fordiac.ide.contractSpec.Model; +import org.eclipse.fordiac.ide.services.ContractSpecGrammarAccess; +import org.eclipse.xtext.Action; +import org.eclipse.xtext.Parameter; +import org.eclipse.xtext.ParserRule; +import org.eclipse.xtext.serializer.ISerializationContext; +import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer; + +@SuppressWarnings("all") +public class ContractSpecSemanticSequencer extends AbstractDelegatingSemanticSequencer { + + @Inject + private ContractSpecGrammarAccess grammarAccess; + + @Override + public void sequence(ISerializationContext context, EObject semanticObject) { + EPackage epackage = semanticObject.eClass().getEPackage(); + ParserRule rule = context.getParserRule(); + Action action = context.getAssignedAction(); + Set parameters = context.getEnabledBooleanParameters(); + if (epackage == ContractSpecPackage.eINSTANCE) + switch (semanticObject.eClass().getClassifierID()) { + case ContractSpecPackage.MODEL: + sequence_Model(context, (Model) semanticObject); + return; + } + if (errorAcceptor != null) + errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context)); + } + + /** + *
+	 * Contexts:
+	 *     Model returns Model
+	 *
+	 * Constraint:
+	 *     timeSpec+=TimeSpec+
+	 * 
+ */ + protected void sequence_Model(ISerializationContext context, Model semanticObject) { + genericSequencer.createSequence(context, semanticObject); + } + + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/serializer/ContractSpecSyntacticSequencer.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/serializer/ContractSpecSyntacticSequencer.java new file mode 100644 index 0000000000..b6a6564f4c --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/serializer/ContractSpecSyntacticSequencer.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.serializer; + +import com.google.inject.Inject; +import java.util.List; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.fordiac.ide.services.ContractSpecGrammarAccess; +import org.eclipse.xtext.IGrammarAccess; +import org.eclipse.xtext.RuleCall; +import org.eclipse.xtext.nodemodel.INode; +import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias; +import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition; +import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer; + +@SuppressWarnings("all") +public class ContractSpecSyntacticSequencer extends AbstractSyntacticSequencer { + + protected ContractSpecGrammarAccess grammarAccess; + + @Inject + protected void init(IGrammarAccess access) { + grammarAccess = (ContractSpecGrammarAccess) access; + } + + @Override + protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { + return ""; + } + + + @Override + protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) { + if (transition.getAmbiguousSyntaxes().isEmpty()) return; + List transitionNodes = collectNodes(fromNode, toNode); + for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) { + List syntaxNodes = getNodesFor(transitionNodes, syntax); + acceptNodes(getLastNavigableState(), syntaxNodes); + } + } + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/services/ContractSpecGrammarAccess.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/services/ContractSpecGrammarAccess.java new file mode 100644 index 0000000000..fab036d13a --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/services/ContractSpecGrammarAccess.java @@ -0,0 +1,161 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.services; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.util.List; +import org.eclipse.xtext.Assignment; +import org.eclipse.xtext.Grammar; +import org.eclipse.xtext.GrammarUtil; +import org.eclipse.xtext.Keyword; +import org.eclipse.xtext.ParserRule; +import org.eclipse.xtext.RuleCall; +import org.eclipse.xtext.TerminalRule; +import org.eclipse.xtext.common.services.TerminalsGrammarAccess; +import org.eclipse.xtext.service.AbstractElementFinder; +import org.eclipse.xtext.service.GrammarProvider; + +@Singleton +public class ContractSpecGrammarAccess extends AbstractElementFinder.AbstractGrammarElementFinder { + + public class ModelElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.fordiac.ide.ContractSpec.Model"); + private final Assignment cTimeSpecAssignment = (Assignment)rule.eContents().get(1); + private final RuleCall cTimeSpecTimeSpecParserRuleCall_0 = (RuleCall)cTimeSpecAssignment.eContents().get(0); + + //Model: + // timeSpec+=TimeSpec*; + @Override public ParserRule getRule() { return rule; } + + //timeSpec+=TimeSpec* + public Assignment getTimeSpecAssignment() { return cTimeSpecAssignment; } + + //TimeSpec + public RuleCall getTimeSpecTimeSpecParserRuleCall_0() { return cTimeSpecTimeSpecParserRuleCall_0; } + } + public class TimeSpecElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.fordiac.ide.ContractSpec.TimeSpec"); + private final Keyword cDummy_ruleKeyword = (Keyword)rule.eContents().get(1); + + //TimeSpec: + // 'dummy_rule'; + @Override public ParserRule getRule() { return rule; } + + //'dummy_rule' + public Keyword getDummy_ruleKeyword() { return cDummy_ruleKeyword; } + } + + + private final ModelElements pModel; + private final TimeSpecElements pTimeSpec; + + private final Grammar grammar; + + private final TerminalsGrammarAccess gaTerminals; + + @Inject + public ContractSpecGrammarAccess(GrammarProvider grammarProvider, + TerminalsGrammarAccess gaTerminals) { + this.grammar = internalFindGrammar(grammarProvider); + this.gaTerminals = gaTerminals; + this.pModel = new ModelElements(); + this.pTimeSpec = new TimeSpecElements(); + } + + protected Grammar internalFindGrammar(GrammarProvider grammarProvider) { + Grammar grammar = grammarProvider.getGrammar(this); + while (grammar != null) { + if ("org.eclipse.fordiac.ide.ContractSpec".equals(grammar.getName())) { + return grammar; + } + List grammars = grammar.getUsedGrammars(); + if (!grammars.isEmpty()) { + grammar = grammars.iterator().next(); + } else { + return null; + } + } + return grammar; + } + + @Override + public Grammar getGrammar() { + return grammar; + } + + + public TerminalsGrammarAccess getTerminalsGrammarAccess() { + return gaTerminals; + } + + + //Model: + // timeSpec+=TimeSpec*; + public ModelElements getModelAccess() { + return pModel; + } + + public ParserRule getModelRule() { + return getModelAccess().getRule(); + } + + //TimeSpec: + // 'dummy_rule'; + public TimeSpecElements getTimeSpecAccess() { + return pTimeSpec; + } + + public ParserRule getTimeSpecRule() { + return getTimeSpecAccess().getRule(); + } + + //terminal ID: '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; + public TerminalRule getIDRule() { + return gaTerminals.getIDRule(); + } + + //terminal INT returns ecore::EInt: ('0'..'9')+; + public TerminalRule getINTRule() { + return gaTerminals.getINTRule(); + } + + //terminal STRING: + // '"' ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|'"') )* '"' | + // "'" ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|"'") )* "'" + // ; + public TerminalRule getSTRINGRule() { + return gaTerminals.getSTRINGRule(); + } + + //terminal ML_COMMENT : '/*' -> '*/'; + public TerminalRule getML_COMMENTRule() { + return gaTerminals.getML_COMMENTRule(); + } + + //terminal SL_COMMENT : '//' !('\n'|'\r')* ('\r'? '\n')?; + public TerminalRule getSL_COMMENTRule() { + return gaTerminals.getSL_COMMENTRule(); + } + + //terminal WS : (' '|'\t'|'\r'|'\n')+; + public TerminalRule getWSRule() { + return gaTerminals.getWSRule(); + } + + //terminal ANY_OTHER: .; + public TerminalRule getANY_OTHERRule() { + return gaTerminals.getANY_OTHERRule(); + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/validation/AbstractContractSpecValidator.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/validation/AbstractContractSpecValidator.java new file mode 100644 index 0000000000..b07b875788 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/validation/AbstractContractSpecValidator.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.validation; + +import java.util.ArrayList; +import java.util.List; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.xtext.validation.AbstractDeclarativeValidator; + +public abstract class AbstractContractSpecValidator extends AbstractDeclarativeValidator { + + @Override + protected List getEPackages() { + List result = new ArrayList(); + result.add(org.eclipse.fordiac.ide.contractSpec.ContractSpecPackage.eINSTANCE); + return result; + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/validation/ContractSpecConfigurableIssueCodesProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/validation/ContractSpecConfigurableIssueCodesProvider.java new file mode 100644 index 0000000000..148358d621 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src-gen/org/eclipse/fordiac/ide/validation/ContractSpecConfigurableIssueCodesProvider.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.validation; + +import org.eclipse.xtext.preferences.PreferenceKey; +import org.eclipse.xtext.util.IAcceptor; +import org.eclipse.xtext.validation.ConfigurableIssueCodesProvider; +import org.eclipse.xtext.validation.SeverityConverter; + +public class ContractSpecConfigurableIssueCodesProvider extends ConfigurableIssueCodesProvider { + protected static final String ISSUE_CODE_PREFIX = "org.eclipse.fordiac.ide."; + + public static final String DEPRECATED_MODEL_PART = ISSUE_CODE_PREFIX + "deprecatedModelPart"; + + @Override + protected void initialize(IAcceptor acceptor) { + super.initialize(acceptor); + acceptor.accept(create(DEPRECATED_MODEL_PART, SeverityConverter.SEVERITY_WARNING)); + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/ContractSpec.xtext b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/ContractSpec.xtext new file mode 100644 index 0000000000..a5b43b7da1 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/ContractSpec.xtext @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +grammar org.eclipse.fordiac.ide.ContractSpec with org.eclipse.xtext.common.Terminals + +generate contractSpec "http://www.eclipse.org/fordiac/ide/ContractSpec" + +Model: + timeSpec+=TimeSpec*; + +TimeSpec: + 'dummy_rule'; diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/ContractSpecRuntimeModule.java b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/ContractSpecRuntimeModule.java new file mode 100644 index 0000000000..61a50443a7 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/ContractSpecRuntimeModule.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide; + + +/** + * Use this class to register components to be used at runtime / without the Equinox extension registry. + */ +public class ContractSpecRuntimeModule extends AbstractContractSpecRuntimeModule { +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/ContractSpecStandaloneSetup.java b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/ContractSpecStandaloneSetup.java new file mode 100644 index 0000000000..7789b3c931 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/ContractSpecStandaloneSetup.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide; + + +/** + * Initialization support for running Xtext languages without Equinox extension registry. + */ +public class ContractSpecStandaloneSetup extends ContractSpecStandaloneSetupGenerated { + + public static void doSetup() { + new ContractSpecStandaloneSetup().createInjectorAndDoEMFRegistration(); + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/GenerateContractSpec.mwe2 b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/GenerateContractSpec.mwe2 new file mode 100644 index 0000000000..471fdc4b22 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/GenerateContractSpec.mwe2 @@ -0,0 +1,64 @@ +module org.eclipse.fordiac.ide.GenerateContractSpec + +import org.eclipse.xtext.xtext.generator.* +import org.eclipse.xtext.xtext.generator.model.project.* + +var rootPath = ".." + +Workflow { + + component = XtextGenerator { + configuration = { + project = StandardProjectConfig { + baseName = "org.eclipse.fordiac.ide.contractspec" + rootPath = rootPath + runtimeTest = { + enabled = true + } + eclipsePlugin = { + enabled = true + } + eclipsePluginTest = { + enabled = true + } + createEclipseMetaData = true + } + code = { + encoding = "UTF-8" + lineDelimiter = "\r\n" + fileHeader = "/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/" + preferXtendStubs = false + } + } + language = StandardLanguage { + name = "org.eclipse.fordiac.ide.ContractSpec" + fileExtensions = "contract" + + serializer = { + generateStub = false + } + validator = { + // Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage + generateDeprecationValidation = true + } + generator = { + generateXtendStub = true + } + junitSupport = { + junitVersion = "5" + } + } + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/generator/ContractSpecGenerator.xtend b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/generator/ContractSpecGenerator.xtend new file mode 100644 index 0000000000..6097378f68 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/generator/ContractSpecGenerator.xtend @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.generator + +import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.xtext.generator.AbstractGenerator +import org.eclipse.xtext.generator.IFileSystemAccess2 +import org.eclipse.xtext.generator.IGeneratorContext + +/** + * Generates code from your model files on save. + * + * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation + */ +class ContractSpecGenerator extends AbstractGenerator { + + override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) { + + } +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/scoping/ContractSpecScopeProvider.java b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/scoping/ContractSpecScopeProvider.java new file mode 100644 index 0000000000..f87999469e --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/scoping/ContractSpecScopeProvider.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.scoping; + + +/** + * This class contains custom scoping description. + * + * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#scoping + * on how and when to use it. + */ +public class ContractSpecScopeProvider extends AbstractContractSpecScopeProvider { + +} diff --git a/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/validation/ContractSpecValidator.java b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/validation/ContractSpecValidator.java new file mode 100644 index 0000000000..fcaeb0dfb6 --- /dev/null +++ b/plugins/org.eclipse.fordiac.ide.contractspec/src/org/eclipse/fordiac/ide/validation/ContractSpecValidator.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2024 Felix Schmid + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Felix Schmid + * - initial commit of contract specification editor + *******************************************************************************/ +package org.eclipse.fordiac.ide.validation; + + +/** + * This class contains custom validation rules. + * + * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation + */ +public class ContractSpecValidator extends AbstractContractSpecValidator { + +}