Skip to content

Commit d319552

Browse files
authored
Merge pull request #203 from ahoppen/remove-symbol-provider-for-url-api
Revert "Allow retrieval of the symbol provider kind for a source file"
2 parents 43926f9 + c33d0a3 commit d319552

File tree

7 files changed

+7
-76
lines changed

7 files changed

+7
-76
lines changed

Sources/IndexStoreDB/IndexStoreDB.swift

+1-29
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@ public enum SymbolProviderKind {
4040
case clang
4141
case swift
4242

43-
init?(_ cKind: indexstoredb_symbol_provider_kind_t) {
43+
init(_ cKind: indexstoredb_symbol_provider_kind_t) {
4444
switch cKind {
4545
case INDEXSTOREDB_SYMBOL_PROVIDER_KIND_SWIFT:
4646
self = .swift
4747
case INDEXSTOREDB_SYMBOL_PROVIDER_KIND_CLANG:
4848
self = .clang
49-
case INDEXSTOREDB_SYMBOL_PROVIDER_KIND_UNKNOWN:
50-
return nil
5149
default:
5250
preconditionFailure("Unknown enum case in indexstoredb_symbol_provider_kind_t")
5351
}
@@ -313,32 +311,6 @@ public final class IndexStoreDB {
313311
}
314312
return result
315313
}
316-
317-
public func symbolProvider(for sourceFilePath: String) -> SymbolProviderKind? {
318-
var result: SymbolProviderKind? = nil
319-
indexstoredb_index_units_containing_file(impl, sourceFilePath) { unit in
320-
let providerKind = SymbolProviderKind(indexstoredb_unit_info_symbol_provider_kind(unit))
321-
322-
let mainFilePath = String(cString: indexstoredb_unit_info_main_file_path(unit))
323-
if providerKind == .swift && mainFilePath != sourceFilePath {
324-
// We have a unit that is "included" from Swift. This happens for header
325-
// files that Swift files depend on. But Swift doesn't have includes and
326-
// we shouldn't infer the header file's language to Swift based on this unit.
327-
// Ignore it.
328-
return true
329-
}
330-
331-
if result == nil {
332-
result = providerKind
333-
} else if result != providerKind {
334-
// Found two conflicting provider kinds. Return nil as we don't know the provider in this case.
335-
result = nil
336-
return false
337-
}
338-
return true
339-
}
340-
return result
341-
}
342314

343315
@discardableResult
344316
public func foreachFileIncludedByFile(path: String, body: (String) -> Bool) -> Bool {

Sources/IndexStoreDB/SymbolOccurrence.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ extension SymbolOccurrence {
7474
symbol: Symbol(indexstoredb_symbol_occurrence_symbol(value)),
7575
location: SymbolLocation(indexstoredb_symbol_occurrence_location(value)),
7676
roles: SymbolRole(rawValue: indexstoredb_symbol_occurrence_roles(value)),
77-
// Force unwrap is OK because `indexstoredb_symbol_occurrence_symbol_provider_kind` never returns `INDEXSTOREDB_SYMBOL_PROVIDER_KIND_UNKNOWN`
78-
symbolProvider: SymbolProviderKind(indexstoredb_symbol_occurrence_symbol_provider_kind(value))!,
77+
symbolProvider: SymbolProviderKind(indexstoredb_symbol_occurrence_symbol_provider_kind(value)),
7978
relations: relations)
8079
}
8180
}

include/CIndexStoreDB/CIndexStoreDB.h

-3
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,6 @@ indexstoredb_unit_info_main_file_path(_Nonnull indexstoredb_unit_info_t);
498498
INDEXSTOREDB_PUBLIC const char *_Nonnull
499499
indexstoredb_unit_info_unit_name(_Nonnull indexstoredb_unit_info_t);
500500

501-
INDEXSTOREDB_PUBLIC indexstoredb_symbol_provider_kind_t
502-
indexstoredb_unit_info_symbol_provider_kind(_Nonnull indexstoredb_unit_info_t info);
503-
504501
/// Iterates over the compilation units that contain \p path and return their units.
505502
///
506503
/// This can be used to find information for units that include a given header.

include/IndexStoreDB/Index/StoreUnitInfo.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#ifndef INDEXSTOREDB_INDEX_STOREUNITINFO_H
1414
#define INDEXSTOREDB_INDEX_STOREUNITINFO_H
1515

16-
#include "IndexStoreDB/Core/Symbol.h"
1716
#include "IndexStoreDB/Support/Path.h"
1817
#include "llvm/Support/Chrono.h"
1918
#include <string>
@@ -27,18 +26,16 @@ struct StoreUnitInfo {
2726
std::string OutFileIdentifier;
2827
bool HasTestSymbols = false;
2928
llvm::sys::TimePoint<> ModTime;
30-
Optional<SymbolProviderKind> SymProviderKind;
3129

3230
StoreUnitInfo() = default;
3331
StoreUnitInfo(std::string unitName, CanonicalFilePath mainFilePath,
3432
StringRef outFileIdentifier, bool hasTestSymbols,
35-
llvm::sys::TimePoint<> modTime,
36-
Optional<SymbolProviderKind> SymProviderKind)
33+
llvm::sys::TimePoint<> modTime)
3734
: UnitName(unitName),
3835
MainFilePath(mainFilePath),
3936
OutFileIdentifier(outFileIdentifier),
4037
HasTestSymbols(hasTestSymbols),
41-
ModTime(modTime), SymProviderKind(SymProviderKind) {}
38+
ModTime(modTime) {}
4239
};
4340

