mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Shows read and write access of variables in call-hierarchy, bug 156692.
This commit is contained in:
parent
dee3496d78
commit
111b251b62
9 changed files with 64 additions and 6 deletions
|
@ -88,6 +88,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
if (fCProject == null) {
|
||||
fCProject= CProjectHelper.createCProject("indexUpdateTestsC", null, IPDOMManager.ID_FAST_INDEXER);
|
||||
}
|
||||
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
|
||||
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {fCProject, fCppProject});
|
||||
}
|
||||
|
||||
|
|
BIN
core/org.eclipse.cdt.ui/icons/ovr16/read.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/ovr16/read.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 834 B |
BIN
core/org.eclipse.cdt.ui/icons/ovr16/readwrite.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/ovr16/readwrite.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 839 B |
BIN
core/org.eclipse.cdt.ui/icons/ovr16/write.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/ovr16/write.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 831 B |
|
@ -16,12 +16,13 @@ package org.eclipse.cdt.internal.ui;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.resource.ImageRegistry;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
/**
|
||||
* Bundle of all images used by the C plugin.
|
||||
*/
|
||||
|
@ -264,6 +265,9 @@ public class CPluginImages {
|
|||
public static final ImageDescriptor DESC_OVR_SYSTEM_INCLUDE= create(T_OVR, "systeminclude_co.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_OVR_DEFINES= create(T_OVR, "defines_co.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_OVR_INACTIVE= create(T_OVR, "inactive_co.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_OVR_READ_ACCESS= create(T_OVR, "read.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_OVR_READ_WRITE_ACCESS= create(T_OVR, "readwrite.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_OVR_WRITE_ACCESS= create(T_OVR, "write.gif"); //$NON-NLS-1$
|
||||
|
||||
public static final ImageDescriptor DESC_OVR_WARNING= create(T_OVR, "warning_co.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_OVR_ERROR= create(T_OVR, "error_co.gif"); //$NON-NLS-1$
|
||||
|
|
|
@ -197,10 +197,15 @@ public class CHContentProvider extends AsyncTreeContentProvider {
|
|||
if (element instanceof IVariable || element instanceof IEnumerator) {
|
||||
node.setInitializer(true);
|
||||
}
|
||||
boolean readAccess= false;
|
||||
boolean writeAccess= false;
|
||||
for (int i = 0; i < refs.length; i++) {
|
||||
IIndexName reference = refs[i];
|
||||
node.addReference(new CHReferenceInfo(reference.getNodeOffset(), reference.getNodeLength()));
|
||||
readAccess= (readAccess || reference.isReadAccess());
|
||||
writeAccess= (writeAccess || reference.isWriteAccess());
|
||||
}
|
||||
node.setRWAccess(readAccess, writeAccess);
|
||||
node.sortReferencesByOffset();
|
||||
return node;
|
||||
}
|
||||
|
@ -236,11 +241,16 @@ public class CHContentProvider extends AsyncTreeContentProvider {
|
|||
node= new CHMultiDefNode(parent, tu, timestamp, elements);
|
||||
}
|
||||
|
||||
boolean readAccess= false;
|
||||
boolean writeAccess= false;
|
||||
for (int i = 0; i < references.length; i++) {
|
||||
IIndexName reference = references[i];
|
||||
node.addReference(new CHReferenceInfo(reference.getNodeOffset(), reference.getNodeLength()));
|
||||
readAccess= (readAccess || reference.isReadAccess());
|
||||
writeAccess= (writeAccess || reference.isWriteAccess());
|
||||
}
|
||||
node.sortReferencesByOffset();
|
||||
node.setRWAccess(readAccess, writeAccess);
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,6 +142,12 @@ public class CHLabelProvider extends LabelProvider implements IColorProvider {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (node.isReadAccess()) {
|
||||
flags |= CElementImageDescriptor.READ_ACCESS;
|
||||
}
|
||||
if (node.isWriteAccess()) {
|
||||
flags |= CElementImageDescriptor.WRITE_ACCESS;
|
||||
}
|
||||
|
||||
String key= image.toString()+String.valueOf(flags);
|
||||
Image result= (Image) fCachedImages.get(key);
|
||||
|
|
|
@ -28,16 +28,18 @@ 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 fReferences;
|
||||
|
||||
private int fHashCode;
|
||||
private boolean fIsRecursive;
|
||||
private long fTimestamp;
|
||||
private boolean fIsRecursive;
|
||||
private boolean fIsInitializer;
|
||||
private boolean fIsReadAccess;
|
||||
private boolean fIsWriteAccess;
|
||||
|
||||
/**
|
||||
* Creates a new node for the include browser
|
||||
|
@ -175,4 +177,17 @@ public class CHNode implements IAdaptable {
|
|||
Collections.sort(fReferences, CHReferenceInfo.COMPARE_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRWAccess(boolean readAccess, boolean writeAccess) {
|
||||
fIsReadAccess= readAccess;
|
||||
fIsWriteAccess= writeAccess;
|
||||
}
|
||||
|
||||
public boolean isReadAccess() {
|
||||
return fIsReadAccess;
|
||||
}
|
||||
|
||||
public boolean isWriteAccess() {
|
||||
return fIsWriteAccess;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.resource.CompositeImageDescriptor;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.swt.graphics.ImageData;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.jface.resource.CompositeImageDescriptor;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -91,6 +91,12 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
|
|||
/** Flag to render the 'inactive' adornment for include directives */
|
||||
public final static int INACTIVE= 0x8000;
|
||||
|
||||
/** Flag to render the 'read access' adornment for references to variables or fields */
|
||||
public static final int READ_ACCESS = 0x10000;
|
||||
|
||||
/** Flag to render the 'read access' adornment for references to variables or fields */
|
||||
public static final int WRITE_ACCESS = 0x20000;
|
||||
|
||||
private ImageDescriptor fBaseImage;
|
||||
private int fFlags;
|
||||
private Point fSize;
|
||||
|
@ -270,6 +276,22 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
|
|||
data= CPluginImages.DESC_OVR_INACTIVE.getImageData();
|
||||
drawImage(data, 0, 0);
|
||||
}
|
||||
|
||||
final boolean isReadAccess= (fFlags & READ_ACCESS) != 0;
|
||||
final boolean isWriteAccess= (fFlags & WRITE_ACCESS) != 0;
|
||||
if (isReadAccess) {
|
||||
if (isWriteAccess) {
|
||||
data= CPluginImages.DESC_OVR_READ_WRITE_ACCESS.getImageData();
|
||||
}
|
||||
else {
|
||||
data= CPluginImages.DESC_OVR_READ_ACCESS.getImageData();
|
||||
}
|
||||
drawImage(data, 0, 0);
|
||||
}
|
||||
else if (isWriteAccess) {
|
||||
data= CPluginImages.DESC_OVR_WRITE_ACCESS.getImageData();
|
||||
drawImage(data, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawBottomLeft() {
|
||||
|
|
Loading…
Add table
Reference in a new issue