mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RUBY-7065 View task descriptions, part one: quick documentation popup
This commit is contained in:
@@ -95,6 +95,8 @@
|
||||
<applicationService serviceInterface="com.intellij.tasks.config.RecentTaskRepositories"
|
||||
serviceImplementation="com.intellij.tasks.config.RecentTaskRepositories"/>
|
||||
|
||||
<lang.documentationProvider language="TEXT" implementationClass="com.intellij.tasks.doc.TaskDocumentationProvider"/>
|
||||
|
||||
<!--context providers-->
|
||||
<tasks.contextProvider implementation="com.intellij.tasks.context.OpenEditorsContextProvider"/>
|
||||
<tasks.contextProvider implementation="com.intellij.tasks.context.ProjectViewContextProvider"/>
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.tasks.doc;
|
||||
|
||||
import com.intellij.lang.documentation.AbstractDocumentationProvider;
|
||||
import com.intellij.lang.documentation.ExternalDocumentationProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.tasks.Task;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Dennis.Ushakov
|
||||
*/
|
||||
public class TaskDocumentationProvider extends AbstractDocumentationProvider implements ExternalDocumentationProvider {
|
||||
|
||||
@Override
|
||||
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
|
||||
if (element instanceof TaskPsiElement) {
|
||||
final String url = ((TaskPsiElement)element).getTask().getIssueUrl();
|
||||
if (url != null) {
|
||||
return Collections.singletonList(url);
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateDoc(PsiElement element, PsiElement originalElement) {
|
||||
if (!(element instanceof TaskPsiElement)) return null;
|
||||
final Task task = ((TaskPsiElement)element).getTask();
|
||||
final StringBuilder builder = new StringBuilder("<html>");
|
||||
builder.append("<b>Summary:</b> ").append(task.getSummary()).append("<br>");
|
||||
builder.append("<b>Id:</b> ").append(task.getId()).append("<br>");
|
||||
if (task.getCreated() != null) {
|
||||
builder.append("<b>Created at:</b> ").append(task.getCreated()).append("<br>");
|
||||
}
|
||||
if (task.getUpdated() != null) {
|
||||
builder.append("<b>Updated at:</b> ").append(task.getUpdated()).append("<br>");
|
||||
}
|
||||
if (task.getDescription() != null) {
|
||||
builder.append("<b>Description:</b><br>").append(task.getDescription());
|
||||
}
|
||||
builder.append("</html>");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
|
||||
return object instanceof Task ? new TaskPsiElement(psiManager, (Task)object): null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String fetchExternalDocumentation(Project project, PsiElement element, List<String> docUrls) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDocumentationFor(PsiElement element, PsiElement originalElement) {
|
||||
return element instanceof TaskPsiElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPromptToConfigureDocumentation(PsiElement element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void promptToConfigureDocumentation(PsiElement element) {}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.tasks.doc;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.FakePsiElement;
|
||||
import com.intellij.tasks.Task;
|
||||
|
||||
/**
|
||||
* @author Dennis.Ushakov
|
||||
*/
|
||||
public class TaskPsiElement extends FakePsiElement {
|
||||
private final PsiManager myPsiManager;
|
||||
private final Task myTask;
|
||||
|
||||
public TaskPsiElement(PsiManager psiManager, final Task task) {
|
||||
myPsiManager = psiManager;
|
||||
myTask = task;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getParent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Task getTask() {
|
||||
return myTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiManager getManager() {
|
||||
return myPsiManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiFile getContainingFile() {
|
||||
return PsiFileFactory.getInstance(getProject()).createFileFromText("foo.txt", "");
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class TaskCompletionContributor extends CompletionContributor {
|
||||
: AutoCompletionPolicy.NEVER_AUTOCOMPLETE;
|
||||
|
||||
for (final Task task : items) {
|
||||
LookupElementBuilder builder = LookupElementBuilder.create(task.getId())
|
||||
LookupElementBuilder builder = LookupElementBuilder.create(task, task.getId())
|
||||
.setIcon(task.getIcon())
|
||||
.addLookupString(task.getSummary())
|
||||
.setTailText(" " + task.getSummary(), true)
|
||||
|
||||
Reference in New Issue
Block a user