1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-13 20:15:22 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-12-27 11:58:41 -08:00
parent 6428f07759
commit f81a1652f1
3 changed files with 52 additions and 72 deletions

View file

@ -45,7 +45,6 @@ public class CodanRunner {
/** Do not instantiate. All methods are static */ /** Do not instantiate. All methods are static */
private CodanRunner() {} private CodanRunner() {}
/** /**
* Runs all checkers that support "run as you type" mode. * Runs all checkers that support "run as you type" mode.
* *

View file

@ -10,8 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -19,23 +17,22 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IOpenable; import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.cdt.internal.core.util.OverflowingLRUCache; import org.eclipse.cdt.internal.core.util.OverflowingLRUCache;
/** /**
* The cache of C elements to their respective info. * The cache of C elements to their respective info.
* *
* This class is similar to the JDT CModelCache class. * This class is similar to the JDT CModelCache class.
*/ */
public class CModelCache { public class CModelCache {
public static final int PROJ_CACHE_SIZE = 50; public static final int PROJ_CACHE_SIZE = 50;
public static final int FOLDER_CACHE_SIZE = 500; public static final int FOLDER_CACHE_SIZE = 500;
public static final int FILE_CACHE_SIZE = 2000; public static final int FILE_CACHE_SIZE = 2000;
public static final int CHILDREN_CACHE_SIZE = FILE_CACHE_SIZE * 20; public static final int CHILDREN_CACHE_SIZE = FILE_CACHE_SIZE * 20;
/** /**
* Cache of open projects and roots. * Cache of open projects and roots.
*/ */
protected Map<ICElement, Object> projectAndRootCache; protected Map<ICElement, Object> projectAndRootCache;
/** /**
* Cache of open containers * Cache of open containers
*/ */
@ -50,62 +47,62 @@ public class CModelCache {
* Cache of children of C elements * Cache of children of C elements
*/ */
protected Map<ICElement, Object> childrenCache; protected Map<ICElement, Object> childrenCache;
public CModelCache() {
this.projectAndRootCache = new HashMap<ICElement, Object>(PROJ_CACHE_SIZE);
this.folderCache = new HashMap<ICElement, Object>(FOLDER_CACHE_SIZE);
this.fileCache = new ElementCache<Object>(FILE_CACHE_SIZE);
this.childrenCache = new HashMap<ICElement, Object>(CHILDREN_CACHE_SIZE); // average 20 children per openable
}
public double openableFillingRatio() { public CModelCache() {
return this.fileCache.fillingRatio(); this.projectAndRootCache = new HashMap<ICElement, Object>(PROJ_CACHE_SIZE);
} this.folderCache = new HashMap<ICElement, Object>(FOLDER_CACHE_SIZE);
this.fileCache = new ElementCache<Object>(FILE_CACHE_SIZE);
/** this.childrenCache = new HashMap<ICElement, Object>(CHILDREN_CACHE_SIZE); // average 20 children per openable
* Returns the info for the element. }
*/
public Object getInfo(ICElement element) { public double openableFillingRatio() {
switch (element.getElementType()) { return this.fileCache.fillingRatio();
}
/**
* Returns the info for the element.
*/
public Object getInfo(ICElement element) {
switch (element.getElementType()) {
case ICElement.C_MODEL: case ICElement.C_MODEL:
case ICElement.C_PROJECT: case ICElement.C_PROJECT:
return this.projectAndRootCache.get(element); return this.projectAndRootCache.get(element);
case ICElement.C_CCONTAINER: case ICElement.C_CCONTAINER:
return this.folderCache.get(element); return this.folderCache.get(element);
case ICElement.C_ARCHIVE: case ICElement.C_ARCHIVE:
case ICElement.C_BINARY: case ICElement.C_BINARY:
case ICElement.C_UNIT: case ICElement.C_UNIT:
return this.fileCache.get(element); return this.fileCache.get(element);
default: default:
return this.childrenCache.get(element); return this.childrenCache.get(element);
}
} }
}
/** /**
* Returns the info for this element without * Returns the info for this element without
* disturbing the cache ordering. * disturbing the cache ordering.
*/ */
protected Object peekAtInfo(ICElement element) { protected Object peekAtInfo(ICElement element) {
switch (element.getElementType()) { switch (element.getElementType()) {
case ICElement.C_MODEL: case ICElement.C_MODEL:
case ICElement.C_PROJECT: case ICElement.C_PROJECT:
return this.projectAndRootCache.get(element); return this.projectAndRootCache.get(element);
case ICElement.C_CCONTAINER: case ICElement.C_CCONTAINER:
return this.folderCache.get(element); return this.folderCache.get(element);
case ICElement.C_ARCHIVE: case ICElement.C_ARCHIVE:
case ICElement.C_BINARY: case ICElement.C_BINARY:
case ICElement.C_UNIT: case ICElement.C_UNIT:
return this.fileCache.peek((IOpenable) element); return this.fileCache.peek((IOpenable) element);
default: default:
return this.childrenCache.get(element); return this.childrenCache.get(element);
}
} }
}
/** /**
* Remember the info for the element. * Remember the info for the element.
*/ */
protected void putInfo(ICElement element, Object info) { protected void putInfo(ICElement element, Object info) {
switch (element.getElementType()) { switch (element.getElementType()) {
case ICElement.C_MODEL: case ICElement.C_MODEL:
case ICElement.C_PROJECT: case ICElement.C_PROJECT:
this.projectAndRootCache.put(element, info); this.projectAndRootCache.put(element, info);
@ -114,19 +111,20 @@ protected void putInfo(ICElement element, Object info) {
this.folderCache.put(element, info); this.folderCache.put(element, info);
break; break;
case ICElement.C_ARCHIVE: case ICElement.C_ARCHIVE:
case ICElement.C_BINARY: case ICElement.C_BINARY:
case ICElement.C_UNIT: case ICElement.C_UNIT:
this.fileCache.put((IOpenable)element, info); this.fileCache.put((IOpenable)element, info);
break; break;
default: default:
this.childrenCache.put(element, info); this.childrenCache.put(element, info);
}
} }
}
/** /**
* Removes the info of the element from the cache. * Removes the info of the element from the cache.
*/ */
protected void removeInfo(ICElement element) { protected void removeInfo(ICElement element) {
switch (element.getElementType()) { switch (element.getElementType()) {
case ICElement.C_MODEL: case ICElement.C_MODEL:
case ICElement.C_PROJECT: case ICElement.C_PROJECT:
this.projectAndRootCache.remove(element); this.projectAndRootCache.remove(element);
@ -135,13 +133,12 @@ protected void removeInfo(ICElement element) {
this.folderCache.remove(element); this.folderCache.remove(element);
break; break;
case ICElement.C_ARCHIVE: case ICElement.C_ARCHIVE:
case ICElement.C_BINARY: case ICElement.C_BINARY:
case ICElement.C_UNIT: case ICElement.C_UNIT:
this.fileCache.remove((IOpenable)element); this.fileCache.remove((IOpenable)element);
break; break;
default: default:
this.childrenCache.remove(element); this.childrenCache.remove(element);
}
} }
} }
}

View file

@ -32,9 +32,7 @@ import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension { public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
private ITextEditor fEditor; private ITextEditor fEditor;
private IWorkingCopyManager fManager; private IWorkingCopyManager fManager;
private IProgressMonitor fProgressMonitor; private IProgressMonitor fProgressMonitor;
@ -46,32 +44,20 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
fManager= CUIPlugin.getDefault().getWorkingCopyManager(); fManager= CUIPlugin.getDefault().getWorkingCopyManager();
} }
/*
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
*/
@Override @Override
public void setDocument(IDocument document) { public void setDocument(IDocument document) {
} }
/*
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
*/
@Override @Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) { public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
// only called for incremental reconciler // only called for incremental reconciler
} }
/*
* @see IReconcilingStrategyExtension#setProgressMonitor(IProgressMonitor)
*/
@Override @Override
public void setProgressMonitor(IProgressMonitor monitor) { public void setProgressMonitor(IProgressMonitor monitor) {
fProgressMonitor= monitor; fProgressMonitor= monitor;
} }
/*
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
*/
@Override @Override
public void reconcile(IRegion region) { public void reconcile(IRegion region) {
reconcile(false); reconcile(false);
@ -91,10 +77,11 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
forced= workingCopy.isConsistent(); forced= workingCopy.isConsistent();
ast= workingCopy.reconcile(computeAST, true, fProgressMonitor); ast= workingCopy.reconcile(computeAST, true, fProgressMonitor);
} }
} catch (OperationCanceledException oce) { } catch (OperationCanceledException e) {
// document was modified while parsing // document was modified while parsing
} catch (CModelException e) { } catch (CModelException e) {
IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, "Error in CDT UI during reconcile", e); //$NON-NLS-1$ IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK,
"Error in CDT UI during reconcile", e); //$NON-NLS-1$
CUIPlugin.log(status); CUIPlugin.log(status);
} finally { } finally {
if (computeAST) { if (computeAST) {
@ -117,8 +104,9 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
if (canceled) { if (canceled) {
aboutToBeReconciled(); aboutToBeReconciled();
} }
} catch(Exception e) { } catch (Exception e) {
IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, "Error in CDT UI during reconcile", e); //$NON-NLS-1$ IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK,
"Error in CDT UI during reconcile", e); //$NON-NLS-1$
CUIPlugin.log(status); CUIPlugin.log(status);
} finally { } finally {
if (index != null) { if (index != null) {
@ -129,9 +117,6 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
} }
} }
/*
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
*/
@Override @Override
public void initialReconcile() { public void initialReconcile() {
reconcile(true); reconcile(true);
@ -143,5 +128,4 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
((ICReconcilingListener)fEditor).aboutToBeReconciled(); ((ICReconcilingListener)fEditor).aboutToBeReconciled();
} }
} }
} }