1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug #219321 : Info popup should show includes

This commit is contained in:
Oleg Krasilnikov 2008-02-18 15:50:42 +00:00
parent e7d5ea4567
commit 84c9619cf4
4 changed files with 108 additions and 26 deletions

View file

@ -111,6 +111,7 @@ public class CHelpProviderTester{
private String fPrototype = "Prototype";
private String fSummary = "Summary";
private String fSynopsis = "Synopsis";
private IRequiredInclude[] incs = new IRequiredInclude[] { new RequiredInclude("dummy.h")};
private class RequiredInclude implements IRequiredInclude {
private String include;
@ -152,7 +153,7 @@ public class CHelpProviderTester{
public IFunctionPrototypeSummary getPrototype() { return new FunctionPrototypeSummary(); }
public IRequiredInclude[] getIncludes() {
return (IRequiredInclude[])null;
return incs;
}
}

View file

@ -114,8 +114,10 @@ AddIncludeOnSelectionAction.error.noInput=no Editor Input
DefaultCEditorTextHover.html.name=<b>Name:</b>
DefaultCEditorTextHover.html.prototype=<br><b>Prototype:</b>
DefaultCEditorTextHover.html.description=<br><b>Description:</b><br>
DefaultCEditorTextHover.html.includes=<br><b>Referring Includes:</b><br>
CContentOutlinePage.menu.fileSearch=File Search
CContentOutlinePage.error.noInput=no Editor Input
CDocHover.0=Referring Includes:
CEditor.menu.fileSearch=File Search
CEditor.menu.search=Search
CEditor.menu.folding=F&olding

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000 2005 IBM Corporation and others.
* Copyright (c) 2000 2008 IBM Corporation 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
@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
* Intel corp.
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text;
@ -19,7 +20,12 @@ import java.io.Reader;
* Provides a set of convenience methods for creating HTML pages.
*/
public class HTMLPrinter {
private static final String LB = "<"; //$NON-NLS-1$
private static final String CB = "</"; //$NON-NLS-1$
private static final String RB = ">"; //$NON-NLS-1$
private HTMLPrinter() {
}
@ -31,7 +37,7 @@ public class HTMLPrinter {
if (current == -1)
return text;
StringBuffer buffer= new StringBuffer();
StringBuilder buffer= new StringBuilder();
while (current > -1) {
buffer.append(text.substring(previous, current));
buffer.append(s);
@ -50,7 +56,7 @@ public class HTMLPrinter {
public static String read(Reader rd) {
StringBuffer buffer= new StringBuffer();
StringBuilder buffer= new StringBuilder();
char[] readBuffer= new char[2048];
try {
@ -70,47 +76,104 @@ public class HTMLPrinter {
buffer.insert(position, "<html><body text=\"#000000\" bgcolor=\"#FFFF88\"><font size=-1>"); //$NON-NLS-1$
}
public static void insertPageProlog(StringBuilder buffer, int position) {
buffer.insert(position, "<html><body text=\"#000000\" bgcolor=\"#FFFF88\"><font size=-1>"); //$NON-NLS-1$
}
public static void addPageProlog(StringBuffer buffer) {
insertPageProlog(buffer, buffer.length());
}
public static void addPageProlog(StringBuilder buffer) {
insertPageProlog(buffer, buffer.length());
}
public static void addPageEpilog(StringBuffer buffer) {
buffer.append("</font></body></html>"); //$NON-NLS-1$
}
public static void addPageEpilog(StringBuilder buffer) {
buffer.append("</font></body></html>"); //$NON-NLS-1$
}
public static void startBulletList(StringBuffer buffer) {
buffer.append("<ul>"); //$NON-NLS-1$
}
public static void startBulletList(StringBuilder buffer) {
buffer.append("<ul>"); //$NON-NLS-1$
}
public static void endBulletList(StringBuffer buffer) {
buffer.append("</ul>"); //$NON-NLS-1$
}
public static void endBulletList(StringBuilder buffer) {
buffer.append("</ul>"); //$NON-NLS-1$
}
private static void addTag(StringBuffer buffer, String bullet, String tag) {
if (bullet != null && tag != null) {
buffer.append(LB);
buffer.append(tag);
buffer.append(RB);
buffer.append(bullet);
buffer.append(CB);
buffer.append(tag);
buffer.append(RB);
}
}
private static void addTag(StringBuilder buffer, String bullet, String tag) {
if (bullet != null && tag != null) {
buffer.append(LB);
buffer.append(tag);
buffer.append(RB);
buffer.append(bullet);
buffer.append(CB);
buffer.append(tag);
buffer.append(RB);
}
}
public static void addBullet(StringBuffer buffer, String bullet) {
if (bullet != null) {
buffer.append("<li>"); //$NON-NLS-1$
buffer.append(bullet);
buffer.append("</li>"); //$NON-NLS-1$
}
addTag(buffer, bullet, "li"); //$NON-NLS-1$
}
public static void addBullet(StringBuilder buffer, String bullet) {
addTag(buffer, bullet, "li"); //$NON-NLS-1$
}
public static void addSmallHeader(StringBuffer buffer, String header) {
if (header != null) {
buffer.append("<h5>"); //$NON-NLS-1$
buffer.append(header);
buffer.append("</h5>"); //$NON-NLS-1$
}
addTag(buffer, header, "h5"); //$NON-NLS-1$
}
public static void addSmallHeader(StringBuilder buffer, String header) {
addTag(buffer, header, "h5"); //$NON-NLS-1$
}
public static void addParagraph(StringBuffer buffer, String paragraph) {
if (paragraph != null) {
buffer.append("<p>"); //$NON-NLS-1$
buffer.append(paragraph);
}
}
public static void addParagraph(StringBuilder buffer, String paragraph) {
if (paragraph != null) {
buffer.append("<p>"); //$NON-NLS-1$
buffer.append(paragraph);
}
}
public static void addParagraph(StringBuffer buffer, Reader paragraphReader) {
if (paragraphReader != null)
addParagraph(buffer, read(paragraphReader));
}
public static void addParagraph(StringBuilder buffer, Reader paragraphReader) {
if (paragraphReader != null)
addParagraph(buffer, read(paragraphReader));
}
}

View file

@ -12,15 +12,6 @@
package org.eclipse.cdt.internal.ui.text.c.hover;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.CHelpProviderManager;
import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
import org.eclipse.cdt.internal.ui.text.CWordFinder;
import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IFunctionSummary;
import org.eclipse.cdt.ui.IFunctionSummary.IFunctionPrototypeSummary;
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
@ -28,6 +19,18 @@ import org.eclipse.jface.text.Region;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IEditorInput;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IFunctionSummary;
import org.eclipse.cdt.ui.IRequiredInclude;
import org.eclipse.cdt.ui.IFunctionSummary.IFunctionPrototypeSummary;
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
import org.eclipse.cdt.internal.ui.CHelpProviderManager;
import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
import org.eclipse.cdt.internal.ui.text.CWordFinder;
import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
public class CDocHover extends AbstractCEditorTextHover {
/**
@ -50,7 +53,7 @@ public class CDocHover extends AbstractCEditorTextHover {
if (expression.length() == 0)
return null;
StringBuffer buffer = new StringBuffer();
StringBuilder buffer = new StringBuilder();
// call the Help to get info
@ -84,6 +87,19 @@ public class CDocHover extends AbstractCEditorTextHover {
//Don't convert this description since it could already be formatted
buffer.append(fs.getDescription());
}
IRequiredInclude[] incs = fs.getIncludes();
if (incs != null && incs.length > 0) {
buffer.append(CEditorMessages.getString("DefaultCEditorTextHover.html.includes")); //$NON-NLS-1$
int count = 0;
for (IRequiredInclude inc : incs) {
buffer.append(inc.getIncludeName());
buffer.append("<br>"); //$NON-NLS-1$
if (count++ > 4) {
buffer.append("...<br>"); //$NON-NLS-1$
break; // too long list: do not display all
}
}
}
}
if (buffer.length() > 0) {
HTMLPrinter.insertPageProlog(buffer, 0);