1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-10-01 18:56:48 -07:00
parent aa09934d72
commit 5f065af0d8
5 changed files with 36 additions and 67 deletions

View file

@ -317,7 +317,7 @@ public class BaseUITestCase extends BaseTestCase {
final protected TreeItem checkTreeNode(Tree tree, int i0, String label) { final protected TreeItem checkTreeNode(Tree tree, int i0, String label) {
TreeItem root= null; TreeItem root= null;
for (int millis=0; millis < 5000; millis= millis==0 ? 1 : millis*2) { for (int millis= 0; millis < 5000; millis= millis == 0 ? 1 : millis * 2) {
runEventQueue(millis); runEventQueue(millis);
try { try {
root= tree.getItem(i0); root= tree.getItem(i0);
@ -340,7 +340,7 @@ public class BaseUITestCase extends BaseTestCase {
String itemText= null; String itemText= null;
SWTException ex= null; SWTException ex= null;
String firstItemText= null; String firstItemText= null;
for (int millis=0; millis < 5000; millis= millis==0 ? 1 : millis*2) { for (int millis= 0; millis < 5000; millis= millis == 0 ? 1 : millis * 2) {
runEventQueue(millis); runEventQueue(millis);
TreeItem root= tree.getItem(i0); TreeItem root= tree.getItem(i0);
if (!root.getExpanded()) { if (!root.getExpanded()) {

View file

@ -34,13 +34,12 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
return suite(BasicIncludeBrowserTest.class); return suite(BasicIncludeBrowserTest.class);
} }
// // source // // source
// #include "user.h" // #include "user.h"
// #include <system.h> // #include <system.h>
public void testSimpleInclusion() throws Exception { public void testSimpleInclusion() throws Exception {
TestScannerProvider.sIncludes= new String[]{getProject().getProject().getLocation().toOSString()}; TestScannerProvider.sIncludes= new String[] { getProject().getProject().getLocation().toOSString() };
StringBuilder[] contents= getContentsForTest(1); StringBuilder[] contents= getContentsForTest(1);
IProject project= getProject().getProject(); IProject project= getProject().getProject();
@ -55,7 +54,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
checkTreeNode(tree, 0, 0, "user.h"); checkTreeNode(tree, 0, 0, "user.h");
checkTreeNode(tree, 0, 1, "system.h"); checkTreeNode(tree, 0, 1, "system.h");
// the tree has to be reversed // The tree has to be reversed
openIncludeBrowser(user, true); openIncludeBrowser(user, true);
checkTreeNode(tree, 0, "user.h"); checkTreeNode(tree, 0, "user.h");
checkTreeNode(tree, 0, 0, "source.cpp"); checkTreeNode(tree, 0, 0, "source.cpp");
@ -72,9 +71,9 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
public void testInclusionAccrossProjects() throws Exception { public void testInclusionAccrossProjects() throws Exception {
ICProject op= CProjectHelper.createCCProject("__ibTest_other__", "bin", IPDOMManager.ID_FAST_INDEXER); ICProject op= CProjectHelper.createCCProject("__ibTest_other__", "bin", IPDOMManager.ID_FAST_INDEXER);
try { try {
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {getProject(), op}); fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] { getProject(), op });
TestScannerProvider.sIncludes= new String[]{op.getProject().getLocation().toOSString()}; TestScannerProvider.sIncludes= new String[] { op.getProject().getLocation().toOSString() };
StringBuilder[] contents= getContentsForTest(1); StringBuilder[] contents= getContentsForTest(1);
IFile user= createFile(op.getProject(), "user.h", ""); IFile user= createFile(op.getProject(), "user.h", "");
@ -89,7 +88,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
checkTreeNode(tree, 0, 0, "user.h"); checkTreeNode(tree, 0, 0, "user.h");
checkTreeNode(tree, 0, 1, "system.h"); checkTreeNode(tree, 0, 1, "system.h");
// the tree has to be reversed // The tree has to be reversed
openIncludeBrowser(user, true); openIncludeBrowser(user, true);
checkTreeNode(tree, 0, "user.h"); checkTreeNode(tree, 0, "user.h");
checkTreeNode(tree, 0, 0, "source.cpp"); checkTreeNode(tree, 0, 0, "source.cpp");
@ -97,10 +96,8 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
openIncludeBrowser(system); openIncludeBrowser(system);
checkTreeNode(tree, 0, "system.h"); checkTreeNode(tree, 0, "system.h");
checkTreeNode(tree, 0, 0, "source.cpp"); checkTreeNode(tree, 0, 0, "source.cpp");
} finally { } finally {
CProjectHelper.delete(op); CProjectHelper.delete(op);
} }
} }
} }

View file

@ -34,7 +34,6 @@ import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
* This is the content provider for the include browser. * This is the content provider for the include browser.
*/ */
public class IBContentProvider extends AsyncTreeContentProvider { public class IBContentProvider extends AsyncTreeContentProvider {
private static final IProgressMonitor NPM = new NullProgressMonitor(); private static final IProgressMonitor NPM = new NullProgressMonitor();
private boolean fComputeIncludedBy = true; private boolean fComputeIncludedBy = true;
@ -66,7 +65,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
return NO_CHILDREN; return NO_CHILDREN;
} }
} }
// allow for async computation // Allow for asynchronous computation
return null; return null;
} }
@ -98,8 +97,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
IIndexInclude[] includes; IIndexInclude[] includes;
if (fComputeIncludedBy) { if (fComputeIncludedBy) {
includes= findIncludedBy(index, ifl, NPM); includes= findIncludedBy(index, ifl, NPM);
} } else {
else {
includes= findIncludesTo(index, ifl, NPM); includes= findIncludesTo(index, ifl, NPM);
directiveFile= node.getRepresentedFile(); directiveFile= node.getRepresentedFile();
} }
@ -110,13 +108,11 @@ public class IBContentProvider extends AsyncTreeContentProvider {
try { try {
if (fComputeIncludedBy) { if (fComputeIncludedBy) {
directiveFile= targetFile= new IBFile(project, include.getIncludedByLocation()); directiveFile= targetFile= new IBFile(project, include.getIncludedByLocation());
} } else {
else {
IIndexFileLocation includesPath= include.getIncludesLocation(); IIndexFileLocation includesPath= include.getIncludesLocation();
if (includesPath == null) { if (includesPath == null) {
targetFile= new IBFile(include.getFullName()); targetFile= new IBFile(include.getFullName());
} } else {
else {
targetFile= new IBFile(project, includesPath); targetFile= new IBFile(project, includesPath);
} }
} }
@ -127,24 +123,20 @@ public class IBContentProvider extends AsyncTreeContentProvider {
newnode.setIsActiveCode(include.isActive()); newnode.setIsActiveCode(include.isActive());
newnode.setIsSystemInclude(include.isSystemInclude()); newnode.setIsSystemInclude(include.isSystemInclude());
result.add(newnode); result.add(newnode);
} } catch (CoreException e) {
catch (CoreException e) {
CUIPlugin.log(e); CUIPlugin.log(e);
} }
} }
return result.toArray(); return result.toArray();
} }
} } finally {
finally {
index.releaseReadLock(); index.releaseReadLock();
} }
} }
return NO_CHILDREN; return NO_CHILDREN;
} }
public void setComputeIncludedBy(boolean value) { public void setComputeIncludedBy(boolean value) {
fComputeIncludedBy = value; fComputeIncludedBy = value;
} }
@ -153,7 +145,6 @@ public class IBContentProvider extends AsyncTreeContentProvider {
return fComputeIncludedBy; return fComputeIncludedBy;
} }
private IIndexInclude[] findIncludedBy(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) { private IIndexInclude[] findIncludedBy(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
try { try {
if (ifl != null) { if (ifl != null) {
@ -176,8 +167,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
return list.toArray(new IIndexInclude[list.size()]); return list.toArray(new IIndexInclude[list.size()]);
} }
} }
} } catch (CoreException e) {
catch (CoreException e) {
CUIPlugin.log(e); CUIPlugin.log(e);
} }
return new IIndexInclude[0]; return new IIndexInclude[0];
@ -205,8 +195,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
return list.toArray(new IIndexInclude[list.size()]); return list.toArray(new IIndexInclude[list.size()]);
} }
} }
} } catch (CoreException e) {
catch (CoreException e) {
CUIPlugin.log(e); CUIPlugin.log(e);
} }
return new IIndexInclude[0]; return new IIndexInclude[0];

