1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-11-13 16:24:59 -08:00
parent 2d58772f73
commit 38fd6392e2
32 changed files with 147 additions and 238 deletions

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.core.model;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICContainer extends ICElement, IParent, IOpenable {
/**
* Returns an array of non-C resources directly contained in this project.
* It does not transitively answer non-C resources contained in folders;
@ -97,5 +96,4 @@ public interface ICContainer extends ICElement, IParent, IOpenable {
* @return the container with the given name
*/
ICContainer getCContainer(String name);
}

View file

@ -26,7 +26,6 @@ import org.eclipse.core.runtime.IPath;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICElement extends IAdaptable {
/**
* IResource from 10-20
*/
@ -296,17 +295,18 @@ public interface ICElement extends IAdaptable {
/**
* Returns whether this C element exists in the model.
*
* @return <code>true</code> if this element exists in the C model
* @return {@code true} if this element exists in the C model
*/
boolean exists();
/**
* Returns the first ancestor of this C element that has the given type.
* Returns <code>null</code> if no such an ancestor can be found.
* Returns {@code null} if no such an ancestor can be found.
* This is a handle-only method.
*
* @param ancestorType the given type
* @return the first ancestor of this C element that has the given type, null if no such an ancestor can be found
* @return the first ancestor of this C element that has the given type, {@code null} if no such
* an ancestor can be found
* @since 2.0
*/
ICElement getAncestor(int ancestorType);
@ -322,9 +322,7 @@ public interface ICElement extends IAdaptable {
* Returns this element's kind encoded as an integer.
* This is a handle-only method.
*
* @return the kind of element; one of the constants declared in
* <code>ICElement</code>
* @see ICElement
* @return the kind of element; one of the constants declared in {@link ICElement}
*/
int getElementType();
@ -336,19 +334,19 @@ public interface ICElement extends IAdaptable {
ICModel getCModel();
/**
* Returns the C project this element is contained in,
* or <code>null</code> if this element is not contained in any C project
* Returns the C project this element is contained in, or {@code null} if this element
* is not contained in any C project
*
* @return the containing C project, or <code>null</code> if this element is
* not contained in a C project
* @return the containing C project, or {@code null} if this element is
* not contained in a C project
*/
ICProject getCProject();
/**
* Returns the element directly containing this element,
* or <code>null</code> if this element has no parent.
* or {@code null} if this element has no parent.
*
* @return the parent element, or <code>null</code> if this element has no parent
* @return the parent element, or {@code null} if this element has no parent
*/
ICElement getParent();
@ -360,7 +358,6 @@ public interface ICElement extends IAdaptable {
* If this element is included in an external archive,
* the path returned is the absolute path to the archive in the file system.
* This is a handle-only method.
*
*/
IPath getPath();
@ -374,19 +371,19 @@ public interface ICElement extends IAdaptable {
/**
* Returns the underlying resource that contains
* this element, or <code>null</code> if this element is not contained
* this element, or {@code null} if this element is not contained
* in a resource.
*
* @return the underlying resource, or <code>null</code> if none
* @return the underlying resource, or {@code null} if none
*/
IResource getUnderlyingResource();
/**
* Returns the Corresponding resource for
* this element, or <code>null</code> if this element does not have
* this element, or {@code null} if this element does not have
* a corresponding resource.
*
* @return the corresponding resource, or <code>null</code> if none
* @return the corresponding resource, or {@code null} if none
*/
IResource getResource();
@ -394,21 +391,20 @@ public interface ICElement extends IAdaptable {
* Returns whether this C element is read-only. An element is read-only
* if its structure cannot be modified by the C model.
*
* @return <code>true</code> if this element is read-only
* @return {@code true} if this element is read-only
*/
boolean isReadOnly();
/**
* Returns whether the structure of this element is known. For example, for a
* translation unit that could not be parsed, <code>false</code> is returned.
* translation unit that could not be parsed, {@code false} is returned.
* If the structure of an element is unknown, navigations will return reasonable
* defaults. For example, <code>getChildren</code> will return an empty collection.
* defaults. For example, {@code getChildren} will return an empty collection.
* <p>
* Note: This does not imply anything about consistency with the
* underlying resource/buffer contents.
* </p>
*
* @return <code>true</code> if the structure of this element is known
* @return {@code true} if the structure of this element is known
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
@ -422,7 +418,6 @@ public interface ICElement extends IAdaptable {
*/
void accept(ICElementVisitor visitor) throws CoreException;
/**
* Returns a string representation of this element handle. The format of the
* string is not specified; however, the identifier is stable across
@ -430,15 +425,13 @@ public interface ICElement extends IAdaptable {
* <code>CoreModel.create(String)</code> method.
* <p>
* Some element types, like binaries, do not support handle identifiers and
* return <code>null</code>.
* return {@code null}.
* </p>
*
* @return the string handle identifier, or <code>null</code> if the
* element type is not supported
* @return the string handle identifier, or {@code null} if the element type is not supported
* @see CoreModel#create(java.lang.String)
*
* @since 5.0
*/
String getHandleIdentifier();
}

View file

@ -1,14 +1,13 @@
/*******************************************************************************
* Copyright (c) 2005, 2009 QnX Software Systems and others.
* Copyright (c) 2005, 2009 QNX Software Systems 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:
* Qnx Software Systems - initial API and implementation
* QNX Software Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.model;
/**
@ -18,5 +17,4 @@ package org.eclipse.cdt.core.model;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IMethodTemplate extends IMethodTemplateDeclaration, IMethod {
}

View file

@ -1,14 +1,13 @@
/*******************************************************************************
* Copyright (c) 2005, 2009 QnX Software Systems and others.
* Copyright (c) 2005, 2009 QNX Software Systems 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:
* Qnx Software Systems - initial API and implementation
* QNX Software Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.model;
/**
@ -18,5 +17,4 @@ package org.eclipse.cdt.core.model;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IMethodTemplateDeclaration extends ITemplate, IMethodDeclaration {
}

View file

@ -12,12 +12,10 @@ package org.eclipse.cdt.core.model;
import java.util.List;
/**
* Common protocol for C elements that contain other C elements.
*/
public interface IParent {
/**
* Returns the immediate children of this element.
* The children are in no particular order.
@ -34,8 +32,7 @@ public interface IParent {
/**
* Returns whether this element has one or more immediate children.
* This is a convenience method, and may be more efficient than
* testing whether <code>getChildren</code> is an empty array.
* testing whether {@link #getChildren()} returns an empty array.
*/
boolean hasChildren();
}

View file

@ -21,17 +21,15 @@ package org.eclipse.cdt.core.model;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ISourceReference {
/**
* Returns the source code associated with this element.
* <p>
* For binary files, this returns the source of the entire translation unit
* For binary files, this returns the source of the entire translation unit
* associated with the binary file (if there is one).
* </p>
*
* @return the source code, or <code>null</code> if this element has no
* @return the source code, or <code>null</code> if this element has no
* associated source code
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
@ -41,11 +39,11 @@ public interface ISourceReference {
/**
* Returns the source range associated with this element.
* <p>
* For binary files, this returns the range of the entire translation unit
* For binary files, this returns the range of the entire translation unit
* associated with the binary file (if there is one).
* </p>
*
* @return the source range, or <code>null</code> if if this element has no
* @return the source range, or <code>null</code> if if this element has no
* associated source code
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
@ -57,7 +55,7 @@ public interface ISourceReference {
* if this member is not declared in a translation unit (for example, a binary type).
*/
ITranslationUnit getTranslationUnit();
/**
* Returns whether this element is in active code. Code is inactive when it is hidden
* by conditional compilation.

View file

@ -12,12 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementVisitor;
@ -39,6 +33,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
public abstract class CElement extends PlatformObject implements ICElement {
public static final char CEM_ESCAPE = '\\';
public static final char CEM_CPROJECT = '=';
@ -61,9 +61,6 @@ public abstract class CElement extends PlatformObject implements ICElement {
fType= type;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Object getAdapter(Class adapter) {
@ -248,7 +245,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
}
@Override
public abstract IResource getResource() ;
public abstract IResource getResource();
protected abstract CElementInfo createElementInfo();

View file

@ -117,9 +117,6 @@ public class CModelBuilder2 implements IContributedModelBuilder {
fProgressMonitor= monitor;
}
/*
* @see org.eclipse.cdt.core.model.IContributedModelBuilder#parse(boolean)
*/
@Override
public void parse(boolean quickParseMode) throws Exception {
final IIndexManager indexManager= CCorePlugin.getIndexManager();
@ -865,7 +862,6 @@ public class CModelBuilder2 implements IContributedModelBuilder {
final FunctionInfo info;
if (declarator instanceof ICPPASTFunctionDeclarator) {
final ICPPASTFunctionDeclarator cppFunctionDeclarator= (ICPPASTFunctionDeclarator) declarator;
final IASTName simpleAstName;
if (name instanceof ICPPASTQualifiedName) {

View file

@ -6,17 +6,16 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Rational Software - Initial API and implementation
* Rational Software - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMethod;
public class Method extends MethodDeclaration implements IMethod {
public Method(ICElement parent, String name){
public Method(ICElement parent, String name) {
this(parent, name, ICElement.C_METHOD);
}

View file

@ -6,17 +6,15 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Rational Software - Initial API and implementation
* Rational Software - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMethodTemplate;
public class MethodTemplate extends Method implements IMethodTemplate {
protected Template fTemplate;
public MethodTemplate(ICElement parent, String name) {
@ -55,34 +53,29 @@ public class MethodTemplate extends Method implements IMethodTemplate {
return fTemplate.getNumberOfTemplateParameters();
}
/**
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
*/
/*
* The signature in the outline view will be:
* The class X followed by its template parameters,
* then the scope resolution, then the function name,
* followed by its template parameters, folowed by its
* followed by its template parameters, followed by its
* normal parameter list, then a colon then the function's
* return type.
*/
@Override
public String getTemplateSignature() throws CModelException {
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
sig.append(this.getParameterClause());
if(isConst())
if (isConst())
sig.append(" const"); //$NON-NLS-1$
if(isVolatile())
if (isVolatile())
sig.append(" volatile"); //$NON-NLS-1$
if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){
if ((this.getReturnType() != null) && (this.getReturnType().length() > 0)){
sig.append(" : "); //$NON-NLS-1$
sig.append(this.getReturnType());
}
return sig.toString();
}
}

View file

@ -6,15 +6,11 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Anton Leherbauer (Wind River Systems)
* Markus Schorn - initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IPositionConverter;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
@ -39,9 +35,13 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import java.net.URI;
import java.util.Collections;
import java.util.List;
abstract class CElementHandle implements ICElementHandle, ISourceReference {
protected static final String[] EMPTY_STRING_ARRAY = new String[0];
private static final ICElement[] NO_CHILDREN = new ICElement[0];
protected static final String[] EMPTY_STRING_ARRAY = {};
private static final ICElement[] NO_CHILDREN = {};
private ICElement fParent;
private String fName;
@ -54,15 +54,14 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
public CElementHandle(ICElement parent, int type, String name) {
fParent= parent;
fType= type;
// anonymous types are assigned a name in the index, we
// undo this here
if (name.length() > 0 && name.charAt(0)=='{') {
// Anonymous types are assigned a name in the index, we undo this here.
if (name.length() > 0 && name.charAt(0) == '{') {
fName= ""; //$NON-NLS-1$
fIndex= name.hashCode();
} else {
fName= name;
}
fRegion= new Region(0,0);
fRegion= new Region(0, 0);
}
@Override
@ -78,7 +77,6 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
return CElement.hashCode(this);
}
@Override
@SuppressWarnings("rawtypes")
public Object getAdapter(Class adapter) {

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext;
@ -41,7 +41,6 @@ public class MethodDeclarationHandle extends CElementHandle implements IMethodDe
fIsConstructor= method instanceof ICPPConstructor;
if (!fIsConstructor)
fIsDestructor= method.isDestructor();
}
@Override
@ -91,5 +90,4 @@ public class MethodDeclarationHandle extends CElementHandle implements IMethodDe
public boolean isDestructor() throws CModelException {
return fIsDestructor;
}
}

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
@ -16,7 +15,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMethod;
public class MethodHandle extends MethodDeclarationHandle implements IMethod {
public MethodHandle(ICElement parent, ICPPMethod method) {
super(parent, ICElement.C_METHOD, method);
}

View file

@ -6,15 +6,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.model.ISourceRange;
public class SourceRange implements ISourceRange {
private int fOffset;
private int fLength;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
@ -56,8 +56,7 @@ public class CElementSet {
if (other.fSet != null) {
return false;
}
}
else {
} else {
if (fSet.size() != other.fSet.size()) {
return false;
}

View file

@ -19,20 +19,19 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
/**
* Action used for the include browser forward / backward buttons
*/
public class CHHistoryAction extends Action {
final static long LABEL_OPTIONS=
CElementLabels.M_PARAMETER_TYPES |
CElementLabels.ALL_FULLY_QUALIFIED |
CElementLabels.TEMPLATE_ARGUMENTS |
CElementLabels.MF_POST_FILE_QUALIFIED;
CElementLabels.M_PARAMETER_TYPES |
CElementLabels.ALL_FULLY_QUALIFIED |
CElementLabels.TEMPLATE_ARGUMENTS |
CElementLabels.MF_POST_FILE_QUALIFIED;
private CHViewPart fViewPart;
private ICElement fElement;
public CHHistoryAction(CHViewPart viewPart, ICElement element) {
super("", AS_RADIO_BUTTON); //$NON-NLS-1$
fViewPart= viewPart;
@ -42,20 +41,16 @@ public class CHHistoryAction extends Action {
setText(elementName);
setImageDescriptor(getImageDescriptor(element));
}
private ImageDescriptor getImageDescriptor(ICElement elem) {
CElementImageProvider imageProvider= new CElementImageProvider();
ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
imageProvider.dispose();
return desc;
}
/*
* @see Action#run()
*/
@Override
public void run() {
fViewPart.setInput(fElement);
}
}
}

View file

@ -17,8 +17,8 @@ import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.StatusDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
@ -84,9 +84,6 @@ public class CHHistoryListAction extends Action {
fHistoryList.selectElements(sel);
}
/*
* @see Dialog#createDialogArea(Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
initializeDialogUnits(parent);
@ -142,24 +139,17 @@ public class CHHistoryListAction extends Action {
return elems.toArray(new ICElement[elems.size()]);
}
/*
* @see org.eclipse.jface.window.Window#configureShell(Shell)
*/
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
// PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
}
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#create()
*/
@Override
public void create() {
setShellStyle(getShellStyle() | SWT.RESIZE);
super.create();
}
}
private CHViewPart fView;
@ -169,9 +159,6 @@ public class CHHistoryListAction extends Action {
setText(CHMessages.CHHistoryListAction_OpenHistory_label);
}
/*
* @see IAction#run()
*/
@Override
public void run() {
ICElement[] historyEntries= CallHierarchyUI.getHistoryEntries();

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Patrick Hofer [bug 325799]
* Markus Schorn - initial API and implementation
* Patrick Hofer [bug 325799]
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
@ -24,12 +24,12 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
import org.eclipse.cdt.ui.CElementImageDescriptor;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor;
@ -56,8 +56,7 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
if (node.isInitializer()) {
ImageDescriptor desc= CElementImageProvider.getFunctionImageDescriptor();
image= CUIPlugin.getImageDescriptorRegistry().get(desc);
}
else {
} else {
ICElement decl= node.getOneRepresentedDeclaration();
if (decl != null) {
image= fCLabelProvider.getImage(decl);
@ -82,8 +81,7 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE);
label= fCLabelProvider.getText(decl);
fCLabelProvider.setTextFlags(options);
}
else {
} else {
label= fCLabelProvider.getText(decl);
if (node.isInitializer()) {
label= addInitializerDecoration(label);
@ -111,8 +109,7 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE);
label= fCLabelProvider.getStyledText(decl);
fCLabelProvider.setTextFlags(options);
}
else {
} else {
label= fCLabelProvider.getStyledText(decl);
if (node.isInitializer()) {
label= addInitializerDecoration(label);
@ -125,7 +122,6 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
label.setStyle(offset, label.length() - offset, StyledString.COUNTER_STYLER);
}
//return label;
String decorated= decorateText(label.getString(), element);
if (decorated != null) {
return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER, label);
@ -174,7 +170,6 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
return label2;
}
@Override
public void dispose() {
fCLabelProvider.dispose();
@ -189,16 +184,13 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
int flags= 0;
if (node.isRecursive()) {
flags |= CElementImageDescriptor.RECURSIVE_RELATION;
}
else if (fContentProvider.hasChildren(node)) {
} else if (fContentProvider.hasChildren(node)) {
if (fContentProvider.getComputeReferencedBy()) {
flags |= CElementImageDescriptor.REFERENCED_BY;
}
else {
} else {
if (node.isMultiDef()) {
flags |= CElementImageDescriptor.RELATES_TO_MULTIPLE;
}
else {
} else {
flags |= CElementImageDescriptor.RELATES_TO;
}
}

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
@ -18,7 +18,8 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
*/
public class CHMultiDefChildNode extends CHNode {
public CHMultiDefChildNode(CHMultiDefNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl, int linkageID) {
public CHMultiDefChildNode(CHMultiDefNode parent, ITranslationUnit fileOfReferences,
long timestamp, ICElement decl, int linkageID) {
super(parent, fileOfReferences, timestamp, decl, linkageID);
}

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
@ -16,15 +16,15 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.util.CoreUtility;
public class CHMultiDefNode extends CHNode {
private CHNode[] fChildren;
public CHMultiDefNode(CHNode parent, ITranslationUnit tu, long timestamp, ICElement[] elements, int linkageID) {
public CHMultiDefNode(CHNode parent, ITranslationUnit tu, long timestamp, ICElement[] elements,
int linkageID) {
super(parent, tu, timestamp, null, linkageID);
if (elements.length == 0) {
throw new IllegalArgumentException();
}
fHashCode+= elements[0].hashCode();
fHashCode += elements[0].hashCode();
fChildren= new CHNode[elements.length];
for (int i = 0; i < elements.length; i++) {
ICElement element = elements[i];
@ -65,5 +65,4 @@ public class CHMultiDefNode extends CHNode {
final CHMultiDefNode rhs = (CHMultiDefNode) o;
return CoreUtility.safeEquals(getOneRepresentedDeclaration(), rhs.getOneRepresentedDeclaration());
}
}

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.ArrayList;
@ -27,12 +27,12 @@ import org.eclipse.cdt.internal.ui.util.CoreUtility;
/**
* Represents a node in the include browser
*/
public class CHNode implements IAdaptable {
public class CHNode implements IAdaptable {
private CHNode fParent;
private ICElement fRepresentedDecl;
private ITranslationUnit fFileOfReferences;
private List<CHReferenceInfo> fReferences;
protected int fHashCode;
private long fTimestamp;
private boolean fIsRecursive;
@ -44,7 +44,8 @@ public class CHNode implements IAdaptable {
/**
* Creates a new node for the include browser
*/
public CHNode(CHNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl, int linkageID) {
public CHNode(CHNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl,
int linkageID) {
fParent= parent;
fFileOfReferences= fileOfReferences;
fReferences= Collections.emptyList();
@ -54,7 +55,7 @@ public class CHNode implements IAdaptable {
fTimestamp= timestamp;
fLinkageID= linkageID;
}
private int computeHashCode() {
int hashCode= 1;
if (fParent != null) {
@ -64,13 +65,13 @@ public class CHNode implements IAdaptable {
hashCode+= fRepresentedDecl.hashCode();
}
return hashCode;
}
}
@Override
public int hashCode() {
return fHashCode;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof CHNode)) {
@ -84,7 +85,7 @@ public class CHNode implements IAdaptable {
return CoreUtility.safeEquals(fRepresentedDecl, rhs.fRepresentedDecl);
}
private boolean computeIsRecursive(CHNode parent, ICElement decl) {
if (parent == null || decl == null) {
return false;
@ -113,11 +114,11 @@ public class CHNode implements IAdaptable {
public int getReferenceCount() {
return fReferences.size();
}
public CHReferenceInfo getReference(int idx) {
return fReferences.get(idx);
}
public ICElement getRepresentedDeclaration() {
return fRepresentedDecl;
}
@ -134,11 +135,11 @@ public class CHNode implements IAdaptable {
return fRepresentedDecl instanceof IVariableDeclaration ||
fRepresentedDecl instanceof IEnumerator;
}
public int getFirstReferenceOffset() {
return fReferences.isEmpty() ? -1 : getReference(0).getOffset();
}
public void addReference(CHReferenceInfo info) {
switch (fReferences.size()) {
case 0:
@ -163,7 +164,7 @@ public class CHNode implements IAdaptable {
}
return null;
}
public boolean isMultiDef() {
return false;
}

View file

@ -17,7 +17,7 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.cdt.internal.ui.CPluginImages;
public class CHPinAction extends Action {
private CHViewPart fView= null;
private CHViewPart fView;
/**
* Constructs a 'Pin Call Hierarchy view' action.
@ -31,9 +31,6 @@ public class CHPinAction extends Action {
fView= view;
}
/*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
fView.setPinned(isChecked());

View file

@ -40,7 +40,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
* @since 4.0
*/
public class CHQueries {
private static final CHNode[] EMPTY_NODES= new CHNode[0];
private static final CHNode[] EMPTY_NODES= {};
private CHQueries() {}
@ -63,7 +63,7 @@ public class CHQueries {
final String ct = tu.getContentTypeId();
if (ct.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER)) {
// bug 260262: in a header file we need to consider c and c++
// Bug 260262: in a header file we need to consider C and C++.
findCalledBy(callee, ILinkage.C_LINKAGE_ID, index, result);
findCalledBy(callee, ILinkage.CPP_LINKAGE_ID, index, result);
done= true;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
@ -19,6 +19,7 @@ public class CHReferenceInfo {
return r1.fOffset - r2.fOffset;
}
};
private int fOffset;
private int fLength;
@ -26,7 +27,7 @@ public class CHReferenceInfo {
fOffset= offset;
fLength= length;
}
public int getOffset() {
return fOffset;
}

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
@ -224,9 +224,6 @@ public class CHViewPart extends ViewPart {
private void addPartListener() {
fPartListener= new IPartListener2() {
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference)
*/
@Override
public void partActivated(IWorkbenchPartReference partRef) {
if (isThisView(partRef))
@ -236,9 +233,6 @@ public class CHViewPart extends ViewPart {
@Override
public void partBroughtToTop(IWorkbenchPartReference partRef) { }
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
*/
@Override
public void partClosed(IWorkbenchPartReference partRef) {
if (isThisView(partRef)) {
@ -249,16 +243,15 @@ public class CHViewPart extends ViewPart {
@Override
public void partDeactivated(IWorkbenchPartReference partRef) {}
@Override
public void partOpened(IWorkbenchPartReference partRef) { }
public void partOpened(IWorkbenchPartReference partRef) {}
@Override
public void partHidden(IWorkbenchPartReference partRef) { }
public void partHidden(IWorkbenchPartReference partRef) {}
@Override
public void partVisible(IWorkbenchPartReference partRef) { }
public void partVisible(IWorkbenchPartReference partRef) {}
@Override
public void partInputChanged(IWorkbenchPartReference partRef) { }
public void partInputChanged(IWorkbenchPartReference partRef) {}
};
getViewSite().getPage().addPartListener(fPartListener);
}
@Override
@ -396,7 +389,7 @@ public class CHViewPart extends ViewPart {
}
private void createActions() {
// action groups
// Action groups
fOpenViewActionGroup= new OpenViewActionGroup(this);
fOpenViewActionGroup.setSuppressCallHierarchy(true);
fOpenViewActionGroup.setSuppressProperties(true);
@ -454,8 +447,7 @@ public class CHViewPart extends ViewPart {
public void run() {
if (isChecked()) {
fTreeViewer.addFilter(fVariableFilter);
}
else {
} else {
fTreeViewer.removeFilter(fVariableFilter);
}
}
@ -472,6 +464,7 @@ public class CHViewPart extends ViewPart {
}
return 1;
}
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (!(e1 instanceof CHNode)) {
@ -591,22 +584,18 @@ public class CHViewPart extends ViewPart {
fNavigationNode= null;
return;
}
if (selectedItem.getData().equals(fNavigationNode)) {
if (forward && fNavigationDetail < getReferenceCount(fNavigationNode)-1) {
fNavigationDetail++;
}
else if (!forward && fNavigationDetail > 0) {
} else if (!forward && fNavigationDetail > 0) {
fNavigationDetail--;
}
else {
} else {
selectedItem= navigator.getNextSibbling(selectedItem, forward);
fNavigationNode= selectedItem == null ? null : (CHNode) selectedItem.getData();
initNavigationDetail(forward);
}
}
else {
} else {
fNavigationNode= (CHNode) selectedItem.getData();
initNavigationDetail(forward);
}
@ -615,8 +604,7 @@ public class CHViewPart extends ViewPart {
private void initNavigationDetail(boolean forward) {
if (!forward && fNavigationNode != null) {
fNavigationDetail= Math.max(0, getReferenceCount(fNavigationNode) -1);
}
else {
} else {
fNavigationDetail= 0;
}
}
@ -625,8 +613,7 @@ public class CHViewPart extends ViewPart {
CHNode node= selectionToNode(selection);
if (node != null && node == fNavigationNode && node.getReferenceCount() > 0) {
fNavigationDetail= (fNavigationDetail + 1) % node.getReferenceCount();
}
else {
} else {
fNavigationDetail= 0;
}
fNavigationNode= node;
@ -673,8 +660,7 @@ public class CHViewPart extends ViewPart {
private void updateSorter() {
if (fReferencedByAction.isChecked()) {
fTreeViewer.setComparator(fSorterAlphaNumeric);
}
else {
} else {
fTreeViewer.setComparator(fSorterReferencePosition);
}
}
@ -693,16 +679,14 @@ public class CHViewPart extends ViewPart {
IWorkingSet workingSet= fWorkingSetFilterUI.getWorkingSet();
if (workingSet == null) {
scope= CHMessages.CHViewPart_WorkspaceScope;
}
else {
} else {
scope= workingSet.getLabel();
}
// format
if (fReferencedByAction.isChecked()) {
format= CHMessages.CHViewPart_Title_callers;
}
else {
} else {
format= CHMessages.CHViewPart_Title_callees;
}
@ -761,7 +745,7 @@ public class CHViewPart extends ViewPart {
}
}
// action groups
// Action groups
ISelection selection = getSite().getSelectionProvider().getSelection();
if (OpenViewActionGroup.canActionBeAdded(selection)){
fOpenViewActionGroup.fillContextMenu(menu);
@ -786,16 +770,14 @@ public class CHViewPart extends ViewPart {
long timestamp= fNavigationNode.getTimestamp();
if (fNavigationDetail < 0) {
fNavigationDetail= 0;
}
else if (fNavigationDetail >= fNavigationNode.getReferenceCount()-1) {
} else if (fNavigationDetail >= fNavigationNode.getReferenceCount()-1) {
fNavigationDetail= fNavigationNode.getReferenceCount()-1;
}
CHReferenceInfo ref= fNavigationNode.getReference(fNavigationDetail);
Region region= new Region(ref.getOffset(), ref.getLength());
EditorOpener.open(page, file, region, timestamp);
}
else {
} else {
try {
EditorOpener.open(page, fNavigationNode.getRepresentedDeclaration());
} catch (CModelException e) {
@ -816,7 +798,6 @@ public class CHViewPart extends ViewPart {
}
return 0;
}
private CHNode selectionToNode(ISelection selection) {
if (selection instanceof IStructuredSelection) {
@ -834,7 +815,7 @@ public class CHViewPart extends ViewPart {
public Control getPageBook() {
return fPagebook;
}
public ICElement getInput() {
Object input= fTreeViewer.getInput();
if (input instanceof ICElement) {
@ -852,7 +833,7 @@ public class CHViewPart extends ViewPart {
super(CHMessages.CHViewPart_CopyCallHierarchy_label, view, viewer);
}
}
/**
* Marks the view as pinned.
*
@ -861,7 +842,7 @@ public class CHViewPart extends ViewPart {
void setPinned(boolean pinned) {
fIsPinned= pinned;
}
/**
* Indicates whether the Call Hierarchy view is pinned.
*

View file

@ -63,13 +63,13 @@ public class CallHierarchyUI {
static final int INDEX_SEARCH_OPTION = IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT
| IIndexManager.ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY;
private static final ICElement[] NO_ELEMENTS = {};
private static boolean sIsJUnitTest= false;
private static boolean sIsJUnitTest;
/**
* List of the Call Hierarchy views in LRU order, where the most recently used view is at index 0.
*/
private static List<CHViewPart> fLRUCallHierarchyViews= new ArrayList<CHViewPart>();
private static int fViewCount = 0;
private static int fViewCount;
private static final int MAX_HISTORY_SIZE = 10;
private static List<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
@ -404,7 +404,7 @@ public class CallHierarchyUI {
}
}
if (!viewFoundInPage) {
// find unresolved views
// Find unresolved views
IViewReference[] viewReferences= page.getViewReferences();
for (IViewReference curr : viewReferences) {
if (CUIPlugin.ID_CALL_HIERARCHY.equals(curr.getId()) && page.equals(curr.getPage())) {
@ -436,5 +436,4 @@ public class CallHierarchyUI {
}
}
}
}

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
@ -26,7 +26,7 @@ public class CallsToResult {
Set<CElementSet> elementSets = fElementSetsToReferences.keySet();
return elementSets.toArray(new CElementSet[elementSets.size()]);
}
public IIndexName[] getReferences(CElementSet elementSet) {
List<IIndexName> references= fElementSetsToReferences.get(elementSet);
return references.toArray(new IIndexName[references.size()]);

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import org.eclipse.core.runtime.IAdaptable;
@ -25,7 +24,6 @@ import org.eclipse.cdt.core.model.IVariableDeclaration;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
public class OpenCallHierarchyAction extends SelectionDispatchAction {
private ITextEditor fEditor;

View file

@ -61,7 +61,7 @@ public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionD
String message = NLS.bind(CHMessages.OpenElementInCallHierarchyAction_errorNoDefinition,
info.getQualifiedTypeName().toString());
MessageDialog.openError(getShell(), title, message);
} else {
} else {
CallHierarchyUI.open(fWorkbenchWindow, elements[0]);
}
}

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.ArrayList;
@ -34,7 +33,7 @@ class ReferenceVisitor extends ASTVisitor {
fFileName= fileName;
fOffset= offset;
fEndOffset= offset+length;
fEndOffset= offset + length;
}
public IASTName[] getReferences() {