4441
} // namespace index

lib/CIndexStoreDB/CIndexStoreDB.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -589,20 +589,6 @@ indexstoredb_unit_info_unit_name(indexstoredb_unit_info_t info) {
589589
return obj->UnitName.c_str();
590590
}
591591

592-
indexstoredb_symbol_provider_kind_t
593-
indexstoredb_unit_info_symbol_provider_kind(_Nonnull indexstoredb_unit_info_t info) {
594-
auto obj = (const StoreUnitInfo *)info;
595-
if (!obj->SymProviderKind) {
596-
return INDEXSTOREDB_SYMBOL_PROVIDER_KIND_UNKNOWN;
597-
}
598-
switch (*obj->SymProviderKind) {
599-
case IndexStoreDB::SymbolProviderKind::Clang:
600-
return INDEXSTOREDB_SYMBOL_PROVIDER_KIND_CLANG;
601-
case IndexStoreDB::SymbolProviderKind::Swift:
602-
return INDEXSTOREDB_SYMBOL_PROVIDER_KIND_SWIFT;
603-
}
604-
}
605-
606592
bool
607593
indexstoredb_index_units_containing_file(
608594
indexstoredb_index_t index,

lib/Index/FilePathIndex.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ bool FileIndexImpl::foreachMainUnitContainingFile(CanonicalFilePathRef filePath,
166166
currUnit.ModTime = unitInfo.ModTime;
167167
currUnit.MainFilePath = reader.getFullFilePathFromCode(unitInfo.MainFileCode);
168168
currUnit.OutFileIdentifier = reader.getUnitFileIdentifierFromCode(unitInfo.OutFileCode);
169-
currUnit.SymProviderKind = unitInfo.SymProviderKind;
170169
return true;
171170
});
172171
}

lib/Index/IndexDatastore.cpp