View file

@ -104,9 +104,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
/** /**
* The view part for the include browser. * The view part for the include browser.
*/ */
public class IBViewPart extends ViewPart public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget, IShowInTargetList {
implements IShowInSource, IShowInTarget, IShowInTargetList {
private static final int MAX_HISTORY_SIZE = 10; private static final int MAX_HISTORY_SIZE = 10;
private static final String TRUE = "true"; //$NON-NLS-1$ private static final String TRUE = "true"; //$NON-NLS-1$
private static final String FALSE = "false"; //$NON-NLS-1$ private static final String FALSE = "false"; //$NON-NLS-1$
@ -183,8 +181,7 @@ public class IBViewPart extends ViewPart
if (CCorePlugin.getIndexManager().isIndexerIdle()) { if (CCorePlugin.getIndexManager().isIndexerIdle()) {
setInputIndexerIdle(input); setInputIndexerIdle(input);
} } else {
else {
setMessage(IBMessages.IBViewPart_waitingOnIndexerMessage); setMessage(IBMessages.IBViewPart_waitingOnIndexerMessage);
fSetInputJob.setInput(input); fSetInputJob.setInput(input);
fSetInputJob.schedule(); fSetInputJob.schedule();
@ -202,8 +199,7 @@ public class IBViewPart extends ViewPart
fIncludesToAction.setChecked(!isHeader); fIncludesToAction.setChecked(!isHeader);
fIncludedByAction.setEnabled(false); fIncludedByAction.setEnabled(false);
updateSorter(); updateSorter();
} } else {
else {
fIncludedByAction.setEnabled(true); fIncludedByAction.setEnabled(true);
} }
fTreeViewer.setInput(input); fTreeViewer.setInput(input);
@ -349,14 +345,12 @@ public class IBViewPart extends ViewPart
} }
} }
@Override @Override
public void init(IViewSite site, IMemento memento) throws PartInitException { public void init(IViewSite site, IMemento memento) throws PartInitException {
fMemento= memento; fMemento= memento;
super.init(site, memento); super.init(site, memento);
} }
@Override @Override
public void saveState(IMemento memento) { public void saveState(IMemento memento) {
putDialogSettings(); putDialogSettings();
@ -501,8 +495,7 @@ public class IBViewPart extends ViewPart
public void run() { public void run() {
if (isChecked()) { if (isChecked()) {
fTreeViewer.addFilter(fInactiveFilter); fTreeViewer.addFilter(fInactiveFilter);
} } else {
else {
fTreeViewer.removeFilter(fInactiveFilter); fTreeViewer.removeFilter(fInactiveFilter);
} }
} }
@ -525,8 +518,7 @@ public class IBViewPart extends ViewPart
public void run() { public void run() {
if (isChecked()) { if (isChecked()) {
fTreeViewer.addFilter(fSystemFilter); fTreeViewer.addFilter(fSystemFilter);
} } else {
else {
fTreeViewer.removeFilter(fSystemFilter); fTreeViewer.removeFilter(fSystemFilter);
} }
} }
@ -675,8 +667,7 @@ public class IBViewPart extends ViewPart
private void updateSorter() { private void updateSorter() {
if (fIncludedByAction.isChecked()) { if (fIncludedByAction.isChecked()) {
fTreeViewer.setComparator(fSorterAlphaNumeric); fTreeViewer.setComparator(fSorterAlphaNumeric);
} } else {
else {
fTreeViewer.setComparator(fSorterReferencePosition); fTreeViewer.setComparator(fSorterReferencePosition);
} }
} }
@ -693,15 +684,13 @@ public class IBViewPart extends ViewPart
file= path.lastSegment() + "(" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$//$NON-NLS-2$ file= path.lastSegment() + "(" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$//$NON-NLS-2$
if (fWorkingSetFilter == null) { if (fWorkingSetFilter == null) {
scope= IBMessages.IBViewPart_workspaceScope; scope= IBMessages.IBViewPart_workspaceScope;
} } else {
else {
scope= fWorkingSetFilter.getLabel(); scope= fWorkingSetFilter.getLabel();
} }
if (fIncludedByAction.isChecked()) { if (fIncludedByAction.isChecked()) {
format= IBMessages.IBViewPart_IncludedByContentDescription; format= IBMessages.IBViewPart_IncludedByContentDescription;
} } else {
else {
format= IBMessages.IBViewPart_IncludesToContentDescription; format= IBMessages.IBViewPart_IncludesToContentDescription;
} }
message= Messages.format(format, file, scope); message= Messages.format(format, file, scope);
@ -717,12 +706,10 @@ public class IBViewPart extends ViewPart
fTreeViewer.removeFilter(fWorkingSetFilter); fTreeViewer.removeFilter(fWorkingSetFilter);
fWorkingSetFilter= null; fWorkingSetFilter= null;
} }
} } else {
else {
if (fWorkingSetFilter != null) { if (fWorkingSetFilter != null) {
fTreeViewer.refresh(); fTreeViewer.refresh();
} } else {
else {
fWorkingSetFilter= new IBWorkingSetFilter(filterUI); fWorkingSetFilter= new IBWorkingSetFilter(filterUI);
fTreeViewer.addFilter(fWorkingSetFilter); fTreeViewer.addFilter(fWorkingSetFilter);
} }
@ -777,7 +764,6 @@ public class IBViewPart extends ViewPart
} }
}); });
} }
} }
} }
m.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS)); m.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
@ -797,8 +783,7 @@ public class IBViewPart extends ViewPart
IFile f= ibf.getResource(); IFile f= ibf.getResource();
if (f != null) { if (f != null) {
EditorOpener.open(page, f, region, timestamp); EditorOpener.open(page, f, region, timestamp);
} } else {
else {
IIndexFileLocation ifl = ibf.getLocation(); IIndexFileLocation ifl = ibf.getLocation();
if (ifl != null) { if (ifl != null) {
IPath location= IndexLocationFactory.getAbsolutePath(ifl); IPath location= IndexLocationFactory.getAbsolutePath(ifl);
@ -807,8 +792,7 @@ public class IBViewPart extends ViewPart
} }
} }
} }
} } else {
else {
ITranslationUnit tu= IBConversions.selectionToTU(selection); ITranslationUnit tu= IBConversions.selectionToTU(selection);
if (tu != null) { if (tu != null) {
IResource r= tu.getResource(); IResource r= tu.getResource();

View file

@ -39,7 +39,7 @@ public class IncludeBrowserUI {
ITranslationUnit tu= convertToTranslationUnit(input); ITranslationUnit tu= convertToTranslationUnit(input);
if (tu != null) { if (tu != null) {
IWorkbenchPage page= window.getActivePage(); IWorkbenchPage page= window.getActivePage();
IBViewPart result= (IBViewPart)page.showView(CUIPlugin.ID_INCLUDE_BROWSER); IBViewPart result= (IBViewPart) page.showView(CUIPlugin.ID_INCLUDE_BROWSER);
result.setInput(tu); result.setInput(tu);
} }
} catch (CoreException e) { } catch (CoreException e) {
@ -52,7 +52,7 @@ public class IncludeBrowserUI {
public static void open(final ITextEditor editor, final ITextSelection sel) { public static void open(final ITextEditor editor, final ITextSelection sel) {
if (editor != null) { if (editor != null) {
ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()); ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
open (editor.getSite().getWorkbenchWindow(), inputCElement); open(editor.getSite().getWorkbenchWindow(), inputCElement);
} }
} }
@ -80,8 +80,7 @@ public class IncludeBrowserUI {
return CoreModelUtil.findTranslationUnitForLocation(loc, project); return CoreModelUtil.findTranslationUnitForLocation(loc, project);
} }
} }
} } finally {
finally {
index.releaseReadLock(); index.releaseReadLock();
} }
} }