1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Leave the indexer alone it is dependent on those

file extensions.  TODO remove later.
This commit is contained in:
Alain Magloire 2004-04-30 00:21:48 +00:00
parent 87257e4718
commit 7b5b147d8d
3 changed files with 36 additions and 4 deletions

View file

@ -21,7 +21,7 @@ import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
@ -371,7 +371,31 @@ public class Util {
* @return
*/
public static boolean isCCFileName(String fileName) {
return CoreModel.isValidTranslationUnitName(fileName);
String[] sourceExtensions = CModelManager.sourceExtensions;
String[] headerExtensions = CModelManager.headerExtensions;
int dot =fileName.lastIndexOf("."); //$NON-NLS-1$
//No extension, give benefit of doubt
if (dot == -1)
return true;
//Extract extension
String extension = ""; //$NON-NLS-1$
if (dot + 1 <= fileName.length())
extension = fileName.substring(dot + 1);
for (int i=0; i<sourceExtensions.length; i++){
if (sourceExtensions[i].equals(extension))
return true;
}
for (int i=0; i<headerExtensions.length; i++){
if (headerExtensions[i].equals(extension))
return true;
}
return false;
}
}

View file

@ -34,6 +34,7 @@ import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.index.IDocument;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.cdt.utils.TimeOut;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@ -75,7 +76,7 @@ public class SourceIndexer extends AbstractIndexer {
* Returns the file types the <code>IIndexer</code> handles.
*/
public String[] getFileTypes(){
return CoreModel.getDefault().getSourceExtensions();
return CModelManager.sourceExtensions;
}
protected void indexFile(IDocument document) throws IOException {
@ -97,7 +98,7 @@ public class SourceIndexer extends AbstractIndexer {
}
//C or CPP?
ParserLanguage language = CoreModel.hasCCNature(currentProject) ? ParserLanguage.CPP : ParserLanguage.C;
ParserLanguage language = CoreModel.getDefault().hasCCNature(currentProject) ? ParserLanguage.CPP : ParserLanguage.C;
IParser parser = null;

View file

@ -131,6 +131,13 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
* The lis of the SourceMappers on projects.
*/
private HashMap sourceMappers = new HashMap();
// TODO: This should be in a preference/property page
public static final String [] sourceExtensions = {"c", "cxx", "cc", "C", "cpp"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
public static final String [] headerExtensions = {"h", "hh", "hpp", "H"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
public static final String [] assemblyExtensions = {"s", "S"}; //$NON-NLS-1$ //$NON-NLS-2$
public static final IWorkingCopy[] NoWorkingCopy = new IWorkingCopy[0];