+3-22
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,6 @@ void StoreUnitRepo::registerUnit(StringRef unitName, bool isInitialScan, std::sh
474474
bool needDatabaseUpdate;
475475
Optional<bool> optIsSystem;
476476
Optional<bool> PrevHasTestSymbols;
477-
Optional<SymbolProviderKind> PrevSymProviderKind;
478477
IDCode PrevMainFileCode;
479478
IDCode PrevOutFileCode;
480479
Optional<StoreUnitInfo> StoreUnitInfoOpt;
@@ -494,7 +493,6 @@ void StoreUnitRepo::registerUnit(StringRef unitName, bool isInitialScan, std::sh
494493
PrevMainFileCode = unitImport.getPrevMainFileCode();
495494
PrevOutFileCode = unitImport.getPrevOutFileCode();
496495
PrevHasTestSymbols = unitImport.getHasTestSymbols();
497-
PrevSymProviderKind = unitImport.getSymbolProviderKind();
498496
return false;
499497
}
500498

@@ -592,14 +590,7 @@ void StoreUnitRepo::registerUnit(StringRef unitName, bool isInitialScan, std::sh
592590
}
593591

594592
unitImport.commit();
595-
StoreUnitInfoOpt = StoreUnitInfo{
596-
unitName,
597-
CanonMainFile,
598-
OutFileIdentifier,
599-
unitImport.getHasTestSymbols().getValue(),
600-
unitModTime,
601-
unitImport.getSymbolProviderKind()
602-
};
593+
StoreUnitInfoOpt = StoreUnitInfo{unitName, CanonMainFile, OutFileIdentifier, unitImport.getHasTestSymbols().getValue(), unitModTime};
603594
import.commit();
604595
return false;
605596
};
@@ -612,14 +603,7 @@ void StoreUnitRepo::registerUnit(StringRef unitName, bool isInitialScan, std::sh
612603
ReadTransaction reader(SymIndex->getDBase());
613604
CanonicalFilePath mainFile = reader.getFullFilePathFromCode(PrevMainFileCode);
614605
std::string outFileIdentifier = reader.getUnitFileIdentifierFromCode(PrevOutFileCode);
615-
StoreUnitInfoOpt = StoreUnitInfo{
616-
unitName,
617-
mainFile,
618-
outFileIdentifier,
619-
PrevHasTestSymbols.getValue(),
620-
unitModTime,
621-
PrevSymProviderKind.getValue()
622-
};
606+
StoreUnitInfoOpt = StoreUnitInfo{unitName, mainFile, outFileIdentifier, PrevHasTestSymbols.getValue(), unitModTime};
623607
}
624608
Delegate->processedStoreUnit(StoreUnitInfoOpt.getValue());
625609
}
@@ -826,7 +810,6 @@ void StoreUnitRepo::onUnitOutOfDate(IDCode unitCode, StringRef unitName,
826810
CanonicalFilePath MainFilePath;
827811
std::string OutFileIdentifier;
828812
bool hasTestSymbols = false;
829-
Optional<SymbolProviderKind> SymProviderKind;
830813
llvm::sys::TimePoint<> CurrModTime;
831814
SmallVector<IDCode, 8> dependentUnits;
832815
{
@@ -838,7 +821,6 @@ void StoreUnitRepo::onUnitOutOfDate(IDCode unitCode, StringRef unitName,
838821
}
839822
OutFileIdentifier = reader.getUnitFileIdentifierFromCode(unitInfo.OutFileCode);
840823
hasTestSymbols = unitInfo.HasTestSymbols;
841-
SymProviderKind = unitInfo.SymProviderKind;
842824
CurrModTime = unitInfo.ModTime;
843825
}
844826
reader.getDirectDependentUnits(unitCode, dependentUnits);
@@ -850,8 +832,7 @@ void StoreUnitRepo::onUnitOutOfDate(IDCode unitCode, StringRef unitName,
850832
MainFilePath,
851833
OutFileIdentifier,
852834
hasTestSymbols,
853-
CurrModTime,
854-
SymProviderKind
835+
CurrModTime
855836
};
856837
Delegate->unitIsOutOfDate(unitInfo, trigger, synchronous);
857838
}

0 commit comments

Comments
 (0)