PT #134848903: added syntax coloring to eclipse-lsp editors for properties and yaml files
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -7,4 +7,8 @@ Bundle-Vendor: Pivotal, Inc.
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: org.eclipse.languageserver;bundle-version="0.1.0",
|
||||
org.eclipse.ui.genericeditor;bundle-version="1.0.0",
|
||||
org.eclipse.core.runtime;bundle-version="3.12.0"
|
||||
org.eclipse.core.runtime;bundle-version="3.12.0",
|
||||
org.eclipse.jface.text;bundle-version="3.11.100",
|
||||
org.eclipse.jdt.ui;bundle-version="3.13.0",
|
||||
org.dadacoalition.yedit;bundle-version="1.0.20"
|
||||
Import-Package: org.eclipse.jface.preference
|
||||
|
||||
@@ -71,4 +71,28 @@
|
||||
</editorContentTypeBinding>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.genericeditor.presentationReconcilers">
|
||||
<presentationReconciler
|
||||
class="org.springframework.boot.ide.properties.editors.SpringPropertiesPresentationReconciler"
|
||||
contentType="org.springframework.boot.ide.properties.application.properties">
|
||||
</presentationReconciler>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.genericeditor.presentationReconcilers">
|
||||
<presentationReconciler
|
||||
class="org.springframework.boot.ide.properties.editors.SpringYMLPresentationReconciler"
|
||||
contentType="org.springframework.boot.ide.properties.application.yml">
|
||||
</presentationReconciler>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.genericeditor.presentationReconcilers">
|
||||
<presentationReconciler
|
||||
class="org.springframework.boot.ide.properties.editors.SpringYMLPresentationReconciler"
|
||||
contentType="org.springframework.boot.ide.manifest.yml">
|
||||
</presentationReconciler>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* 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:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.boot.ide.properties.editors;
|
||||
|
||||
import org.eclipse.jdt.internal.ui.JavaPlugin;
|
||||
import org.eclipse.jdt.internal.ui.propertiesfileeditor.IPropertiesFilePartitions;
|
||||
import org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyValueScanner;
|
||||
import org.eclipse.jdt.internal.ui.text.SingleTokenJavaScanner;
|
||||
import org.eclipse.jdt.ui.PreferenceConstants;
|
||||
import org.eclipse.jdt.ui.text.IColorManager;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.presentation.PresentationReconciler;
|
||||
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
|
||||
import org.eclipse.jface.text.rules.ITokenScanner;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class SpringPropertiesPresentationReconciler extends PresentationReconciler {
|
||||
|
||||
public SpringPropertiesPresentationReconciler() {
|
||||
|
||||
IColorManager colorManager = JavaPlugin.getDefault().getJavaTextTools().getColorManager();
|
||||
IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
|
||||
|
||||
ITokenScanner propertyKeyScanner= new SingleTokenJavaScanner(colorManager, store, PreferenceConstants.PROPERTIES_FILE_COLORING_KEY);
|
||||
ITokenScanner propertyValueScanner= new PropertyValueScanner(colorManager, store);
|
||||
ITokenScanner propertyCommentScanner= new SingleTokenJavaScanner(colorManager, store, PreferenceConstants.PROPERTIES_FILE_COLORING_COMMENT);
|
||||
|
||||
this.setDocumentPartitioning(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING);
|
||||
|
||||
DefaultDamagerRepairer dr= new DefaultDamagerRepairer(propertyKeyScanner);
|
||||
this.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
this.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
|
||||
dr= new DefaultDamagerRepairer(propertyCommentScanner);
|
||||
this.setDamager(dr, IPropertiesFilePartitions.COMMENT);
|
||||
this.setRepairer(dr, IPropertiesFilePartitions.COMMENT);
|
||||
|
||||
dr= new DefaultDamagerRepairer(propertyValueScanner);
|
||||
this.setDamager(dr, IPropertiesFilePartitions.PROPERTY_VALUE);
|
||||
this.setRepairer(dr, IPropertiesFilePartitions.PROPERTY_VALUE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* 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:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.boot.ide.properties.editors;
|
||||
|
||||
import org.dadacoalition.yedit.editor.ColorManager;
|
||||
import org.dadacoalition.yedit.editor.YEditDamageRepairer;
|
||||
import org.dadacoalition.yedit.editor.scanner.YAMLScanner;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.presentation.PresentationReconciler;
|
||||
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
|
||||
import org.eclipse.jface.text.rules.ITokenScanner;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class SpringYMLPresentationReconciler extends PresentationReconciler {
|
||||
|
||||
public SpringYMLPresentationReconciler() {
|
||||
|
||||
ColorManager colorManager = new ColorManager();
|
||||
ITokenScanner yamlScanner = new YAMLScanner( colorManager );
|
||||
DefaultDamagerRepairer dr = new YEditDamageRepairer(yamlScanner);
|
||||
|
||||
this.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
this.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user