Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDeltaBuilder.java12
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java4
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/IStandaloneScannerInfoProvider.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexer.java41
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerInputAdapter.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerTask.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java15
9 files changed, 108 insertions, 32 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDeltaBuilder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDeltaBuilder.java
index bb7451b9085..53f1fffc8f2 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDeltaBuilder.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDeltaBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2008 IBM Corporation and others.
+ * Copyright (c) 2002, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,7 +21,7 @@ import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.IParent;
/**
- * A C element delta biulder creates a C element delta on a C element between
+ * A C element delta builder creates a C element delta on a C element between
* the version of the C element at the time the comparator was created and the
* current version of the C element.
*
@@ -391,5 +391,13 @@ private void trimDelta(CElementDelta delta) {
}
}
}
+
+/**
+ * Get the change delta built by the builder.
+ * @return the change delta built by the builder.
+ */
+public CElementDelta getDelta() {
+ return delta;
+}
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java
index bc590b6bb09..3c59d3a0b0e 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,7 +22,7 @@ import org.eclipse.core.resources.IResource;
* Holds cached structure and properties for a C element.
* Subclassed to carry properties for specific kinds of elements.
*/
-class CElementInfo {
+public class CElementInfo {
/**
* Shared empty collection used for efficiency.
*/
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 24a55d72816..e98d47d060d 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -648,18 +648,22 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
}
+ URI fileUri = file.getLocationURI();
//Avoid name special devices, empty files and the like
- if (! Util.isNonZeroLengthFile(file.getLocationURI())) {
+ 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
- File f = new File(file.getLocationURI());
- if (f.length() == 0) {
- return null;
+ if("file".equals(fileUri.getScheme())) { //$NON-NLS-1$
+ File f = new File(fileUri);
+ if (f.length() == 0) {
+ return null;
+ }
}
//return null;
}
+
int hints = 0;
for (BinaryParserConfig parser2 : parsers) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/IStandaloneScannerInfoProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/IStandaloneScannerInfoProvider.java
index 0e33a448c19..b8804ced584 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/IStandaloneScannerInfoProvider.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/IStandaloneScannerInfoProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,8 +15,6 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
/**
- * Returns a IScannerInfo for the given file by a path.
- *
* Similar to IScannerInfoProvider but computes the IScannerInfo
* based on a String path instead of IResource.
*
@@ -24,5 +22,20 @@ import org.eclipse.cdt.core.parser.IScannerInfoProvider;
*/
public interface IStandaloneScannerInfoProvider {
+ /**
+ * Returns an IScannerInfo for the given file path,
+ * or an empty IScannerInfo object if the file path is invalid.
+ */
IScannerInfo getScannerInformation(String path);
+
+ /**
+ * Returns an IScannerInfo when you don't necessary have access to a path.
+ *
+ * This is used by the "parse up front" feature. Since we are parsing
+ * files outside of the project a "default" IScannerInfo object
+ * is needed to get the minimal amount of available info in order
+ * to parse the file.
+ * @param linkageID
+ */
+ IScannerInfo getDefaultScannerInformation(int linkageID);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexer.java
index c7faec4f8fd..cc33da2f75d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.IParserLogService;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.internal.core.index.IWritableIndex;
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
+import org.eclipse.cdt.internal.core.pdom.PDOMWriter;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -47,17 +48,17 @@ public abstract class StandaloneIndexer {
/**
* Parser should not skip any references.
*/
- public static final int SKIP_NO_REFERENCES= 0;
+ public static final int SKIP_NO_REFERENCES = PDOMWriter.SKIP_NO_REFERENCES;
/**
* Parser to skip all references.
*/
- public static final int SKIP_ALL_REFERENCES= 1;
+ public static final int SKIP_ALL_REFERENCES = PDOMWriter.SKIP_ALL_REFERENCES;
/**
- * Parser to skp type references.
+ * Parser to skip type references.
*/
- public static final int SKIP_TYPE_REFERENCES= 2;
+ public static final int SKIP_TYPE_REFERENCES = PDOMWriter.SKIP_TYPE_REFERENCES;
/**
* Constant for indicating to update all translation units.
@@ -98,6 +99,7 @@ public abstract class StandaloneIndexer {
* be provided, but not both. If a single IScannerInfo object is provided
* it will always be used. Otherwise the provider will be used.
*/
+ @Deprecated
protected IScannerInfo fScanner;
/**
@@ -158,6 +160,10 @@ public abstract class StandaloneIndexer {
}
};
+ /**
+ * @deprecated Its better to provide a scanner info provider instead.
+ */
+ @Deprecated
public StandaloneIndexer(IWritableIndex index, boolean indexAllFiles,
ILanguageMapper mapper, IParserLogService log, IScannerInfo scanner) {
fIndex = index;
@@ -202,6 +208,13 @@ public abstract class StandaloneIndexer {
}
/**
+ * If true then all files will be indexed.
+ */
+ public void setIndexAllFiles(boolean indexAllFiles) {
+ fIndexAllFiles = indexAllFiles;
+ }
+
+ /**
* Returns the collection of valid file extensions for C/C++ source.
*/
public Set<String> getValidSourceUnitNames() {
@@ -217,7 +230,10 @@ public abstract class StandaloneIndexer {
/**
* Returns the IScannerInfo that provides include paths and defined symbols.
+ * @deprecated Should probably be using a IStandaloneScannerInfoProvider instead and
+ * calling getScannerInfo(String).
*/
+ @Deprecated
public IScannerInfo getScannerInfo() {
return fScanner;
}
@@ -235,7 +251,14 @@ public abstract class StandaloneIndexer {
return fScannerInfoProvider.getScannerInformation(path);
}
-
+
+
+ /**
+ * Returns the IStandaloneScannerInfoProvider or null if one was not provided.
+ */
+ public IStandaloneScannerInfoProvider getScannerInfoProvider() {
+ return fScannerInfoProvider;
+ }
/**
* Returns the ILanguageMapper that determines the ILanguage for a file.
@@ -244,6 +267,11 @@ public abstract class StandaloneIndexer {
return fMapper;
}
+
+ public void setLanguageMapper(ILanguageMapper mapper) {
+ fMapper = mapper;
+ }
+
/**
* Returns the logger.
*/
@@ -350,6 +378,7 @@ public abstract class StandaloneIndexer {
clearIndex();
fDelegate= createTask(getFilesAdded(tus), NO_TUS, NO_TUS);
fDelegate.setUpdateFlags(fUpdateOptions);
+ fDelegate.setParseUpFront();
if (fDelegate != null) {
fDelegate.run(monitor);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerInputAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerInputAdapter.java
index 63dd9d9c41a..2ed9eebdb92 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerInputAdapter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerInputAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
+ * IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.core.indexer;
@@ -21,6 +22,7 @@ import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.internal.core.index.IndexFileLocation;
import org.eclipse.cdt.internal.core.pdom.IndexerInputAdapter;
+import org.eclipse.cdt.internal.core.pdom.indexer.FileExistsCache;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -30,8 +32,9 @@ import org.eclipse.core.runtime.Path;
* @since 5.0
*/
public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
- private HashMap<String, IIndexFileLocation> fIflCache= new HashMap<String, IIndexFileLocation>();
-
+ private final HashMap<String, IIndexFileLocation> fIflCache= new HashMap<String, IIndexFileLocation>();
+ private final FileExistsCache fExistsCache = new FileExistsCache();
+
private final StandaloneIndexer fIndexer;
public StandaloneIndexerInputAdapter(StandaloneIndexer indexer) {
@@ -82,11 +85,14 @@ public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
@Override
public boolean doesIncludeFileExist(String includePath) {
- return new File(includePath).isFile();
+ return fExistsCache.isFile(includePath);
}
@Override
public IIndexFileLocation resolveIncludeFile(String includePath) {
+ if (!fExistsCache.isFile(includePath)) {
+ return null;
+ }
IIndexFileLocation result= fIflCache.get(includePath);
if (result == null) {
File file= new File(includePath);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerTask.java
index f5dab80fbbe..14d22104568 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerTask.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/StandaloneIndexerTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.model.AbstractLanguage;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.IParserLogService;
+import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.internal.core.index.IWritableIndex;
import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask;
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
@@ -224,6 +225,20 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
getLogService().traceLog(s.getMessage());
}
+ @SuppressWarnings("deprecation")
+ @Override
+ protected IScannerInfo createDefaultScannerConfig(int linkageID) {
+ IStandaloneScannerInfoProvider provider = fIndexer.getScannerInfoProvider();
+ if(provider != null)
+ return provider.getDefaultScannerInformation(linkageID);
+
+ IScannerInfo scannerInfo = fIndexer.getScannerInfo();
+ if(scannerInfo != null)
+ return scannerInfo;
+
+ return super.createDefaultScannerConfig(linkageID);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask#getLinkagesToParse()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java
index 9935492a676..78f06b54d48 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -84,7 +84,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
protected Control createContents(Composite parent) {
IFile file = getFile();
IProject project = file.getProject();
- fContentType = CContentTypes.getContentType(project, file.getLocation().toString());
+ fContentType = CContentTypes.getContentType(project, file.getName());
fContents = new Composite(parent, SWT.NONE);
fContents.setLayout(new GridLayout(2, false));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java
index 31b5f564767..b85c420964d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 QNX Software Systems and others.
+ * Copyright (c) 2004, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -502,8 +502,8 @@ public class NewClassCodeGenerator {
ICProject cProject = headerTU.getCProject();
IProject project = cProject.getProject();
- IPath projectLocation = project.getLocation();
- IPath headerLocation = headerTU.getResource().getLocation();
+ IPath projectLocation = new Path(project.getLocationURI().getPath());
+ IPath headerLocation = new Path(headerTU.getResource().getLocationURI().getPath());
List<IPath> includePaths = getIncludePaths(headerTU);
List<IPath> baseClassPaths = getBaseClassPaths(verifyBaseClasses());
@@ -610,7 +610,7 @@ public class NewClassCodeGenerator {
ICProject includeProject = PathUtil.getEnclosingProject(folderToAdd);
if (includeProject != null) {
// make sure that the include is made the same way that build properties for projects makes them, so .contains below is a valid check
- IIncludeEntry entry = CoreModel.newIncludeEntry(addToResourcePath, null, includeProject.getProject().getLocation(), true);
+ IIncludeEntry entry = CoreModel.newIncludeEntry(addToResourcePath, null, new Path(includeProject.getProject().getLocationURI().getPath()), true);
if (!checkEntryList.contains(entry)) // if the path already exists in the #includes then don't add it
pathEntryList.add(entry);
@@ -803,9 +803,10 @@ public class NewClassCodeGenerator {
private String getHeaderIncludeString(ITranslationUnit sourceTU, ITranslationUnit headerTU, StringBuffer text, IProgressMonitor monitor) {
IProject project = headerTU.getCProject().getProject();
- IPath projectLocation = project.getLocation();
- IPath headerLocation = headerTU.getResource().getLocation();
- IPath sourceLocation = sourceTU.getResource().getLocation();
+
+ IPath projectLocation = new Path(project.getLocationURI().getPath());
+ IPath headerLocation = new Path(headerTU.getResource().getLocationURI().getPath());
+ IPath sourceLocation = new Path(sourceTU.getResource().getLocationURI().getPath());
IPath includePath = PathUtil.makeRelativePathToProjectIncludes(headerLocation, project);
boolean isSystemIncludePath = false;

Back to the top