diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-02-04 17:30:51 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-04 17:30:51 -0500 |
| commit | 9b80537bc0272a9caf93f146d8964d9bdd4a407e (patch) | |
| tree | 13c2e92adca1b78b632bd8dd6cc1fecb5a12ded9 /source/slang/source-loc.cpp | |
| parent | 0d206996cd68b9f08ae1b4d9da6f16293984302c (diff) | |
Feature/view path (#824)
* Use 'is' over 'as' where appropriate.
* dynamic_cast -> dynamicCast
* Replace 'dynamicCast' with 'as' where has no change in behavior/ambiguity.
* Replace dynamicCast with as where doesn't change behavior/non ambiguous.
* Keep a per view path to the file loaded - such that diagnostic messages always display the path to the requested file.
* Add simplifyPath to ISlangFileSystemExt
Simplify (if possible) paths that are set on SourceFile and SourcView - doing so makes reading paths simpler.
* Fix small typo.
* Improve documentation in source for getFileUniqueIdentity
* Fix override warning.
Diffstat (limited to 'source/slang/source-loc.cpp')
| -rw-r--r-- | source/slang/source-loc.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/source/slang/source-loc.cpp b/source/slang/source-loc.cpp index 6507ea4b7..00b6d3be4 100644 --- a/source/slang/source-loc.cpp +++ b/source/slang/source-loc.cpp @@ -150,16 +150,30 @@ HumaneSourceLoc SourceView::getHumaneLoc(SourceLoc loc, SourceLocType type) pathHandle = entry.m_pathHandle; } - humaneLoc.pathInfo = _getPathInfo(pathHandle); + humaneLoc.pathInfo = _getPathInfoFromHandle(pathHandle); return humaneLoc; } -PathInfo SourceView::_getPathInfo(StringSlicePool::Handle pathHandle) const +PathInfo SourceView::_getPathInfo() const +{ + if (m_viewPath.Length()) + { + PathInfo pathInfo(m_sourceFile->getPathInfo()); + pathInfo.foundPath = m_viewPath; + return pathInfo; + } + else + { + return m_sourceFile->getPathInfo(); + } +} + +PathInfo SourceView::_getPathInfoFromHandle(StringSlicePool::Handle pathHandle) const { // If there is no override path, then just the source files path if (pathHandle == StringSlicePool::Handle(0)) { - return m_sourceFile->getPathInfo(); + return _getPathInfo(); } else { @@ -171,11 +185,11 @@ PathInfo SourceView::getPathInfo(SourceLoc loc, SourceLocType type) { if (type == SourceLocType::Actual) { - return m_sourceFile->getPathInfo(); + return _getPathInfo(); } const int entryIndex = findEntryIndex(loc); - return _getPathInfo((entryIndex >= 0) ? m_entries[entryIndex].m_pathHandle : StringSlicePool::Handle(0)); + return _getPathInfoFromHandle((entryIndex >= 0) ? m_entries[entryIndex].m_pathHandle : StringSlicePool::Handle(0)); } /* !!!!!!!!!!!!!!!!!!!!!!! SourceFile !!!!!!!!!!!!!!!!!!!!!!!!!!!! */ @@ -418,10 +432,21 @@ SourceFile* SourceManager::createSourceFileWithBlob(const PathInfo& pathInfo, IS return sourceFile; } -SourceView* SourceManager::createSourceView(SourceFile* sourceFile) +SourceView* SourceManager::createSourceView(SourceFile* sourceFile, const PathInfo* pathInfo) { SourceRange range = allocateSourceRange(sourceFile->getContentSize()); - SourceView* sourceView = new SourceView(sourceFile, range); + + SourceView* sourceView = nullptr; + if (pathInfo && + (pathInfo->foundPath.Length() && sourceFile->getPathInfo().foundPath != pathInfo->foundPath)) + { + sourceView = new SourceView(sourceFile, range, &pathInfo->foundPath); + } + else + { + sourceView = new SourceView(sourceFile, range, nullptr); + } + m_sourceViews.Add(sourceView); return sourceView; |
