Commit 844a031c authored by Vladislav Belov's avatar Vladislav Belov Committed by Commit Bot

[GN] Remove a duplication of a source type check

There was a duplication of the source type checking. It may lead
errors when a type set will be changed for a language.

R=dpranke@chromium.org

Bug: None
Change-Id: Ieab8885899446e625cfe20c1650418a085b937ee
Reviewed-on: https://chromium-review.googlesource.com/702414Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506763}
parent e5af3c18
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "tools/gn/filesystem_utils.h" #include "tools/gn/filesystem_utils.h"
#include "tools/gn/source_file.h"
#include "tools/gn/source_file_type.h"
// Helper methods ------------------------------------------------------------- // Helper methods -------------------------------------------------------------
...@@ -153,9 +155,10 @@ bool HasExplicitFileType(const base::StringPiece& ext) { ...@@ -153,9 +155,10 @@ bool HasExplicitFileType(const base::StringPiece& ext) {
return ext == "dart"; return ext == "dart";
} }
bool IsSourceFileForIndexing(const base::StringPiece& ext) { bool IsSourceFileForIndexing(const SourceFile& src) {
return ext == "c" || ext == "cc" || ext == "cpp" || ext == "cxx" || const SourceFileType type = GetSourceFileType(src);
ext == "m" || ext == "mm"; return type == SOURCE_C || type == SOURCE_CPP || type == SOURCE_M ||
type == SOURCE_MM;
} }
void PrintValue(std::ostream& out, IndentRules rules, unsigned value) { void PrintValue(std::ostream& out, IndentRules rules, unsigned value) {
...@@ -692,8 +695,7 @@ void PBXProject::AddSourceFile(const std::string& navigator_path, ...@@ -692,8 +695,7 @@ void PBXProject::AddSourceFile(const std::string& navigator_path,
PBXNativeTarget* target) { PBXNativeTarget* target) {
PBXFileReference* file_reference = PBXFileReference* file_reference =
sources_->AddSourceFile(navigator_path, source_path); sources_->AddSourceFile(navigator_path, source_path);
base::StringPiece ext = FindExtension(&source_path); if (!IsSourceFileForIndexing(SourceFile(source_path)))
if (!IsSourceFileForIndexing(ext))
return; return;
DCHECK(target); DCHECK(target);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment