Skip to content

Commit

Permalink
Fixes #3071 by adding the desired preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Apr 18, 2021
1 parent 282e6b1 commit 72e1337
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
20 changes: 13 additions & 7 deletions msi.gama.core/src/msi/gama/common/preferences/GamaPreferences.java
Expand Up @@ -169,14 +169,20 @@ public static class Modeling {
public static Pref<String> OPERATORS_MENU_SORT = GamaPreferences
.create("pref_menu_operators_sort", "Sort operators menu by", "Category", IType.STRING, false)
.among("Name", "Category").in(Interface.NAME, Interface.MENUS);
public static final Pref<Boolean> CORE_CLOSE_CURLY =
GamaPreferences.create("pref_editor_close_curly", "Close curly brackets ( { )", true, IType.BOOL, false)
.in(NAME, TEXT);
public static final Pref<Boolean> CORE_CLOSE_SQUARE = GamaPreferences
.create("pref_editor_close_square", "Close square brackets ( [ )", true, IType.BOOL, false)

public static final Pref<Boolean> CORE_CLOSE_QUOTE = GamaPreferences
.create("pref_editor_close_quote", "Automatically close single quotes — '..'", true, IType.BOOL, false)
.in(NAME, TEXT);
public static final Pref<Boolean> CORE_CLOSE_DOUBLE = GamaPreferences.create("pref_editor_close_double",
"Automatically close double quotes — \"..\"", true, IType.BOOL, false).in(NAME, TEXT);
public static final Pref<Boolean> CORE_CLOSE_CURLY = GamaPreferences
.create("pref_editor_close_curly", "Automatically close curly brackets — {..}", true, IType.BOOL, false)
.in(NAME, TEXT);
public static final Pref<Boolean> CORE_CLOSE_PARENTHESES = GamaPreferences
.create("pref_editor_close_parentheses", "Close parentheses", true, IType.BOOL, false).in(NAME, TEXT);
public static final Pref<Boolean> CORE_CLOSE_SQUARE = GamaPreferences.create("pref_editor_close_square",
"Automatically close square brackets — [..]", true, IType.BOOL, false).in(NAME, TEXT);
public static final Pref<Boolean> CORE_CLOSE_PARENTHESES =
GamaPreferences.create("pref_editor_close_parentheses", "Automatically close parentheses — (..)", true,
IType.BOOL, false).in(NAME, TEXT);
public static final Pref<Boolean> EDITOR_CLEAN_UP =
GamaPreferences.create("pref_editor_save_format", "Apply formatting on save", false, IType.BOOL, false)
.in(NAME, GamaPreferences.Modeling.OPTIONS);
Expand Down
Expand Up @@ -6,23 +6,24 @@
* (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners
*
* Visit https://github.com/gama-platform/gama for license information and developers contact.
*
*
*
**********************************************************************************************/
package msi.gama.lang.gaml.ui.editor;

import org.eclipse.jface.text.IDocument;
import org.eclipse.xtext.ui.editor.autoedit.CompoundMultiLineTerminalsEditStrategy;
import org.eclipse.xtext.ui.editor.autoedit.DefaultAutoEditStrategyProvider;
import org.eclipse.xtext.ui.editor.model.TerminalsTokenTypeToPartitionMapper;

import msi.gama.common.preferences.GamaPreferences;

/**
* The class GamaAutoEditStrategyProvider.
*
*
* @author drogoul
* @since 17 mars 2015
*
*
*/

public class GamaAutoEditStrategyProvider extends DefaultAutoEditStrategyProvider {
Expand All @@ -48,30 +49,36 @@ protected void configureCompoundBracesBlocks(final IEditStrategyAcceptor accepto
}
}

if (s != null) {
acceptor.accept(s, IDocument.DEFAULT_CONTENT_TYPE);
if (s != null) { acceptor.accept(s, IDocument.DEFAULT_CONTENT_TYPE); }
}

@Override
protected void configureStringLiteral(final IEditStrategyAcceptor acceptor) {
if (GamaPreferences.Modeling.CORE_CLOSE_DOUBLE.getValue()) {
acceptor.accept(partitionInsert.newInstance("\"", "\""), IDocument.DEFAULT_CONTENT_TYPE);
acceptor.accept(partitionDeletion.newInstance("\"", "\""), IDocument.DEFAULT_CONTENT_TYPE);
}
if (GamaPreferences.Modeling.CORE_CLOSE_QUOTE.getValue()) {
acceptor.accept(partitionInsert.newInstance("'", "'"), IDocument.DEFAULT_CONTENT_TYPE);
acceptor.accept(partitionDeletion.newInstance("'", "'"), IDocument.DEFAULT_CONTENT_TYPE);
}
acceptor.accept(partitionEndSkippingEditStrategy.get(),
TerminalsTokenTypeToPartitionMapper.STRING_LITERAL_PARTITION);
}

@Override
protected void configureCurlyBracesBlock(final IEditStrategyAcceptor acceptor) {
if (GamaPreferences.Modeling.CORE_CLOSE_CURLY.getValue()) {
super.configureCurlyBracesBlock(acceptor);
}
if (GamaPreferences.Modeling.CORE_CLOSE_CURLY.getValue()) { super.configureCurlyBracesBlock(acceptor); }
}

@Override
protected void configureSquareBrackets(final IEditStrategyAcceptor acceptor) {
if (GamaPreferences.Modeling.CORE_CLOSE_SQUARE.getValue()) {
super.configureSquareBrackets(acceptor);
}
if (GamaPreferences.Modeling.CORE_CLOSE_SQUARE.getValue()) { super.configureSquareBrackets(acceptor); }
}

@Override
protected void configureParenthesis(final IEditStrategyAcceptor acceptor) {
if (GamaPreferences.Modeling.CORE_CLOSE_PARENTHESES.getValue()) {
super.configureParenthesis(acceptor);
}
if (GamaPreferences.Modeling.CORE_CLOSE_PARENTHESES.getValue()) { super.configureParenthesis(acceptor); }
}

}

0 comments on commit 72e1337

Please sign in to comment.