diff options
4 files changed, 104 insertions, 88 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml index 724ef281d1..866c8de514 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml @@ -192,26 +192,56 @@ </command> </menuContribution> </extension> - + <extension + point="org.eclipse.core.contenttype.contentTypes"> + <content-type + base-type="org.eclipse.core.runtime.text" + file-extensions="stp" + id="org.eclipse.linuxtools.stap.content-type" + name="SystemTap Script" + priority="high"> + </content-type> + </extension> <extension point="org.eclipse.ui.editors"> <editor class="org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor" contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor" default="true" - extensions="stp" icon="icons/views/page_obj.gif" id="org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor" name="%editor.stp.name"> + <contentTypeBinding + contentTypeId="org.eclipse.linuxtools.stap.content-type"> + </contentTypeBinding> </editor> - <editor - name="%editor.simple.name" - id="org.eclipse.linuxtools.systemtap.ui.editor.SimpleEditor" - class="org.eclipse.linuxtools.systemtap.ui.editor.SimpleEditor" - icon="icons/views/page_obj.gif" - contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor" - default="true"> - </editor> + </extension> + <extension + point="org.eclipse.ui.genericeditor.presentationReconcilers"> + <presentationReconciler + class="org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPPresentationReconciler" + contentType="org.eclipse.linuxtools.stap.content-type"> + </presentationReconciler> + </extension> + <extension point="org.eclipse.ui.genericeditor.contentAssistProcessors"> + <contentAssistProcessor + class="org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPCompletionProcessor" + contentType="org.eclipse.linuxtools.stap.content-type"> + </contentAssistProcessor> + </extension> + <extension point="org.eclipse.ui.genericeditor.hoverProviders"> + <hoverProvider + class="org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPCompletionProcessor" + contentType="org.eclipse.linuxtools.stap.content-type"> + </hoverProvider> + </extension> + <extension + point="org.eclipse.ui.editors.documentProviders"> + <provider + class="org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPDocumentProvider" + extensions="stp" + id="org.eclipse.linuxtools.stap.editor.documentProvider"> + </provider> </extension> <extension diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java index 8aa8237007..f640a87334 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Phil Muldoon <pkmuldoon@picobot.org>. + * Copyright (c) 2008, 2017 Phil Muldoon and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -16,30 +16,22 @@ import org.eclipse.jface.text.IAutoEditStrategy; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextDoubleClickStrategy; import org.eclipse.jface.text.ITextHover; -import org.eclipse.jface.text.TextAttribute; 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.rules.Token; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.linuxtools.systemtap.ui.editor.ColorManager; import org.eclipse.linuxtools.systemtap.ui.editor.DoubleClickStrategy; public class STPConfiguration extends SourceViewerConfiguration { - private STPElementScanner scanner; - private ColorManager colorManager; private STPEditor editor; private DoubleClickStrategy doubleClickStrategy; private STPCompletionProcessor processor; - public STPConfiguration(ColorManager colorManager, STPEditor editor) { - this.colorManager = colorManager; + public STPConfiguration(STPEditor editor) { this.editor = editor; this.processor = new STPCompletionProcessor(); } @@ -70,20 +62,6 @@ public class STPConfiguration extends SourceViewerConfiguration { return assistant; } - /** - * Return the default Element scanner. - * - * @return default element scanner. - */ - private STPElementScanner getSTPScanner() { - if (scanner == null) { - scanner = new STPElementScanner(colorManager); - scanner.setDefaultReturnToken(new Token(new TextAttribute( - colorManager.getColor(STPColorConstants.DEFAULT)))); - } - return scanner; - } - @Override public IReconciler getReconciler(ISourceViewer sourceViewer) { @@ -107,22 +85,7 @@ public class STPConfiguration extends SourceViewerConfiguration { @Override public IPresentationReconciler getPresentationReconciler( ISourceViewer sourceViewer) { - - PresentationReconciler reconciler = new PresentationReconciler(); - - DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getSTPScanner()); - reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); - reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); - - dr = new DefaultDamagerRepairer(getSTPScanner()); - reconciler.setDamager(dr, STPPartitionScanner.STP_COMMENT); - reconciler.setRepairer(dr, STPPartitionScanner.STP_COMMENT); - - dr = new DefaultDamagerRepairer(getSTPScanner()); - reconciler.setDamager(dr, STPPartitionScanner.STP_CONDITIONAL); - reconciler.setRepairer(dr, STPPartitionScanner.STP_CONDITIONAL); - - return reconciler; + return new STPPresentationReconciler(); } @Override diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java index 8a812fe752..9fe6ebfda6 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Phil Muldoon <pkmuldoon@picobot.org>. + * Copyright (c) 2008, 2017 Phil Muldoon and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -26,7 +26,6 @@ import org.eclipse.jface.text.source.projection.ProjectionAnnotation; import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; import org.eclipse.jface.text.source.projection.ProjectionSupport; import org.eclipse.jface.text.source.projection.ProjectionViewer; -import org.eclipse.linuxtools.systemtap.ui.editor.ColorManager; import org.eclipse.linuxtools.systemtap.ui.editor.PathEditorInput; import org.eclipse.linuxtools.systemtap.ui.editor.SimpleEditor; import org.eclipse.swt.widgets.Composite; @@ -36,8 +35,6 @@ import org.eclipse.ui.texteditor.ITextEditorActionConstants; public class STPEditor extends SimpleEditor { - private ColorManager colorManager; - private Annotation[] stpOldAnnotations; private ProjectionAnnotationModel stpAnnotationModel; @@ -45,14 +42,12 @@ public class STPEditor extends SimpleEditor { public STPEditor() { super(); - colorManager = new ColorManager(); - setSourceViewerConfiguration(new STPConfiguration(colorManager,this)); + setSourceViewerConfiguration(new STPConfiguration(this)); } @Override protected void internalInit() { configureInsertMode(SMART_INSERT, false); - setDocumentProvider(new STPDocumentProvider()); } @Override @@ -84,40 +79,29 @@ public class STPEditor extends SimpleEditor { } - public void updateFoldingStructure(ArrayList<Position> updatedPositions) - { - ProjectionAnnotation annotation; - Annotation[] updatedAnnotations = new Annotation[updatedPositions.size()]; - HashMap<ProjectionAnnotation, Position> newAnnotations = new HashMap<>(); - for(int i =0;i<updatedPositions.size();i++) - { - annotation = new ProjectionAnnotation(); - newAnnotations.put(annotation,updatedPositions.get(i)); - updatedAnnotations[i]=annotation; - } - stpAnnotationModel.modifyAnnotations(stpOldAnnotations,newAnnotations,null); - stpOldAnnotations = updatedAnnotations; - } - - public ISourceViewer getMySourceViewer() { - return this.getSourceViewer(); - } + public void updateFoldingStructure(ArrayList<Position> updatedPositions) { + ProjectionAnnotation annotation; + Annotation[] updatedAnnotations = new Annotation[updatedPositions.size()]; + HashMap<ProjectionAnnotation, Position> newAnnotations = new HashMap<>(); + for (int i = 0; i < updatedPositions.size(); i++) { + annotation = new ProjectionAnnotation(); + newAnnotations.put(annotation, updatedPositions.get(i)); + updatedAnnotations[i] = annotation; + } + stpAnnotationModel.modifyAnnotations(stpOldAnnotations, newAnnotations, null); + stpOldAnnotations = updatedAnnotations; + } - @Override - public void dispose() { - colorManager.dispose(); - super.dispose(); - } + public ISourceViewer getMySourceViewer() { + return this.getSourceViewer(); + } @Override - protected void editorContextMenuAboutToShow(IMenuManager menu) { + protected void editorContextMenuAboutToShow(IMenuManager menu) { + super.editorContextMenuAboutToShow(menu); + addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.SHIFT_RIGHT); + addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.SHIFT_LEFT); - super.editorContextMenuAboutToShow(menu); - addAction(menu, ITextEditorActionConstants.GROUP_EDIT, - ITextEditorActionConstants.SHIFT_RIGHT); - addAction(menu, ITextEditorActionConstants.GROUP_EDIT, - ITextEditorActionConstants.SHIFT_LEFT); - - } + } }
\ No newline at end of file diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPPresentationReconciler.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPPresentationReconciler.java new file mode 100644 index 0000000000..cb8b93a7b7 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPPresentationReconciler.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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.linuxtools.internal.systemtap.ui.ide.editors.stp; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.TextAttribute; +import org.eclipse.jface.text.presentation.PresentationReconciler; +import org.eclipse.jface.text.rules.DefaultDamagerRepairer; +import org.eclipse.jface.text.rules.Token; +import org.eclipse.linuxtools.systemtap.ui.editor.ColorManager; + +public class STPPresentationReconciler extends PresentationReconciler { + + public STPPresentationReconciler() { + ColorManager colorManager = new ColorManager(); + STPElementScanner scanner = new STPElementScanner(colorManager); + scanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(STPColorConstants.DEFAULT)))); + DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner); + setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); + setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); + + dr = new DefaultDamagerRepairer(scanner); + setDamager(dr, STPPartitionScanner.STP_COMMENT); + setRepairer(dr, STPPartitionScanner.STP_COMMENT); + + dr = new DefaultDamagerRepairer(scanner); + setDamager(dr, STPPartitionScanner.STP_CONDITIONAL); + setRepairer(dr, STPPartitionScanner.STP_CONDITIONAL); + } +} |