mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
07f9700ccd
commit
31e3729d82
13 changed files with 95 additions and 125 deletions
|
@ -45,8 +45,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a utility class to help convert AST elements to Strings corresponding to the
|
* This is a utility class to help convert AST elements to Strings corresponding to
|
||||||
* AST element's type.
|
* the AST element's type.
|
||||||
*
|
*
|
||||||
* @noextend This class is not intended to be subclassed by clients.
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
|
@ -58,9 +58,9 @@ public class ASTTypeUtil {
|
||||||
private static final int DEAULT_ITYPE_SIZE = 2;
|
private static final int DEAULT_ITYPE_SIZE = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation for the parameters of the given function type. The
|
* Returns a string representation for the parameters of the given function type.
|
||||||
* representation contains the comma-separated list of the normalized parameter type
|
* The representation contains the comma-separated list of the normalized parameter
|
||||||
* representations wrapped in parentheses.
|
* type representations wrapped in parentheses.
|
||||||
*/
|
*/
|
||||||
public static String getParameterTypeString(IFunctionType type) {
|
public static String getParameterTypeString(IFunctionType type) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
|
@ -493,7 +493,7 @@ public class ASTTypeUtil {
|
||||||
} else {
|
} else {
|
||||||
if (type instanceof ICPPReferenceType) {
|
if (type instanceof ICPPReferenceType) {
|
||||||
// reference types ignore cv-qualifiers
|
// reference types ignore cv-qualifiers
|
||||||
cvq=null;
|
cvq= null;
|
||||||
// lvalue references win over rvalue references
|
// lvalue references win over rvalue references
|
||||||
if (ref == null || ref.isRValueReference()) {
|
if (ref == null || ref.isRValueReference()) {
|
||||||
// delay reference to see if there are more
|
// delay reference to see if there are more
|
||||||
|
@ -599,23 +599,24 @@ public class ASTTypeUtil {
|
||||||
*
|
*
|
||||||
* @noreference This method is not intended to be referenced by clients.
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
*/
|
*/
|
||||||
public static String getType(IASTDeclarator decltor) {
|
public static String getType(IASTDeclarator declarator) {
|
||||||
// get the most nested declarator
|
// get the most nested declarator
|
||||||
while (decltor.getNestedDeclarator() != null)
|
while (declarator.getNestedDeclarator() != null) {
|
||||||
decltor = decltor.getNestedDeclarator();
|
declarator = declarator.getNestedDeclarator();
|
||||||
|
}
|
||||||
|
|
||||||
IBinding binding = decltor.getName().resolveBinding();
|
IBinding binding = declarator.getName().resolveBinding();
|
||||||
IType type = null;
|
IType type = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (binding instanceof IEnumerator) {
|
if (binding instanceof IEnumerator) {
|
||||||
type = ((IEnumerator)binding).getType();
|
type = ((IEnumerator) binding).getType();
|
||||||
} else if (binding instanceof IFunction) {
|
} else if (binding instanceof IFunction) {
|
||||||
type = ((IFunction)binding).getType();
|
type = ((IFunction) binding).getType();
|
||||||
} else if (binding instanceof ITypedef) {
|
} else if (binding instanceof ITypedef) {
|
||||||
type = ((ITypedef)binding).getType();
|
type = ((ITypedef) binding).getType();
|
||||||
} else if (binding instanceof IVariable) {
|
} else if (binding instanceof IVariable) {
|
||||||
type = ((IVariable)binding).getType();
|
type = ((IVariable) binding).getType();
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return EMPTY_STRING;
|
return EMPTY_STRING;
|
||||||
|
|
|
@ -21,15 +21,15 @@ public interface IASTTypeId extends IASTNode {
|
||||||
public static final IASTTypeId[] EMPTY_TYPEID_ARRAY = new IASTTypeId[0];
|
public static final IASTTypeId[] EMPTY_TYPEID_ARRAY = new IASTTypeId[0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>DECL_SPECIFIER</code> represents the relationship between an <code>IASTTypeId</code> and
|
* <code>DECL_SPECIFIER</code> represents the relationship between an <code>IASTTypeId</code>
|
||||||
* it's nested <code>IASTDeclSpecifier</code>.
|
* and it's nested <code>IASTDeclSpecifier</code>.
|
||||||
*/
|
*/
|
||||||
public static final ASTNodeProperty DECL_SPECIFIER = new ASTNodeProperty(
|
public static final ASTNodeProperty DECL_SPECIFIER = new ASTNodeProperty(
|
||||||
"IASTTypeId.DECL_SPECIFIER - IASTDeclSpecifier for IASTTypeId"); //$NON-NLS-1$
|
"IASTTypeId.DECL_SPECIFIER - IASTDeclSpecifier for IASTTypeId"); //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>ABSTRACT_DECLARATOR</code> represents the relationship between an <code>IASTTypeId</code> and
|
* <code>ABSTRACT_DECLARATOR</code> represents the relationship between an <code>IASTTypeId</code>
|
||||||
* it's nested <code>IASTDeclarator</code>.
|
* and it's nested <code>IASTDeclarator</code>.
|
||||||
*/
|
*/
|
||||||
public static final ASTNodeProperty ABSTRACT_DECLARATOR = new ASTNodeProperty(
|
public static final ASTNodeProperty ABSTRACT_DECLARATOR = new ASTNodeProperty(
|
||||||
"IASTTypeId.ABSTRACT_DECLARATOR - IASTDeclarator for IASTTypeId"); //$NON-NLS-1$
|
"IASTTypeId.ABSTRACT_DECLARATOR - IASTDeclarator for IASTTypeId"); //$NON-NLS-1$
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -22,5 +22,4 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IProblemType extends IType, ISemanticProblem {
|
public interface IProblemType extends IType, ISemanticProblem {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,8 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
|
||||||
CPPASTTypeId copy = new CPPASTTypeId();
|
CPPASTTypeId copy = new CPPASTTypeId();
|
||||||
copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy(style));
|
copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy(style));
|
||||||
copy.setAbstractDeclarator(absDecl == null ? null : absDecl.copy(style));
|
copy.setAbstractDeclarator(absDecl == null ? null : absDecl.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
|
||||||
copy.isPackExpansion = isPackExpansion;
|
copy.isPackExpansion = isPackExpansion;
|
||||||
if (style == CopyStyle.withLocations) {
|
return copy(copy, style);
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1762,10 +1762,9 @@ public class CPPVisitor extends ASTQueries {
|
||||||
* Creates the type for a parameter declaration.
|
* Creates the type for a parameter declaration.
|
||||||
*/
|
*/
|
||||||
public static IType createType(final ICPPASTParameterDeclaration pdecl, boolean forFuncType) {
|
public static IType createType(final ICPPASTParameterDeclaration pdecl, boolean forFuncType) {
|
||||||
IType pt;
|
|
||||||
IASTDeclSpecifier pDeclSpec = pdecl.getDeclSpecifier();
|
IASTDeclSpecifier pDeclSpec = pdecl.getDeclSpecifier();
|
||||||
ICPPASTDeclarator pDtor = pdecl.getDeclarator();
|
ICPPASTDeclarator pDtor = pdecl.getDeclarator();
|
||||||
pt = createType(pDeclSpec);
|
IType pt = createType(pDeclSpec);
|
||||||
if (pDtor != null) {
|
if (pDtor != null) {
|
||||||
pt = createType(pt, pDtor);
|
pt = createType(pt, pDtor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,4 +110,4 @@ OccurrencesFinder_label_singular=''{0}'' - 1 occurrence in ''{1}''
|
||||||
# The first argument will be replaced by the element name, the second by the count and the last by the file name
|
# The first argument will be replaced by the element name, the second by the count and the last by the file name
|
||||||
OccurrencesFinder_label_plural=''{0}'' - {1} occurrences in ''{2}''
|
OccurrencesFinder_label_plural=''{0}'' - {1} occurrences in ''{2}''
|
||||||
OccurrencesFinder_occurrence_description=Occurrence of ''{0}''
|
OccurrencesFinder_occurrence_description=Occurrence of ''{0}''
|
||||||
OccurrencesFinder_occurrence_write_description=Write Occurrence of ''{0}''
|
OccurrencesFinder_occurrence_write_description=Write occurrence of ''{0}''
|
|
@ -10,7 +10,6 @@
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
import org.eclipse.jface.text.DefaultInformationControl;
|
import org.eclipse.jface.text.DefaultInformationControl;
|
||||||
|
@ -32,12 +31,10 @@ import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
import org.eclipse.cdt.internal.ui.text.CWordFinder;
|
import org.eclipse.cdt.internal.ui.text.CWordFinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for providing hover information for C
|
* Abstract class for providing hover information for C elements.
|
||||||
* elements.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITextHoverExtension, ITextHoverExtension2, IInformationProviderExtension2 {
|
public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITextHoverExtension,
|
||||||
|
ITextHoverExtension2, IInformationProviderExtension2 {
|
||||||
private IEditorPart fEditor;
|
private IEditorPart fEditor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -102,7 +99,7 @@ public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITe
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.ITextHoverExtension2#getInformationPresenterControlCreator()
|
* @see ITextHoverExtension2#getInformationPresenterControlCreator()
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* Ericsson - Fix improper hover order (Bug 294812)
|
* Ericsson - Fix improper hover order (Bug 294812)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -39,10 +38,8 @@ import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
* hovers being placed before less specific ones.
|
* hovers being placed before less specific ones.
|
||||||
*/
|
*/
|
||||||
public class BestMatchHover extends AbstractCEditorTextHover {
|
public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that hover ordering is very important to be preserved by this
|
* Note that hover ordering is very important to be preserved by this class (bug 294812).
|
||||||
* class. (Bug 294812)
|
|
||||||
*/
|
*/
|
||||||
private List<CEditorTextHoverDescriptor> fTextHoverSpecifications;
|
private List<CEditorTextHoverDescriptor> fTextHoverSpecifications;
|
||||||
private List<ITextHover> fInstantiatedTextHovers;
|
private List<ITextHover> fInstantiatedTextHovers;
|
||||||
|
@ -63,16 +60,16 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
private void installTextHovers() {
|
private void installTextHovers() {
|
||||||
CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
|
CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
|
||||||
|
|
||||||
// initialize lists - indicates that the initialization happened
|
// Initialize lists - indicates that the initialization happened
|
||||||
fTextHoverSpecifications= new ArrayList<CEditorTextHoverDescriptor>(hoverDescs.length-1);
|
fTextHoverSpecifications= new ArrayList<CEditorTextHoverDescriptor>(hoverDescs.length-1);
|
||||||
fInstantiatedTextHovers= new ArrayList<ITextHover>(hoverDescs.length-1);
|
fInstantiatedTextHovers= new ArrayList<ITextHover>(hoverDescs.length-1);
|
||||||
|
|
||||||
// populate list
|
// Populate list
|
||||||
for (int i= 0; i < hoverDescs.length; i++) {
|
for (int i= 0; i < hoverDescs.length; i++) {
|
||||||
// ensure that we don't add ourselves to the list
|
// Ensure that we don't add ourselves to the list
|
||||||
if (!PreferenceConstants.ID_BESTMATCH_HOVER.equals(hoverDescs[i].getId())) {
|
if (!PreferenceConstants.ID_BESTMATCH_HOVER.equals(hoverDescs[i].getId())) {
|
||||||
fTextHoverSpecifications.add(hoverDescs[i]);
|
fTextHoverSpecifications.add(hoverDescs[i]);
|
||||||
// add place-holder for hover instance
|
// Add place-holder for hover instance
|
||||||
fInstantiatedTextHovers.add(null);
|
fInstantiatedTextHovers.add(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +87,7 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
ICEditorTextHover hover= spec.createTextHover();
|
ICEditorTextHover hover= spec.createTextHover();
|
||||||
if (hover != null) {
|
if (hover != null) {
|
||||||
hover.setEditor(getEditor());
|
hover.setEditor(getEditor());
|
||||||
// remember instance and mark as created
|
// Remember instance and mark as created
|
||||||
fInstantiatedTextHovers.set(i, hover);
|
fInstantiatedTextHovers.set(i, hover);
|
||||||
fTextHoverSpecifications.set(i, null);
|
fTextHoverSpecifications.set(i, null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -109,7 +106,6 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
|
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
|
||||||
|
|
||||||
checkTextHovers();
|
checkTextHovers();
|
||||||
fBestHover= null;
|
fBestHover= null;
|
||||||
|
|
||||||
|
@ -130,12 +126,11 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
|
* @see ITextHoverExtension2#getHoverInfo2(ITextViewer, IRegion)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
|
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
|
||||||
|
|
||||||
checkTextHovers();
|
checkTextHovers();
|
||||||
fBestHover= null;
|
fBestHover= null;
|
||||||
|
|
||||||
|
@ -164,7 +159,7 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
|
* @see ITextHoverExtension#getHoverControlCreator()
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -176,16 +171,15 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
|
* @see IInformationProviderExtension2#getInformationPresenterControlCreator()
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IInformationControlCreator getInformationPresenterControlCreator() {
|
public IInformationControlCreator getInformationPresenterControlCreator() {
|
||||||
// this is wrong, but left here for backwards compatibility
|
// This is wrong, but left here for backwards compatibility
|
||||||
if (fBestHover instanceof IInformationProviderExtension2)
|
if (fBestHover instanceof IInformationProviderExtension2)
|
||||||
return ((IInformationProviderExtension2)fBestHover).getInformationPresenterControlCreator();
|
return ((IInformationProviderExtension2) fBestHover).getInformationPresenterControlCreator();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.ITextViewer;
|
import org.eclipse.jface.text.ITextViewer;
|
||||||
|
@ -22,8 +21,8 @@ import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.IFunctionSummary;
|
import org.eclipse.cdt.ui.IFunctionSummary;
|
||||||
import org.eclipse.cdt.ui.IRequiredInclude;
|
|
||||||
import org.eclipse.cdt.ui.IFunctionSummary.IFunctionPrototypeSummary;
|
import org.eclipse.cdt.ui.IFunctionSummary.IFunctionPrototypeSummary;
|
||||||
|
import org.eclipse.cdt.ui.IRequiredInclude;
|
||||||
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
||||||
import org.eclipse.cdt.ui.text.IHoverHelpInvocationContext;
|
import org.eclipse.cdt.ui.text.IHoverHelpInvocationContext;
|
||||||
|
|
||||||
|
@ -34,14 +33,11 @@ import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
|
||||||
|
|
||||||
public class CDocHover extends AbstractCEditorTextHover {
|
public class CDocHover extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for DefaultCEditorTextHover
|
|
||||||
*/
|
|
||||||
public CDocHover() {
|
public CDocHover() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
|
* @see ITextHover#getHoverInfo(ITextViewer, IRegion)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getHoverInfo(ITextViewer viewer, IRegion region) {
|
public String getHoverInfo(ITextViewer viewer, IRegion region) {
|
||||||
|
@ -61,7 +57,6 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
// call the Help to get info
|
// call the Help to get info
|
||||||
|
|
||||||
ICHelpInvocationContext context = new IHoverHelpInvocationContext() {
|
ICHelpInvocationContext context = new IHoverHelpInvocationContext() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IProject getProject() {
|
public IProject getProject() {
|
||||||
ITranslationUnit unit = getTranslationUnit();
|
ITranslationUnit unit = getTranslationUnit();
|
||||||
|
@ -81,7 +76,6 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
public IRegion getHoverRegion() {
|
public IRegion getHoverRegion() {
|
||||||
return hoverRegion;
|
return hoverRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IFunctionSummary fs = CHelpProviderManager.getDefault().getFunctionInfo(context, expression);
|
IFunctionSummary fs = CHelpProviderManager.getDefault().getFunctionInfo(context, expression);
|
||||||
|
@ -93,7 +87,7 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
buffer.append(CEditorMessages.DefaultCEditorTextHover_html_prototype);
|
buffer.append(CEditorMessages.DefaultCEditorTextHover_html_prototype);
|
||||||
buffer.append(HTMLPrinter.convertToHTMLContent(prototype.getPrototypeString(false)));
|
buffer.append(HTMLPrinter.convertToHTMLContent(prototype.getPrototypeString(false)));
|
||||||
}
|
}
|
||||||
if(fs.getDescription() != null) {
|
if (fs.getDescription() != null) {
|
||||||
buffer.append(CEditorMessages.DefaultCEditorTextHover_html_description);
|
buffer.append(CEditorMessages.DefaultCEditorTextHover_html_description);
|
||||||
//Don't convert this description since it could already be formatted
|
//Don't convert this description since it could already be formatted
|
||||||
buffer.append(fs.getDescription());
|
buffer.append(fs.getDescription());
|
||||||
|
@ -117,7 +111,7 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
HTMLPrinter.addPageEpilog(buffer);
|
HTMLPrinter.addPageEpilog(buffer);
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
} catch(Exception ex) {
|
} catch (Exception e) {
|
||||||
/* Ignore */
|
/* Ignore */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +119,7 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
|
* @see ITextHover#getHoverRegion(ITextViewer, int)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IRegion getHoverRegion(ITextViewer viewer, int offset) {
|
public IRegion getHoverRegion(ITextViewer viewer, int offset) {
|
||||||
|
@ -134,12 +128,12 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
if (selectedRange.x >= 0 &&
|
if (selectedRange.x >= 0 &&
|
||||||
selectedRange.y > 0 &&
|
selectedRange.y > 0 &&
|
||||||
offset >= selectedRange.x &&
|
offset >= selectedRange.x &&
|
||||||
offset <= selectedRange.x + selectedRange.y)
|
offset <= selectedRange.x + selectedRange.y) {
|
||||||
return new Region( selectedRange.x, selectedRange.y );
|
return new Region(selectedRange.x, selectedRange.y);
|
||||||
|
}
|
||||||
|
|
||||||
return CWordFinder.findWord(viewer.getDocument(), offset);
|
return CWordFinder.findWord(viewer.getDocument(), offset);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
import org.eclipse.jface.text.IInformationControlCreator;
|
import org.eclipse.jface.text.IInformationControlCreator;
|
||||||
|
@ -26,7 +25,6 @@ import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
* CEditorTexHoverProxy
|
* CEditorTexHoverProxy
|
||||||
*/
|
*/
|
||||||
public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
|
public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
private CEditorTextHoverDescriptor fHoverDescriptor;
|
private CEditorTextHoverDescriptor fHoverDescriptor;
|
||||||
private ICEditorTextHover fHover;
|
private ICEditorTextHover fHover;
|
||||||
|
|
||||||
|
@ -132,5 +130,4 @@ public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.ui.part.IWorkbenchPartOrientation;
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
|
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
|
||||||
Object hoverInfo= getHoverInfo2(textViewer, hoverRegion);
|
Object hoverInfo= getHoverInfo2(textViewer, hoverRegion);
|
||||||
|
@ -33,7 +32,7 @@ public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.internal.ui.text.c.hover.AbstractCEditorTextHover#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
|
* @see AbstractCEditorTextHover#getHoverInfo2(ITextViewer, IRegion)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
|
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
|
||||||
|
@ -55,7 +54,7 @@ public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.internal.ui.text.c.hover.AbstractCEditorTextHover#getInformationPresenterControlCreator()
|
* @see AbstractCEditorTextHover#getInformationPresenterControlCreator()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IInformationControlCreator getInformationPresenterControlCreator() {
|
public IInformationControlCreator getInformationPresenterControlCreator() {
|
||||||
|
@ -70,5 +69,4 @@ public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
|
@ -95,15 +95,16 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||||
* A text hover presenting the source of the element under the cursor.
|
* A text hover presenting the source of the element under the cursor.
|
||||||
*/
|
*/
|
||||||
public class CSourceHover extends AbstractCEditorTextHover {
|
public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
protected static class SingletonRule implements ISchedulingRule {
|
protected static class SingletonRule implements ISchedulingRule {
|
||||||
public static final ISchedulingRule INSTANCE = new SingletonRule();
|
public static final ISchedulingRule INSTANCE = new SingletonRule();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(ISchedulingRule rule) {
|
public boolean contains(ISchedulingRule rule) {
|
||||||
return rule == this;
|
return rule == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConflicting(ISchedulingRule rule) {
|
public boolean isConflicting(ISchedulingRule rule) {
|
||||||
return rule == this;
|
return rule == this;
|
||||||
|
@ -114,7 +115,6 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
* Computes the source location for a given identifier.
|
* Computes the source location for a given identifier.
|
||||||
*/
|
*/
|
||||||
protected static class ComputeSourceRunnable implements ASTRunnable {
|
protected static class ComputeSourceRunnable implements ASTRunnable {
|
||||||
|
|
||||||
private final ITranslationUnit fTU;
|
private final ITranslationUnit fTU;
|
||||||
private final IRegion fTextRegion;
|
private final IRegion fTextRegion;
|
||||||
private final IProgressMonitor fMonitor;
|
private final IProgressMonitor fMonitor;
|
||||||
|
@ -132,7 +132,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable#runOnAST(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
|
* @see org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable#runOnAST(IASTTranslationUnit)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
||||||
|
@ -142,21 +142,20 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
IBinding binding= name.resolveBinding();
|
IBinding binding= name.resolveBinding();
|
||||||
if (binding != null) {
|
if (binding != null) {
|
||||||
|
|
||||||
// Check for implicit names first, could be an implicit constructor call
|
// Check for implicit names first, could be an implicit constructor call
|
||||||
if(name.getParent() instanceof IASTImplicitNameOwner) {
|
if (name.getParent() instanceof IASTImplicitNameOwner) {
|
||||||
IASTImplicitNameOwner iastImplicitNameOwner = (IASTImplicitNameOwner) name.getParent();
|
IASTImplicitNameOwner iastImplicitNameOwner = (IASTImplicitNameOwner) name.getParent();
|
||||||
IASTName [] implicitNames = iastImplicitNameOwner.getImplicitNames();
|
IASTName [] implicitNames = iastImplicitNameOwner.getImplicitNames();
|
||||||
if(implicitNames.length == 1) {
|
if (implicitNames.length == 1) {
|
||||||
IBinding implicitNameBinding = implicitNames[0].resolveBinding();
|
IBinding implicitNameBinding = implicitNames[0].resolveBinding();
|
||||||
if(implicitNameBinding instanceof ICPPConstructor) {
|
if (implicitNameBinding instanceof ICPPConstructor) {
|
||||||
binding = implicitNameBinding;
|
binding = implicitNameBinding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
// report problem as source comment
|
// Report problem as source comment
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
IProblemBinding problem= (IProblemBinding) binding;
|
IProblemBinding problem= (IProblemBinding) binding;
|
||||||
fSource= "/* Indexer Problem!\n" + //$NON-NLS-1$
|
fSource= "/* Indexer Problem!\n" + //$NON-NLS-1$
|
||||||
|
@ -173,10 +172,10 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException exc) {
|
} catch (CoreException e) {
|
||||||
return exc.getStatus();
|
return e.getStatus();
|
||||||
} catch (DOMException exc) {
|
} catch (DOMException e) {
|
||||||
return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Internal Error", exc); //$NON-NLS-1$
|
return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Internal Error", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
|
@ -219,8 +218,8 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
private String computeSourceForBinding(IASTTranslationUnit ast, IBinding binding) throws CoreException, DOMException {
|
private String computeSourceForBinding(IASTTranslationUnit ast, IBinding binding) throws CoreException, DOMException {
|
||||||
IName[] names = findDefsOrDecls(ast, binding);
|
IName[] names = findDefsOrDecls(ast, binding);
|
||||||
|
|
||||||
// in case the binding is a non-explicit specialization we need
|
// In case the binding is a non-explicit specialization we need
|
||||||
// to consider the original binding (bug 281396)
|
// to consider the original binding (bug 281396).
|
||||||
while (names.length == 0 && binding instanceof ICPPSpecialization) {
|
while (names.length == 0 && binding instanceof ICPPSpecialization) {
|
||||||
IBinding specializedBinding = ((ICPPSpecialization) binding).getSpecializedBinding();
|
IBinding specializedBinding = ((ICPPSpecialization) binding).getSpecializedBinding();
|
||||||
if (specializedBinding == null || specializedBinding instanceof IProblemBinding) {
|
if (specializedBinding == null || specializedBinding instanceof IProblemBinding) {
|
||||||
|
@ -275,24 +274,24 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
int hoverOffset = fTextRegion.getOffset();
|
int hoverOffset = fTextRegion.getOffset();
|
||||||
if (hoverOffset <= nodeOffset && nodeOffset < hoverOffset + fTextRegion.getLength() ||
|
if (hoverOffset <= nodeOffset && nodeOffset < hoverOffset + fTextRegion.getLength() ||
|
||||||
hoverOffset >= nodeOffset && hoverOffset < nodeOffset + nodeLength) {
|
hoverOffset >= nodeOffset && hoverOffset < nodeOffset + nodeLength) {
|
||||||
// bug 359352 - don't show source if its the same we are hovering on
|
// Bug 359352 - don't show source if its the same we are hovering on.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (fTU.getResource() != null) {
|
if (fTU.getResource() != null) {
|
||||||
// reuse editor buffer for names local to the translation unit
|
// Reuse editor buffer for names local to the translation unit
|
||||||
location= fTU.getResource().getFullPath();
|
location= fTU.getResource().getFullPath();
|
||||||
locationKind= LocationKind.IFILE;
|
locationKind= LocationKind.IFILE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// try to resolve path to a resource for proper encoding (bug 221029)
|
// Try to resolve path to a resource for proper encoding (bug 221029)
|
||||||
IFile file= EditorUtility.getWorkspaceFileAtLocation(location, fTU);
|
IFile file= EditorUtility.getWorkspaceFileAtLocation(location, fTU);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
location= file.getFullPath();
|
location= file.getFullPath();
|
||||||
locationKind= LocationKind.IFILE;
|
locationKind= LocationKind.IFILE;
|
||||||
if (name instanceof IIndexName) {
|
if (name instanceof IIndexName) {
|
||||||
// need to adjust index offsets to current offsets
|
// Need to adjust index offsets to current offsets
|
||||||
// in case file has been modified since last index time
|
// in case file has been modified since last index time.
|
||||||
IIndexName indexName= (IIndexName) name;
|
IIndexName indexName= (IIndexName) name;
|
||||||
long timestamp= indexName.getFile().getTimestamp();
|
long timestamp= indexName.getFile().getTimestamp();
|
||||||
IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(file, timestamp);
|
IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(file, timestamp);
|
||||||
|
@ -331,7 +330,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// expand source range to include preceding comment, if any
|
// Expand source range to include preceding comment, if any
|
||||||
boolean isKnR= isKnRSource(name);
|
boolean isKnR= isKnRSource(name);
|
||||||
sourceStart= computeSourceStart(doc, nameOffset, binding, isKnR);
|
sourceStart= computeSourceStart(doc, nameOffset, binding, isKnR);
|
||||||
if (sourceStart == CHeuristicScanner.NOT_FOUND) {
|
if (sourceStart == CHeuristicScanner.NOT_FOUND) {
|
||||||
|
@ -342,9 +341,9 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
String source= buffer.getDocument().get(sourceStart, sourceEnd - sourceStart);
|
String source= buffer.getDocument().get(sourceStart, sourceEnd - sourceStart);
|
||||||
return source;
|
return source;
|
||||||
|
|
||||||
} catch (BadLocationException exc) {
|
} catch (BadLocationException e) {
|
||||||
// ignore - should not happen anyway
|
// Ignore - should not happen anyway
|
||||||
if (DEBUG) exc.printStackTrace();
|
if (DEBUG) e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
mgr.disconnect(location, LocationKind.LOCATION, fMonitor);
|
mgr.disconnect(location, LocationKind.LOCATION, fMonitor);
|
||||||
}
|
}
|
||||||
|
@ -455,7 +454,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
if (nextNonWS != CHeuristicScanner.NOT_FOUND) {
|
if (nextNonWS != CHeuristicScanner.NOT_FOUND) {
|
||||||
int nextNonWSLine= doc.getLineOfOffset(nextNonWS);
|
int nextNonWSLine= doc.getLineOfOffset(nextNonWS);
|
||||||
int lineOffset= doc.getLineOffset(nextNonWSLine);
|
int lineOffset= doc.getLineOffset(nextNonWSLine);
|
||||||
if (doc.get(lineOffset, nextNonWS - lineOffset).trim().length() == 0) {
|
if (doc.get(lineOffset, nextNonWS - lineOffset).trim().isEmpty()) {
|
||||||
sourceStart= doc.getLineOffset(nextNonWSLine);
|
sourceStart= doc.getLineOffset(nextNonWSLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -467,7 +466,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
private int computeSourceEnd(IDocument doc, int start, IBinding binding, boolean isDefinition, boolean isKnR) throws BadLocationException {
|
private int computeSourceEnd(IDocument doc, int start, IBinding binding, boolean isDefinition, boolean isKnR) throws BadLocationException {
|
||||||
int sourceEnd= start;
|
int sourceEnd= start;
|
||||||
CHeuristicScanner scanner= new CHeuristicScanner(doc);
|
CHeuristicScanner scanner= new CHeuristicScanner(doc);
|
||||||
// expand forward to the end of the definition/declaration
|
// Expand forward to the end of the definition/declaration
|
||||||
boolean searchBrace= false;
|
boolean searchBrace= false;
|
||||||
boolean searchSemi= false;
|
boolean searchSemi= false;
|
||||||
boolean searchComma= false;
|
boolean searchComma= false;
|
||||||
|
@ -498,7 +497,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
sourceEnd= doc.getLength();
|
sourceEnd= doc.getLength();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// expand region to include whole line
|
// Expand region to include whole line
|
||||||
IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
|
IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
|
||||||
sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
|
sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
|
||||||
} else if (searchSemi) {
|
} else if (searchSemi) {
|
||||||
|
@ -506,7 +505,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
if (semi != CHeuristicScanner.NOT_FOUND) {
|
if (semi != CHeuristicScanner.NOT_FOUND) {
|
||||||
sourceEnd= semi+1;
|
sourceEnd= semi+1;
|
||||||
}
|
}
|
||||||
// expand region to include whole line
|
// Expand region to include whole line
|
||||||
IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
|
IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
|
||||||
sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
|
sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
|
||||||
} else if (searchComma) {
|
} else if (searchComma) {
|
||||||
|
@ -552,8 +551,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
* @return an array of definitions, never <code>null</code>
|
* @return an array of definitions, never <code>null</code>
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
private IName[] findDefinitions(IASTTranslationUnit ast,
|
private IName[] findDefinitions(IASTTranslationUnit ast, IBinding binding) throws CoreException {
|
||||||
IBinding binding) throws CoreException {
|
|
||||||
IName[] declNames= ast.getDefinitionsInAST(binding);
|
IName[] declNames= ast.getDefinitionsInAST(binding);
|
||||||
if (declNames.length == 0 && ast.getIndex() != null) {
|
if (declNames.length == 0 && ast.getIndex() != null) {
|
||||||
// search definitions in index
|
// search definitions in index
|
||||||
|
@ -570,8 +568,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
* @return an array of declarations, never <code>null</code>
|
* @return an array of declarations, never <code>null</code>
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
private IName[] findDeclarations(IASTTranslationUnit ast,
|
private IName[] findDeclarations(IASTTranslationUnit ast, IBinding binding) throws CoreException {
|
||||||
IBinding binding) throws CoreException {
|
|
||||||
IName[] declNames= ast.getDeclarationsInAST(binding);
|
IName[] declNames= ast.getDeclarationsInAST(binding);
|
||||||
if (declNames.length == 0 && ast.getIndex() != null) {
|
if (declNames.length == 0 && ast.getIndex() != null) {
|
||||||
// search declarations in index
|
// search declarations in index
|
||||||
|
@ -586,7 +583,6 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
public String getSource() {
|
public String getSource() {
|
||||||
return fSource;
|
return fSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -618,10 +614,10 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
try {
|
try {
|
||||||
expression = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
|
expression = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
|
||||||
expression = expression.trim();
|
expression = expression.trim();
|
||||||
if (expression.length() == 0)
|
if (expression.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
//Before trying a search lets make sure that the user is not hovering over a keyword
|
// Before trying a search lets make sure that the user is not hovering over a keyword
|
||||||
if (selectionIsKeyword(expression))
|
if (selectionIsKeyword(expression))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -630,10 +626,10 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
// Try with the indexer
|
// Try with the indexer
|
||||||
source= searchInIndex(copy, hoverRegion);
|
source= searchInIndex(copy, hoverRegion);
|
||||||
|
|
||||||
if (source == null || source.trim().length() == 0)
|
if (source == null || source.trim().isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// we are actually interested in the comments, too.
|
// We are actually interested in the comments, too.
|
||||||
// source= removeLeadingComments(source);
|
// source= removeLeadingComments(source);
|
||||||
|
|
||||||
String delim= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
String delim= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -645,7 +641,6 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
source = Strings.concatenate(sourceLines, delim);
|
source = Strings.concatenate(sourceLines, delim);
|
||||||
return source;
|
return source;
|
||||||
|
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -680,7 +675,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
final int startLine= doc.getLineOfOffset(partitionOffset);
|
final int startLine= doc.getLineOfOffset(partitionOffset);
|
||||||
final int lineOffset= doc.getLineOffset(startLine);
|
final int lineOffset= doc.getLineOffset(startLine);
|
||||||
if (partitionOffset == lineOffset ||
|
if (partitionOffset == lineOffset ||
|
||||||
doc.get(lineOffset, partitionOffset - lineOffset).trim().length() == 0) {
|
doc.get(lineOffset, partitionOffset - lineOffset).trim().isEmpty()) {
|
||||||
return lineOffset;
|
return lineOffset;
|
||||||
}
|
}
|
||||||
return commentOffset;
|
return commentOffset;
|
||||||
|
@ -690,13 +685,13 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
final int startLine= doc.getLineOfOffset(partitionOffset);
|
final int startLine= doc.getLineOfOffset(partitionOffset);
|
||||||
final int lineOffset= doc.getLineOffset(startLine);
|
final int lineOffset= doc.getLineOffset(startLine);
|
||||||
if (partitionOffset == lineOffset ||
|
if (partitionOffset == lineOffset ||
|
||||||
doc.get(lineOffset, partitionOffset - lineOffset).trim().length() == 0) {
|
doc.get(lineOffset, partitionOffset - lineOffset).trim().isEmpty()) {
|
||||||
commentOffset= lineOffset;
|
commentOffset= lineOffset;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return commentOffset;
|
return commentOffset;
|
||||||
} else if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) {
|
} else if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) {
|
||||||
if (doc.get(partition.getOffset(), partition.getLength()).trim().length() == 0) {
|
if (doc.get(partition.getOffset(), partition.getLength()).trim().isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (commentOffset >= 0) {
|
if (commentOffset >= 0) {
|
||||||
|
@ -713,7 +708,6 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip the leading comment from the given source string.
|
* Strip the leading comment from the given source string.
|
||||||
*
|
*
|
||||||
|
@ -732,13 +726,13 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
i= reader.getOffset();
|
i= reader.getOffset();
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException e) {
|
||||||
i= 0;
|
i= 0;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException e) {
|
||||||
CUIPlugin.log(ex);
|
CUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,7 +747,8 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
return ASTProvider.getASTProvider().runOnAST(tUnit, ASTProvider.WAIT_ACTIVE_ONLY, monitor, computer);
|
return ASTProvider.getASTProvider().runOnAST(tUnit, ASTProvider.WAIT_ACTIVE_ONLY,
|
||||||
|
monitor, computer);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
CUIPlugin.log(t);
|
CUIPlugin.log(t);
|
||||||
}
|
}
|
||||||
|
@ -776,9 +771,8 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
return computer.getSource();
|
return computer.getSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether the given name is a known keyword.
|
* Checks whether the given name is a known keyword.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @return <code>true</code> if the name is a known keyword or <code>false</code> if the
|
* @return <code>true</code> if the name is a known keyword or <code>false</code> if the
|
||||||
|
@ -802,7 +796,8 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
int orientation= SWT.NONE;
|
int orientation= SWT.NONE;
|
||||||
if (editor instanceof IWorkbenchPartOrientation)
|
if (editor instanceof IWorkbenchPartOrientation)
|
||||||
orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
|
orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
|
||||||
return new SourceViewerInformationControl(parent, false, orientation, getTooltipAffordanceString());
|
return new SourceViewerInformationControl(parent, false, orientation,
|
||||||
|
getTooltipAffordanceString());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue