diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java index 60809769641..278a16667f1 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java @@ -133,7 +133,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang /** * Set of elements which are out of sync with their buffers. */ - protected Map elementsOutOfSynchWithBuffers = new HashMap(11); + protected Map elementsOutOfSynchWithBuffers = new HashMap(11); /* * Temporary cache of newly opened elements @@ -378,11 +378,11 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang if (bin.getType() == IBinaryFile.ARCHIVE) { ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer(); - celement = new Archive(cfolder, file, (IBinaryArchive)bin); + celement = new Archive(cfolder, file, (IBinaryArchive) bin); vlib.addChild(celement); } else { BinaryContainer vbin = (BinaryContainer)cproject.getBinaryContainer(); - celement = new Binary(cfolder, file, (IBinaryObject)bin); + celement = new Binary(cfolder, file, (IBinaryObject) bin); vbin.addChild(celement); } } @@ -421,7 +421,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang } 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. if (contentTypeId != null && path.toFile().exists()) { // TODO: use URI @@ -470,41 +470,42 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang IFileStore fileStore = null; try { fileStore = EFS.getStore(locationURI); - } catch (CoreException e1) { - CCorePlugin.log(e1); + } catch (CoreException e) { + CCorePlugin.log(e); return null; } final String contentTypeId = CoreModel.getRegistedContentTypeId(project, fileStore.getName()); - if (!Util.isNonZeroLengthFile(locationURI)) { - return null; - } + if (!Util.isNonZeroLengthFile(locationURI)) { + return null; + } - try { - IIncludeReference[] includeReferences = cproject.getIncludeReferences(); - for (IIncludeReference includeReference : includeReferences) { - // crecoskie - // TODO FIXME: include entries don't handle URIs yet - IPath path = URIUtil.toPath(locationURI); - if (path != null && includeReference.isOnIncludeEntry(path)) { - String headerContentTypeId= contentTypeId; - if (headerContentTypeId == null) { - headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER; - } - - return new ExternalTranslationUnit(includeReference, locationURI, headerContentTypeId); + try { + IIncludeReference[] includeReferences = cproject.getIncludeReferences(); + for (IIncludeReference includeReference : includeReferences) { + // crecoskie + // TODO FIXME: include entries don't handle URIs yet + IPath path = URIUtil.toPath(locationURI); + if (path != null && includeReference.isOnIncludeEntry(path)) { + String headerContentTypeId= contentTypeId; + if (headerContentTypeId == null) { + headerContentTypeId= CoreModel.hasCCNature(project) ? + CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER; } + + return new ExternalTranslationUnit(includeReference, locationURI, headerContentTypeId); } - } catch (CModelException e) { } + } catch (CModelException e) { + } - // if the file exists and it has a known C/C++ file extension then just create - // an external translation unit for it. - IFileInfo info = fileStore.fetchInfo(); + // if the file exists and it has a known C/C++ file extension then just create + // an external translation unit for it. + IFileInfo info = fileStore.fetchInfo(); - if (contentTypeId != null && info != null && info.exists()) { - return new ExternalTranslationUnit(cproject, locationURI, contentTypeId); - } + if (contentTypeId != null && info != null && info.exists()) { + return new ExternalTranslationUnit(cproject, locationURI, contentTypeId); + } return null; } @@ -663,11 +664,11 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang } URI fileUri = file.getLocationURI(); - //Avoid name special devices, empty files and the like + // Avoid name special devices, empty files and the like if (!Util.isNonZeroLengthFile(fileUri)) { // PR:xxx the EFS does not seem to work for newly created file // so before bailing out give another try? - //Avoid name special devices, empty files and the like + // Avoid name special devices, empty files and the like if("file".equals(fileUri.getScheme())) { //$NON-NLS-1$ File f = new File(fileUri); if (f.length() == 0) { @@ -770,14 +771,14 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang runner = binaryRunners.get(project); } 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); synchronized (binaryRunners) { if (binaryRunners.get(project) == null) { binaryRunners.put(project, runner); runner.start(); } else { - // another thread was faster + // Another thread was faster runner = binaryRunners.get(project); } } @@ -920,12 +921,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang } } if ((flags & ICDescriptionDelta.EXT_REF) != 0) { - // update binary parsers + // Update binary parsers IProject project = newDes.getProject(); try { ICConfigExtensionReference[] newExts = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project); BinaryParserConfig[] currentConfigs = binaryParsersMap.get(project); - // anything added/removed + // Anything added/removed if (currentConfigs != null) { if (newExts.length != currentConfigs.length) { resetBinaryParser(project); @@ -959,9 +960,6 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang return null; } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeListener#contentTypeChanged() - */ @Override public void contentTypeChanged(ContentTypeChangeEvent event) { ContentTypeProcessor.processContentTypeChanges(new ContentTypeChangeEvent[]{ event }); @@ -1048,7 +1046,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang System.out.println(deltaToNotify == null ? "" : deltaToNotify.toString()); //$NON-NLS-1$ } 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.flush(); notifyListeners(deltaToNotify, ElementChangedEvent.POST_CHANGE, listeners, listenerMask, listenerCount); } @@ -1061,7 +1059,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang System.out.println(deltaToNotify == null ? "" : deltaToNotify.toString()); //$NON-NLS-1$ } 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(); 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, int[] listenerMask, int listenerCount) { - // post change deltas + // Post change deltas if (Util.VERBOSE_DELTA) { System.out.println("FIRING POST_SHIFT event [" + Thread.currentThread() + "]:"); //$NON-NLS-1$//$NON-NLS-2$ System.out.println(deltaToNotify == null ? "" : 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$ 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() { @Override public void handleException(Throwable exception) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ExternalTranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ExternalTranslationUnit.java index 60cad88f9f6..30cd5dc8129 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ExternalTranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ExternalTranslationUnit.java @@ -10,7 +10,6 @@ * Anton Leherbauer (Wind River Systems) * Warren Paul (Nokia) - Bug 218266 *******************************************************************************/ - package org.eclipse.cdt.internal.core.model; import java.net.URI; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerUtility.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerUtility.java index 28e6eb48ac5..6afddc421c7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerUtility.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerUtility.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation + * IBM Rational Software - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; @@ -14,10 +14,8 @@ import java.io.File; /** * @author jcamelon - * */ public class ScannerUtility { - static final char DOT = '.'; static final char SLASH = '/'; static final char BSLASH = '\\'; @@ -68,8 +66,7 @@ public class ScannerUtility { } } - - for (int i=0; i0) + // No separator before, not a 1st string symbol. + if (noSepBefore && j > 0) { aus[j++] = c; - else { // separator before "." ! + } else { // Separator before "." if (i < len1) { - c = ein[i+1]; // check for next symbol - // check for "/./" case + c = ein[i + 1]; // Check for next symbol + // Check for "/./" case if (c == SLASH || c == BSLASH) { - // write nothing to output - // skip the next symbol + // Write nothing to output, skip the next symbol i++; noSepBefore = false; - } - // symbol other than "." - write it also - else if (c != DOT) { + } else { // Process as usual i++; noSepBefore = true; aus[j++] = DOT; aus[j++] = c; } - // Processed as usual - else { - i++; - noSepBefore = true; - aus[j++] = DOT; - aus[j++] = DOT; - } - } else - {} // do nothing when "." is last symbol + } } break; default: @@ -125,10 +111,10 @@ public class ScannerUtility { /** * @param path - include path * @param fileName - include file name - * @return - reconsiled path + * @return - reconciled path */ public static String createReconciledPath(String path, String fileName) { boolean pathEmpty = (path == null || path.length() == 0); - return (pathEmpty ? fileName : reconcilePath(path + File.separatorChar + fileName)); + return pathEmpty ? fileName : reconcilePath(path + File.separatorChar + fileName); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java index a67dc06a458..8a15c8298a1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java @@ -307,6 +307,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { private final LinkedList fUrgentTasks; boolean fTaskCompleted; private IndexerProgress fInfo= new IndexerProgress(); + public AbstractIndexerTask(Object[] filesToUpdate, Object[] filesToRemove, IndexerInputAdapter resolver, boolean fastIndexer) { super(resolver); @@ -384,6 +385,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { protected abstract IWritableIndex createIndex(); protected abstract IIncludeFileResolutionHeuristics createIncludeHeuristics(); protected abstract IncludeFileContentProvider createReaderFactory(); + protected ITodoTaskUpdater createTodoTaskUpdater() { return null; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMFastIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMFastIndexerTask.java index 5f7eaf90272..6058d285666 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMFastIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMFastIndexerTask.java @@ -6,10 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation - * Markus Schorn (Wind River Systems) + * QNX - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.core.pdom.indexer; 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. */ class PDOMFastIndexerTask extends PDOMIndexerTask { + public PDOMFastIndexerTask(PDOMFastIndexer indexer, ITranslationUnit[] added, ITranslationUnit[] changed, ITranslationUnit[] removed) { super(added, changed, removed, indexer, true); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java index 3cf21f99917..349ea0fde3f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java @@ -43,7 +43,7 @@ import org.eclipse.osgi.util.NLS; */ public class PDOMUpdateTask implements IPDOMIndexerTask { 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 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 set= new HashSet(); TranslationUnitCollector collector= new TranslationUnitCollector(set, set, monitor); boolean haveProject= false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerIncludeResolutionHeuristics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerIncludeResolutionHeuristics.java index a16957cfc7e..7f86c02366a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerIncludeResolutionHeuristics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerIncludeResolutionHeuristics.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.indexer; @@ -30,7 +30,7 @@ import org.eclipse.core.runtime.Path; * Heuristics for picking up includes from the project */ 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[] fProjects; @@ -52,8 +52,7 @@ public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileRe if (fProject == null) return null; - - + if (fProjects == null) { if (fProject.isOpen()) { String val= IndexerPreferences.get(fProject, IndexerPreferences.KEY_INCLUDE_HEURISTICS, TRUE); @@ -77,8 +76,7 @@ public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileRe return bestLocation.toString(); } - - + private IResource selectBest(IFile[] files, char[] currentFullPath) { IFile best= files[0]; int bestScore= computeScore(best.getFullPath().toString().toCharArray(), currentFullPath); @@ -96,14 +94,14 @@ public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileRe private int computeScore(char[] path1, char[] path2) { final int limit= Math.min(path1.length, path2.length); - int match=0; + int match= 0; for (int i = 0; i < limit; i++) { if (path1[i] != path2[i]) break; if (path1[i] == '/') match= i; } - // prefer shortest path with longest matches with + // Prefer shortest path with longest matches with. return (match << 16) - path1.length; } @@ -115,7 +113,7 @@ public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileRe List projectsToSearch= new ArrayList(); projectsToSearch.add(prj); - for (int i=0; i