From 9b94c5004165055b7f49388164e7447641067dcb Mon Sep 17 00:00:00 2001 From: Nicolas FAUVERGUE Date: Tue, 17 Mar 2015 15:47:00 +0100 Subject: Bug 462365: [XText] Papyrus Value Specification XText editor must provide update instead of creation https://bugs.eclipse.org/bugs/show_bug.cgi?id=462365 - Manage the update of ValueSpecification instead of creation - Manage the ".2" possible real (grammar change) - Manage the "0." possible real (grammar change) - Manage a problem with background text color - Add tests for Update of ValueSpecification Change-Id: Ifff88731fc8e5acdae4e83c112e2984789fafbc9 Signed-off-by: Nicolas FAUVERGUE (cherry picked from commit 014b7a65c3d8a0a723fcd57c064ff82b443e973d) --- .../widgets/editors/StyledTextReferenceDialog.java | 15 +- .../xtext/widget/UMLXtextReferenceValueEditor.java | 43 +- .../antlr/internal/InternalUmlValueSpecification.g | 2 +- .../InternalUmlValueSpecificationLexer.java | 615 +++++++++++++-------- .../commands/ValueSpecificationSetCommand.java | 551 ++++++++++++------ .../xtext/UmlValueSpecification.xtextbin | Bin 2899 -> 3003 bytes .../antlr/internal/InternalUmlValueSpecification.g | 2 +- .../InternalUmlValueSpecificationLexer.java | 605 ++++++++++++-------- .../UmlValueSpecificationGrammarAccess.java | 2 +- .../xtext/UmlValueSpecification.xtext | 3 +- .../suites/ValueSpecificationGrammarTests.java | 21 + 11 files changed, 1203 insertions(+), 656 deletions(-) diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StyledTextReferenceDialog.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StyledTextReferenceDialog.java index a00452dd51f..6b1b44ddb1d 100644 --- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StyledTextReferenceDialog.java +++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StyledTextReferenceDialog.java @@ -135,7 +135,7 @@ public class StyledTextReferenceDialog extends AbstractValueEditor implements Se /** * The control decoration of the styled text. */ - private ControlDecoration controlDecoration; + protected ControlDecoration controlDecoration; /** * Determinate if an error occurred. @@ -177,8 +177,7 @@ public class StyledTextReferenceDialog extends AbstractValueEditor implements Se @Override public void mouseDoubleClick(MouseEvent e) { editAction(); // TODO : Try to determine whether the double - // click should call the edit, create or browse - // action + // click should call the edit, create or browse action // e.g. if the value is null, try to browse. If we cannot // browse, try to create an instance. } @@ -668,12 +667,15 @@ public class StyledTextReferenceDialog extends AbstractValueEditor implements Se */ @Override public void dispose() { - if (changeColorTask != null) { + if (null != changeColorTask) { changeColorTask.cancel(); } - if (timer != null) { + if (null != timer) { timer.cancel(); } + if (null != styledTextStringEditor) { + styledTextStringEditor.dispose(); + } super.dispose(); } @@ -695,7 +697,7 @@ public class StyledTextReferenceDialog extends AbstractValueEditor implements Se public void changeColorField() { if (!error & !edit) { - if (timer == null) { + if (null == timer) { timer = new Timer(true); } @@ -744,6 +746,7 @@ public class StyledTextReferenceDialog extends AbstractValueEditor implements Se } } else { styledTextStringEditor.setBackground(DEFAULT); + styledTextStringEditor.update(); } } diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/UMLXtextReferenceValueEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/UMLXtextReferenceValueEditor.java index 182ff901e2b..74677af4d73 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/UMLXtextReferenceValueEditor.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/UMLXtextReferenceValueEditor.java @@ -41,6 +41,7 @@ import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; /** * This class provides a ReferenceValueEditor, with a text field with the xtext @@ -62,9 +63,14 @@ public class UMLXtextReferenceValueEditor extends StyledTextReferenceDialog /** * The context element adapter. */ - final private ContextElementAdapter contextElementAdapter = new ContextElementAdapter( + private final ContextElementAdapter contextElementAdapter = new ContextElementAdapter( this); + /** + * This allow to manage the focus lsot manually (for the 'ENTER' key). + */ + private boolean isFocus = false; + /** * Constructor. * @@ -78,23 +84,31 @@ public class UMLXtextReferenceValueEditor extends StyledTextReferenceDialog styledTextStringEditor.getText().addFocusListener(new FocusListener() { public void focusLost(FocusEvent e) { - IParser parser = getParser(); - if (null == xtextAdapter) { - return; - } + if (isFocus) { + IParser parser = getParser(); + if (null == xtextAdapter) { + return; + } + + if (null != xtextAdapter + && null != xtextAdapter.getCompletionProposalAdapter() + && xtextAdapter.getCompletionProposalAdapter() + .delayedIsPopupOpen()) { + // ignore focus lost + return; + } + manageParserCommand(parser); - if (null != xtextAdapter - && null != xtextAdapter.getCompletionProposalAdapter() - && xtextAdapter.getCompletionProposalAdapter() - .delayedIsPopupOpen()) { - // ignore focus lost - return; + // Manage the color field and the control decoration + styledTextStringEditor.notifyListeners(SWT.FocusOut, new Event()); + styledTextStringEditor.changeColorField(); + controlDecoration.hide(); + isFocus = false; } - manageParserCommand(parser); } public void focusGained(FocusEvent e) { - // Nothing + isFocus = true; } }); } @@ -139,8 +153,7 @@ public class UMLXtextReferenceValueEditor extends StyledTextReferenceDialog /** * {@inheritDoc} * - * @see org.eclipse.papyrus.infra.widgets.editors.StyledTextReferenceDialog#createStyledTextStringEditor(org.eclipse.swt.widgets.Composite, - * java.lang.String, int) + * @see org.eclipse.papyrus.infra.widgets.editors.StyledTextReferenceDialog#createStyledTextStringEditor(org.eclipse.swt.widgets.Composite, java.lang.String, int) */ @Override protected StyledTextStringEditor createStyledTextStringEditor( diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g index 0751a6ee5ab..2e94a76d937 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g @@ -863,7 +863,7 @@ finally { } -RULE_DOUBLE : ('0'..'9')+ '.' ('0'..'9')+; +RULE_DOUBLE : (('0'..'9')+ ('.'|',') ('0'..'9')*|('0'..'9')* ('.'|',') ('0'..'9')+); RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecificationLexer.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecificationLexer.java index 893a605954c..9036c73ccba 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecificationLexer.java +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecificationLexer.java @@ -233,69 +233,155 @@ public class InternalUmlValueSpecificationLexer extends Lexer { try { int _type = RULE_DOUBLE; int _channel = DEFAULT_TOKEN_CHANNEL; - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:13: ( ( '0' .. '9' )+ '.' ( '0' .. '9' )+ ) - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:15: ( '0' .. '9' )+ '.' ( '0' .. '9' )+ + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:13: ( ( ( '0' .. '9' )+ ( '.' | ',' ) ( '0' .. '9' )* | ( '0' .. '9' )* ( '.' | ',' ) ( '0' .. '9' )+ ) ) + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:15: ( ( '0' .. '9' )+ ( '.' | ',' ) ( '0' .. '9' )* | ( '0' .. '9' )* ( '.' | ',' ) ( '0' .. '9' )+ ) { - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:15: ( '0' .. '9' )+ - int cnt1=0; - loop1: - do { - int alt1=2; - int LA1_0 = input.LA(1); + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:15: ( ( '0' .. '9' )+ ( '.' | ',' ) ( '0' .. '9' )* | ( '0' .. '9' )* ( '.' | ',' ) ( '0' .. '9' )+ ) + int alt5=2; + alt5 = dfa5.predict(input); + switch (alt5) { + case 1 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:16: ( '0' .. '9' )+ ( '.' | ',' ) ( '0' .. '9' )* + { + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:16: ( '0' .. '9' )+ + int cnt1=0; + loop1: + do { + int alt1=2; + int LA1_0 = input.LA(1); - if ( ((LA1_0>='0' && LA1_0<='9')) ) { - alt1=1; - } + if ( ((LA1_0>='0' && LA1_0<='9')) ) { + alt1=1; + } - switch (alt1) { - case 1 : - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:16: '0' .. '9' - { - matchRange('0','9'); + switch (alt1) { + case 1 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:17: '0' .. '9' + { + matchRange('0','9'); - } - break; + } + break; - default : - if ( cnt1 >= 1 ) break loop1; - EarlyExitException eee = - new EarlyExitException(1, input); - throw eee; - } - cnt1++; - } while (true); + default : + if ( cnt1 >= 1 ) break loop1; + EarlyExitException eee = + new EarlyExitException(1, input); + throw eee; + } + cnt1++; + } while (true); - match('.'); - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:31: ( '0' .. '9' )+ - int cnt2=0; - loop2: - do { - int alt2=2; - int LA2_0 = input.LA(1); + if ( input.LA(1)==','||input.LA(1)=='.' ) { + input.consume(); - if ( ((LA2_0>='0' && LA2_0<='9')) ) { - alt2=1; - } + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:38: ( '0' .. '9' )* + loop2: + do { + int alt2=2; + int LA2_0 = input.LA(1); - switch (alt2) { - case 1 : - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:32: '0' .. '9' - { - matchRange('0','9'); + if ( ((LA2_0>='0' && LA2_0<='9')) ) { + alt2=1; + } - } - break; - default : - if ( cnt2 >= 1 ) break loop2; - EarlyExitException eee = - new EarlyExitException(2, input); - throw eee; - } - cnt2++; - } while (true); + switch (alt2) { + case 1 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:39: '0' .. '9' + { + matchRange('0','9'); + + } + break; + + default : + break loop2; + } + } while (true); + + + } + break; + case 2 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:50: ( '0' .. '9' )* ( '.' | ',' ) ( '0' .. '9' )+ + { + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:50: ( '0' .. '9' )* + loop3: + do { + int alt3=2; + int LA3_0 = input.LA(1); + + if ( ((LA3_0>='0' && LA3_0<='9')) ) { + alt3=1; + } + + + switch (alt3) { + case 1 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:51: '0' .. '9' + { + matchRange('0','9'); + + } + break; + + default : + break loop3; + } + } while (true); + + if ( input.LA(1)==','||input.LA(1)=='.' ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:72: ( '0' .. '9' )+ + int cnt4=0; + loop4: + do { + int alt4=2; + int LA4_0 = input.LA(1); + + if ( ((LA4_0>='0' && LA4_0<='9')) ) { + alt4=1; + } + + + switch (alt4) { + case 1 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:866:73: '0' .. '9' + { + matchRange('0','9'); + + } + break; + + default : + if ( cnt4 >= 1 ) break loop4; + EarlyExitException eee = + new EarlyExitException(4, input); + throw eee; + } + cnt4++; + } while (true); + + + } + break; + + } } @@ -317,13 +403,13 @@ public class InternalUmlValueSpecificationLexer extends Lexer { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:868:11: ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:868:11: ( '^' )? - int alt3=2; - int LA3_0 = input.LA(1); + int alt6=2; + int LA6_0 = input.LA(1); - if ( (LA3_0=='^') ) { - alt3=1; + if ( (LA6_0=='^') ) { + alt6=1; } - switch (alt3) { + switch (alt6) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:868:11: '^' { @@ -344,17 +430,17 @@ public class InternalUmlValueSpecificationLexer extends Lexer { throw mse;} // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:868:40: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* - loop4: + loop7: do { - int alt4=2; - int LA4_0 = input.LA(1); + int alt7=2; + int LA7_0 = input.LA(1); - if ( ((LA4_0>='0' && LA4_0<='9')||(LA4_0>='A' && LA4_0<='Z')||LA4_0=='_'||(LA4_0>='a' && LA4_0<='z')) ) { - alt4=1; + if ( ((LA7_0>='0' && LA7_0<='9')||(LA7_0>='A' && LA7_0<='Z')||LA7_0=='_'||(LA7_0>='a' && LA7_0<='z')) ) { + alt7=1; } - switch (alt4) { + switch (alt7) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g: { @@ -372,7 +458,7 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - break loop4; + break loop7; } } while (true); @@ -396,18 +482,18 @@ public class InternalUmlValueSpecificationLexer extends Lexer { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:870:12: ( '0' .. '9' )+ { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:870:12: ( '0' .. '9' )+ - int cnt5=0; - loop5: + int cnt8=0; + loop8: do { - int alt5=2; - int LA5_0 = input.LA(1); + int alt8=2; + int LA8_0 = input.LA(1); - if ( ((LA5_0>='0' && LA5_0<='9')) ) { - alt5=1; + if ( ((LA8_0>='0' && LA8_0<='9')) ) { + alt8=1; } - switch (alt5) { + switch (alt8) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:870:13: '0' .. '9' { @@ -417,12 +503,12 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - if ( cnt5 >= 1 ) break loop5; + if ( cnt8 >= 1 ) break loop8; EarlyExitException eee = - new EarlyExitException(5, input); + new EarlyExitException(8, input); throw eee; } - cnt5++; + cnt8++; } while (true); @@ -445,41 +531,41 @@ public class InternalUmlValueSpecificationLexer extends Lexer { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:872:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:872:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) - int alt8=2; - int LA8_0 = input.LA(1); + int alt11=2; + int LA11_0 = input.LA(1); - if ( (LA8_0=='\"') ) { - alt8=1; + if ( (LA11_0=='\"') ) { + alt11=1; } - else if ( (LA8_0=='\'') ) { - alt8=2; + else if ( (LA11_0=='\'') ) { + alt11=2; } else { NoViableAltException nvae = - new NoViableAltException("", 8, 0, input); + new NoViableAltException("", 11, 0, input); throw nvae; } - switch (alt8) { + switch (alt11) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:872:16: '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' { match('\"'); // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:872:20: ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* - loop6: + loop9: do { - int alt6=3; - int LA6_0 = input.LA(1); + int alt9=3; + int LA9_0 = input.LA(1); - if ( (LA6_0=='\\') ) { - alt6=1; + if ( (LA9_0=='\\') ) { + alt9=1; } - else if ( ((LA6_0>='\u0000' && LA6_0<='!')||(LA6_0>='#' && LA6_0<='[')||(LA6_0>=']' && LA6_0<='\uFFFF')) ) { - alt6=2; + else if ( ((LA9_0>='\u0000' && LA9_0<='!')||(LA9_0>='#' && LA9_0<='[')||(LA9_0>=']' && LA9_0<='\uFFFF')) ) { + alt9=2; } - switch (alt6) { + switch (alt9) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:872:21: '\\\\' . { @@ -505,7 +591,7 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - break loop6; + break loop9; } } while (true); @@ -518,20 +604,20 @@ public class InternalUmlValueSpecificationLexer extends Lexer { { match('\''); // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:872:53: ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* - loop7: + loop10: do { - int alt7=3; - int LA7_0 = input.LA(1); + int alt10=3; + int LA10_0 = input.LA(1); - if ( (LA7_0=='\\') ) { - alt7=1; + if ( (LA10_0=='\\') ) { + alt10=1; } - else if ( ((LA7_0>='\u0000' && LA7_0<='&')||(LA7_0>='(' && LA7_0<='[')||(LA7_0>=']' && LA7_0<='\uFFFF')) ) { - alt7=2; + else if ( ((LA10_0>='\u0000' && LA10_0<='&')||(LA10_0>='(' && LA10_0<='[')||(LA10_0>=']' && LA10_0<='\uFFFF')) ) { + alt10=2; } - switch (alt7) { + switch (alt10) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:872:54: '\\\\' . { @@ -557,7 +643,7 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - break loop7; + break loop10; } } while (true); @@ -590,29 +676,29 @@ public class InternalUmlValueSpecificationLexer extends Lexer { match("/*"); // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:874:24: ( options {greedy=false; } : . )* - loop9: + loop12: do { - int alt9=2; - int LA9_0 = input.LA(1); + int alt12=2; + int LA12_0 = input.LA(1); - if ( (LA9_0=='*') ) { - int LA9_1 = input.LA(2); + if ( (LA12_0=='*') ) { + int LA12_1 = input.LA(2); - if ( (LA9_1=='/') ) { - alt9=2; + if ( (LA12_1=='/') ) { + alt12=2; } - else if ( ((LA9_1>='\u0000' && LA9_1<='.')||(LA9_1>='0' && LA9_1<='\uFFFF')) ) { - alt9=1; + else if ( ((LA12_1>='\u0000' && LA12_1<='.')||(LA12_1>='0' && LA12_1<='\uFFFF')) ) { + alt12=1; } } - else if ( ((LA9_0>='\u0000' && LA9_0<=')')||(LA9_0>='+' && LA9_0<='\uFFFF')) ) { - alt9=1; + else if ( ((LA12_0>='\u0000' && LA12_0<=')')||(LA12_0>='+' && LA12_0<='\uFFFF')) ) { + alt12=1; } - switch (alt9) { + switch (alt12) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:874:52: . { @@ -622,7 +708,7 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - break loop9; + break loop12; } } while (true); @@ -650,17 +736,17 @@ public class InternalUmlValueSpecificationLexer extends Lexer { match("//"); // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:876:24: (~ ( ( '\\n' | '\\r' ) ) )* - loop10: + loop13: do { - int alt10=2; - int LA10_0 = input.LA(1); + int alt13=2; + int LA13_0 = input.LA(1); - if ( ((LA10_0>='\u0000' && LA10_0<='\t')||(LA10_0>='\u000B' && LA10_0<='\f')||(LA10_0>='\u000E' && LA10_0<='\uFFFF')) ) { - alt10=1; + if ( ((LA13_0>='\u0000' && LA13_0<='\t')||(LA13_0>='\u000B' && LA13_0<='\f')||(LA13_0>='\u000E' && LA13_0<='\uFFFF')) ) { + alt13=1; } - switch (alt10) { + switch (alt13) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:876:24: ~ ( ( '\\n' | '\\r' ) ) { @@ -678,29 +764,29 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - break loop10; + break loop13; } } while (true); // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:876:40: ( ( '\\r' )? '\\n' )? - int alt12=2; - int LA12_0 = input.LA(1); + int alt15=2; + int LA15_0 = input.LA(1); - if ( (LA12_0=='\n'||LA12_0=='\r') ) { - alt12=1; + if ( (LA15_0=='\n'||LA15_0=='\r') ) { + alt15=1; } - switch (alt12) { + switch (alt15) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:876:41: ( '\\r' )? '\\n' { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:876:41: ( '\\r' )? - int alt11=2; - int LA11_0 = input.LA(1); + int alt14=2; + int LA14_0 = input.LA(1); - if ( (LA11_0=='\r') ) { - alt11=1; + if ( (LA14_0=='\r') ) { + alt14=1; } - switch (alt11) { + switch (alt14) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:876:41: '\\r' { @@ -738,18 +824,18 @@ public class InternalUmlValueSpecificationLexer extends Lexer { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:878:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:878:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ - int cnt13=0; - loop13: + int cnt16=0; + loop16: do { - int alt13=2; - int LA13_0 = input.LA(1); + int alt16=2; + int LA16_0 = input.LA(1); - if ( ((LA13_0>='\t' && LA13_0<='\n')||LA13_0=='\r'||LA13_0==' ') ) { - alt13=1; + if ( ((LA16_0>='\t' && LA16_0<='\n')||LA16_0=='\r'||LA16_0==' ') ) { + alt16=1; } - switch (alt13) { + switch (alt16) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g: { @@ -767,12 +853,12 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - if ( cnt13 >= 1 ) break loop13; + if ( cnt16 >= 1 ) break loop16; EarlyExitException eee = - new EarlyExitException(13, input); + new EarlyExitException(16, input); throw eee; } - cnt13++; + cnt16++; } while (true); @@ -808,9 +894,9 @@ public class InternalUmlValueSpecificationLexer extends Lexer { public void mTokens() throws RecognitionException { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:1:8: ( T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | T__18 | T__19 | T__20 | RULE_DOUBLE | RULE_ID | RULE_INT | RULE_STRING | RULE_ML_COMMENT | RULE_SL_COMMENT | RULE_WS | RULE_ANY_OTHER ) - int alt14=17; - alt14 = dfa14.predict(input); - switch (alt14) { + int alt17=17; + alt17 = dfa17.predict(input); + switch (alt17) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/ui/contentassist/antlr/internal/InternalUmlValueSpecification.g:1:10: T__12 { @@ -936,107 +1022,162 @@ public class InternalUmlValueSpecificationLexer extends Lexer { } - protected DFA14 dfa14 = new DFA14(this); - static final String DFA14_eotS = - "\1\uffff\2\23\1\uffff\1\23\1\21\4\uffff\1\34\1\21\1\uffff\3\21"+ - "\2\uffff\1\23\1\uffff\1\23\1\uffff\1\23\6\uffff\1\34\5\uffff\3\23"+ - "\1\51\1\23\1\53\1\uffff\1\54\2\uffff"; - static final String DFA14_eofS = - "\55\uffff"; - static final String DFA14_minS = - "\1\0\1\162\1\141\1\uffff\1\165\1\125\4\uffff\1\56\1\101\1\uffff"+ - "\2\0\1\52\2\uffff\1\165\1\uffff\1\154\1\uffff\1\154\6\uffff\1\56"+ - "\5\uffff\1\145\1\163\1\154\1\60\1\145\1\60\1\uffff\1\60\2\uffff"; - static final String DFA14_maxS = - "\1\uffff\1\162\1\141\1\uffff\1\165\1\125\4\uffff\1\71\1\172\1\uffff"+ - "\2\uffff\1\57\2\uffff\1\165\1\uffff\1\154\1\uffff\1\154\6\uffff"+ - "\1\71\5\uffff\1\145\1\163\1\154\1\172\1\145\1\172\1\uffff\1\172"+ + protected DFA5 dfa5 = new DFA5(this); + protected DFA17 dfa17 = new DFA17(this); + static final String DFA5_eotS = + "\3\uffff\1\4\1\uffff"; + static final String DFA5_eofS = + "\5\uffff"; + static final String DFA5_minS = + "\2\54\1\uffff\1\0\1\uffff"; + static final String DFA5_maxS = + "\2\71\1\uffff\1\0\1\uffff"; + static final String DFA5_acceptS = + "\2\uffff\1\2\1\uffff\1\1"; + static final String DFA5_specialS = + "\5\uffff}>"; + static final String[] DFA5_transitionS = { + "\1\2\1\uffff\1\2\1\uffff\12\1", + "\1\3\1\uffff\1\3\1\uffff\12\1", + "", + "\1\uffff", + "" + }; + + static final short[] DFA5_eot = DFA.unpackEncodedString(DFA5_eotS); + static final short[] DFA5_eof = DFA.unpackEncodedString(DFA5_eofS); + static final char[] DFA5_min = DFA.unpackEncodedStringToUnsignedChars(DFA5_minS); + static final char[] DFA5_max = DFA.unpackEncodedStringToUnsignedChars(DFA5_maxS); + static final short[] DFA5_accept = DFA.unpackEncodedString(DFA5_acceptS); + static final short[] DFA5_special = DFA.unpackEncodedString(DFA5_specialS); + static final short[][] DFA5_transition; + + static { + int numStates = DFA5_transitionS.length; + DFA5_transition = new short[numStates][]; + for (int i=0; i"; - static final String[] DFA14_transitionS = { - "\11\21\2\20\2\21\1\20\22\21\1\20\1\21\1\15\1\10\3\21\1\16\3"+ - "\21\1\6\1\21\1\7\1\21\1\17\12\12\2\21\1\5\1\3\3\21\32\14\3\21"+ - "\1\13\1\14\1\21\5\14\1\2\7\14\1\4\5\14\1\1\6\14\3\21\1\11\uff81"+ - "\21", - "\1\22", - "\1\24", + "\1\12\1\uffff\1\15\1\16\1\17\1\20\6\uffff\1\1\1\uffff\1\4\1\2"; + static final String DFA17_specialS = + "\1\0\15\uffff\1\1\1\2\36\uffff}>"; + static final String[] DFA17_transitionS = { + "\11\22\2\21\2\22\1\21\22\22\1\21\1\22\1\16\1\10\3\22\1\17\3"+ + "\22\1\6\1\13\1\7\1\13\1\20\12\12\2\22\1\5\1\3\3\22\32\15\3\22"+ + "\1\14\1\15\1\22\5\15\1\2\7\15\1\4\5\15\1\1\6\15\3\22\1\11\uff81"+ + "\22", + "\1\23", + "\1\25", "", - "\1\26", "\1\27", + "\1\30", "", "", "", "", - "\1\36\1\uffff\12\35", - "\32\23\4\uffff\1\23\1\uffff\32\23", + "\1\36\1\uffff\1\36\1\uffff\12\37", + "\12\36", + "\32\24\4\uffff\1\24\1\uffff\32\24", "", - "\0\37", - "\0\37", - "\1\40\4\uffff\1\41", + "\0\40", + "\0\40", + "\1\41\4\uffff\1\42", "", "", - "\1\43", - "", "\1\44", "", "\1\45", "", + "\1\46", + "", "", "", "", "", "", - "\1\36\1\uffff\12\35", "", + "\1\36\1\uffff\1\36\1\uffff\12\37", "", "", "", "", - "\1\46", "\1\47", "\1\50", - "\12\23\7\uffff\32\23\4\uffff\1\23\1\uffff\32\23", - "\1\52", - "\12\23\7\uffff\32\23\4\uffff\1\23\1\uffff\32\23", + "\1\51", + "\12\24\7\uffff\32\24\4\uffff\1\24\1\uffff\32\24", + "\1\53", + "\12\24\7\uffff\32\24\4\uffff\1\24\1\uffff\32\24", "", - "\12\23\7\uffff\32\23\4\uffff\1\23\1\uffff\32\23", + "\12\24\7\uffff\32\24\4\uffff\1\24\1\uffff\32\24", "", "" }; - static final short[] DFA14_eot = DFA.unpackEncodedString(DFA14_eotS); - static final short[] DFA14_eof = DFA.unpackEncodedString(DFA14_eofS); - static final char[] DFA14_min = DFA.unpackEncodedStringToUnsignedChars(DFA14_minS); - static final char[] DFA14_max = DFA.unpackEncodedStringToUnsignedChars(DFA14_maxS); - static final short[] DFA14_accept = DFA.unpackEncodedString(DFA14_acceptS); - static final short[] DFA14_special = DFA.unpackEncodedString(DFA14_specialS); - static final short[][] DFA14_transition; + static final short[] DFA17_eot = DFA.unpackEncodedString(DFA17_eotS); + static final short[] DFA17_eof = DFA.unpackEncodedString(DFA17_eofS); + static final char[] DFA17_min = DFA.unpackEncodedStringToUnsignedChars(DFA17_minS); + static final char[] DFA17_max = DFA.unpackEncodedStringToUnsignedChars(DFA17_maxS); + static final short[] DFA17_accept = DFA.unpackEncodedString(DFA17_acceptS); + static final short[] DFA17_special = DFA.unpackEncodedString(DFA17_specialS); + static final short[][] DFA17_transition; static { - int numStates = DFA14_transitionS.length; - DFA14_transition = new short[numStates][]; + int numStates = DFA17_transitionS.length; + DFA17_transition = new short[numStates][]; for (int i=0; i='\u0000' && LA14_14<='\uFFFF')) ) {s = 31;} + if ( (LA17_0=='t') ) {s = 1;} - else s = 17; + else if ( (LA17_0=='f') ) {s = 2;} - if ( s>=0 ) return s; - break; - case 1 : - int LA14_13 = input.LA(1); + else if ( (LA17_0=='=') ) {s = 3;} - s = -1; - if ( ((LA14_13>='\u0000' && LA14_13<='\uFFFF')) ) {s = 31;} + else if ( (LA17_0=='n') ) {s = 4;} - else s = 17; + else if ( (LA17_0=='<') ) {s = 5;} - if ( s>=0 ) return s; - break; - case 2 : - int LA14_0 = input.LA(1); + else if ( (LA17_0=='+') ) {s = 6;} - s = -1; - if ( (LA14_0=='t') ) {s = 1;} + else if ( (LA17_0=='-') ) {s = 7;} - else if ( (LA14_0=='f') ) {s = 2;} + else if ( (LA17_0=='#') ) {s = 8;} - else if ( (LA14_0=='=') ) {s = 3;} + else if ( (LA17_0=='~') ) {s = 9;} - else if ( (LA14_0=='n') ) {s = 4;} + else if ( ((LA17_0>='0' && LA17_0<='9')) ) {s = 10;} - else if ( (LA14_0=='<') ) {s = 5;} + else if ( (LA17_0==','||LA17_0=='.') ) {s = 11;} - else if ( (LA14_0=='+') ) {s = 6;} + else if ( (LA17_0=='^') ) {s = 12;} - else if ( (LA14_0=='-') ) {s = 7;} + else if ( ((LA17_0>='A' && LA17_0<='Z')||LA17_0=='_'||(LA17_0>='a' && LA17_0<='e')||(LA17_0>='g' && LA17_0<='m')||(LA17_0>='o' && LA17_0<='s')||(LA17_0>='u' && LA17_0<='z')) ) {s = 13;} - else if ( (LA14_0=='#') ) {s = 8;} + else if ( (LA17_0=='\"') ) {s = 14;} - else if ( (LA14_0=='~') ) {s = 9;} + else if ( (LA17_0=='\'') ) {s = 15;} - else if ( ((LA14_0>='0' && LA14_0<='9')) ) {s = 10;} + else if ( (LA17_0=='/') ) {s = 16;} - else if ( (LA14_0=='^') ) {s = 11;} + else if ( ((LA17_0>='\t' && LA17_0<='\n')||LA17_0=='\r'||LA17_0==' ') ) {s = 17;} - else if ( ((LA14_0>='A' && LA14_0<='Z')||LA14_0=='_'||(LA14_0>='a' && LA14_0<='e')||(LA14_0>='g' && LA14_0<='m')||(LA14_0>='o' && LA14_0<='s')||(LA14_0>='u' && LA14_0<='z')) ) {s = 12;} + else if ( ((LA17_0>='\u0000' && LA17_0<='\b')||(LA17_0>='\u000B' && LA17_0<='\f')||(LA17_0>='\u000E' && LA17_0<='\u001F')||LA17_0=='!'||(LA17_0>='$' && LA17_0<='&')||(LA17_0>='(' && LA17_0<='*')||(LA17_0>=':' && LA17_0<=';')||(LA17_0>='>' && LA17_0<='@')||(LA17_0>='[' && LA17_0<=']')||LA17_0=='`'||(LA17_0>='{' && LA17_0<='}')||(LA17_0>='\u007F' && LA17_0<='\uFFFF')) ) {s = 18;} - else if ( (LA14_0=='\"') ) {s = 13;} + if ( s>=0 ) return s; + break; + case 1 : + int LA17_14 = input.LA(1); + + s = -1; + if ( ((LA17_14>='\u0000' && LA17_14<='\uFFFF')) ) {s = 32;} - else if ( (LA14_0=='\'') ) {s = 14;} + else s = 18; - else if ( (LA14_0=='/') ) {s = 15;} + if ( s>=0 ) return s; + break; + case 2 : + int LA17_15 = input.LA(1); - else if ( ((LA14_0>='\t' && LA14_0<='\n')||LA14_0=='\r'||LA14_0==' ') ) {s = 16;} + s = -1; + if ( ((LA17_15>='\u0000' && LA17_15<='\uFFFF')) ) {s = 32;} - else if ( ((LA14_0>='\u0000' && LA14_0<='\b')||(LA14_0>='\u000B' && LA14_0<='\f')||(LA14_0>='\u000E' && LA14_0<='\u001F')||LA14_0=='!'||(LA14_0>='$' && LA14_0<='&')||(LA14_0>='(' && LA14_0<='*')||LA14_0==','||LA14_0=='.'||(LA14_0>=':' && LA14_0<=';')||(LA14_0>='>' && LA14_0<='@')||(LA14_0>='[' && LA14_0<=']')||LA14_0=='`'||(LA14_0>='{' && LA14_0<='}')||(LA14_0>='\u007F' && LA14_0<='\uFFFF')) ) {s = 17;} + else s = 18; if ( s>=0 ) return s; break; } NoViableAltException nvae = - new NoViableAltException(getDescription(), 14, _s, input); + new NoViableAltException(getDescription(), 17, _s, input); error(nvae); throw nvae; } diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/utils/commands/ValueSpecificationSetCommand.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/utils/commands/ValueSpecificationSetCommand.java index d38529127b8..0b55a90e932 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/utils/commands/ValueSpecificationSetCommand.java +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/utils/commands/ValueSpecificationSetCommand.java @@ -20,6 +20,7 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; @@ -40,6 +41,7 @@ import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter.ICon import org.eclipse.uml2.uml.InstanceValue; import org.eclipse.uml2.uml.LiteralBoolean; import org.eclipse.uml2.uml.LiteralInteger; +import org.eclipse.uml2.uml.LiteralNull; import org.eclipse.uml2.uml.LiteralReal; import org.eclipse.uml2.uml.LiteralString; import org.eclipse.uml2.uml.LiteralUnlimitedNatural; @@ -144,6 +146,7 @@ public class ValueSpecificationSetCommand { // No error during the parser of xtext string value EObject xtextObject = context.getFakeResource().getParseResult() .getRootASTElement(); + ICommand cmd = getParseCommand(objectToEdit, initialValueSpecification, structuralFeature, xtextObject, xtextStringValue, defaultLanguages); @@ -152,9 +155,7 @@ public class ValueSpecificationSetCommand { } } else { // The parser of xtext string value throw errors - result.add(getOpaqueExpressionCommand(objectToEdit, - initialValueSpecification, structuralFeature, - xtextStringValue, defaultLanguages)); + result.add(manageOpaqueExpression(objectToEdit, structuralFeature, initialValueSpecification, xtextStringValue, defaultLanguages)); } AbstractValidateCommand validationCommand = new AsyncValidateSubtreeCommand( objectToEdit, new UMLDiagnostician()); @@ -222,52 +223,19 @@ public class ValueSpecificationSetCommand { final EObject xtextObject, final String xtextStringValue, final Collection defaultLanguages) { - ValueSpecification createdValueSpecification = null; - // Check if the object to edit is not multi-valued if (null != objectToEdit && (!(objectToEdit instanceof MultiplicityElement) || !(((MultiplicityElement) objectToEdit) .isMultivalued()))) { - createdValueSpecification = createValueSpecification(objectToEdit, + return manageValueSpecification(objectToEdit, structuralFeature, initialValueSpecification, xtextObject, xtextStringValue, defaultLanguages); } else { // The object is multi-valued, create an opaque expression - createdValueSpecification = createOpaqueExpression( - initialValueSpecification, xtextStringValue, + return manageOpaqueExpression( + objectToEdit, structuralFeature, initialValueSpecification, xtextStringValue, defaultLanguages); } - return createCommand((EObject) objectToEdit, structuralFeature, - createdValueSpecification); - } - - /** - * Create he command for the opaque expression creation. - * - * @param objectToEdit - * The parent object of value specification. - * @param initialValueSpecification - * The initial value specification. - * @param structuralFeature - * The structural feature. - * @param xtextStringValue - * The initial xtext string value. - * @param defaultLanguages - * The default languages for an opaque expression. - * @return The command to set the value specification. - */ - protected ICommand getOpaqueExpressionCommand(final EObject objectToEdit, - final ValueSpecification initialValueSpecification, - final EStructuralFeature structuralFeature, - final String xtextStringValue, - final Collection defaultLanguages) { - - // Just return a command of opaque expression - return createCommand( - objectToEdit, - structuralFeature, - createOpaqueExpression(initialValueSpecification, - xtextStringValue, defaultLanguages)); } /** @@ -285,8 +253,7 @@ public class ValueSpecificationSetCommand { final EStructuralFeature structuralFeature, final ValueSpecification valueSpecification) { - final CompositeCommand setValueCommand = new CompositeCommand( - "Set Value Specification Command"); //$NON-NLS-1$ + final CompositeCommand setValueCommand = new CompositeCommand("Set Value Specification Command"); //$NON-NLS-1$ final SetRequest request = new SetRequest(objectToEdit, structuralFeature, valueSpecification); @@ -300,16 +267,18 @@ public class ValueSpecificationSetCommand { setValueCommand.add(setDefaultValueCommand); } else { setValueCommand - .add(org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE); + .add(UnexecutableCommand.INSTANCE); } return setValueCommand.isEmpty() ? null : setValueCommand; } /** - * This allow to create the value specification from the xtext parser. + * This allow to update/create the value specification from the xtext parser. * * @param objectToEdit * The parent object of value specification. + * @param structuralFeature + * The structural feature. * @param initialValueSpecification * The initial value specification. * @param xtextObject @@ -320,127 +289,164 @@ public class ValueSpecificationSetCommand { * The default languages for an opaque expression. * @return The create {@link ValueSpecification} */ - protected ValueSpecification createValueSpecification( + protected ICommand manageValueSpecification( final EObject objectToEdit, + final EStructuralFeature structuralFeature, final ValueSpecification initialValueSpecification, final EObject xtextObject, final String xtextStringValue, final Collection defaultLanguages) { - ValueSpecification createdValueSpecification = null; + ICommand resultCommand = null; + ValueSpecification newValueSpecification = null; // Check that the xtext object parsed is the correct one - if (xtextObject instanceof AbstractRule - && null == ((AbstractRule) xtextObject).getUndefined()) { - final AbstractRule abstractRule = (AbstractRule) xtextObject; - final EObject value = abstractRule.getValue(); - if (null != abstractRule.getInstanceSpecification()) { - // Create an instance value with specification value - createdValueSpecification = UMLFactory.eINSTANCE - .createInstanceValue(); - ((InstanceValue) createdValueSpecification) - .setInstance(abstractRule.getInstanceSpecification()); + if (xtextObject instanceof AbstractRule) { + if (null != ((AbstractRule) xtextObject).getUndefined()) { + if (null != initialValueSpecification) { + resultCommand = createCommand(objectToEdit, structuralFeature, null); + } } else { - if (value instanceof LiteralBooleanRule) { - // Check that the type of the parent is a boolean - if (isTypeNeeeded(objectToEdit, - UMLPackage.Literals.LITERAL_BOOLEAN)) { - // Create a literal boolean - createdValueSpecification = UMLFactory.eINSTANCE - .createLiteralBoolean(); - copyFeatureValues(createdValueSpecification, - initialValueSpecification); - ((LiteralBoolean) createdValueSpecification) - .setValue(Boolean - .parseBoolean(((LiteralBooleanRule) value) - .getValue())); - } - } else if (value instanceof LiteralIntegerOrUnlimitedNaturalRule) { - boolean created = false; - final LiteralIntegerOrUnlimitedNaturalRule integerValue = (LiteralIntegerOrUnlimitedNaturalRule) value; - // Check that the value is upper than 0 and the type of the - // parent is a integer - if (0 <= integerValue.getValue() - && isTypeNeeeded( - objectToEdit, - UMLPackage.Literals.LITERAL_UNLIMITED_NATURAL)) { - // Create a literal unlimited natural - createdValueSpecification = UMLFactory.eINSTANCE - .createLiteralUnlimitedNatural(); - copyFeatureValues(createdValueSpecification, - initialValueSpecification); - ((LiteralUnlimitedNatural) createdValueSpecification) - .setValue(integerValue.getValue()); - created = true; + final AbstractRule abstractRule = (AbstractRule) xtextObject; + // Get the object to update if the existing is corresponding to the parsed potential value specification + + newValueSpecification = getObjectToUpdate(objectToEdit, initialValueSpecification, abstractRule); + + // If the object to update is not correct, create the good ValueSpecification + if (null != newValueSpecification) { + resultCommand = createUpdateValueSpecificationCommand(newValueSpecification, abstractRule); + } else { + newValueSpecification = createValueSpecification(objectToEdit, initialValueSpecification, abstractRule); + + if (null != newValueSpecification) { + // Affect the name and the visibility + affectAttributes(newValueSpecification, abstractRule); + } else { + // Create the opaque expression if no value specification + // was created + newValueSpecification = createOpaqueExpression( + initialValueSpecification, xtextStringValue, + defaultLanguages); } - // Check that the value specification is not already created - // and the type of the parent is an integer - if (!created - && isTypeNeeeded(objectToEdit, - UMLPackage.Literals.LITERAL_INTEGER)) { - // Create a literal unlimited natural - createdValueSpecification = UMLFactory.eINSTANCE - .createLiteralInteger(); - copyFeatureValues(createdValueSpecification, - initialValueSpecification); - ((LiteralInteger) createdValueSpecification) - .setValue(integerValue.getValue()); - created = true; - } + resultCommand = createCommand(objectToEdit, structuralFeature, newValueSpecification); + } + } + } + return resultCommand; + } - // Check that the value specification is not already created - // and the type of the parent is a real - if (!created - && isTypeNeeeded(objectToEdit, - UMLPackage.Literals.LITERAL_REAL)) { - // Create a literal unlimited natural - createdValueSpecification = UMLFactory.eINSTANCE - .createLiteralReal(); - copyFeatureValues(createdValueSpecification, - initialValueSpecification); - ((LiteralReal) createdValueSpecification) - .setValue(integerValue.getValue()); - } - } else if (value instanceof LiteralRealRule) { - // Check that the type of the parent is a real - if (isTypeNeeeded(objectToEdit, - UMLPackage.Literals.LITERAL_REAL)) { - // Create a literal real - createdValueSpecification = UMLFactory.eINSTANCE - .createLiteralReal(); - copyFeatureValues(createdValueSpecification, - initialValueSpecification); - ((LiteralReal) createdValueSpecification) - .setValue(((LiteralRealRule) value).getValue()); - } - } else if (value instanceof LiteralNullRule) { - // Create a literal null + /** + * This allow to create the {@link ValueSpecification} corresponding to the xtext object parsed. + * + * @param objectToEdit + * The object to edit (parent of ValueSpecification). + * @param initialValueSpecification + * The initial {@link ValueSpecification} + * @param abstractRule + * The xtext object parsed. + * @return The created {@link ValueSpecification} or null. + */ + protected ValueSpecification createValueSpecification(final EObject objectToEdit, final EObject initialValueSpecification, final AbstractRule abstractRule) { + ValueSpecification createdValueSpecification = null; + + final EObject value = abstractRule.getValue(); + if (null != abstractRule.getInstanceSpecification()) { + // Create an instance value with specification value + createdValueSpecification = UMLFactory.eINSTANCE + .createInstanceValue(); + ((InstanceValue) createdValueSpecification) + .setInstance(abstractRule.getInstanceSpecification()); + } else { + if (value instanceof LiteralBooleanRule) { + // Check that the type of the parent is a boolean + if (isTypeNeeeded(objectToEdit, + UMLPackage.Literals.LITERAL_BOOLEAN)) { + // Create a literal boolean createdValueSpecification = UMLFactory.eINSTANCE - .createLiteralNull(); + .createLiteralBoolean(); copyFeatureValues(createdValueSpecification, initialValueSpecification); - } else if (value instanceof LiteralStringRule) { - // Create a literal real + ((LiteralBoolean) createdValueSpecification) + .setValue(Boolean + .parseBoolean(((LiteralBooleanRule) value) + .getValue())); + } + } else if (value instanceof LiteralIntegerOrUnlimitedNaturalRule) { + boolean created = false; + final LiteralIntegerOrUnlimitedNaturalRule integerValue = (LiteralIntegerOrUnlimitedNaturalRule) value; + // Check that the value is upper than 0 and the type of the + // parent is a integer + if (0 <= integerValue.getValue() + && isTypeNeeeded( + objectToEdit, + UMLPackage.Literals.LITERAL_UNLIMITED_NATURAL)) { + // Create a literal unlimited natural createdValueSpecification = UMLFactory.eINSTANCE - .createLiteralString(); + .createLiteralUnlimitedNatural(); copyFeatureValues(createdValueSpecification, initialValueSpecification); - ((LiteralString) createdValueSpecification) - .setValue(((LiteralStringRule) value).getValue()); + ((LiteralUnlimitedNatural) createdValueSpecification) + .setValue(integerValue.getValue()); + created = true; } - } - if (null != createdValueSpecification) { - // Affect the name and the visibility - affectAttributes(createdValueSpecification, abstractRule); - } else { - // Create the opaque expression if no value specification - // was created - createdValueSpecification = createOpaqueExpression( - initialValueSpecification, xtextStringValue, - defaultLanguages); + // Check that the value specification is not already created + // and the type of the parent is an integer + if (!created + && isTypeNeeeded(objectToEdit, + UMLPackage.Literals.LITERAL_INTEGER)) { + // Create a literal unlimited natural + createdValueSpecification = UMLFactory.eINSTANCE + .createLiteralInteger(); + copyFeatureValues(createdValueSpecification, + initialValueSpecification); + ((LiteralInteger) createdValueSpecification) + .setValue(integerValue.getValue()); + created = true; + } + + // Check that the value specification is not already created + // and the type of the parent is a real + if (!created + && isTypeNeeeded(objectToEdit, + UMLPackage.Literals.LITERAL_REAL)) { + // Create a literal unlimited natural + createdValueSpecification = UMLFactory.eINSTANCE + .createLiteralReal(); + copyFeatureValues(createdValueSpecification, + initialValueSpecification); + ((LiteralReal) createdValueSpecification) + .setValue(integerValue.getValue()); + } + } else if (value instanceof LiteralRealRule) { + // Check that the type of the parent is a real + if (isTypeNeeeded(objectToEdit, + UMLPackage.Literals.LITERAL_REAL)) { + // Create a literal real + createdValueSpecification = UMLFactory.eINSTANCE + .createLiteralReal(); + copyFeatureValues(createdValueSpecification, + initialValueSpecification); + ((LiteralReal) createdValueSpecification) + .setValue(((LiteralRealRule) value).getValue()); + } + } else if (value instanceof LiteralNullRule) { + // Create a literal null + createdValueSpecification = UMLFactory.eINSTANCE + .createLiteralNull(); + copyFeatureValues(createdValueSpecification, + initialValueSpecification); + } else if (value instanceof LiteralStringRule) { + // Create a literal real + createdValueSpecification = UMLFactory.eINSTANCE + .createLiteralString(); + copyFeatureValues(createdValueSpecification, + initialValueSpecification); + ((LiteralString) createdValueSpecification) + .setValue(((LiteralStringRule) value).getValue()); } } + return createdValueSpecification; } @@ -478,6 +484,134 @@ public class ValueSpecificationSetCommand { } } + /** + * This allow to create the command to update the value specification (visibility, name and value). + * + * @param valueSpecification + * The value specification to update. + * @param abstractRule + * The xtext object parsed. + * @return The command with the update commands. + */ + protected ICommand createUpdateValueSpecificationCommand(final ValueSpecification valueSpecification, final AbstractRule abstractRule) { + final CompositeCommand setAttributesCommand = new CompositeCommand("Update Value Specification Command"); //$NON-NLS-1$ + + // Check that the visibility was set + if (null != abstractRule.getVisibility()) { + VisibilityKind visibility = null; + if (null != abstractRule.getVisibility().getPublic()) { + visibility = VisibilityKind.PUBLIC_LITERAL; + } else if (null != abstractRule.getVisibility().getPackage()) { + visibility = VisibilityKind.PACKAGE_LITERAL; + } else if (null != abstractRule.getVisibility().getProtected()) { + visibility = VisibilityKind.PROTECTED_LITERAL; + } else if (null != abstractRule.getVisibility().getPrivate()) { + visibility = VisibilityKind.PRIVATE_LITERAL; + } + + if (null == valueSpecification.getVisibility() || !valueSpecification.getVisibility().equals(visibility)) { + // Set the visibility by command + final SetRequest request = new SetRequest(valueSpecification, + UMLPackage.Literals.NAMED_ELEMENT__VISIBILITY, visibility); + + final IElementEditService commandProvider = ElementEditServiceUtils + .getCommandProvider(valueSpecification); + ICommand setVisibilityCommand = commandProvider + .getEditCommand(request); + if (null != setVisibilityCommand + && setVisibilityCommand.canExecute()) { + setAttributesCommand.add(setVisibilityCommand); + } + } + } + + // Set the name if it was created + if (null != abstractRule.getName()) { + // Set the name by command + final ICommand setNameCommand = createSetNameCommand(valueSpecification, abstractRule.getName()); + if (null != setNameCommand + && setNameCommand.canExecute()) { + setAttributesCommand.add(setNameCommand); + } + } + + // Set the value by command + final ICommand setValueCommand = createSetValueCommand(valueSpecification, abstractRule); + if (null != setValueCommand + && setValueCommand.canExecute()) { + setAttributesCommand.add(setValueCommand); + } + + return setAttributesCommand.isEmpty() ? null : setAttributesCommand; + } + + /** + * This allow to create the set name command for a value specification. + * + * @param valueSpecification + * The value specification to update. + * @param name + * The name to affect. + * @return The command which allow to update the value specification. + */ + protected ICommand createSetNameCommand(final ValueSpecification valueSpecification, final String name) { + ICommand resultCommand = null; + // Set the name by command + if (null == valueSpecification.getName() || !valueSpecification.getName().equals(name)) { + final SetRequest request = new SetRequest(valueSpecification, + UMLPackage.Literals.NAMED_ELEMENT__NAME, name); + + final IElementEditService commandProvider = ElementEditServiceUtils + .getCommandProvider(valueSpecification); + resultCommand = commandProvider.getEditCommand(request); + } + return resultCommand; + } + + /** + * This allow to create the set value command for a value specification. + * + * @param valueSpecification + * The value specification to update. + * @param abstractRule + * The xtext object parsed. + * @return The command which allow to update the value specification. + */ + protected ICommand createSetValueCommand(final ValueSpecification valueSpecification, final AbstractRule abstractRule) { + ICommand resultCommand = null; + SetRequest request = null; + if (valueSpecification instanceof InstanceValue && null != abstractRule.getInstanceSpecification()) { + request = new SetRequest(valueSpecification, + UMLPackage.Literals.INSTANCE_VALUE__INSTANCE, abstractRule.getInstanceSpecification()); + } else { + final EObject xtextValue = abstractRule.getValue(); + if (valueSpecification instanceof LiteralBoolean && xtextValue instanceof LiteralBooleanRule) { + request = new SetRequest(valueSpecification, + UMLPackage.Literals.LITERAL_BOOLEAN__VALUE, Boolean.parseBoolean(((LiteralBooleanRule) xtextValue).getValue())); + } else if (valueSpecification instanceof LiteralInteger && xtextValue instanceof LiteralIntegerOrUnlimitedNaturalRule) { + request = new SetRequest(valueSpecification, + UMLPackage.Literals.LITERAL_INTEGER__VALUE, ((LiteralIntegerOrUnlimitedNaturalRule) xtextValue).getValue()); + } else if (valueSpecification instanceof LiteralUnlimitedNatural && xtextValue instanceof LiteralIntegerOrUnlimitedNaturalRule) { + request = new SetRequest(valueSpecification, + UMLPackage.Literals.LITERAL_UNLIMITED_NATURAL__VALUE, ((LiteralIntegerOrUnlimitedNaturalRule) xtextValue).getValue()); + } else if (valueSpecification instanceof LiteralReal && xtextValue instanceof LiteralRealRule) { + request = new SetRequest(valueSpecification, + UMLPackage.Literals.LITERAL_REAL__VALUE, ((LiteralRealRule) xtextValue).getValue()); + } else if (valueSpecification instanceof LiteralString && xtextValue instanceof LiteralStringRule) { + request = new SetRequest(valueSpecification, + UMLPackage.Literals.LITERAL_STRING__VALUE, ((LiteralStringRule) xtextValue).getValue()); + } + } + + if (null != request) { + final IElementEditService commandProvider = ElementEditServiceUtils + .getCommandProvider(valueSpecification); + resultCommand = commandProvider.getEditCommand(request); + } + + return resultCommand; + } + /** * This allow to copy all the old feature values from the existing object to * the new one. @@ -491,6 +625,7 @@ public class ValueSpecificationSetCommand { final ValueSpecification newValueSpecification, final EObject existingObject) { + // The copy of feature isn't possible for the Opaque Expression if (null != existingObject && existingObject instanceof ValueSpecification) { ValueSpecification existingValueSpecification = (ValueSpecification) existingObject; @@ -504,8 +639,10 @@ public class ValueSpecificationSetCommand { && newValueSpecification.eClass() .getEAllStructuralFeatures() .contains(structuralFeature)) { - newValueSpecification.eSet(structuralFeature, - existingObject.eGet(structuralFeature)); + if (!(existingObject instanceof OpaqueExpression && structuralFeature.equals(UMLPackage.Literals.NAMED_ELEMENT__NAME))) { + newValueSpecification.eSet(structuralFeature, + existingObject.eGet(structuralFeature)); + } } } } @@ -519,8 +656,7 @@ public class ValueSpecificationSetCommand { * The object to check. * @param typeNeeded * The type needed. - * @return true if the object allow the typed needed, - * false otherwise. + * @return true if the object allow the typed needed, false otherwise. */ protected boolean isTypeNeeeded(final Object object, final Object typeNeeded) { @@ -552,31 +688,80 @@ public class ValueSpecificationSetCommand { } /** - * This allow to create the opaque expression. + * This allow to manage the opaque expression update or create. * * @param initialEObject - * The initial EObject. + * The initial object to edit. + * @param structuralFeature + * The structural feature to update/create. + * @param initialValueSpecification + * The initial {@link ValueSpecification}. + * @param xtextStringValue + * The xtext string value. + * @param defaultLanguages + * The default languages for the {@link paqueExpression}. + * @return The created command for the update or creation of the {@link paqueExpression}. + */ + protected ICommand manageOpaqueExpression(final EObject initialEObject, final EStructuralFeature structuralFeature, final ValueSpecification initialValueSpecification, final String xtextStringValue, final Collection defaultLanguages) { + ICommand resultCommand = null; + if (null != initialValueSpecification && initialValueSpecification instanceof OpaqueExpression && !xtextStringValue.isEmpty()) { + resultCommand = createUpdateOpaqueExpressionCommand((OpaqueExpression) initialValueSpecification, xtextStringValue); + } else { + OpaqueExpression createdOpaqueExpression = null; + if (!xtextStringValue.isEmpty()) { + createdOpaqueExpression = createOpaqueExpression(initialValueSpecification, xtextStringValue, defaultLanguages); + } + resultCommand = createCommand(initialEObject, structuralFeature, createdOpaqueExpression); + } + return resultCommand; + } + + /** + * This allow to create the update command of the {@link OpaqueExpression}. + * + * @param opaqueExpression + * The {@link OpaqueExpression} to update. + * @param name + * The new name of the {@link OpaqueExpression}. + * @return The update command which allow to update the {@link OpaqueExpression}. + */ + protected ICommand createUpdateOpaqueExpressionCommand(final OpaqueExpression opaqueExpression, final String name) { + final CompositeCommand setAttributesCommand = new CompositeCommand("Update Opaque Expression Command"); //$NON-NLS-1$ + + if (!name.isEmpty()) { + // Set the name by command + ICommand setNameCommand = createSetNameCommand(opaqueExpression, name); + if (null != setNameCommand + && setNameCommand.canExecute()) { + setAttributesCommand.add(setNameCommand); + } + } + + return setAttributesCommand; + } + + /** + * This allow to create the opaque expression. + * + * @param initiaValueSpecification + * The initial value specification. * @param xtextStringValue * The xtext string value. * @param defaultLanguages * The default languages for an opaque expression. * @return The created {@link OpaqueExpression}. */ - protected ValueSpecification createOpaqueExpression( - final EObject initialEObject, final String xtextStringValue, + protected OpaqueExpression createOpaqueExpression( + final EObject initiaValueSpecification, final String xtextStringValue, final Collection defaultLanguages) { - - if (!xtextStringValue.isEmpty()) { - // Create the opaque expression - ValueSpecification valueSpecification = UMLFactory.eINSTANCE - .createOpaqueExpression(); - copyFeatureValues(valueSpecification, initialEObject); - ((OpaqueExpression) valueSpecification).getLanguages().addAll( - defaultLanguages); - valueSpecification.setName(xtextStringValue); - return valueSpecification; - } - return null; + // Create the opaque expression + final OpaqueExpression valueSpecification = UMLFactory.eINSTANCE + .createOpaqueExpression(); + copyFeatureValues(valueSpecification, initiaValueSpecification); + valueSpecification.getLanguages().addAll( + defaultLanguages); + valueSpecification.setName(xtextStringValue); + return valueSpecification; } /** @@ -599,4 +784,44 @@ public class ValueSpecificationSetCommand { } }; } + + /** + * This allow to get the existing object to update if this is possible. + * + * @param objectToEdit + * The object to edit (parent of ValueSpecification). + * @param initialValueSpecification + * The object to edit. + * @param xtextObject + * The xtext object. + * @return The {@link ValueSpecification} existing or null. + */ + protected ValueSpecification getObjectToUpdate(final EObject objectToEdit, final ValueSpecification initialValueSpecification, final EObject xtextObject) { + ValueSpecification result = null; + if (null != initialValueSpecification && null != xtextObject && xtextObject instanceof AbstractRule && null == ((AbstractRule) xtextObject).getUndefined()) { + final AbstractRule abstractRule = (AbstractRule) xtextObject; + if (initialValueSpecification instanceof InstanceValue && null != abstractRule.getInstanceSpecification()) { + result = (InstanceValue) initialValueSpecification; + } else { + final EObject xtextValue = abstractRule.getValue(); + if (initialValueSpecification instanceof LiteralBoolean && xtextValue instanceof LiteralBooleanRule && isTypeNeeeded(objectToEdit, UMLPackage.Literals.LITERAL_BOOLEAN)) { + result = (LiteralBoolean) initialValueSpecification; + } else if (initialValueSpecification instanceof LiteralInteger && xtextValue instanceof LiteralIntegerOrUnlimitedNaturalRule && isTypeNeeeded(objectToEdit, UMLPackage.Literals.LITERAL_INTEGER)) { + result = (LiteralInteger) initialValueSpecification; + } else if (initialValueSpecification instanceof LiteralUnlimitedNatural && xtextValue instanceof LiteralIntegerOrUnlimitedNaturalRule && isTypeNeeeded(objectToEdit, UMLPackage.Literals.LITERAL_UNLIMITED_NATURAL)) { + // Check that the value if positive for the unlimited natural type + if (((LiteralIntegerOrUnlimitedNaturalRule) xtextValue).getValue() >= 0) { + result = (LiteralUnlimitedNatural) initialValueSpecification; + } + } else if (initialValueSpecification instanceof LiteralReal && xtextValue instanceof LiteralRealRule && isTypeNeeeded(objectToEdit, UMLPackage.Literals.LITERAL_REAL)) { + result = (LiteralReal) initialValueSpecification; + } else if (initialValueSpecification instanceof LiteralNull && xtextValue instanceof LiteralNullRule) { + result = (LiteralNull) initialValueSpecification; + } else if (initialValueSpecification instanceof LiteralString && xtextValue instanceof LiteralStringRule) { + result = (LiteralString) initialValueSpecification; + } + } + } + return result; + } } diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/UmlValueSpecification.xtextbin b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/UmlValueSpecification.xtextbin index 0675228f0b1..403e64042ab 100644 Binary files a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/UmlValueSpecification.xtextbin and b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/UmlValueSpecification.xtextbin differ diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g index bdeb6e1478b..d67e2f87c23 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g @@ -562,7 +562,7 @@ ruleVisibilityKind returns [EObject current=null] -RULE_DOUBLE : ('0'..'9')+ '.' ('0'..'9')+; +RULE_DOUBLE : (('0'..'9')+ ('.'|',') ('0'..'9')*|('0'..'9')* ('.'|',') ('0'..'9')+); RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecificationLexer.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecificationLexer.java index 427f65fa620..acd3df11d23 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecificationLexer.java +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecificationLexer.java @@ -233,69 +233,155 @@ public class InternalUmlValueSpecificationLexer extends Lexer { try { int _type = RULE_DOUBLE; int _channel = DEFAULT_TOKEN_CHANNEL; - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:13: ( ( '0' .. '9' )+ '.' ( '0' .. '9' )+ ) - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:15: ( '0' .. '9' )+ '.' ( '0' .. '9' )+ + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:13: ( ( ( '0' .. '9' )+ ( '.' | ',' ) ( '0' .. '9' )* | ( '0' .. '9' )* ( '.' | ',' ) ( '0' .. '9' )+ ) ) + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:15: ( ( '0' .. '9' )+ ( '.' | ',' ) ( '0' .. '9' )* | ( '0' .. '9' )* ( '.' | ',' ) ( '0' .. '9' )+ ) { - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:15: ( '0' .. '9' )+ - int cnt1=0; - loop1: - do { - int alt1=2; - int LA1_0 = input.LA(1); + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:15: ( ( '0' .. '9' )+ ( '.' | ',' ) ( '0' .. '9' )* | ( '0' .. '9' )* ( '.' | ',' ) ( '0' .. '9' )+ ) + int alt5=2; + alt5 = dfa5.predict(input); + switch (alt5) { + case 1 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:16: ( '0' .. '9' )+ ( '.' | ',' ) ( '0' .. '9' )* + { + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:16: ( '0' .. '9' )+ + int cnt1=0; + loop1: + do { + int alt1=2; + int LA1_0 = input.LA(1); - if ( ((LA1_0>='0' && LA1_0<='9')) ) { - alt1=1; - } + if ( ((LA1_0>='0' && LA1_0<='9')) ) { + alt1=1; + } - switch (alt1) { - case 1 : - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:16: '0' .. '9' - { - matchRange('0','9'); + switch (alt1) { + case 1 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:17: '0' .. '9' + { + matchRange('0','9'); - } - break; + } + break; - default : - if ( cnt1 >= 1 ) break loop1; - EarlyExitException eee = - new EarlyExitException(1, input); - throw eee; - } - cnt1++; - } while (true); + default : + if ( cnt1 >= 1 ) break loop1; + EarlyExitException eee = + new EarlyExitException(1, input); + throw eee; + } + cnt1++; + } while (true); - match('.'); - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:31: ( '0' .. '9' )+ - int cnt2=0; - loop2: - do { - int alt2=2; - int LA2_0 = input.LA(1); + if ( input.LA(1)==','||input.LA(1)=='.' ) { + input.consume(); - if ( ((LA2_0>='0' && LA2_0<='9')) ) { - alt2=1; - } + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:38: ( '0' .. '9' )* + loop2: + do { + int alt2=2; + int LA2_0 = input.LA(1); - switch (alt2) { - case 1 : - // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:32: '0' .. '9' - { - matchRange('0','9'); + if ( ((LA2_0>='0' && LA2_0<='9')) ) { + alt2=1; + } - } - break; - default : - if ( cnt2 >= 1 ) break loop2; - EarlyExitException eee = - new EarlyExitException(2, input); - throw eee; - } - cnt2++; - } while (true); + switch (alt2) { + case 1 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:39: '0' .. '9' + { + matchRange('0','9'); + + } + break; + + default : + break loop2; + } + } while (true); + + + } + break; + case 2 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:50: ( '0' .. '9' )* ( '.' | ',' ) ( '0' .. '9' )+ + { + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:50: ( '0' .. '9' )* + loop3: + do { + int alt3=2; + int LA3_0 = input.LA(1); + + if ( ((LA3_0>='0' && LA3_0<='9')) ) { + alt3=1; + } + + + switch (alt3) { + case 1 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:51: '0' .. '9' + { + matchRange('0','9'); + + } + break; + + default : + break loop3; + } + } while (true); + + if ( input.LA(1)==','||input.LA(1)=='.' ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:72: ( '0' .. '9' )+ + int cnt4=0; + loop4: + do { + int alt4=2; + int LA4_0 = input.LA(1); + + if ( ((LA4_0>='0' && LA4_0<='9')) ) { + alt4=1; + } + + + switch (alt4) { + case 1 : + // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:565:73: '0' .. '9' + { + matchRange('0','9'); + + } + break; + + default : + if ( cnt4 >= 1 ) break loop4; + EarlyExitException eee = + new EarlyExitException(4, input); + throw eee; + } + cnt4++; + } while (true); + + + } + break; + + } } @@ -317,13 +403,13 @@ public class InternalUmlValueSpecificationLexer extends Lexer { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:567:11: ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:567:11: ( '^' )? - int alt3=2; - int LA3_0 = input.LA(1); + int alt6=2; + int LA6_0 = input.LA(1); - if ( (LA3_0=='^') ) { - alt3=1; + if ( (LA6_0=='^') ) { + alt6=1; } - switch (alt3) { + switch (alt6) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:567:11: '^' { @@ -344,17 +430,17 @@ public class InternalUmlValueSpecificationLexer extends Lexer { throw mse;} // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:567:40: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* - loop4: + loop7: do { - int alt4=2; - int LA4_0 = input.LA(1); + int alt7=2; + int LA7_0 = input.LA(1); - if ( ((LA4_0>='0' && LA4_0<='9')||(LA4_0>='A' && LA4_0<='Z')||LA4_0=='_'||(LA4_0>='a' && LA4_0<='z')) ) { - alt4=1; + if ( ((LA7_0>='0' && LA7_0<='9')||(LA7_0>='A' && LA7_0<='Z')||LA7_0=='_'||(LA7_0>='a' && LA7_0<='z')) ) { + alt7=1; } - switch (alt4) { + switch (alt7) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g: { @@ -372,7 +458,7 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - break loop4; + break loop7; } } while (true); @@ -396,18 +482,18 @@ public class InternalUmlValueSpecificationLexer extends Lexer { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:569:12: ( '0' .. '9' )+ { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:569:12: ( '0' .. '9' )+ - int cnt5=0; - loop5: + int cnt8=0; + loop8: do { - int alt5=2; - int LA5_0 = input.LA(1); + int alt8=2; + int LA8_0 = input.LA(1); - if ( ((LA5_0>='0' && LA5_0<='9')) ) { - alt5=1; + if ( ((LA8_0>='0' && LA8_0<='9')) ) { + alt8=1; } - switch (alt5) { + switch (alt8) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:569:13: '0' .. '9' { @@ -417,12 +503,12 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - if ( cnt5 >= 1 ) break loop5; + if ( cnt8 >= 1 ) break loop8; EarlyExitException eee = - new EarlyExitException(5, input); + new EarlyExitException(8, input); throw eee; } - cnt5++; + cnt8++; } while (true); @@ -445,41 +531,41 @@ public class InternalUmlValueSpecificationLexer extends Lexer { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:571:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:571:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) - int alt8=2; - int LA8_0 = input.LA(1); + int alt11=2; + int LA11_0 = input.LA(1); - if ( (LA8_0=='\"') ) { - alt8=1; + if ( (LA11_0=='\"') ) { + alt11=1; } - else if ( (LA8_0=='\'') ) { - alt8=2; + else if ( (LA11_0=='\'') ) { + alt11=2; } else { NoViableAltException nvae = - new NoViableAltException("", 8, 0, input); + new NoViableAltException("", 11, 0, input); throw nvae; } - switch (alt8) { + switch (alt11) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:571:16: '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' { match('\"'); // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:571:20: ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* - loop6: + loop9: do { - int alt6=3; - int LA6_0 = input.LA(1); + int alt9=3; + int LA9_0 = input.LA(1); - if ( (LA6_0=='\\') ) { - alt6=1; + if ( (LA9_0=='\\') ) { + alt9=1; } - else if ( ((LA6_0>='\u0000' && LA6_0<='!')||(LA6_0>='#' && LA6_0<='[')||(LA6_0>=']' && LA6_0<='\uFFFF')) ) { - alt6=2; + else if ( ((LA9_0>='\u0000' && LA9_0<='!')||(LA9_0>='#' && LA9_0<='[')||(LA9_0>=']' && LA9_0<='\uFFFF')) ) { + alt9=2; } - switch (alt6) { + switch (alt9) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:571:21: '\\\\' . { @@ -505,7 +591,7 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - break loop6; + break loop9; } } while (true); @@ -518,20 +604,20 @@ public class InternalUmlValueSpecificationLexer extends Lexer { { match('\''); // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:571:53: ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* - loop7: + loop10: do { - int alt7=3; - int LA7_0 = input.LA(1); + int alt10=3; + int LA10_0 = input.LA(1); - if ( (LA7_0=='\\') ) { - alt7=1; + if ( (LA10_0=='\\') ) { + alt10=1; } - else if ( ((LA7_0>='\u0000' && LA7_0<='&')||(LA7_0>='(' && LA7_0<='[')||(LA7_0>=']' && LA7_0<='\uFFFF')) ) { - alt7=2; + else if ( ((LA10_0>='\u0000' && LA10_0<='&')||(LA10_0>='(' && LA10_0<='[')||(LA10_0>=']' && LA10_0<='\uFFFF')) ) { + alt10=2; } - switch (alt7) { + switch (alt10) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:571:54: '\\\\' . { @@ -557,7 +643,7 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - break loop7; + break loop10; } } while (true); @@ -590,29 +676,29 @@ public class InternalUmlValueSpecificationLexer extends Lexer { match("/*"); // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:573:24: ( options {greedy=false; } : . )* - loop9: + loop12: do { - int alt9=2; - int LA9_0 = input.LA(1); + int alt12=2; + int LA12_0 = input.LA(1); - if ( (LA9_0=='*') ) { - int LA9_1 = input.LA(2); + if ( (LA12_0=='*') ) { + int LA12_1 = input.LA(2); - if ( (LA9_1=='/') ) { - alt9=2; + if ( (LA12_1=='/') ) { + alt12=2; } - else if ( ((LA9_1>='\u0000' && LA9_1<='.')||(LA9_1>='0' && LA9_1<='\uFFFF')) ) { - alt9=1; + else if ( ((LA12_1>='\u0000' && LA12_1<='.')||(LA12_1>='0' && LA12_1<='\uFFFF')) ) { + alt12=1; } } - else if ( ((LA9_0>='\u0000' && LA9_0<=')')||(LA9_0>='+' && LA9_0<='\uFFFF')) ) { - alt9=1; + else if ( ((LA12_0>='\u0000' && LA12_0<=')')||(LA12_0>='+' && LA12_0<='\uFFFF')) ) { + alt12=1; } - switch (alt9) { + switch (alt12) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:573:52: . { @@ -622,7 +708,7 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - break loop9; + break loop12; } } while (true); @@ -650,17 +736,17 @@ public class InternalUmlValueSpecificationLexer extends Lexer { match("//"); // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:575:24: (~ ( ( '\\n' | '\\r' ) ) )* - loop10: + loop13: do { - int alt10=2; - int LA10_0 = input.LA(1); + int alt13=2; + int LA13_0 = input.LA(1); - if ( ((LA10_0>='\u0000' && LA10_0<='\t')||(LA10_0>='\u000B' && LA10_0<='\f')||(LA10_0>='\u000E' && LA10_0<='\uFFFF')) ) { - alt10=1; + if ( ((LA13_0>='\u0000' && LA13_0<='\t')||(LA13_0>='\u000B' && LA13_0<='\f')||(LA13_0>='\u000E' && LA13_0<='\uFFFF')) ) { + alt13=1; } - switch (alt10) { + switch (alt13) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:575:24: ~ ( ( '\\n' | '\\r' ) ) { @@ -678,29 +764,29 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - break loop10; + break loop13; } } while (true); // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:575:40: ( ( '\\r' )? '\\n' )? - int alt12=2; - int LA12_0 = input.LA(1); + int alt15=2; + int LA15_0 = input.LA(1); - if ( (LA12_0=='\n'||LA12_0=='\r') ) { - alt12=1; + if ( (LA15_0=='\n'||LA15_0=='\r') ) { + alt15=1; } - switch (alt12) { + switch (alt15) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:575:41: ( '\\r' )? '\\n' { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:575:41: ( '\\r' )? - int alt11=2; - int LA11_0 = input.LA(1); + int alt14=2; + int LA14_0 = input.LA(1); - if ( (LA11_0=='\r') ) { - alt11=1; + if ( (LA14_0=='\r') ) { + alt14=1; } - switch (alt11) { + switch (alt14) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:575:41: '\\r' { @@ -738,18 +824,18 @@ public class InternalUmlValueSpecificationLexer extends Lexer { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:577:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:577:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ - int cnt13=0; - loop13: + int cnt16=0; + loop16: do { - int alt13=2; - int LA13_0 = input.LA(1); + int alt16=2; + int LA16_0 = input.LA(1); - if ( ((LA13_0>='\t' && LA13_0<='\n')||LA13_0=='\r'||LA13_0==' ') ) { - alt13=1; + if ( ((LA16_0>='\t' && LA16_0<='\n')||LA16_0=='\r'||LA16_0==' ') ) { + alt16=1; } - switch (alt13) { + switch (alt16) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g: { @@ -767,12 +853,12 @@ public class InternalUmlValueSpecificationLexer extends Lexer { break; default : - if ( cnt13 >= 1 ) break loop13; + if ( cnt16 >= 1 ) break loop16; EarlyExitException eee = - new EarlyExitException(13, input); + new EarlyExitException(16, input); throw eee; } - cnt13++; + cnt16++; } while (true); @@ -808,9 +894,9 @@ public class InternalUmlValueSpecificationLexer extends Lexer { public void mTokens() throws RecognitionException { // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:1:8: ( T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | T__18 | T__19 | T__20 | RULE_DOUBLE | RULE_ID | RULE_INT | RULE_STRING | RULE_ML_COMMENT | RULE_SL_COMMENT | RULE_WS | RULE_ANY_OTHER ) - int alt14=17; - alt14 = dfa14.predict(input); - switch (alt14) { + int alt17=17; + alt17 = dfa17.predict(input); + switch (alt17) { case 1 : // ../org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/parser/antlr/internal/InternalUmlValueSpecification.g:1:10: T__12 { @@ -936,106 +1022,161 @@ public class InternalUmlValueSpecificationLexer extends Lexer { } - protected DFA14 dfa14 = new DFA14(this); - static final String DFA14_eotS = - "\2\uffff\3\24\1\21\4\uffff\1\34\1\21\1\uffff\3\21\3\uffff\1\24"+ - "\1\uffff\2\24\6\uffff\1\34\5\uffff\3\24\1\51\1\24\1\53\1\uffff\1"+ - "\54\2\uffff"; - static final String DFA14_eofS = - "\55\uffff"; - static final String DFA14_minS = - "\1\0\1\uffff\1\162\1\141\1\165\1\125\4\uffff\1\56\1\101\1\uffff"+ - "\2\0\1\52\3\uffff\1\165\1\uffff\2\154\6\uffff\1\56\5\uffff\1\145"+ - "\1\163\1\154\1\60\1\145\1\60\1\uffff\1\60\2\uffff"; - static final String DFA14_maxS = - "\1\uffff\1\uffff\1\162\1\141\1\165\1\125\4\uffff\1\71\1\172\1\uffff"+ - "\2\uffff\1\57\3\uffff\1\165\1\uffff\2\154\6\uffff\1\71\5\uffff\1"+ + protected DFA5 dfa5 = new DFA5(this); + protected DFA17 dfa17 = new DFA17(this); + static final String DFA5_eotS = + "\3\uffff\1\4\1\uffff"; + static final String DFA5_eofS = + "\5\uffff"; + static final String DFA5_minS = + "\2\54\1\uffff\1\0\1\uffff"; + static final String DFA5_maxS = + "\2\71\1\uffff\1\0\1\uffff"; + static final String DFA5_acceptS = + "\2\uffff\1\2\1\uffff\1\1"; + static final String DFA5_specialS = + "\5\uffff}>"; + static final String[] DFA5_transitionS = { + "\1\2\1\uffff\1\2\1\uffff\12\1", + "\1\3\1\uffff\1\3\1\uffff\12\1", + "", + "\1\uffff", + "" + }; + + static final short[] DFA5_eot = DFA.unpackEncodedString(DFA5_eotS); + static final short[] DFA5_eof = DFA.unpackEncodedString(DFA5_eofS); + static final char[] DFA5_min = DFA.unpackEncodedStringToUnsignedChars(DFA5_minS); + static final char[] DFA5_max = DFA.unpackEncodedStringToUnsignedChars(DFA5_maxS); + static final short[] DFA5_accept = DFA.unpackEncodedString(DFA5_acceptS); + static final short[] DFA5_special = DFA.unpackEncodedString(DFA5_specialS); + static final short[][] DFA5_transition; + + static { + int numStates = DFA5_transitionS.length; + DFA5_transition = new short[numStates][]; + for (int i=0; i"; - static final String[] DFA14_transitionS = { - "\11\21\2\20\2\21\1\20\22\21\1\20\1\21\1\15\1\10\3\21\1\16\3"+ - "\21\1\6\1\21\1\7\1\21\1\17\12\12\2\21\1\5\1\1\3\21\32\14\3\21"+ - "\1\13\1\14\1\21\5\14\1\3\7\14\1\4\5\14\1\2\6\14\3\21\1\11\uff81"+ - "\21", + static final String DFA17_acceptS = + "\1\uffff\1\1\4\uffff\1\6\1\7\1\10\1\11\3\uffff\1\13\3\uffff\1\20"+ + "\1\21\1\1\1\uffff\1\13\2\uffff\1\5\1\6\1\7\1\10\1\11\1\14\1\12\1"+ + "\uffff\1\15\1\16\1\17\1\20\6\uffff\1\2\1\uffff\1\4\1\3"; + static final String DFA17_specialS = + "\1\1\15\uffff\1\0\1\2\36\uffff}>"; + static final String[] DFA17_transitionS = { + "\11\22\2\21\2\22\1\21\22\22\1\21\1\22\1\16\1\10\3\22\1\17\3"+ + "\22\1\6\1\13\1\7\1\13\1\20\12\12\2\22\1\5\1\1\3\22\32\15\3\22"+ + "\1\14\1\15\1\22\5\15\1\3\7\15\1\4\5\15\1\2\6\15\3\22\1\11\uff81"+ + "\22", "", - "\1\23", - "\1\25", + "\1\24", "\1\26", "\1\27", + "\1\30", "", "", "", "", - "\1\36\1\uffff\12\35", - "\32\24\4\uffff\1\24\1\uffff\32\24", - "", - "\0\37", - "\0\37", - "\1\40\4\uffff\1\41", + "\1\36\1\uffff\1\36\1\uffff\12\37", + "\12\36", + "\32\25\4\uffff\1\25\1\uffff\32\25", "", + "\0\40", + "\0\40", + "\1\41\4\uffff\1\42", "", "", - "\1\43", "", "\1\44", + "", "\1\45", + "\1\46", "", "", "", "", "", "", - "\1\36\1\uffff\12\35", "", + "\1\36\1\uffff\1\36\1\uffff\12\37", "", "", "", "", - "\1\46", "\1\47", "\1\50", - "\12\24\7\uffff\32\24\4\uffff\1\24\1\uffff\32\24", - "\1\52", - "\12\24\7\uffff\32\24\4\uffff\1\24\1\uffff\32\24", + "\1\51", + "\12\25\7\uffff\32\25\4\uffff\1\25\1\uffff\32\25", + "\1\53", + "\12\25\7\uffff\32\25\4\uffff\1\25\1\uffff\32\25", "", - "\12\24\7\uffff\32\24\4\uffff\1\24\1\uffff\32\24", + "\12\25\7\uffff\32\25\4\uffff\1\25\1\uffff\32\25", "", "" }; - static final short[] DFA14_eot = DFA.unpackEncodedString(DFA14_eotS); - static final short[] DFA14_eof = DFA.unpackEncodedString(DFA14_eofS); - static final char[] DFA14_min = DFA.unpackEncodedStringToUnsignedChars(DFA14_minS); - static final char[] DFA14_max = DFA.unpackEncodedStringToUnsignedChars(DFA14_maxS); - static final short[] DFA14_accept = DFA.unpackEncodedString(DFA14_acceptS); - static final short[] DFA14_special = DFA.unpackEncodedString(DFA14_specialS); - static final short[][] DFA14_transition; + static final short[] DFA17_eot = DFA.unpackEncodedString(DFA17_eotS); + static final short[] DFA17_eof = DFA.unpackEncodedString(DFA17_eofS); + static final char[] DFA17_min = DFA.unpackEncodedStringToUnsignedChars(DFA17_minS); + static final char[] DFA17_max = DFA.unpackEncodedStringToUnsignedChars(DFA17_maxS); + static final short[] DFA17_accept = DFA.unpackEncodedString(DFA17_acceptS); + static final short[] DFA17_special = DFA.unpackEncodedString(DFA17_specialS); + static final short[][] DFA17_transition; static { - int numStates = DFA14_transitionS.length; - DFA14_transition = new short[numStates][]; + int numStates = DFA17_transitionS.length; + DFA17_transition = new short[numStates][]; for (int i=0; i='\u0000' && LA14_14<='\uFFFF')) ) {s = 31;} + if ( ((LA17_14>='\u0000' && LA17_14<='\uFFFF')) ) {s = 32;} - else s = 17; + else s = 18; if ( s>=0 ) return s; break; case 1 : - int LA14_13 = input.LA(1); + int LA17_0 = input.LA(1); s = -1; - if ( ((LA14_13>='\u0000' && LA14_13<='\uFFFF')) ) {s = 31;} + if ( (LA17_0=='=') ) {s = 1;} - else s = 17; + else if ( (LA17_0=='t') ) {s = 2;} - if ( s>=0 ) return s; - break; - case 2 : - int LA14_0 = input.LA(1); + else if ( (LA17_0=='f') ) {s = 3;} - s = -1; - if ( (LA14_0=='=') ) {s = 1;} + else if ( (LA17_0=='n') ) {s = 4;} + + else if ( (LA17_0=='<') ) {s = 5;} - else if ( (LA14_0=='t') ) {s = 2;} + else if ( (LA17_0=='+') ) {s = 6;} - else if ( (LA14_0=='f') ) {s = 3;} + else if ( (LA17_0=='-') ) {s = 7;} - else if ( (LA14_0=='n') ) {s = 4;} + else if ( (LA17_0=='#') ) {s = 8;} - else if ( (LA14_0=='<') ) {s = 5;} + else if ( (LA17_0=='~') ) {s = 9;} - else if ( (LA14_0=='+') ) {s = 6;} + else if ( ((LA17_0>='0' && LA17_0<='9')) ) {s = 10;} - else if ( (LA14_0=='-') ) {s = 7;} + else if ( (LA17_0==','||LA17_0=='.') ) {s = 11;} - else if ( (LA14_0=='#') ) {s = 8;} + else if ( (LA17_0=='^') ) {s = 12;} - else if ( (LA14_0=='~') ) {s = 9;} + else if ( ((LA17_0>='A' && LA17_0<='Z')||LA17_0=='_'||(LA17_0>='a' && LA17_0<='e')||(LA17_0>='g' && LA17_0<='m')||(LA17_0>='o' && LA17_0<='s')||(LA17_0>='u' && LA17_0<='z')) ) {s = 13;} - else if ( ((LA14_0>='0' && LA14_0<='9')) ) {s = 10;} + else if ( (LA17_0=='\"') ) {s = 14;} - else if ( (LA14_0=='^') ) {s = 11;} + else if ( (LA17_0=='\'') ) {s = 15;} - else if ( ((LA14_0>='A' && LA14_0<='Z')||LA14_0=='_'||(LA14_0>='a' && LA14_0<='e')||(LA14_0>='g' && LA14_0<='m')||(LA14_0>='o' && LA14_0<='s')||(LA14_0>='u' && LA14_0<='z')) ) {s = 12;} + else if ( (LA17_0=='/') ) {s = 16;} - else if ( (LA14_0=='\"') ) {s = 13;} + else if ( ((LA17_0>='\t' && LA17_0<='\n')||LA17_0=='\r'||LA17_0==' ') ) {s = 17;} - else if ( (LA14_0=='\'') ) {s = 14;} + else if ( ((LA17_0>='\u0000' && LA17_0<='\b')||(LA17_0>='\u000B' && LA17_0<='\f')||(LA17_0>='\u000E' && LA17_0<='\u001F')||LA17_0=='!'||(LA17_0>='$' && LA17_0<='&')||(LA17_0>='(' && LA17_0<='*')||(LA17_0>=':' && LA17_0<=';')||(LA17_0>='>' && LA17_0<='@')||(LA17_0>='[' && LA17_0<=']')||LA17_0=='`'||(LA17_0>='{' && LA17_0<='}')||(LA17_0>='\u007F' && LA17_0<='\uFFFF')) ) {s = 18;} - else if ( (LA14_0=='/') ) {s = 15;} + if ( s>=0 ) return s; + break; + case 2 : + int LA17_15 = input.LA(1); - else if ( ((LA14_0>='\t' && LA14_0<='\n')||LA14_0=='\r'||LA14_0==' ') ) {s = 16;} + s = -1; + if ( ((LA17_15>='\u0000' && LA17_15<='\uFFFF')) ) {s = 32;} - else if ( ((LA14_0>='\u0000' && LA14_0<='\b')||(LA14_0>='\u000B' && LA14_0<='\f')||(LA14_0>='\u000E' && LA14_0<='\u001F')||LA14_0=='!'||(LA14_0>='$' && LA14_0<='&')||(LA14_0>='(' && LA14_0<='*')||LA14_0==','||LA14_0=='.'||(LA14_0>=':' && LA14_0<=';')||(LA14_0>='>' && LA14_0<='@')||(LA14_0>='[' && LA14_0<=']')||LA14_0=='`'||(LA14_0>='{' && LA14_0<='}')||(LA14_0>='\u007F' && LA14_0<='\uFFFF')) ) {s = 17;} + else s = 18; if ( s>=0 ) return s; break; } NoViableAltException nvae = - new NoViableAltException(getDescription(), 14, _s, input); + new NoViableAltException(getDescription(), 17, _s, input); error(nvae); throw nvae; } diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/services/UmlValueSpecificationGrammarAccess.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/services/UmlValueSpecificationGrammarAccess.java index d32f8425dc7..27ac2dba168 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/services/UmlValueSpecificationGrammarAccess.java +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src-gen/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/services/UmlValueSpecificationGrammarAccess.java @@ -366,7 +366,7 @@ public class UmlValueSpecificationGrammarAccess extends AbstractGrammarElementFi } //terminal DOUBLE returns ecore::EDouble: - // "0".."9"+ "." "0".."9"+; + // "0".."9"+ ("." | ",") "0".."9"* | "0".."9"* ("." | ",") "0".."9"+; public TerminalRule getDOUBLERule() { return tDOUBLE; } diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/UmlValueSpecification.xtext b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/UmlValueSpecification.xtext index 5d6ef4846a0..9f2da31c530 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/UmlValueSpecification.xtext +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/src/org/eclipse/papyrus/uml/textedit/valuespecification/xtext/UmlValueSpecification.xtext @@ -42,13 +42,12 @@ LiteralRealRule: value=DOUBLE ; -terminal DOUBLE returns ecore::EDouble: ('0'..'9')+"."('0'..'9')+; +terminal DOUBLE returns ecore::EDouble: (('0'..'9')+("."|",")('0'..'9')*|('0'..'9')*("."|",")('0'..'9')+); LiteralNullRule: value='null' ; - LiteralStringRule: value=STRING ; diff --git a/tests/junit/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.tests/src/org/eclipse/papyrus/uml/textedit/valuespecification/tests/suites/ValueSpecificationGrammarTests.java b/tests/junit/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.tests/src/org/eclipse/papyrus/uml/textedit/valuespecification/tests/suites/ValueSpecificationGrammarTests.java index b59796cc98f..bf67f01eaa9 100644 --- a/tests/junit/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.tests/src/org/eclipse/papyrus/uml/textedit/valuespecification/tests/suites/ValueSpecificationGrammarTests.java +++ b/tests/junit/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.tests/src/org/eclipse/papyrus/uml/textedit/valuespecification/tests/suites/ValueSpecificationGrammarTests.java @@ -14,6 +14,7 @@ package org.eclipse.papyrus.uml.textedit.valuespecification.tests.suites; import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.xmi.XMIResource; import org.eclipse.papyrus.junit.utils.rules.PluginResource; import org.eclipse.papyrus.uml.textedit.valuespecification.tests.AbstractGrammarTest; import org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.contribution.ValueSpecificationXtextDirectEditorConfiguration; @@ -143,6 +144,10 @@ public class ValueSpecificationGrammarTests extends AbstractGrammarTest