aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Guzman2013-09-12 16:02:59 (EDT)
committerNeil Guzman2013-10-28 11:40:34 (EDT)
commitbdd2d3a5841fb75c6a4ec84ba91fbc72f52bbbcf (patch)
tree5ca2c75f402fc7d1bdce5627cd2f06cd10e9636b
parent4e78a8fe2ac70cb1ab43a9ba05472c4199272e3c (diff)
downloadorg.eclipse.linuxtools-bdd2d3a5841fb75c6a4ec84ba91fbc72f52bbbcf.zip
org.eclipse.linuxtools-bdd2d3a5841fb75c6a4ec84ba91fbc72f52bbbcf.tar.gz
org.eclipse.linuxtools-bdd2d3a5841fb75c6a4ec84ba91fbc72f52bbbcf.tar.bz2
RPM: specfile compare editor and NPEsrefs/changes/13/17113/5
The initial opening of a .spec file with an ERROR marker in it will cause Ctrl + hovering over certain specfile elements (e.g. user-defined macros, hyperlinks, etc.) to cause an NPE. Another error was that comparing a .spec file with an ERROR marker in it to any other .spec file would cause NPEs and open up the compare editor with a blank page. Lastly, comparing specfile editors now properly attach to the document being edited. Changes done in the compare editor (merge viewer) will persist on the document(s) being compared. Bug: 415468 Change-Id: I48102855ff132d7110c4af3b1861267f1542c8fa Signed-off-by: Neil Guzman <nguzman@redhat.com> Reviewed-on: https://git.eclipse.org/r/17113 Tested-by: Hudson CI
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/META-INF/MANIFEST.MF2
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/plugin.xml6
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/pom.xml4
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileDocumentProvider.java7
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/compare/SpecMergeViewer.java7
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/compare/SpecStructureCreator.java112
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/hyperlink/SpecfileElementHyperlinkDetector.java18
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/markers/SpecfileTaskHandler.java39
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileParser.java11
9 files changed, 156 insertions, 50 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/META-INF/MANIFEST.MF b/rpm/org.eclipse.linuxtools.rpm.ui.editor/META-INF/MANIFEST.MF
index bcaad8a..df1d867 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/META-INF/MANIFEST.MF
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.linuxtools.rpm.ui.editor; singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.2.0.qualifier
Bundle-Activator: org.eclipse.linuxtools.internal.rpm.ui.editor.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/plugin.xml b/rpm/org.eclipse.linuxtools.rpm.ui.editor/plugin.xml
index 1b4d17b..4c0fdc7 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/plugin.xml
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/plugin.xml
@@ -24,7 +24,7 @@
point="org.eclipse.ui.editors">
<editor
name="%editor.name"
- extensions="spec"
+ extensions="spec,spec2"
icon="icons/rpm.gif"
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
class="org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor"
@@ -94,8 +94,8 @@
<extension
point="org.eclipse.ui.editors.documentProviders">
<provider
- extensions="spec"
class="org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileDocumentProvider"
+ extensions="spec,spec2"
id="org.eclipse.linuxtools.rpm.ui.editor.specfileDocumentProvider">
</provider>
</extension>
@@ -447,7 +447,7 @@
<extension point="org.eclipse.compare.contentMergeViewers">
<viewer
id="org.eclipse.linuxtools.rpm.ui.editor.SpecMergeViewer"
- extensions="spec"
+ extensions="spec,spec2"
class="org.eclipse.linuxtools.internal.rpm.ui.editor.compare.SpecMergeViewerCreator">
</viewer>
</extension>
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/pom.xml b/rpm/org.eclipse.linuxtools.rpm.ui.editor/pom.xml
index 76b5ad9..8c65fba 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/pom.xml
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (C) 2011, Red Hat, Inc.
+ Copyright (C) 2011, 2013 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
@@ -18,7 +18,7 @@
</parent>
<artifactId>org.eclipse.linuxtools.rpm.ui.editor</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools RPM Specfile Editor Plug-in</name>
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileDocumentProvider.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileDocumentProvider.java
index 727e06d..acf6850 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileDocumentProvider.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileDocumentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Copyright (c) 2007, 2013 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
@@ -108,18 +108,22 @@ public class SpecfileDocumentProvider extends TextFileDocumentProvider {
try {
input.close();
} catch (IOException e) {
+ SpecfileLog.logError(e);
}
}
}
}
return super.canSaveDocument(element);
}
+
/*
* @see org.eclipse.ui.texteditor.IDocumentProvider#createSaveOperation(java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
*/
+
@Override
protected DocumentProviderOperation createSaveOperation(final Object element, final IDocument document, final boolean overwrite) throws CoreException {
final DocumentProviderOperation saveOperation = super.createSaveOperation(element, document, overwrite);
+
if (element instanceof IURIEditorInput) {
return new DocumentProviderOperation() {
/*
@@ -148,6 +152,7 @@ public class SpecfileDocumentProvider extends TextFileDocumentProvider {
}
};
}
+
return saveOperation;
}
} \ No newline at end of file
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/compare/SpecMergeViewer.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/compare/SpecMergeViewer.java
index 9ca69d5..342e705 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/compare/SpecMergeViewer.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/compare/SpecMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
+ * Copyright (c) 2009, 2013 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
@@ -54,6 +54,11 @@ public class SpecMergeViewer extends TextMergeViewer {
}
@Override
+ protected String getDocumentPartitioning() {
+ return SpecfilePartitionScanner.SPEC_FILE_PARTITIONING;
+ }
+
+ @Override
protected void configureTextViewer(TextViewer textViewer) {
if (textViewer instanceof SourceViewer) {
this.colorManager = new ColorManager();
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/compare/SpecStructureCreator.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/compare/SpecStructureCreator.java
index 0a551e7..ab80560 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/compare/SpecStructureCreator.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/compare/SpecStructureCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
+ * Copyright (c) 2009, 2013 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
@@ -18,6 +18,7 @@ import java.io.InputStreamReader;
import org.eclipse.compare.CompareUI;
import org.eclipse.compare.IEditableContent;
import org.eclipse.compare.IEncodedStreamContentAccessor;
+import org.eclipse.compare.IResourceProvider;
import org.eclipse.compare.ISharedDocumentAdapter;
import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
@@ -25,6 +26,8 @@ import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
import org.eclipse.compare.structuremergeviewer.IStructureComparator;
import org.eclipse.compare.structuremergeviewer.StructureCreator;
import org.eclipse.compare.structuremergeviewer.StructureRootNode;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -36,11 +39,15 @@ import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileLog;
import org.eclipse.linuxtools.internal.rpm.ui.editor.scanners.SpecfilePartitionScanner;
+import org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor;
+import org.eclipse.linuxtools.rpm.ui.editor.markers.SpecfileErrorHandler;
+import org.eclipse.linuxtools.rpm.ui.editor.markers.SpecfileTaskHandler;
import org.eclipse.linuxtools.rpm.ui.editor.parser.Specfile;
import org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfilePackage;
import org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileParser;
import org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileSection;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.part.FileEditorInput;
/**
* Structure creator making which structure is based on the following tree.
@@ -48,30 +55,31 @@ import org.eclipse.swt.graphics.Image;
* <pre>
* ROOT_NODE
* SECTIONS...N
+ * SPECFILE_NODE
* SUB_PACKAGE...N
* SUB_PACKAGE_SECTIONS...N
* </pre>
*/
public class SpecStructureCreator extends StructureCreator {
- static class SpecNode extends DocumentRangeNode implements ITypedElement {
+ private static class SpecNode extends DocumentRangeNode implements ITypedElement {
public SpecNode(DocumentRangeNode parent, int type, String id,
IDocument doc, int start, int length) {
super(parent, type, id, doc, start, length);
if (parent != null) {
- parent.addChild(SpecNode.this);
+ parent.addChild(this);
}
}
@Override
public String getName() {
- return this.getId();
+ return getId();
}
@Override
public String getType() {
- return "spec"; //$NON-NLS-1$
+ return "spec2"; //$NON-NLS-1$
}
@Override
@@ -80,6 +88,8 @@ public class SpecStructureCreator extends StructureCreator {
}
}
+ private static final String SPECFILE_ROOT_NODE = "Specfile Sections"; //$NON-NLS-1$
+
@Override
public String getName() {
return Messages.SpecStructureCreator_0;
@@ -96,50 +106,65 @@ public class SpecStructureCreator extends StructureCreator {
IStreamContentAccessor sca = (IStreamContentAccessor) node;
try {
return readString(sca);
- } catch (CoreException ex) {
+ } catch (CoreException e) {
+ SpecfileLog.logError(e);
}
}
return null;
}
- private void parseSpecfile(DocumentRangeNode root, IDocument doc,
- IProgressMonitor monitor) {
- try {
- SpecfileParser parser = new SpecfileParser();
+ private void parseSpecfile(DocumentRangeNode root, IDocument doc, IFile file) {
+ SpecfileParser parser = new SpecfileParser();
+
+ // setup the error and task handlers
+ // FIXME: error markers do not show
+ if (file != null) {
+ FileEditorInput fei = new FileEditorInput(file);
+ // this allows compare editor to work with specfiles with errors
+ // without it, the compare editor is blank
+ try {
+ SpecfileEditor.getSpecfileDocumentProvider().disconnect(fei);
+ SpecfileEditor.getSpecfileDocumentProvider().connect(fei);
+ } catch (CoreException e) {
+ SpecfileLog.logError(e);
+ }
+ parser.setErrorHandler(new SpecfileErrorHandler(fei, doc));
+ parser.setTaskHandler(new SpecfileTaskHandler(fei, doc));
+
Specfile specfile = parser.parse(doc);
String id = specfile.getName();
- SpecNode parent = new SpecNode(root, 0, id, doc, 0, doc.getLength());
- monitor = beginWork(monitor);
+ // Be a child under parent node of specfileSectionRoot (would be rootNode)
+ SpecNode fileNode = new SpecNode((DocumentRangeNode) root.getParentNode(), 1, id, doc, 0, doc.getLength());
for (SpecfileSection sec : specfile.getSections()) {
try {
- addNode(parent, doc, sec.getName(), doc.getLineOffset(sec
- .getLineNumber()), doc.getLineOffset(sec
- .getSectionEndLine())
- - doc.getLineOffset(sec.getLineNumber()));
+ addNode(root, doc, sec.getName(),
+ doc.getLineOffset(sec.getLineNumber()),
+ doc.getLineOffset(sec.getSectionEndLine()) - doc.getLineOffset(sec.getLineNumber()),
+ 2);
} catch (BadLocationException e) {
SpecfileLog.logError(e);
}
}
+
+ // Be a child under the parent file node
for (SpecfilePackage sPackage : specfile.getPackages()
.getPackages()) {
try {
- SpecNode pNode = addNode(parent, doc, sPackage
- .getPackageName(), doc.getLineOffset(sPackage
- .getLineNumber()), doc.getLineOffset(sPackage
- .getSectionEndLine())
- - doc.getLineOffset(sPackage.getLineNumber()));
+ SpecNode pNode = addNode(fileNode, doc, sPackage.getPackageName(),
+ doc.getLineOffset(sPackage.getLineNumber()),
+ doc.getLineOffset(sPackage.getSectionEndLine()) - doc.getLineOffset(sPackage.getLineNumber()),
+ 3);
for (SpecfileSection section : sPackage.getSections()) {
- addNode(pNode, doc, section.getName(), doc
- .getLineOffset(section.getLineNumber()), doc
- .getLineOffset(section.getSectionEndLine())
- - doc.getLineOffset(section.getLineNumber()));
+ addNode(pNode, doc, section.getName(),
+ doc.getLineOffset(section.getLineNumber()),
+ doc.getLineOffset(section.getSectionEndLine()) - doc.getLineOffset(section.getLineNumber()),
+ 4);
}
} catch (BadLocationException e) {
SpecfileLog.logError(e);
}
}
- } finally {
- monitor.done();
+
}
}
@@ -150,9 +175,9 @@ public class SpecStructureCreator extends StructureCreator {
return new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN);
}
- private SpecNode addNode(DocumentRangeNode root, IDocument doc,
- String name, int start, int end) {
- return new SpecNode(root, 1, name, doc, start, end);
+ private SpecNode addNode(DocumentRangeNode parent, IDocument doc,
+ String name, int start, int end, int type) {
+ return new SpecNode(parent, type, name, doc, start, end);
}
private static String readString(InputStream is, String encoding) {
@@ -174,12 +199,13 @@ public class SpecStructureCreator extends StructureCreator {
} catch (IOException ex) {
// NeedWork
+ SpecfileLog.logError(ex);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ex) {
- // silently ignored
+ SpecfileLog.logError(ex);
}
}
}
@@ -226,15 +252,31 @@ public class SpecStructureCreator extends StructureCreator {
isEditable = false;
}
- DocumentRangeNode rootNode = new StructureRootNode(document, input,
- this, adapter) {
+ // get the resource being compared, but treat compare with history as null resource
+ IFile file = null;
+ if (input instanceof IResourceProvider) {
+ IResource res = ((IResourceProvider)input).getResource();
+ file = (IFile) res.getAdapter(IFile.class);
+ }
+
+ DocumentRangeNode rootNode = new StructureRootNode(document, input, this, adapter) {
@Override
public boolean isEditable() {
return isEditable;
}
};
- parseSpecfile(rootNode, document, monitor);
+
+ try {
+ monitor = beginWork(monitor);
+ // Section Root
+ SpecNode specfileSectionRoot = new SpecNode(rootNode, 0, SPECFILE_ROOT_NODE, document, 0, document.getLength());
+ parseSpecfile(specfileSectionRoot, document, file);
+ } finally {
+ if (monitor != null) {
+ monitor.done();
+ }
+ }
+
return rootNode;
}
-
}
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/hyperlink/SpecfileElementHyperlinkDetector.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/hyperlink/SpecfileElementHyperlinkDetector.java
index 4a40f5b..c5ebb1e 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/hyperlink/SpecfileElementHyperlinkDetector.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/hyperlink/SpecfileElementHyperlinkDetector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Alexander Kurtakov.
+ * Copyright (c) 2008, 2013 Alexander Kurtakov.
* 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
@@ -24,6 +24,7 @@ import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.linuxtools.internal.rpm.ui.editor.ISpecfileSpecialSymbols;
import org.eclipse.linuxtools.internal.rpm.ui.editor.parser.SpecfileSource;
+import org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor;
import org.eclipse.linuxtools.rpm.ui.editor.parser.Specfile;
import org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileDefine;
import org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement;
@@ -60,12 +61,19 @@ public class SpecfileElementHyperlinkDetector extends AbstractHyperlinkDetector
return null;
}
+ // Keeps the errorHandler on the initial opening of the .spec file
+ // otherwise, a new SpecfileParser does not initialize errorHandler
+ // until a SpecfileEditor#editorSaved is called
if (specfile == null) {
- SpecfileParser parser = new SpecfileParser();
- specfile = parser.parse(document);
+ SpecfileEditor a = ((SpecfileEditor) this.getAdapter(SpecfileEditor.class));
+ if (a != null && a.getSpecfile() != null) {
+ specfile = a.getSpecfile();
+ } else {
+ SpecfileParser parser = new SpecfileParser();
+ specfile = parser.parse(document);
+ }
}
-
int offset = region.getOffset();
IRegion lineInfo;
@@ -141,6 +149,8 @@ public class SpecfileElementHyperlinkDetector extends AbstractHyperlinkDetector
IRegion urlRegion = new Region(lineInfo.getOffset()
+ line.indexOf(word, lineIndex), word.length());
+ // will only work with 1 active page
+ // does not work with CompareEditor
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/markers/SpecfileTaskHandler.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/markers/SpecfileTaskHandler.java
index fb1d9a0..5372f53 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/markers/SpecfileTaskHandler.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/markers/SpecfileTaskHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Red Hat, Inc.
+ * Copyright (c) 2008, 2013 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
@@ -19,16 +19,47 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.linuxtools.internal.rpm.ui.editor.Activator;
import org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileLog;
+import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.MarkerUtilities;
+/**
+ * A class designated to handle the tasks of a specfile.
+ *
+ * @since 1.2.0
+ */
public class SpecfileTaskHandler extends SpecfileMarkerHandler{
public static final String SPECFILE_TASK_MARKER_ID = Activator.PLUGIN_ID
+ ".specfiletask"; //$NON-NLS-1$
+ /**
+ * Construct a specfile task handler given a IFile.
+ *
+ * @param file The specfile file.
+ * @param document The specfile document.
+ */
public SpecfileTaskHandler(IFile file, IDocument document) {
super(file, document);
}
+ /**
+ * Construct a specfile task handler given a FileEditorInput.
+ *
+ * @param file The FileEditorInput to get the file from.
+ * @param document The specfile document.
+ *
+ * @since 1.2.0
+ */
+ public SpecfileTaskHandler(FileEditorInput file, IDocument document) {
+ this(file.getFile(), document);
+ }
+
+ /**
+ * Handle the task of the specfile.
+ *
+ * @param lineNumber The line number of the task.
+ * @param line The line contents.
+ * @param taskType The task type.
+ */
public void handleTask(int lineNumber, String line, String taskType) {
if (file == null) {
return;
@@ -57,10 +88,12 @@ public class SpecfileTaskHandler extends SpecfileMarkerHandler{
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.rpm.ui.editor.markers.SpecfileMarkerHandler#getMarkerID()
+ */
@Override
String getMarkerID() {
return SPECFILE_TASK_MARKER_ID;
}
-
-
}
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileParser.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileParser.java
index 5e7b63b..c7853ba 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileParser.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/rpm/ui/editor/parser/SpecfileParser.java
@@ -161,6 +161,17 @@ public class SpecfileParser {
}
}
}
+
+ // sets the last SpecfileSection's end line to that of the end of
+ // the end of the specfileDocument.
+ // SpecfileParser#parseMacro will handle correcting the end line
+ // if the last SpecfileSection was not truly the last 1
+ // This is for the purpose of making DocumentRangeNode work
+ if (lastSection != null) {
+ lastSection.setSectionEndLine(specfileDocument
+ .getNumberOfLines() - 1);
+ }
+
// The +1 is for the line delimiter. FIXME: will we end up off
// by one on the last line?
lineStartPosition += line.length() + 1;