mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
The IndexView now skips linkages in the hierarchy if there is only one in a project (i.e. not a multi-language project). Also fixed a bug with paths in the GCCLanguage and warnings in GPPLanguage.
This commit is contained in:
parent
4f0893f7f7
commit
e9eb7ef7e6
3 changed files with 25 additions and 15 deletions
|
@ -92,20 +92,22 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
|
|||
fileCreator = SavedCodeReaderFactory.getInstance();
|
||||
|
||||
CodeReader reader;
|
||||
IFile rfile = (IFile)file.getResource();
|
||||
if (file instanceof IWorkingCopy) {
|
||||
// get the working copy contents
|
||||
IFile rfile = (IFile)file.getResource();
|
||||
reader = new CodeReader(rfile.getLocation().toOSString(), file.getContents());
|
||||
} else {
|
||||
String path = file.getPath().toOSString();
|
||||
String path
|
||||
= rfile != null
|
||||
? rfile.getLocation().toOSString()
|
||||
: file.getPath().toOSString();
|
||||
reader = fileCreator.createCodeReaderForTranslationUnit(path);
|
||||
if (reader == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration =
|
||||
scannerExtensionConfiguration = C_GNU_SCANNER_EXTENSION;
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration
|
||||
= C_GNU_SCANNER_EXTENSION;
|
||||
|
||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||
ParserLanguage.C, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, fileCreator );
|
||||
|
|
|
@ -90,8 +90,8 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
|
|||
else
|
||||
fileCreator = SavedCodeReaderFactory.getInstance();
|
||||
|
||||
IFile rfile = (IFile)file.getResource();
|
||||
CodeReader reader;
|
||||
IFile rfile = (IFile)file.getResource();
|
||||
if (file instanceof IWorkingCopy) {
|
||||
// get the working copy contents
|
||||
reader = new CodeReader(rfile.getLocation().toOSString(), file.getContents());
|
||||
|
@ -105,8 +105,8 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
|
|||
return null;
|
||||
}
|
||||
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration =
|
||||
scannerExtensionConfiguration = CPP_GNU_SCANNER_EXTENSION;
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration
|
||||
= CPP_GNU_SCANNER_EXTENSION;
|
||||
|
||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||
ParserLanguage.CPP, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, fileCreator );
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
package org.eclipse.cdt.internal.ui.indexview;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
|
@ -29,10 +28,8 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPNamespace;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
|
@ -48,7 +45,6 @@ import org.eclipse.jface.action.Separator;
|
|||
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
|
@ -104,7 +100,7 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
|||
* editor (if option enabled)
|
||||
*/
|
||||
void handleSelectionChanged(SelectionChangedEvent event) {
|
||||
final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
|
||||
// final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
|
||||
// updateStatusLine(selection);
|
||||
// updateActionBars(selection);
|
||||
if (isLinking) {
|
||||
|
@ -187,8 +183,13 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
|||
if (parentElement instanceof ICProject) {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM((ICProject)parentElement);
|
||||
int n = 0;
|
||||
for (PDOMLinkage linkage = pdom.getFirstLinkage(); linkage != null; linkage = linkage.getNextLinkage())
|
||||
PDOMLinkage firstLinkage = pdom.getFirstLinkage();
|
||||
for (PDOMLinkage linkage = firstLinkage; linkage != null; linkage = linkage.getNextLinkage())
|
||||
++n;
|
||||
if (n == 1) {
|
||||
// Skip linkages in hierarchy if there is only one
|
||||
return getChildren(firstLinkage);
|
||||
}
|
||||
PDOMLinkage[] linkages = new PDOMLinkage[n];
|
||||
int i = 0;
|
||||
for (PDOMLinkage linkage = pdom.getFirstLinkage(); linkage != null; linkage = linkage.getNextLinkage())
|
||||
|
@ -218,7 +219,14 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
|||
try {
|
||||
if (element instanceof ICProject) {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM((ICProject)element);
|
||||
return pdom.getFirstLinkage() != null;
|
||||
PDOMLinkage firstLinkage = pdom.getFirstLinkage();
|
||||
if (firstLinkage == null)
|
||||
return false;
|
||||
else if (firstLinkage.getNextLinkage() == null)
|
||||
// Skipping linkages if only one
|
||||
return hasChildren(firstLinkage);
|
||||
else
|
||||
return true;
|
||||
} else if (element instanceof IPDOMNode) {
|
||||
HasChildren hasChildren = new HasChildren();
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue