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 2012-05-06 16:32:22 -07:00
parent 365587f654
commit ad6104f082
8 changed files with 69 additions and 86 deletions

View file

@ -421,7 +421,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} catch (CModelException e) { } catch (CModelException e) {
} }
// if the file exists and it has a known C/C++ file extension then just create // If the file exists and it has a known C/C++ file extension then just create
// an external translation unit for it. // an external translation unit for it.
if (contentTypeId != null && path.toFile().exists()) { if (contentTypeId != null && path.toFile().exists()) {
// TODO: use URI // TODO: use URI
@ -470,8 +470,8 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
IFileStore fileStore = null; IFileStore fileStore = null;
try { try {
fileStore = EFS.getStore(locationURI); fileStore = EFS.getStore(locationURI);
} catch (CoreException e1) { } catch (CoreException e) {
CCorePlugin.log(e1); CCorePlugin.log(e);
return null; return null;
} }
@ -489,7 +489,8 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
if (path != null && includeReference.isOnIncludeEntry(path)) { if (path != null && includeReference.isOnIncludeEntry(path)) {
String headerContentTypeId= contentTypeId; String headerContentTypeId= contentTypeId;
if (headerContentTypeId == null) { if (headerContentTypeId == null) {
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER; headerContentTypeId= CoreModel.hasCCNature(project) ?
CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
} }
return new ExternalTranslationUnit(includeReference, locationURI, headerContentTypeId); return new ExternalTranslationUnit(includeReference, locationURI, headerContentTypeId);
@ -770,14 +771,14 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
runner = binaryRunners.get(project); runner = binaryRunners.get(project);
} }
if (runner == null) { if (runner == null) {
// creation of BinaryRunner must occur outside the synchronized block // Creation of BinaryRunner must occur outside the synchronized block
runner = new BinaryRunner(project); runner = new BinaryRunner(project);
synchronized (binaryRunners) { synchronized (binaryRunners) {
if (binaryRunners.get(project) == null) { if (binaryRunners.get(project) == null) {
binaryRunners.put(project, runner); binaryRunners.put(project, runner);
runner.start(); runner.start();
} else { } else {
// another thread was faster // Another thread was faster
runner = binaryRunners.get(project); runner = binaryRunners.get(project);
} }
} }
@ -920,12 +921,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} }
} }
if ((flags & ICDescriptionDelta.EXT_REF) != 0) { if ((flags & ICDescriptionDelta.EXT_REF) != 0) {
// update binary parsers // Update binary parsers
IProject project = newDes.getProject(); IProject project = newDes.getProject();
try { try {
ICConfigExtensionReference[] newExts = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project); ICConfigExtensionReference[] newExts = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project);
BinaryParserConfig[] currentConfigs = binaryParsersMap.get(project); BinaryParserConfig[] currentConfigs = binaryParsersMap.get(project);
// anything added/removed // Anything added/removed
if (currentConfigs != null) { if (currentConfigs != null) {
if (newExts.length != currentConfigs.length) { if (newExts.length != currentConfigs.length) {
resetBinaryParser(project); resetBinaryParser(project);
@ -959,9 +960,6 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
return null; return null;
} }
/* (non-Javadoc)
* @see org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeListener#contentTypeChanged()
*/
@Override @Override
public void contentTypeChanged(ContentTypeChangeEvent event) { public void contentTypeChanged(ContentTypeChangeEvent event) {
ContentTypeProcessor.processContentTypeChanges(new ContentTypeChangeEvent[]{ event }); ContentTypeProcessor.processContentTypeChanges(new ContentTypeChangeEvent[]{ event });
@ -1061,7 +1059,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$ System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$
} }
if (deltaToNotify != null) { if (deltaToNotify != null) {
// flush now so as to keep listener reactions to post their own deltas for subsequent iteration // Flush now so as to keep listener reactions to post their own deltas for subsequent iteration
this.reconcileDeltas = new HashMap<IWorkingCopy, ICElementDelta>(); this.reconcileDeltas = new HashMap<IWorkingCopy, ICElementDelta>();
notifyListeners(deltaToNotify, ElementChangedEvent.POST_RECONCILE, listeners, listenerMask, listenerCount); notifyListeners(deltaToNotify, ElementChangedEvent.POST_RECONCILE, listeners, listenerMask, listenerCount);
} }
@ -1069,7 +1067,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
private void fireShiftEvent(ICElementDelta deltaToNotify, IElementChangedListener[] listeners, private void fireShiftEvent(ICElementDelta deltaToNotify, IElementChangedListener[] listeners,
int[] listenerMask, int listenerCount) { int[] listenerMask, int listenerCount) {
// post change deltas // Post change deltas
if (Util.VERBOSE_DELTA) { if (Util.VERBOSE_DELTA) {
System.out.println("FIRING POST_SHIFT event [" + Thread.currentThread() + "]:"); //$NON-NLS-1$//$NON-NLS-2$ System.out.println("FIRING POST_SHIFT event [" + Thread.currentThread() + "]:"); //$NON-NLS-1$//$NON-NLS-2$
System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$ System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$
@ -1092,7 +1090,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
System.out.print("Listener #" + (i + 1) + "=" + listener.toString());//$NON-NLS-1$//$NON-NLS-2$ System.out.print("Listener #" + (i + 1) + "=" + listener.toString());//$NON-NLS-1$//$NON-NLS-2$
start = System.currentTimeMillis(); start = System.currentTimeMillis();
} }
// wrap callbacks with Safe runnable for subsequent listeners to be called when some are causing grief // Wrap callbacks with Safe runnable for subsequent listeners to be called when some are causing grief
SafeRunner.run(new ISafeRunnable() { SafeRunner.run(new ISafeRunnable() {
@Override @Override
public void handleException(Throwable exception) { public void handleException(Throwable exception) {

View file

@ -10,7 +10,6 @@
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Warren Paul (Nokia) - Bug 218266 * Warren Paul (Nokia) - Bug 218266
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.net.URI; import java.net.URI;

View file

@ -14,10 +14,8 @@ import java.io.File;
/** /**
* @author jcamelon * @author jcamelon
*
*/ */
public class ScannerUtility { public class ScannerUtility {
static final char DOT = '.'; static final char DOT = '.';
static final char SLASH = '/'; static final char SLASH = '/';
static final char BSLASH = '\\'; static final char BSLASH = '\\';
@ -68,7 +66,6 @@ public class ScannerUtility {
} }
} }
for (int i= 0; i < len; i++) { for (int i= 0; i < len; i++) {
char c = ein[i]; char c = ein[i];
switch (c) { switch (c) {
@ -83,35 +80,24 @@ public class ScannerUtility {
} }
break; break;
case DOT: case DOT:
// no separator before, not a 1st string symbol. // No separator before, not a 1st string symbol.
if (noSepBefore && j>0) if (noSepBefore && j > 0) {
aus[j++] = c; aus[j++] = c;
else { // separator before "." ! } else { // Separator before "."
if (i < len1) { if (i < len1) {
c = ein[i+1]; // check for next symbol c = ein[i + 1]; // Check for next symbol
// check for "/./" case // Check for "/./" case
if (c == SLASH || c == BSLASH) { if (c == SLASH || c == BSLASH) {
// write nothing to output // Write nothing to output, skip the next symbol
// skip the next symbol
i++; i++;
noSepBefore = false; noSepBefore = false;
} } else { // Process as usual
// symbol other than "." - write it also
else if (c != DOT) {
i++; i++;
noSepBefore = true; noSepBefore = true;
aus[j++] = DOT; aus[j++] = DOT;
aus[j++] = c; aus[j++] = c;
} }
// Processed as usual
else {
i++;
noSepBefore = true;
aus[j++] = DOT;
aus[j++] = DOT;
} }
} else
{} // do nothing when "." is last symbol
} }
break; break;
default: default:
@ -125,10 +111,10 @@ public class ScannerUtility {
/** /**
* @param path - include path * @param path - include path
* @param fileName - include file name * @param fileName - include file name
* @return - reconsiled path * @return - reconciled path
*/ */
public static String createReconciledPath(String path, String fileName) { public static String createReconciledPath(String path, String fileName) {
boolean pathEmpty = (path == null || path.length() == 0); boolean pathEmpty = (path == null || path.length() == 0);
return (pathEmpty ? fileName : reconcilePath(path + File.separatorChar + fileName)); return pathEmpty ? fileName : reconcilePath(path + File.separatorChar + fileName);
} }
} }

View file

@ -307,6 +307,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
private final LinkedList<AbstractIndexerTask> fUrgentTasks; private final LinkedList<AbstractIndexerTask> fUrgentTasks;
boolean fTaskCompleted; boolean fTaskCompleted;
private IndexerProgress fInfo= new IndexerProgress(); private IndexerProgress fInfo= new IndexerProgress();
public AbstractIndexerTask(Object[] filesToUpdate, Object[] filesToRemove, public AbstractIndexerTask(Object[] filesToUpdate, Object[] filesToRemove,
IndexerInputAdapter resolver, boolean fastIndexer) { IndexerInputAdapter resolver, boolean fastIndexer) {
super(resolver); super(resolver);
@ -384,6 +385,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
protected abstract IWritableIndex createIndex(); protected abstract IWritableIndex createIndex();
protected abstract IIncludeFileResolutionHeuristics createIncludeHeuristics(); protected abstract IIncludeFileResolutionHeuristics createIncludeHeuristics();
protected abstract IncludeFileContentProvider createReaderFactory(); protected abstract IncludeFileContentProvider createReaderFactory();
protected ITodoTaskUpdater createTodoTaskUpdater() { protected ITodoTaskUpdater createTodoTaskUpdater() {
return null; return null;
} }

View file

@ -9,7 +9,6 @@
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer; package org.eclipse.cdt.internal.core.pdom.indexer;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
@ -20,6 +19,7 @@ import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics;
* Configures the abstract indexer to return tasks suitable for fast indexing. * Configures the abstract indexer to return tasks suitable for fast indexing.
*/ */
class PDOMFastIndexerTask extends PDOMIndexerTask { class PDOMFastIndexerTask extends PDOMIndexerTask {
public PDOMFastIndexerTask(PDOMFastIndexer indexer, ITranslationUnit[] added, public PDOMFastIndexerTask(PDOMFastIndexer indexer, ITranslationUnit[] added,
ITranslationUnit[] changed, ITranslationUnit[] removed) { ITranslationUnit[] changed, ITranslationUnit[] removed) {
super(added, changed, removed, indexer, true); super(added, changed, removed, indexer, true);

View file

@ -43,7 +43,7 @@ import org.eclipse.osgi.util.NLS;
*/ */
public class PDOMUpdateTask implements IPDOMIndexerTask { public class PDOMUpdateTask implements IPDOMIndexerTask {
protected static final String TRUE= String.valueOf(true); protected static final String TRUE= String.valueOf(true);
protected static final ITranslationUnit[] NO_TUS = new ITranslationUnit[0]; protected static final ITranslationUnit[] NO_TUS = {};
private final IPDOMIndexer fIndexer; private final IPDOMIndexer fIndexer;
private final IndexerProgress fProgress; private final IndexerProgress fProgress;
@ -89,7 +89,8 @@ public class PDOMUpdateTask implements IPDOMIndexerTask {
} }
} }
private void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException, InterruptedException { private void createDelegate(ICProject project, IProgressMonitor monitor)
throws CoreException, InterruptedException {
HashSet<ITranslationUnit> set= new HashSet<ITranslationUnit>(); HashSet<ITranslationUnit> set= new HashSet<ITranslationUnit>();
TranslationUnitCollector collector= new TranslationUnitCollector(set, set, monitor); TranslationUnitCollector collector= new TranslationUnitCollector(set, set, monitor);
boolean haveProject= false; boolean haveProject= false;

View file

@ -30,7 +30,7 @@ import org.eclipse.core.runtime.Path;
* Heuristics for picking up includes from the project * Heuristics for picking up includes from the project
*/ */
public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileResolutionHeuristics { public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileResolutionHeuristics {
private static final String TRUE = "true"; //$NON-NLS-1$ private static final String TRUE = String.valueOf(true);
private IProject fProject; private IProject fProject;
private IProject[] fProjects; private IProject[] fProjects;
@ -53,7 +53,6 @@ public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileRe
if (fProject == null) if (fProject == null)
return null; return null;
if (fProjects == null) { if (fProjects == null) {
if (fProject.isOpen()) { if (fProject.isOpen()) {
String val= IndexerPreferences.get(fProject, IndexerPreferences.KEY_INCLUDE_HEURISTICS, TRUE); String val= IndexerPreferences.get(fProject, IndexerPreferences.KEY_INCLUDE_HEURISTICS, TRUE);
@ -78,7 +77,6 @@ public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileRe
return bestLocation.toString(); return bestLocation.toString();
} }
private IResource selectBest(IFile[] files, char[] currentFullPath) { private IResource selectBest(IFile[] files, char[] currentFullPath) {
IFile best= files[0]; IFile best= files[0];
int bestScore= computeScore(best.getFullPath().toString().toCharArray(), currentFullPath); int bestScore= computeScore(best.getFullPath().toString().toCharArray(), currentFullPath);
@ -103,7 +101,7 @@ public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileRe
if (path1[i] == '/') if (path1[i] == '/')
match= i; match= i;
} }
// prefer shortest path with longest matches with // Prefer shortest path with longest matches with.
return (match << 16) - path1.length; return (match << 16) - path1.length;
} }

View file

@ -98,7 +98,6 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
class OpenDeclarationsJob extends Job implements ASTRunnable { class OpenDeclarationsJob extends Job implements ASTRunnable {
private enum NameKind { REFERENCE, DECLARATION, USING_DECL, DEFINITION } private enum NameKind { REFERENCE, DECLARATION, USING_DECL, DEFINITION }
private final SelectionParseAction fAction; private final SelectionParseAction fAction;