mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 04:35:45 +02:00
Partial fix/adjustment for Bug 91530 - FileTypeResolver reports a C++ header file as a C file.
InternalASTServiceProvider#getTranslationUnit() now assumes that a header file is a C++ file.
This commit is contained in:
parent
241c3fcffe
commit
dbb59673ce
1 changed files with 9 additions and 19 deletions
|
@ -10,7 +10,6 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCProjectNature;
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IASTServiceProvider;
|
import org.eclipse.cdt.core.dom.IASTServiceProvider;
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
|
@ -44,7 +43,6 @@ import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfigurat
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -230,22 +228,14 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
{
|
{
|
||||||
IProject project = resource.getProject();
|
IProject project = resource.getProject();
|
||||||
ICFileType type = CCorePlugin.getDefault().getFileType(project, resource.getLocation().lastSegment());
|
ICFileType type = CCorePlugin.getDefault().getFileType(project, resource.getLocation().lastSegment());
|
||||||
String lid = type.getLanguage().getId();
|
boolean isHeader= type.isHeader();
|
||||||
try {
|
if( isHeader )
|
||||||
if( lid != null ) {
|
return ParserLanguage.CPP; // assumption
|
||||||
if( lid.equals(ICFileTypeConstants.LANG_C )) {
|
String lid = type.getLanguage().getId();
|
||||||
if (type.isHeader() && project.hasNature(CCProjectNature.CC_NATURE_ID))
|
if( lid.equals(ICFileTypeConstants.LANG_CXX))
|
||||||
return ParserLanguage.CPP;
|
return ParserLanguage.CPP;
|
||||||
else
|
if( lid.equals( ICFileTypeConstants.LANG_C ) )
|
||||||
return ParserLanguage.C;
|
return ParserLanguage.C;
|
||||||
} else if( lid.equals(ICFileTypeConstants.LANG_CXX))
|
return ParserLanguage.CPP;
|
||||||
return ParserLanguage.CPP;
|
|
||||||
} else if( project.hasNature( CCProjectNature.CC_NATURE_ID ))
|
|
||||||
return ParserLanguage.CPP;
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actually, it probably isn't a C file, but anyway...
|
|
||||||
return ParserLanguage.C;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue