mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
autotools: automake/autoconf generic editor.
Reorganize code and expose things for generic editor. So far presentation reconciler only is ported. Allows to right-click/Open with/Generic editor on e.g. Makefile.am and see it in the generic editor. It is not as feature rich as the specialized editors we have now but over time it should provide all the features of them with significantly less code. Change-Id: I72324b94ce08ab762979804914adbb1982c88198 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
parent
4572eb75f0
commit
d35f9e1a60
8 changed files with 126 additions and 95 deletions
|
@ -9,21 +9,20 @@ Bundle-Vendor: %provider
|
|||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.cdt.autotools.core;bundle-version="1.0.0",
|
||||
org.eclipse.cdt.make.core;bundle-version="6.0.0",
|
||||
org.eclipse.cdt.core;bundle-version="5.1.0",
|
||||
org.eclipse.core.resources;bundle-version="3.5.0",
|
||||
org.eclipse.cdt.managedbuilder.core;bundle-version="6.0.0",
|
||||
org.eclipse.jface.text;bundle-version="3.5.0",
|
||||
org.eclipse.ui.editors;bundle-version="3.5.0",
|
||||
org.eclipse.cdt.ui;bundle-version="5.1.0",
|
||||
org.eclipse.help;bundle-version="3.4.0",
|
||||
org.eclipse.ui.ide;bundle-version="3.5.0",
|
||||
org.eclipse.cdt.managedbuilder.ui;bundle-version="5.1.0",
|
||||
org.eclipse.core.filesystem;bundle-version="1.2.0",
|
||||
org.eclipse.cdt.make.ui;bundle-version="6.0.0",
|
||||
org.eclipse.ui.views;bundle-version="3.4.0",
|
||||
org.eclipse.cdt.remote.core;bundle-version="1.0.0",
|
||||
org.eclipse.swt
|
||||
org.eclipse.swt,
|
||||
org.eclipse.ui.genericeditor;bundle-version="1.0.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.eclipse.cdt.autotools.ui,
|
||||
|
|
|
@ -95,4 +95,5 @@ GetDefinedSymbols.label = Get Defined Symbols
|
|||
IncludesOption.name = includes
|
||||
SymbolsOption.name = symbols
|
||||
AutomakeEditor.name = AutomakeEditor
|
||||
Automake.name = automake
|
||||
Automake.name = automake
|
||||
Autoconf.name = autoconf
|
|
@ -36,11 +36,14 @@
|
|||
<!-- declares a content type for automake files -->
|
||||
<content-type id="org.eclipse.cdt.autotools.ui.automake" name="%Automake.name"
|
||||
base-type="org.eclipse.core.runtime.text"
|
||||
priority="high"/>
|
||||
<file-association
|
||||
content-type="org.eclipse.cdt.autotools.ui.automake"
|
||||
file-names="Makefile.am"
|
||||
file-extensions="am"/>
|
||||
file-names="Makefile.in"
|
||||
file-extensions="am"
|
||||
priority="high"></content-type>
|
||||
<content-type id="org.eclipse.cdt.autotools.ui.autoconf" name="%Autoconf.name"
|
||||
base-type="org.eclipse.core.runtime.text"
|
||||
file-names="configure.in,configure.ac"
|
||||
file-extensions="m4"
|
||||
priority="high"></content-type>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.editors">
|
||||
|
@ -48,22 +51,32 @@
|
|||
class="org.eclipse.cdt.autotools.ui.editors.AutoconfEditor"
|
||||
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
|
||||
default="true"
|
||||
filenames="configure.in,configure.ac,aclocal.m4,acinclude.m4,libtool.m4,ltversion.m4,ltsugar.m4,ltoptions.m4,ltdl.m4,ltgcc.m4,lt~obsolete.m4"
|
||||
icon="icons/autoconf.gif"
|
||||
id="org.eclipse.cdt.autotools.ui.editor.autoconf"
|
||||
name="%Autoconf.editor.name"/>
|
||||
name="%Autoconf.editor.name">
|
||||
<contentTypeBinding contentTypeId="org.eclipse.cdt.autotools.ui.autoconf"></contentTypeBinding>
|
||||
</editor>
|
||||
<editor
|
||||
class="org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeEditor"
|
||||
contributorClass="org.eclipse.cdt.internal.autotools.ui.editors.automake.MakefileEditorActionContributor"
|
||||
default="true"
|
||||
extensions="am"
|
||||
filenames="Makefile.am,Makefile.in"
|
||||
icon="icons/automake.gif"
|
||||
id="org.eclipse.cdt.autotools.ui.editors.AutomakeEditor"
|
||||
name="%AutomakeEditor.name">
|
||||
<contentTypeBinding contentTypeId="org.eclipse.cdt.autotools.ui.automake"/>
|
||||
<contentTypeBinding contentTypeId="org.eclipse.cdt.autotools.ui.automake"></contentTypeBinding>
|
||||
</editor>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.genericeditor.presentationReconcilers">
|
||||
<presentationReconciler
|
||||
class="org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakefilePresentationReconciler"
|
||||
contentType="org.eclipse.cdt.autotools.ui.automake">
|
||||
</presentationReconciler>
|
||||
<presentationReconciler
|
||||
class="org.eclipse.cdt.internal.autotools.ui.editors.autoconf.AutoconfPresentationReconciler"
|
||||
contentType="org.eclipse.cdt.autotools.ui.autoconf">
|
||||
</presentationReconciler>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.contexts">
|
||||
<context
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2015 Red Hat, Inc.
|
||||
* Copyright (c) 2007, 2017 Red Hat, 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
|
||||
|
@ -10,46 +10,22 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.ui.editors;
|
||||
|
||||
import org.eclipse.jface.text.DocumentEvent;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.ITypedRegion;
|
||||
import org.eclipse.jface.text.TextPresentation;
|
||||
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
|
||||
import org.eclipse.jface.text.rules.ITokenScanner;
|
||||
|
||||
public class AutoconfMacroDamagerRepairer extends DefaultDamagerRepairer {
|
||||
|
||||
public final static String UNMATCHED_RIGHT_PARENTHESIS = "UnmatchedRightParenthesis"; //$NON-NLS-1$
|
||||
public final static String UNMATCHED_LEFT_PARENTHESIS = "UnmatchedLeftParenthesis"; //$NON-NLS-1$
|
||||
public final static String UNMATCHED_RIGHT_QUOTE = "UnmatchedRightQuote"; //$NON-NLS-1$
|
||||
public final static String UNMATCHED_LEFT_QUOTE = "UnmatchedLeftQuote"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
|
||||
* and is assumed to return only token that carry text attributes.
|
||||
* Creates a damager/repairer that uses the given scanner. The scanner may
|
||||
* not be <code>null</code> and is assumed to return only token that carry
|
||||
* text attributes.
|
||||
*
|
||||
* @param scanner the token scanner to be used, may not be <code>null</code>
|
||||
* @param scanner
|
||||
* the token scanner to be used, may not be <code>null</code>
|
||||
*/
|
||||
public AutoconfMacroDamagerRepairer(ITokenScanner scanner) {
|
||||
super(scanner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent e, boolean documentPartitioningChanged) {
|
||||
// In the case of a partition with multiline rules, we will punt to
|
||||
// reparse the entire partition because we don't know if the line being
|
||||
// edited is in the middle of an area covered by a multiline rule. In
|
||||
// such a case, we need to back up and find the start sequence of the
|
||||
// rule. It is easiest to just reparse the whole partition.
|
||||
return partition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPresentation(TextPresentation presentation, ITypedRegion region) {
|
||||
|
||||
// int offset = region.getOffset();
|
||||
// int length = region.getLength();
|
||||
|
||||
super.createPresentation(presentation, region);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2015 Red Hat, Inc.
|
||||
* Copyright (c) 2006, 2017 Red Hat, 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
|
||||
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.ui.editors;
|
||||
|
||||
import org.eclipse.cdt.internal.autotools.ui.editors.autoconf.AutoconfPresentationReconciler;
|
||||
import org.eclipse.cdt.internal.autotools.ui.text.hover.AutoconfTextHover;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
|
@ -19,10 +20,8 @@ import org.eclipse.jface.text.contentassist.ContentAssistant;
|
|||
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
|
||||
import org.eclipse.jface.text.contentassist.IContentAssistant;
|
||||
import org.eclipse.jface.text.presentation.IPresentationReconciler;
|
||||
import org.eclipse.jface.text.presentation.PresentationReconciler;
|
||||
import org.eclipse.jface.text.reconciler.IReconciler;
|
||||
import org.eclipse.jface.text.reconciler.MonoReconciler;
|
||||
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
|
||||
import org.eclipse.jface.text.source.IAnnotationHover;
|
||||
import org.eclipse.jface.text.source.ISourceViewer;
|
||||
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
|
||||
|
@ -91,20 +90,6 @@ public class AutoconfSourceViewerConfiguration extends
|
|||
}
|
||||
@Override
|
||||
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
|
||||
PresentationReconciler reconciler = new PresentationReconciler();
|
||||
|
||||
DefaultDamagerRepairer dr= new AutoconfMacroDamagerRepairer(new AutoconfMacroCodeScanner());
|
||||
reconciler.setDamager(dr, AutoconfPartitionScanner.AUTOCONF_MACRO);
|
||||
reconciler.setRepairer(dr, AutoconfPartitionScanner.AUTOCONF_MACRO);
|
||||
|
||||
dr= new DefaultDamagerRepairer(new AutoconfCodeScanner());
|
||||
reconciler.setDamager(dr, AutoconfPartitionScanner.AUTOCONF_COMMENT);
|
||||
reconciler.setRepairer(dr, AutoconfPartitionScanner.AUTOCONF_COMMENT);
|
||||
|
||||
dr= new MultilineRuleDamagerRepairer(new AutoconfCodeScanner());
|
||||
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
|
||||
return reconciler;
|
||||
return new AutoconfPresentationReconciler();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Red Hat Inc. and others.
|
||||
* 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:
|
||||
* Red Hat Inc. - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.autotools.ui.editors.autoconf;
|
||||
|
||||
import org.eclipse.cdt.autotools.ui.editors.AutoconfCodeScanner;
|
||||
import org.eclipse.cdt.autotools.ui.editors.AutoconfMacroCodeScanner;
|
||||
import org.eclipse.cdt.autotools.ui.editors.AutoconfMacroDamagerRepairer;
|
||||
import org.eclipse.cdt.autotools.ui.editors.AutoconfPartitionScanner;
|
||||
import org.eclipse.cdt.autotools.ui.editors.MultilineRuleDamagerRepairer;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.presentation.PresentationReconciler;
|
||||
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
|
||||
|
||||
public class AutoconfPresentationReconciler extends PresentationReconciler {
|
||||
|
||||
public AutoconfPresentationReconciler() {
|
||||
DefaultDamagerRepairer dr = new AutoconfMacroDamagerRepairer(new AutoconfMacroCodeScanner());
|
||||
setDamager(dr, AutoconfPartitionScanner.AUTOCONF_MACRO);
|
||||
setRepairer(dr, AutoconfPartitionScanner.AUTOCONF_MACRO);
|
||||
|
||||
dr = new DefaultDamagerRepairer(new AutoconfCodeScanner());
|
||||
setDamager(dr, AutoconfPartitionScanner.AUTOCONF_COMMENT);
|
||||
setRepairer(dr, AutoconfPartitionScanner.AUTOCONF_COMMENT);
|
||||
|
||||
dr = new MultilineRuleDamagerRepairer(new AutoconfCodeScanner());
|
||||
setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Red Hat Inc. and others.
|
||||
* 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:
|
||||
* Red Hat Inc. - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.autotools.ui.editors.automake;
|
||||
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.presentation.PresentationReconciler;
|
||||
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
|
||||
|
||||
public class AutomakefilePresentationReconciler extends PresentationReconciler {
|
||||
|
||||
public AutomakefilePresentationReconciler() {
|
||||
AutomakefileCodeScanner scanner = new AutomakefileCodeScanner();
|
||||
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner);
|
||||
setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
|
||||
dr = new DefaultDamagerRepairer(scanner);
|
||||
setDamager(dr, MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION);
|
||||
setRepairer(dr, MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION);
|
||||
|
||||
dr = new DefaultDamagerRepairer(scanner);
|
||||
setDamager(dr, MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION);
|
||||
setRepairer(dr, MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION);
|
||||
|
||||
dr = new DefaultDamagerRepairer(scanner);
|
||||
setDamager(dr, MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION);
|
||||
setRepairer(dr, MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION);
|
||||
|
||||
dr = new DefaultDamagerRepairer(scanner);
|
||||
setDamager(dr, MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION);
|
||||
setRepairer(dr, MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION);
|
||||
|
||||
dr = new DefaultDamagerRepairer(scanner);
|
||||
setDamager(dr, MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION);
|
||||
setRepairer(dr, MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION);
|
||||
|
||||
dr = new DefaultDamagerRepairer(scanner);
|
||||
setDamager(dr, MakefilePartitionScanner.MAKEFILE_OTHER_PARTITION);
|
||||
setRepairer(dr, MakefilePartitionScanner.MAKEFILE_OTHER_PARTITION);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2015 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2017 QNX Software Systems and others.
|
||||
* 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
|
||||
|
@ -19,10 +19,8 @@ import org.eclipse.jface.text.ITextHover;
|
|||
import org.eclipse.jface.text.contentassist.ContentAssistant;
|
||||
import org.eclipse.jface.text.contentassist.IContentAssistant;
|
||||
import org.eclipse.jface.text.presentation.IPresentationReconciler;
|
||||
import org.eclipse.jface.text.presentation.PresentationReconciler;
|
||||
import org.eclipse.jface.text.reconciler.IReconciler;
|
||||
import org.eclipse.jface.text.reconciler.MonoReconciler;
|
||||
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
|
||||
import org.eclipse.jface.text.source.ISourceViewer;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
|
||||
|
@ -82,36 +80,7 @@ public class AutomakefileSourceConfiguration extends
|
|||
@Override
|
||||
public IPresentationReconciler getPresentationReconciler(ISourceViewer v) {
|
||||
|
||||
PresentationReconciler reconciler = new PresentationReconciler();
|
||||
|
||||
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getAutomakeCodeScanner());
|
||||
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
|
||||
dr = new DefaultDamagerRepairer(getAutomakeCodeScanner());
|
||||
reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION);
|
||||
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION);
|
||||
|
||||
dr = new DefaultDamagerRepairer(getAutomakeCodeScanner());
|
||||
reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION);
|
||||
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION);
|
||||
|
||||
dr = new DefaultDamagerRepairer(getAutomakeCodeScanner());
|
||||
reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION);
|
||||
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION);
|
||||
|
||||
dr = new DefaultDamagerRepairer(getAutomakeCodeScanner());
|
||||
reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION);
|
||||
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION);
|
||||
|
||||
dr = new DefaultDamagerRepairer(getAutomakeCodeScanner());
|
||||
reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION);
|
||||
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION);
|
||||
|
||||
dr = new DefaultDamagerRepairer(getAutomakeCodeScanner());
|
||||
reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_OTHER_PARTITION);
|
||||
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_OTHER_PARTITION);
|
||||
return reconciler;
|
||||
return new AutomakefilePresentationReconciler();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue