X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationProposal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationProposal.java index 238423d..9723320 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationProposal.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationProposal.java @@ -5,29 +5,31 @@ package net.sourceforge.phpdt.internal.ui.text.template; import net.sourceforge.phpdt.internal.corext.phpdoc.PHPDocUtil; -import net.sourceforge.phpdt.internal.corext.template.TemplateContext; import net.sourceforge.phpdt.internal.corext.template.TemplateMessages; -import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext; +import net.sourceforge.phpdt.internal.corext.template.php.JavaContext; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager; import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.builder.PHPIdentifierLocation; +import org.eclipse.core.resources.IProject; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.IContextInformation; +import org.eclipse.jface.text.templates.TemplateContext; import org.eclipse.swt.graphics.Image; -//import org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager; -//import org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI; -//import org.eclipse.jdt.internal.ui.util.ExceptionHandler; +//import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager; +//import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI; +//import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler; /** * A PHP identifier proposal. */ public class DeclarationProposal extends AbstractProposal { //implements IPHPCompletionProposal { + private IProject fProject; private final TemplateContext fContext; private final PHPIdentifierLocation fLocation; @@ -48,6 +50,7 @@ public class DeclarationProposal extends AbstractProposal { //implements IPHPCom * @param image the icon of the proposal. */ public DeclarationProposal( + IProject project, String identifierName, PHPIdentifierLocation location, TemplateContext context, @@ -56,6 +59,7 @@ public class DeclarationProposal extends AbstractProposal { //implements IPHPCom super(viewer); // Image image_fun, // Image image_var) { + fProject = project; fIdentifierName = identifierName; fLocation = location; fContext = context; @@ -138,10 +142,18 @@ public class DeclarationProposal extends AbstractProposal { //implements IPHPCom */ public String getAdditionalProposalInfo() { StringBuffer hoverInfoBuffer = new StringBuffer(); - String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString(); +// String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString(); + String workspaceLocation; + if (fProject!=null) { + workspaceLocation = fProject.getLocation().toString()+'/'; + } else { + // should never happen? + workspaceLocation = PHPeclipsePlugin.getWorkspace() + .getRoot().getLocation().toString(); + } String filename = workspaceLocation + fLocation.getFilename(); PHPDocUtil.appendPHPDoc(hoverInfoBuffer, filename, fLocation); - return textToHTML(hoverInfoBuffer.toString()); + return hoverInfoBuffer.toString(); } /* @@ -155,7 +167,15 @@ public class DeclarationProposal extends AbstractProposal { //implements IPHPCom * @see ICompletionProposal#getDisplayString() */ public String getDisplayString() { - String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString(); +// String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString(); + String workspaceLocation; + if (fProject!=null) { + workspaceLocation = fProject.getLocation().toString()+'/'; + } else { + // should never happen? + workspaceLocation = PHPeclipsePlugin.getWorkspace() + .getRoot().getLocation().toString(); + } String filename = workspaceLocation + fLocation.getFilename(); return fIdentifierName + TemplateMessages.getString("TemplateProposal.delimiter") + PHPDocUtil.getUsage(filename, fLocation) + TemplateMessages.getString("TemplateProposal.delimiter") + filename; // $NON-NLS-1$ //$NON-NLS-1$ } @@ -177,32 +197,34 @@ public class DeclarationProposal extends AbstractProposal { //implements IPHPCom return PHPUiImages.get(PHPUiImages.IMG_DEFINE); case PHPIdentifierLocation.VARIABLE : return PHPUiImages.get(PHPUiImages.IMG_VAR); + case PHPIdentifierLocation.GLOBAL_VARIABLE : + return PHPUiImages.get(PHPUiImages.IMG_VAR); } return PHPUiImages.get(PHPUiImages.IMG_FUN); - } + } /* * @see IJavaCompletionProposal#getRelevance() */ public int getRelevance() { - if (fContext instanceof PHPUnitContext) { - PHPUnitContext context = (PHPUnitContext) fContext; + if (fContext instanceof JavaContext) { + JavaContext context = (JavaContext) fContext; switch (context.getCharacterBeforeStart()) { // high relevance after whitespace case ' ' : case '\r' : case '\n' : case '\t' : - return 90; + return 80; case '>' : // -> case ':' : // :: - return 95; + return 85; default : return 0; } } else { - return 90; + return 80; } }