Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2009-12-07 22:47:39 -0500
committerspingel2009-12-07 22:47:39 -0500
commitf1f16a24f8fc9427d83327aae0d8f12ed73a35c9 (patch)
tree40ee58b5defece33b02be855ff6ede63d7756c62
parent983a4790b4c7a5f16f1e86cb0eb659395ed7b3de (diff)
downloadorg.eclipse.mylyn.tasks-f1f16a24f8fc9427d83327aae0d8f12ed73a35c9.tar.gz
org.eclipse.mylyn.tasks-f1f16a24f8fc9427d83327aae0d8f12ed73a35c9.tar.xz
org.eclipse.mylyn.tasks-f1f16a24f8fc9427d83327aae0d8f12ed73a35c9.zip
NEW - bug 296763: content assist pastes bug prefix twice
https://bugs.eclipse.org/bugs/show_bug.cgi?id=296763
-rw-r--r--org.eclipse.mylyn.tasks.tests/.settings/.api_filters14
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java2
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MockTextViewer.java45
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskHyperlinkDetectorTest.java10
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/RepositoryCompletionProcessorTest.java124
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryCompletionProcessor.java144
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java4
8 files changed, 300 insertions, 45 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/.settings/.api_filters b/org.eclipse.mylyn.tasks.tests/.settings/.api_filters
index e90b8b192..5a385dac6 100644
--- a/org.eclipse.mylyn.tasks.tests/.settings/.api_filters
+++ b/org.eclipse.mylyn.tasks.tests/.settings/.api_filters
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.mylyn.tasks.tests" version="2">
- <resource path="src/org/eclipse/mylyn/tasks/tests/ui/editor/TaskUrlHyperlinkDetectorTest.java" type="org.eclipse.mylyn.tasks.tests.ui.editor.TaskUrlHyperlinkDetectorTest">
- <filter id="571519004">
+ <resource path="src/org/eclipse/mylyn/tasks/tests/ui/MockTextViewer.java" type="org.eclipse.mylyn.tasks.tests.ui.MockTextViewer">
+ <filter id="571473929">
<message_arguments>
- <message_argument value="org.eclipse.mylyn.tasks.tests.ui.editor.TaskUrlHyperlinkDetectorTest.detect(String, int, int)"/>
<message_argument value="TextViewer"/>
+ <message_argument value="MockTextViewer"/>
</message_arguments>
</filter>
</resource>
@@ -16,4 +16,12 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/mylyn/tasks/tests/ui/editor/TaskUrlHyperlinkDetectorTest.java" type="org.eclipse.mylyn.tasks.tests.ui.editor.TaskUrlHyperlinkDetectorTest">
+ <filter id="571519004">
+ <message_arguments>
+ <message_argument value="org.eclipse.mylyn.tasks.tests.ui.editor.TaskUrlHyperlinkDetectorTest.detect(String, int, int)"/>
+ <message_argument value="TextViewer"/>
+ </message_arguments>
+ </filter>
+ </resource>
</component>
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
index f292221c6..6201a8801 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
@@ -26,6 +26,7 @@ import org.eclipse.mylyn.tasks.tests.ui.TaskListSynchronizationSchedulerTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskRelationHyperlinkDetectorTest;
import org.eclipse.mylyn.tasks.tests.ui.editor.EditorUtilTest;
import org.eclipse.mylyn.tasks.tests.ui.editor.PlanningPartTest;
+import org.eclipse.mylyn.tasks.tests.ui.editor.RepositoryCompletionProcessorTest;
import org.eclipse.mylyn.tasks.tests.ui.editor.TaskEditorPartDescriptorTest;
import org.eclipse.mylyn.tasks.tests.ui.editor.TaskUrlHyperlinkDetectorTest;
@@ -96,6 +97,7 @@ public class AllTasksTests {
suite.addTestSuite(FileTaskAttachmentSourceTest.class);
suite.addTestSuite(TaskListSynchronizationSchedulerTest.class);
suite.addTestSuite(PlanningPartTest.class);
+ suite.addTestSuite(RepositoryCompletionProcessorTest.class);
// XXX long running tests, put back?
//suite.addTestSuite(TaskDataImportTest.class);
//suite.addTestSuite(QueryExportImportTest.class);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MockTextViewer.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MockTextViewer.java
new file mode 100644
index 000000000..4b634c9d2
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MockTextViewer.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Tasktop Technologies 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests.ui;
+
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextViewer;
+
+/**
+ * @author Steffen Pingel
+ */
+public class MockTextViewer extends TextViewer {
+
+ private String text;
+
+ public MockTextViewer() {
+ }
+
+ public MockTextViewer(String text) {
+ this.text = text;
+ }
+
+ @Override
+ public IDocument getDocument() {
+ return new Document(text);
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskHyperlinkDetectorTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskHyperlinkDetectorTest.java
index 0666da543..74423c8a7 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskHyperlinkDetectorTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskHyperlinkDetectorTest.java
@@ -13,11 +13,8 @@ package org.eclipse.mylyn.tasks.tests.ui;
import junit.framework.TestCase;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskHyperlinkDetector;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -43,12 +40,7 @@ public class TaskHyperlinkDetectorTest extends TestCase {
protected IHyperlink[] detect(final String text, int start, int length) {
AbstractTaskHyperlinkDetector detector = createHyperlinkDetector();
- return detector.detectHyperlinks(new TextViewer() {
- @Override
- public IDocument getDocument() {
- return new Document(text);
- }
- }, new Region(start, length), true);
+ return detector.detectHyperlinks(new MockTextViewer(text), new Region(start, length), true);
}
protected AbstractTaskHyperlinkDetector createHyperlinkDetector() {
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/RepositoryCompletionProcessorTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/RepositoryCompletionProcessorTest.java
new file mode 100644
index 000000000..606ab82bf
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/RepositoryCompletionProcessorTest.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Tasktop Technologies 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests.ui.editor;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.mylyn.internal.tasks.core.TaskTask;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryCompletionProcessor;
+import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryCompletionProcessor.TaskCompletionProposal;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
+import org.eclipse.mylyn.tasks.tests.ui.MockTextViewer;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ * @author Steffen Pingel
+ */
+public class RepositoryCompletionProcessorTest extends TestCase {
+
+ private TaskRepository repository;
+
+ @Override
+ protected void setUp() throws Exception {
+ TaskTestUtil.resetTaskListAndRepositories();
+ repository = TaskTestUtil.createMockRepository();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ TaskTestUtil.resetTaskListAndRepositories();
+ }
+
+ public void testComputeCompletionProposals() {
+ TaskTask taskFoo = addTask("1", "foo");
+ TaskTask taskBar = addTask("2", "bar");
+
+ RepositoryCompletionProcessor processor = new RepositoryCompletionProcessor(repository);
+ ICompletionProposal[] proposals = processor.computeCompletionProposals(new MockTextViewer(""), 0);
+ assertEquals(2, proposals.length);
+ assertEquals(taskFoo, ((TaskCompletionProposal) proposals[0]).getTask());
+ assertEquals(taskBar, ((TaskCompletionProposal) proposals[1]).getTask());
+
+ proposals = processor.computeCompletionProposals(new MockTextViewer("abc"), 1);
+ assertEquals(0, proposals.length);
+
+ }
+
+ public void testComputeCompletionProposalsPrefix() {
+ TaskTask taskFoo = addTask("1", "foo");
+ TaskTask taskBar = addTask("2", "bar");
+
+ RepositoryCompletionProcessor processor = new RepositoryCompletionProcessor(repository);
+ MockTextViewer viewer = new MockTextViewer("task");
+ ICompletionProposal[] proposals = processor.computeCompletionProposals(viewer, 4);
+ assertEquals(2, proposals.length);
+ TaskCompletionProposal proposal = (TaskCompletionProposal) proposals[0];
+ assertEquals(taskFoo, proposal.getTask());
+ assertEquals(taskBar, ((TaskCompletionProposal) proposals[1]).getTask());
+ assertEquals("task 1", proposal.getReplacement());
+
+ IDocument doc = viewer.getDocument();
+ proposal.apply(doc);
+ assertEquals("task 1", doc.get());
+ assertEquals(new Point(6, 0), proposal.getSelection(doc));
+ }
+
+ public void testComputeCompletionProposalsPrefixSpace() {
+ TaskTask taskFoo = addTask("1", "foo");
+ TaskTask taskBar = addTask("2", "bar");
+
+ RepositoryCompletionProcessor processor = new RepositoryCompletionProcessor(repository);
+ MockTextViewer viewer = new MockTextViewer("task ");
+ ICompletionProposal[] proposals = processor.computeCompletionProposals(viewer, 5);
+ assertEquals(2, proposals.length);
+ TaskCompletionProposal proposal = (TaskCompletionProposal) proposals[0];
+ assertEquals(taskFoo, proposal.getTask());
+ assertEquals(taskBar, ((TaskCompletionProposal) proposals[1]).getTask());
+ assertEquals("task 1", proposal.getReplacement());
+
+ IDocument doc = viewer.getDocument();
+ proposal.apply(doc);
+ assertEquals("task 1", doc.get());
+ assertEquals(new Point(6, 0), proposal.getSelection(doc));
+ }
+
+ public void testComputeCompletionProposalsParenthesis() {
+ TaskTask taskFoo = addTask("1", "foo");
+ TaskTask taskBar = addTask("2", "bar");
+
+ RepositoryCompletionProcessor processor = new RepositoryCompletionProcessor(repository);
+ MockTextViewer viewer = new MockTextViewer("(task");
+ ICompletionProposal[] proposals = processor.computeCompletionProposals(viewer, 5);
+ assertEquals(2, proposals.length);
+ TaskCompletionProposal proposal = (TaskCompletionProposal) proposals[0];
+ assertEquals(taskFoo, proposal.getTask());
+ assertEquals(taskBar, ((TaskCompletionProposal) proposals[1]).getTask());
+ assertEquals("task 1", proposal.getReplacement());
+
+ IDocument doc = viewer.getDocument();
+ proposal.apply(doc);
+ assertEquals("(task 1", doc.get());
+ assertEquals(new Point(7, 0), proposal.getSelection(doc));
+ }
+
+ private TaskTask addTask(String taskId, String summary) {
+ TaskTask task = TaskTestUtil.createMockTask(taskId);
+ task.setSummary(summary);
+ TasksUiPlugin.getTaskList().addTask(task);
+ return task;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java
index 85446b3e0..3058d89ee 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java
@@ -96,7 +96,7 @@ public class CopyTaskDetailsAction extends BaseSelectionListenerAction {
if (object instanceof ITask) {
ITask task = (ITask) object;
if (task.getTaskKey() != null) {
- sb.append(TasksUiInternal.getTaskPrefix(task));
+ sb.append(TasksUiInternal.getTaskPrefix(task.getConnectorKind()));
sb.append(task.getTaskKey());
sb.append(": "); //$NON-NLS-1$
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryCompletionProcessor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryCompletionProcessor.java
index 1d626b4bd..31ecf508e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryCompletionProcessor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryCompletionProcessor.java
@@ -29,6 +29,7 @@ import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
@@ -42,6 +43,8 @@ import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TaskElementLabelProvider;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -55,6 +58,88 @@ import org.eclipse.ui.PlatformUI;
*/
public class RepositoryCompletionProcessor implements IContentAssistProcessor {
+ public static class TaskCompletionProposal implements ICompletionProposal {
+
+ private final LabelProvider labelProvider;
+
+ private final TaskRepository repository;
+
+ private final ITask task;
+
+ private final int replacementOffset;
+
+ private final int replacementLength;
+
+ private String replacement;
+
+ private final String defaultReplacement;
+
+ private final boolean includePrefix;
+
+ public TaskCompletionProposal(TaskRepository repository, ITask task, LabelProvider labelProvider,
+ String defaultReplacement, boolean includePrefix, int replacementOffset, int replacementLength) {
+ this.labelProvider = labelProvider;
+ this.repository = repository;
+ this.task = task;
+ this.defaultReplacement = defaultReplacement;
+ this.includePrefix = includePrefix;
+ this.replacementOffset = replacementOffset;
+ this.replacementLength = replacementLength;
+ }
+
+ public void apply(IDocument document) {
+ try {
+ document.replace(replacementOffset, replacementLength, getReplacement());
+ } catch (BadLocationException x) {
+ // ignore
+ }
+ }
+
+ public String getReplacement() {
+ if (replacement == null) {
+ // add an absolute reference to the task if the viewer does not have a repository
+ if (defaultReplacement == null || repository == null
+ || !repository.getRepositoryUrl().equals(task.getRepositoryUrl())) {
+ replacement = CopyTaskDetailsAction.getTextForTask(task);
+ } else if (includePrefix) {
+ replacement = TasksUiInternal.getTaskPrefix(task.getConnectorKind()) + defaultReplacement;
+ } else {
+ replacement = defaultReplacement;
+ }
+ }
+ return replacement;
+ }
+
+ public String getAdditionalProposalInfo() {
+ return null;
+ }
+
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
+ public String getDisplayString() {
+ return labelProvider.getText(task);
+ }
+
+ public Image getImage() {
+ return labelProvider.getImage(task);
+ }
+
+ public Point getSelection(IDocument document) {
+ return new Point(replacementOffset + getReplacement().length(), 0);
+ }
+
+ public TaskRepository getRepository() {
+ return repository;
+ }
+
+ public ITask getTask() {
+ return task;
+ }
+
+ }
+
private class ProposalComputer {
public static final String LABEL_SEPARATOR = " -------------------------------------------- "; //$NON-NLS-1$
@@ -67,7 +152,7 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
private final String prefix;
- private final List<CompletionProposal> resultList = new ArrayList<CompletionProposal>();
+ private final List<ICompletionProposal> resultList = new ArrayList<ICompletionProposal>();
public ProposalComputer(ITextViewer viewer, int offset) {
this.offset = offset;
@@ -82,10 +167,8 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
addSeparator = false;
}
- replacement = getReplacement(task, replacement, includeTaskPrefix);
- String displayString = labelProvider.getText(task);
- resultList.add(new CompletionProposal(replacement, offset - prefix.length(), prefix.length(),
- replacement.length(), labelProvider.getImage(task), displayString, null, null));
+ resultList.add(new TaskCompletionProposal(repository, task, labelProvider, replacement, includeTaskPrefix,
+ offset - prefix.length(), prefix.length()));
addedTasks.add(task);
}
@@ -105,7 +188,7 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
return;
}
- if (getNeverIncludePrefix() && !task.getRepositoryUrl().equals(taskRepository.getRepositoryUrl())) {
+ if (getNeverIncludePrefix() && !task.getRepositoryUrl().equals(repository.getRepositoryUrl())) {
return;
}
@@ -113,31 +196,20 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
if (prefix.length() == 0) {
addProposal(task, taskKey, !getNeverIncludePrefix());
} else if (taskKey != null && taskKey.startsWith(prefix)) {
+ // don't include prefix if completing id since it was most likely already added
addProposal(task, taskKey, false);
} else if (containsPrefix(task)) {
addProposal(task, taskKey, !getNeverIncludePrefix());
}
}
- private String getReplacement(ITask task, String text, boolean includeTaskPrefix) {
- // add an absolute reference to the task if the viewer does not have a repository
- if (taskRepository == null || text == null
- || !taskRepository.getRepositoryUrl().equals(task.getRepositoryUrl())) {
- return CopyTaskDetailsAction.getTextForTask(task);
- }
-
- if (includeTaskPrefix) {
- return TasksUiInternal.getTaskPrefix(task) + text;
- } else {
- return text;
- }
- }
-
private boolean containsPrefix(ITask task) {
- String searchTest = TasksUiInternal.getTaskPrefix(task) + " " + labelProvider.getText(task); //$NON-NLS-1$
- String[] tokens = searchTest.split("\\s"); //$NON-NLS-1$
+ String needle = prefix.trim();
+ String haystack = TasksUiInternal.getTaskPrefix(task.getConnectorKind())
+ + " " + labelProvider.getText(task); //$NON-NLS-1$
+ String[] tokens = haystack.split("\\s"); //$NON-NLS-1$
for (String token : tokens) {
- if (token.toLowerCase().startsWith(prefix)) {
+ if (token.toLowerCase().startsWith(needle)) {
return true;
}
}
@@ -162,13 +234,25 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
try {
while (i > 0) {
- char ch = document.getChar(i - 1);
- if (Character.isWhitespace(ch)) {
+ char c = document.getChar(i - 1);
+ if (Character.isWhitespace(c) || c == '(' || c == ':') {
break;
}
i--;
}
-
+ if (i == offset && repository != null) {
+ // check if document contains "{prefix} "
+ String taskPrefix = TasksUiInternal.getTaskPrefix(repository.getConnectorKind());
+ if (taskPrefix.length() > 1) {
+ try {
+ if (taskPrefix.equals(document.get(offset - taskPrefix.length(), taskPrefix.length()))) {
+ return taskPrefix;
+ }
+ } catch (BadLocationException e) {
+ // ignore
+ }
+ }
+ }
return document.get(i, offset - i);
} catch (BadLocationException e) {
return ""; //$NON-NLS-1$
@@ -186,7 +270,7 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
private boolean select(ITask task) {
return !(task instanceof LocalTask) //
- && (taskRepository == null || task.getRepositoryUrl().equals(taskRepository.getRepositoryUrl()));
+ && (repository == null || task.getRepositoryUrl().equals(repository.getRepositoryUrl()));
}
public ICompletionProposal[] getResult() {
@@ -201,12 +285,12 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
private final TaskElementLabelProvider labelProvider = new TaskElementLabelProvider(false);
- private final TaskRepository taskRepository;
+ private final TaskRepository repository;
private boolean neverIncludePrefix;
public RepositoryCompletionProcessor(TaskRepository taskRepository) {
- this.taskRepository = taskRepository;
+ this.repository = taskRepository;
this.neverIncludePrefix = false;
}
@@ -278,7 +362,7 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
}
// add all remaining tasks for repository
- if (taskRepository != null) {
+ if (repository != null) {
proposalComputer.addSeparator();
TaskList taskList = TasksUiPlugin.getTaskList();
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
index 5be4ac081..4675b5b52 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
@@ -1108,8 +1108,8 @@ public class TasksUiInternal {
return 0;
}
- public static String getTaskPrefix(ITask task) {
- AbstractRepositoryConnector connector = TasksUiPlugin.getConnector(task.getConnectorKind());
+ public static String getTaskPrefix(String connectorKind) {
+ AbstractRepositoryConnector connector = TasksUiPlugin.getConnector(connectorKind);
if (connector != null) {
String prefix = connector.getTaskIdPrefix();
// work around short prefixes which are not separated by space, e.g. "#" for Trac

Back to the top