mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Leave the indexer alone it is dependent on those
file extensions. TODO remove later.
This commit is contained in:
parent
87257e4718
commit
7b5b147d8d
3 changed files with 36 additions and 4 deletions
|
@ -21,7 +21,7 @@ import java.util.Locale;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.ResourceBundle;
|
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.IContainer;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -371,7 +371,31 @@ public class Util {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isCCFileName(String fileName) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.index.IDocument;
|
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.cdt.utils.TimeOut;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -75,7 +76,7 @@ public class SourceIndexer extends AbstractIndexer {
|
||||||
* Returns the file types the <code>IIndexer</code> handles.
|
* Returns the file types the <code>IIndexer</code> handles.
|
||||||
*/
|
*/
|
||||||
public String[] getFileTypes(){
|
public String[] getFileTypes(){
|
||||||
return CoreModel.getDefault().getSourceExtensions();
|
return CModelManager.sourceExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void indexFile(IDocument document) throws IOException {
|
protected void indexFile(IDocument document) throws IOException {
|
||||||
|
@ -97,7 +98,7 @@ public class SourceIndexer extends AbstractIndexer {
|
||||||
}
|
}
|
||||||
|
|
||||||
//C or CPP?
|
//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;
|
IParser parser = null;
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,13 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
* The lis of the SourceMappers on projects.
|
* The lis of the SourceMappers on projects.
|
||||||
*/
|
*/
|
||||||
private HashMap sourceMappers = new HashMap();
|
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];
|
public static final IWorkingCopy[] NoWorkingCopy = new IWorkingCopy[0];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue