Skip to content

Commit 7d70d3e

Browse files
committed
rename localIncludes -> sourceDependencies
1 parent b979d29 commit 7d70d3e

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

src/attributes.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ namespace attributes {
375375
class SourceFileAttributesParser : public SourceFileAttributes {
376376
public:
377377
explicit SourceFileAttributesParser(const std::string& sourceFile,
378-
bool localIncludes);
378+
bool parseDependencies);
379379

380380
private:
381381
// prohibit copying
@@ -426,9 +426,9 @@ namespace attributes {
426426
return embeddedR_;
427427
}
428428

429-
// Get local includes
430-
const std::vector<FileInfo>& localIncludes() const {
431-
return localIncludes_;
429+
// Get source dependencies
430+
const std::vector<FileInfo>& sourceDependencies() const {
431+
return sourceDependencies_;
432432
};
433433

434434
private:
@@ -461,7 +461,7 @@ namespace attributes {
461461
std::vector<Attribute> attributes_;
462462
std::vector<std::string> modules_;
463463
std::vector<std::string> embeddedR_;
464-
std::vector<FileInfo> localIncludes_;
464+
std::vector<FileInfo> sourceDependencies_;
465465
std::vector<std::vector<std::string> > roxygenChunks_;
466466
std::vector<std::string> roxygenBuffer_;
467467
};
@@ -737,23 +737,23 @@ namespace attributes {
737737
}
738738
}
739739

740-
bool addUniqueInclude(Rcpp::CharacterVector include,
741-
std::vector<FileInfo>* pLocalIncludes) {
740+
bool addUniqueDependency(Rcpp::CharacterVector include,
741+
std::vector<FileInfo>* pDependencies) {
742742

743743
// return false if we already have this include
744744
std::string path = Rcpp::as<std::string>(include);
745-
for (size_t i = 0; i<pLocalIncludes->size(); ++i) {
746-
if (pLocalIncludes->at(i).path() == path)
745+
for (size_t i = 0; i<pDependencies->size(); ++i) {
746+
if (pDependencies->at(i).path() == path)
747747
return false;
748748
}
749749

750750
// add it and return true
751-
pLocalIncludes->push_back(FileInfo(path));
751+
pDependencies->push_back(FileInfo(path));
752752
return true;
753753
}
754754

755-
void parseLocalIncludes(const std::string& sourceFile,
756-
std::vector<FileInfo>* pLocalIncludes) {
755+
void parseSourceDependencies(const std::string& sourceFile,
756+
std::vector<FileInfo>* pDependencies) {
757757

758758
// import R functions
759759
Rcpp::Environment baseEnv = Rcpp::Environment::base_env();
@@ -782,7 +782,7 @@ namespace attributes {
782782

783783
// accumulate local includes (skip commented sections)
784784
CommentState commentState;
785-
std::vector<FileInfo> newIncludes;
785+
std::vector<FileInfo> newDependencies;
786786
for (int i = 0; i<matches.size(); i++) {
787787
std::string line = lines[i];
788788
commentState.submitLine(line);
@@ -797,28 +797,28 @@ namespace attributes {
797797
LogicalVector exists = fileExists(include);
798798
if (exists[0]) {
799799
include = normalizePath(include);
800-
if (addUniqueInclude(include, pLocalIncludes)) {
801-
newIncludes.push_back(
800+
if (addUniqueDependency(include, pDependencies)) {
801+
newDependencies.push_back(
802802
FileInfo(Rcpp::as<std::string>(include)));
803803
}
804804
}
805805
}
806806
}
807807
}
808808

809-
// look for includes recursively
810-
for (size_t i = 0; i<newIncludes.size(); i++) {
811-
FileInfo include = newIncludes[i];
812-
parseLocalIncludes(include.path(), pLocalIncludes);
809+
// look for dependencies recursively
810+
for (size_t i = 0; i<newDependencies.size(); i++) {
811+
FileInfo dependency = newDependencies[i];
812+
parseSourceDependencies(dependency.path(), pDependencies);
813813
}
814814
}
815815

816-
// parse the local includes from the passed lines
817-
std::vector<FileInfo> parseLocalIncludes(
816+
// parse the source dependencies from the passed lines
817+
std::vector<FileInfo> parseSourceDependencies(
818818
const std::string& sourceFile) {
819-
std::vector<FileInfo> localIncludes;
820-
parseLocalIncludes(sourceFile, &localIncludes);
821-
return localIncludes;
819+
std::vector<FileInfo> dependencies;
820+
parseSourceDependencies(sourceFile, &dependencies);
821+
return dependencies;
822822
}
823823

824824
// Parse embedded R code chunks from a file (receives the lines of the
@@ -993,7 +993,7 @@ namespace attributes {
993993
// Parse the attributes from a source file
994994
SourceFileAttributesParser::SourceFileAttributesParser(
995995
const std::string& sourceFile,
996-
bool localIncludes)
996+
bool parseDependencies)
997997
: sourceFile_(sourceFile)
998998
{
999999
// First read the entire file into a std::stringstream so we can check
@@ -1084,18 +1084,18 @@ namespace attributes {
10841084
// Parse embedded R
10851085
embeddedR_ = parseEmbeddedR(lines_, lines);
10861086

1087-
// Recursively parse local includes if requested
1088-
if (localIncludes) {
1087+
// Recursively parse dependencies if requested
1088+
if (parseDependencies) {
10891089

10901090
// get local includes
1091-
localIncludes_ = parseLocalIncludes(sourceFile);
1091+
sourceDependencies_ = parseSourceDependencies(sourceFile);
10921092

10931093
// parse attributes and modules from each local include
1094-
for (size_t i = 0; i<localIncludes_.size(); i++) {
1094+
for (size_t i = 0; i<sourceDependencies_.size(); i++) {
10951095

10961096
// perform parse
1097-
std::string include = localIncludes_[i].path();
1098-
SourceFileAttributesParser parser(include, false);
1097+
std::string dependency = sourceDependencies_[i].path();
1098+
SourceFileAttributesParser parser(dependency, false);
10991099

11001100
// copy to base attributes
11011101
std::copy(parser.begin(),
@@ -2730,10 +2730,10 @@ namespace {
27302730
if (!FileInfo(dynlibPath()).exists())
27312731
return true;
27322732

2733-
// variation in local includes means we're dirty
2734-
std::vector<FileInfo> localIncludes = parseLocalIncludes(
2733+
// variation in source dependencies means we're dirty
2734+
std::vector<FileInfo> sourceDependencies = parseSourceDependencies(
27352735
cppSourcePath_);
2736-
if (localIncludes != localIncludes_)
2736+
if (sourceDependencies != sourceDependencies_)
27372737
return true;
27382738

27392739
// not dirty
@@ -2814,8 +2814,8 @@ namespace {
28142814
// capture embededded R
28152815
embeddedR_ = sourceAttributes.embeddedR();
28162816

2817-
// capture local includes
2818-
localIncludes_ = sourceAttributes.localIncludes();
2817+
// capture source dependencies
2818+
sourceDependencies_ = sourceAttributes.sourceDependencies();
28192819
}
28202820

28212821
const std::string& contextId() const {
@@ -2945,7 +2945,7 @@ namespace {
29452945
std::vector<std::string> depends_;
29462946
std::vector<std::string> plugins_;
29472947
std::vector<std::string> embeddedR_;
2948-
std::vector<FileInfo> localIncludes_;
2948+
std::vector<FileInfo> sourceDependencies_;
29492949
};
29502950

29512951
// Dynlib cache that allows lookup by either file path or code contents

0 commit comments

Comments
 (0)