Skip to content

Commit

Permalink
Fix tab size in the Gradle editor
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Moine <christophe.moine@free.fr>
  • Loading branch information
cmoine committed Oct 3, 2017
1 parent b399d19 commit 15892da
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 13 deletions.
Expand Up @@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Moine - #514 Add Gradle editor
*/
package org.eclipse.buildship.ui.editor;

Expand All @@ -16,7 +19,6 @@
/**
* The document setup participant for a properties file document.
*
* @since 3.1
*/
public class GradleDocumentSetupParticipant implements IDocumentSetupParticipant {

Expand Down Expand Up @@ -50,6 +52,6 @@ public static void setupDocument(IDocument document) {
* @return a newly created properties file document partitioner
*/
private static IDocumentPartitioner createDocumentPartitioner() {
return new FastPartitioner(new GradlePartitionScanner(), IGradlePartitions.PARTITION_TYPES);
return new FastPartitioner(new GradlePartitionScanner(), IGradlePartitions.PARTITIONS);
}
}
Expand Up @@ -4,10 +4,15 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Moine - #514 Add Gradle editor
*/
package org.eclipse.buildship.ui.editor;

import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;

/**
* Gradle Editor entry point
Expand All @@ -20,4 +25,14 @@ protected void initializeEditor() {
setSourceViewerConfiguration(new GradleTextViewerConfiguration());
super.initializeEditor();
}

/*
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#isTabsToSpacesConversionEnabled()
* @since 3.7
*/
@Override
protected boolean isTabsToSpacesConversionEnabled() {
// Can't use our own preference store because JDT disables this functionality in its preferences.
return EditorsUI.getPreferenceStore().getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
}
}
Expand Up @@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Moine - #514 Add Gradle editor
*/
package org.eclipse.buildship.ui.editor;

Expand All @@ -21,7 +24,6 @@
/**
* Action contributor for the Gradle Editor
*
* @author Christophe Moine
*/
public class GradleEditorContributor extends EditorActionBarContributor {
@Override
Expand Down
Expand Up @@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Moine - #514 Add Gradle editor
*/
package org.eclipse.buildship.ui.editor;

Expand Down
Expand Up @@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Moine - #514 Add Gradle editor
*/
package org.eclipse.buildship.ui.editor;

Expand Down Expand Up @@ -41,10 +44,9 @@
/**
* Presentation Reconcilier for the Gradle Editor
*
* @author Christophe Moine
*/
public class GradlePresentationReconciler extends PresentationReconciler {
private static final List<String> GRADLE_IDENTIFIERS = Arrays.asList("assert", "if", "else", "void", "null", "new", "return", "try", "catch", "def", "allprojects", //
private static final List<String> KEYWORDS = Arrays.asList("assert", "if", "else", "void", "null", "new", "return", "try", "catch", "def", "allprojects", //
"artifacts", "buildscript", "configurations", "dependencies", "repositories", "sourceSets", "subprojects", "publishing", "task", "apply", "sourceCompatibility", //
"targetCompatibility", "test", "project", "ext", "plugins", "jar", "shadowJar", "for", "while");

Expand Down Expand Up @@ -108,7 +110,7 @@ private boolean updateToken(String key) {
private static class KeywordRule extends WordRule {
public KeywordRule(IToken token) {
super(new WordDetector());
for (String word : GRADLE_IDENTIFIERS) {
for (String word : KEYWORDS) {
addWord(word, token);
}
}
Expand Down
Expand Up @@ -4,23 +4,26 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Moine - #514 Add Gradle editor
*/
package org.eclipse.buildship.ui.editor;

import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;

import org.eclipse.buildship.ui.UiPlugin;

public class GradleTextViewerConfiguration extends TextSourceViewerConfiguration {
/**
*
* @param editor the editor we're creating.
* @param preferenceStore the preference store.
*/
public GradleTextViewerConfiguration() {
super(UiPlugin.getInstance().getPreferenceStore());
super(EditorsUI.getPreferenceStore());
}

@Override
Expand All @@ -30,13 +33,18 @@ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceVie
return reconciler;
}

@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
return null;
}

@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return IGradlePartitions.PARTITIONS;
}

@Override
public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
return IGradlePartitions.PARTITIONING;
}
@Override
public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
return IGradlePartitions.PARTITIONING;
}
}
Expand Up @@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Moine - #514 Add Gradle editor
*/
package org.eclipse.buildship.ui.editor;

Expand Down
Expand Up @@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Moine - #514 Add Gradle editor
*/
package org.eclipse.buildship.ui.editor;

Expand Down

0 comments on commit 15892da

Please sign in to comment.