Skip to main content
summaryrefslogtreecommitdiffstats
blob: ba4579ff1dd8978a86e80ea1dd4a6a8065c188f0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*******************************************************************************
 * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 * 
 * CONTRIBUTORS:
 * 		Juergen Haug (initial contribution)
 * 
 *******************************************************************************/

package org.eclipse.etrice.core.common.ui.autoedit;

import org.eclipse.etrice.core.common.ui.editor.model.BaseTokenTypeToPartitionMapper;
import org.eclipse.jface.text.IDocument;
import org.eclipse.xtext.ui.editor.autoedit.DefaultAutoEditStrategyProvider;

public class BaseAutoEditStrategyProvider extends DefaultAutoEditStrategyProvider {

	@Override
	protected void configureIndentationEditStrategy(IEditStrategyAcceptor acceptor) {
		acceptor.accept(defaultIndentLineAutoEditStrategy.get(), BaseTokenTypeToPartitionMapper.CCSTRING_LITERAL_PARTITION);
		super.configureIndentationEditStrategy(acceptor);
	}
	
	@Override
	protected void configureStringLiteral(IEditStrategyAcceptor acceptor) {
		acceptor.accept(partitionInsert.newInstance("'''", "'''"), IDocument.DEFAULT_CONTENT_TYPE);
		super.configureStringLiteral(acceptor);
	}
	
	protected void configureCompoundBracesBlocks(IEditStrategyAcceptor acceptor) {
		acceptor.accept(compoundMultiLineTerminals.newInstanceFor("{", "}").and("[", "]").and("(", ")"), BaseTokenTypeToPartitionMapper.CCSTRING_LITERAL_PARTITION);
		super.configureCompoundBracesBlocks(acceptor);
	}
	
	@Override
	protected void configureCurlyBracesBlock(IEditStrategyAcceptor acceptor) {
		acceptor.accept(singleLineTerminals.newInstance("{", "}"), BaseTokenTypeToPartitionMapper.CCSTRING_LITERAL_PARTITION);
		super.configureCurlyBracesBlock(acceptor);
	}

	@Override
	protected void configureSquareBrackets(IEditStrategyAcceptor acceptor) {
		acceptor.accept(singleLineTerminals.newInstance("[", "]"), BaseTokenTypeToPartitionMapper.CCSTRING_LITERAL_PARTITION);
		super.configureSquareBrackets(acceptor);
	}

	@Override
	protected void configureParenthesis(IEditStrategyAcceptor acceptor) {
		acceptor.accept(singleLineTerminals.newInstance("(", ")"), BaseTokenTypeToPartitionMapper.CCSTRING_LITERAL_PARTITION);
		super.configureParenthesis(acceptor);
	}
	
}

Back to the top