Delete trailing whitespace (#42)

This commit is contained in:
Avi Dessauer 2019-08-21 06:03:31 -04:00 committed by Alexey Kiryushin
parent 5295ac7f7f
commit af41ab40e1
67 changed files with 639 additions and 640 deletions

View File

@ -65,11 +65,11 @@ jobs:
environment:
- STACK_FILE: "stack-8.6.4.yaml"
<<: *defaults
ghc-8.6.5:
environment:
- STACK_FILE: "stack-8.6.5.yaml"
<<: *defaults
<<: *defaults
workflows:
version: 2

View File

@ -42,7 +42,7 @@ import Options.Applicative
, strOption
, value
)
import Paths_haskell_code_explorer as HSE (version)
import Paths_haskell_code_explorer as HSE (version)
import System.Directory (createDirectoryIfMissing)
import System.Exit (ExitCode(..), exitWith)
import System.FilePath ((</>))
@ -187,7 +187,7 @@ logger loggerSet minLogLevel logLevel msg =
let showLogLevel :: LogLevel -> T.Text
showLogLevel LevelDebug = "[debug]"
showLogLevel LevelInfo = "[info]"
showLogLevel LevelWarn = "[warn]"
showLogLevel LevelWarn = "[warn]"
showLogLevel LevelError = "[error]"
showLogLevel (LevelOther t) = T.concat ["[",t,"]"]
text =

View File

@ -350,7 +350,7 @@ instance Store.StoreItem [HCE.ExternalIdentifierInfo] where
, TE.encodeUtf8 $ HCE.packageIdToText packageId
, "|"
, BSC.pack prefix
]
]
instance Store.StoreItem (S.Set HCE.IdentifierSrcSpan) where
toByteString = Serialize.encode
@ -381,7 +381,7 @@ instance (Serialize.Serialize modInfo) =>
toByteString = Serialize.encode
fromByteString = Serialize.decode
type KeyArgs (HM.HashMap HCE.HaskellModulePath modInfo) =
(HCE.PackageId,Proxy (HM.HashMap HCE.HaskellModulePath modInfo))
(HCE.PackageId,Proxy (HM.HashMap HCE.HaskellModulePath modInfo))
itemKey (packageId, _) =
BSS.toShort $ BS.append "moduleMap|" $ TE.encodeUtf8 $ HCE.packageIdToText packageId
@ -390,7 +390,7 @@ instance Store.StoreItem HCE.ExpressionInfoMap where
fromByteString = Serialize.decode
type KeyArgs HCE.ExpressionInfoMap = ( HCE.PackageId
, HCE.HaskellModulePath
, BS.ByteString
, BS.ByteString
, Proxy HCE.ExpressionInfoMap)
itemKey (packageId, HCE.HaskellModulePath modulePath, topLevelExprKey, _) =
BSS.toShort $ BS.concat
@ -400,7 +400,7 @@ instance Store.StoreItem HCE.ExpressionInfoMap where
, "|"
, TE.encodeUtf8 modulePath
, "|"
, topLevelExprKey
, topLevelExprKey
]
instance Store.StoreItem (IVM.IntervalMap (Int, Int) BS.ByteString) where
@ -418,7 +418,7 @@ instance Store.StoreItem (IVM.IntervalMap (Int, Int) BS.ByteString) where
, "|"
, TE.encodeUtf8 modulePath
]
instance Store.StoreItem HCE.DefinitionSiteMap where
toByteString = Serialize.encode
fromByteString = Serialize.decode
@ -433,7 +433,7 @@ instance Store.StoreItem HCE.DefinitionSiteMap where
, "|"
, TE.encodeUtf8 modulePath
]
instance Store.StoreItem (V.Vector T.Text) where
toByteString = Serialize.encode
fromByteString = Serialize.decode
@ -476,7 +476,7 @@ instance Store.StoreItem GlobalIdentifierMapWrapper where
toByteString (GlobalIdentifierMapWrapper idMap) = Serialize.encode idMap
fromByteString bs = GlobalIdentifierMapWrapper <$> Serialize.decode bs
type KeyArgs GlobalIdentifierMapWrapper = Proxy GlobalIdentifierMapWrapper
itemKey _ = "globalIdentifierMap"
itemKey _ = "globalIdentifierMap"
instance Store.StoreItem [PackageVersions] where
toByteString = Serialize.encode
@ -494,7 +494,7 @@ findTopLevelExpressions =
| subsumes (fst currentTopLevelInterval) (fst interval) -> topLevelIntervals
| subsumes (fst interval) (fst currentTopLevelInterval) ->
interval : rest
| otherwise -> interval : topLevelIntervals)
| otherwise -> interval : topLevelIntervals)
[] .
IVM.assocs
@ -768,7 +768,7 @@ loadPackages _config mbStore
, ignoreRight eitherPackageVersions
, ignoreRight eitherGlobalIdentifierMap
]
return Nothing
return Nothing
loadPackages config _ = do
packageDirectories <- findDirectories (configPackagesPath config)
result <- mapM (loadPackageInfo config) packageDirectories
@ -859,7 +859,7 @@ loadPackages config _ = do
, packagePathMapCompacted
, packageVersionsCompacted
, globalReferenceMapCompacted
, globalIdentifierMapCompacted
, globalIdentifierMapCompacted
)
else return Nothing
where
@ -941,7 +941,7 @@ type API = GetAllPackages
:<|> GetIdentifiers
:<|> GetGlobalReferences
:<|> GetGlobalIdentifiers
:<|> GetHoogleDocs
:<|> GetHoogleDocs
type GetAllPackages = "api" :> "packages" :> Get '[JSON] AllPackages
@ -979,7 +979,7 @@ type GetIdentifiers = "api" :> "identifiers"
[HCE.ExternalIdentifierInfo])
type GetGlobalReferences = "api" :> "globalReferences"
:> Capture "externalId" HCE.ExternalId
:> Capture "externalId" HCE.ExternalId
:> Get '[JSON] [GlobalReferences]
type GetGlobalIdentifiers = "api" :> "globalIdentifiers"
@ -994,7 +994,7 @@ type GetHoogleDocs = "api" :> "hoogleDocs"
:> Capture "moduleName" HCE.HaskellModuleName
:> Capture "entity" HoogleItemSort
:> Capture "name" T.Text
:> Get '[JSON] T.Text
:> Get '[JSON] T.Text
instance AllCTRender '[ JSON] AllPackages where
handleAcceptH _ _ (AllPackages bytestring) =
@ -1020,10 +1020,10 @@ instance ToHttpApiData HCE.LocatableEntity where
instance ToHttpApiData HCE.ExternalId where
toUrlPiece (HCE.ExternalId i) = i
instance ToHttpApiData PackageId where
toUrlPiece (PackageId p) = p
instance FromHttpApiData HCE.HaskellModulePath where
parseQueryParam = Right . HCE.HaskellModulePath
@ -1035,10 +1035,10 @@ instance FromHttpApiData HCE.HaskellModuleName where
instance FromHttpApiData HCE.ExternalId where
parseQueryParam = Right . HCE.ExternalId
instance FromHttpApiData PackageId where
parseQueryParam = Right . PackageId
--------------------------------------------------------------------------------
-- Request handlers
--------------------------------------------------------------------------------
@ -1074,7 +1074,7 @@ instance A.ToJSON SourceFile
getAllPackages :: ReaderT Environment IO AllPackages
getAllPackages = asks envPackageVersions
getExpressions ::
PackageId
-> HCE.HaskellModulePath
@ -1287,8 +1287,8 @@ getGlobalReferences ::
HCE.ExternalId -> ReaderT Environment IO [GlobalReferences]
getGlobalReferences externalId = do
refMap <- asks envGlobalReferenceMap
return $ maybe [] S.toDescList (HM.lookup externalId refMap)
return $ maybe [] S.toDescList (HM.lookup externalId refMap)
getReferences ::
PackageId
-> HCE.ExternalId
@ -1345,7 +1345,7 @@ getReferences packageId externalId mbPage mbPerPage =
]
in case packageInfo' of
PackageInfo packageInfo ->
mkRefsWithSource $ S.toList <$> HM.lookup externalId (HCE.externalIdOccMap packageInfo)
mkRefsWithSource $ S.toList <$> HM.lookup externalId (HCE.externalIdOccMap packageInfo)
PackageInfoStore pId store -> do
let eitherOccurrences =
Store.lookup
@ -1489,7 +1489,7 @@ findIdentifiers packageId query' mbPage mbPerPage =
respond $
S.toList $
HCE.match (T.unpack $ T.drop 4 query) trie
Left _ -> respond []
Left _ -> respond []
findGlobalIdentifiers ::
T.Text
@ -1543,7 +1543,7 @@ valueToHoogleResultItem value =
| T.isInfixOf "#t" url = Just Typ
urlToSort _ = Nothing
mbResultSort = value ^? AL.key "url" . AL._String >>= urlToSort
in HoogleResultItem <$> mbResultSort <*> mbModuleName <*> mbHtmlDocs
in HoogleResultItem <$> mbResultSort <*> mbModuleName <*> mbHtmlDocs
hoogleApiHost :: String
hoogleApiHost = "https://hoogle.haskell.org/"
@ -1561,7 +1561,7 @@ getHoogleDocs packageId (HCE.HaskellModuleName moduleName) itemSort name
let hoogleQuery =
T.unpack name ++
" is:exact package:" ++ T.unpack (getPackageName packageName)
url = hoogleApiHost ++ "?hoogle=" ++ encode hoogleQuery ++ "&mode=json"
url = hoogleApiHost ++ "?hoogle=" ++ encode hoogleQuery ++ "&mode=json"
error502 e =
throwServantError $
err502 {errBody = BSL.fromStrict $ BSC.pack $ show e}
@ -1605,7 +1605,7 @@ paginateItems mbPage mbPerPage items = do
(fromIntegral totalCount)
(\offset limit -> return . L.take limit . L.drop offset $ items)
return (paginated, page, perPage, totalCount)
error404 :: BSL.ByteString -> ReaderT Environment IO a
error404 body = throwServantError $ err404 {errBody = body}
@ -1619,7 +1619,7 @@ data PackageInfo
= PackageInfo (HCE.PackageInfo HCE.CompactModuleInfo)
| PackageInfoStore HCE.PackageId
Store.Store
withPackageInfo ::
PackageId
-> (PackageInfo -> ReaderT Environment IO a)
@ -1709,7 +1709,7 @@ withModulePath packageInfo' componentId moduleName action =
store
case eitherModNameMap of
Right modNameMap ->
case HM.lookup (ghcPrimHack packageInfo' moduleName) modNameMap of
case HM.lookup (ghcPrimHack packageInfo' moduleName) modNameMap of
Just componentMap -> case HM.lookup componentId componentMap of
Just modulePath -> action modulePath
Nothing -> case HM.lookup (HCE.ComponentId "lib") componentMap of
@ -1748,7 +1748,7 @@ ghcPrimHack packageInfo' modName@(HCE.HaskellModuleName name) =
| packageName == "ghc-prim" && name == "GHC.Prim" ->
HCE.HaskellModuleName "GHC.Prim_"
| otherwise -> modName
parsePackageId :: PackageId -> Maybe (PackageName, Maybe Version)
parsePackageId (PackageId text) =
case T.splitOn "-" text of
@ -1797,7 +1797,7 @@ staticMiddleware staticFilesPrefix packagePathMap _ app req callback
if exists
then callback $ sendFile path
else callback fileNotFound
_ -> callback fileNotFound
_ -> callback fileNotFound
staticMiddleware _ _ mbJsDistPath _app req callback =
case mbJsDistPath of
Just jsDistPath -> do
@ -1833,7 +1833,7 @@ sendEmbeddedFile path bs =
responseLBS
status200
[(hContentType, defaultMimeLookup $ T.pack $ takeFileName path)]
(BSL.fromStrict bs)
(BSL.fromStrict bs)
fileNotFound :: Response
fileNotFound =
@ -1843,8 +1843,7 @@ fileNotFound =
throwServantError :: (MonadIO m) => ServerError -> m a
#else
throwServantError :: (MonadIO m) => ServantErr -> m a
#endif
throwServantError = liftIO . throwIO
throwServantError = liftIO . throwIO
server :: Environment -> ServerT API Handler
server env =
@ -1852,7 +1851,7 @@ server env =
(Proxy :: Proxy API)
toServantHandler
(getAllPackages :<|>
getDefinitionSite :<|>
getDefinitionSite :<|>
getExpressions :<|>
getReferences :<|>
findIdentifiers :<|>

View File

@ -30,7 +30,7 @@ import Data.Serialize (
#if MIN_VERSION_cereal(0,5,8)
#else
get, put
#endif
#endif
)
import GHC.Generics (Generic)
import Prelude hiding (lookup)
@ -43,7 +43,7 @@ data Store = Store
{ index :: M.Map BSS.ShortByteString Location
, values :: BS.ByteString
}
data Location = Location
{ offset :: Int
, length :: Int
@ -56,7 +56,7 @@ instance Serialize Location
instance Serialize BSS.ShortByteString where
put = put . BSS.fromShort
get = BSS.toShort <$> get
#endif
#endif
class StoreItem item where
toByteString :: item -> BS.ByteString
@ -74,7 +74,7 @@ data ReadMode
= ReadEntireFile
| MemoryMapFile
deriving (Show, Eq)
load :: FilePath -> ReadMode -> IO (Either String Store)
load directoryPath readMode = do
let valuesFilePath = directoryPath </> valuesFileName
@ -99,7 +99,7 @@ load directoryPath readMode = do
lookup :: (StoreItem item) => KeyArgs item -> Store -> Either String item
lookup keyArgs = lookupByteString (itemKey keyArgs)
lookupByteString ::
(StoreItem item) => BSS.ShortByteString -> Store -> Either String item
lookupByteString key store =
@ -127,7 +127,7 @@ createStore directoryPath action =
withFile (directoryPath </> valuesFileName) WriteMode $ \valuesHandle -> do
locMap <- action valuesHandle
BS.writeFile (directoryPath </> indexFileName) (encode locMap)
writeValues ::
Handle
-> M.Map BSS.ShortByteString Location

View File

@ -9,7 +9,7 @@
-- A common config might be:
-- -- all local packages
-- optimization: 0
--
--
-- -- always build dependencies with highest optimization
-- package *
-- optimization: 2

View File

@ -20,7 +20,7 @@ library
, HaskellCodeExplorer.AST.RenamedSource
, HaskellCodeExplorer.AST.TypecheckedSource
hs-source-dirs: src
ghc-options: -Wall -O2 -funbox-strict-fields
ghc-options: -Wall -O2 -funbox-strict-fields
build-depends: IntervalMap
, aeson
, attoparsec
@ -56,8 +56,8 @@ executable haskell-code-indexer
other-modules: Paths_haskell_code_explorer
hs-source-dirs: app
build-depends: IntervalMap
, aeson
, base
, aeson
, base
, bytestring
, cereal
, directory
@ -69,8 +69,8 @@ executable haskell-code-indexer
, uri-encode
, fast-logger
, monad-logger
, zlib
, haskell-code-explorer
, zlib
, haskell-code-explorer
default-language: Haskell2010
executable haskell-code-server
@ -85,25 +85,25 @@ executable haskell-code-server
, cereal
, containers
, deepseq
, directory
, directory
, filemanip
, filepath
, blaze-html
, text
, unordered-containers
, blaze-html
, text
, unordered-containers
, hashable
, vector
, wai
, syb
, haddock-library
, servant
, servant
, servant-server
, mime-types
, mtl
, wai-extra
, wai-middleware-static
, warp
, http-types
, http-types
, http-api-data
, fast-logger
, monad-logger
@ -118,7 +118,7 @@ executable haskell-code-server
, wreq
if impl(ghc >= 8.4.3)
build-depends: ghc-compact
test-suite test
default-language: Haskell2010
type: exitcode-stdio-1.0
@ -136,7 +136,7 @@ test-suite test
, hspec
, text
, uniplate
, unordered-containers
, unordered-containers
, monad-logger
, process
, vector

View File

@ -6,7 +6,7 @@ import config from './config/environment';
var App;
App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
modulePrefix: config.modulePrefix,
Resolver: Resolver
});

View File

@ -1,6 +1,6 @@
import Ember from 'ember';
function show(component) {
function show(component) {
const height = Math.floor(component.$containerElement.height() /2);
component.$().css({
"display":"block",
@ -40,13 +40,13 @@ export default Ember.Component.extend({
}
});
});
},
},
visibilityObserver : Ember.observer('visible',function () {
this.get('visible') ? show(this) : hide(this);
}),
actions : {
close () {
this.set('visible',false);
this.set('visible',false);
}
}
});

View File

@ -10,7 +10,7 @@ const directoryTreeToJsTree = function (packageId,directoryTree) {
jsTreeNode.a_attr = {href:"/package/" + packageId + "/show/" + node.path};
}
if(node.tag === "Dir") {
jsTreeNode.children = directoryTreeToJsTree(packageId,node);
jsTreeNode.children = directoryTreeToJsTree(packageId,node);
jsTreeNode.state = {"opened" : containsHaskellModule(node)};
} else {
if(node.isHaskellModule) {
@ -25,8 +25,8 @@ const directoryTreeToJsTree = function (packageId,directoryTree) {
});
};
const containsHaskellModule = function(node) {
return node.contents.some((n) => {
const containsHaskellModule = function(node) {
return node.contents.some((n) => {
if(n.tag === "File") {
return n.isHaskellModule;
} else {
@ -35,9 +35,9 @@ const containsHaskellModule = function(node) {
});
}
const fileExtension = function (filename) {
const idx = filename.lastIndexOf('.');
return (idx < 1) ? "" : filename.substr(idx + 1);
const fileExtension = function (filename) {
const idx = filename.lastIndexOf('.');
return (idx < 1) ? "" : filename.substr(idx + 1);
}
export default Ember.Component.extend({
@ -49,10 +49,10 @@ export default Ember.Component.extend({
});
}),
didInsertElement : function () {
this._super(...arguments);
this._super(...arguments);
const element = this.element.getElementsByClassName('file-tree')[0];
const component = this;
const jstreeElement = Ember.$(element).jstree({
'core' : {
'data' : directoryTreeToJsTree(this.get('packageId'),this.get('directoryTree'))
@ -69,16 +69,16 @@ export default Ember.Component.extend({
'sort' : function (a,b) {
const node1 = this.get_node(a).data;
const node2 = this.get_node(b).data;
if(component.get("sortType") === "alphabetical") {
if(component.get("sortType") === "alphabetical") {
return node1.name > node2.name;
} else {
} else {
const extendedName1 = (node1.tag === "Dir" ? "0" : "1") + fileExtension(node1.name) + node1.name;
const extendedName2 = (node2.tag === "Dir" ? "0" : "1") + fileExtension(node2.name) + node2.name;
const extendedName2 = (node2.tag === "Dir" ? "0" : "1") + fileExtension(node2.name) + node2.name;
return extendedName1 > extendedName2;
}
}
});
jstreeElement.on("select_node.jstree",(event,data) => {
const file = data.node.data;
if(file.tag != "Dir") {
@ -86,8 +86,8 @@ export default Ember.Component.extend({
}
});
const jstree = jstreeElement.jstree(true);
const jstree = jstreeElement.jstree(true);
if(this.get('currentFile')) {
jstree.select_node(this.get('currentFile'));
const node = jstree.get_node(this.get('currentFile'),true)[0];
@ -111,7 +111,7 @@ export default Ember.Component.extend({
}
}),
actions : {
hide() {
hide() {
this.get('hide')();
}
}

View File

@ -19,17 +19,17 @@ function compareLocations (p1,p2) {
}
}
function buildSrcSpan(sourceCodeLines,start,end) {
function buildSrcSpan(sourceCodeLines,start,end) {
if(sourceCodeLines[start.line] && sourceCodeLines[end.line]) {
if(start.line === end.line) {
return sourceCodeLines[start.line].slice(start.column-1,end.column-1);
} else {
} else {
const firstLine = sourceCodeLines[start.line];
let middleLines = [];
for(let i = start.line + 1; i < end.line;i ++) {
for(let i = start.line + 1; i < end.line;i ++) {
middleLines.push(sourceCodeLines[i]);
}
const lastLine = sourceCodeLines[end.line];
const lastLine = sourceCodeLines[end.line];
const minOffset = Math.min(start.column,
(middleLines.concat([lastLine]))
.map((line) => line.search(/\S/))
@ -52,7 +52,7 @@ function modifyClass(element,on) {
}
function highlightIdentifiers(parentElement,identifierElement,on) {
if(identifierElement.id) {
if(identifierElement.id) {
const identifiers = Array.prototype.slice.call(parentElement.querySelectorAll("span[id='"+identifierElement.id+"']"));
identifiers.forEach((identifier) => {
modifyClass(identifier,on);
@ -63,7 +63,7 @@ function highlightIdentifiers(parentElement,identifierElement,on) {
}
//divident is a string
//divident may have any number of digits
//divident may have any number of digits
function modulo(divident, divisor) {
return Array.from(divident).map(c => parseInt(c))
.reduce((acc, value) => {
@ -82,12 +82,12 @@ function identifierStyle(identifierElement,
occurrences,
path,
colorTheme,
moduleName) {
moduleName) {
const idOcc = occurrences[identifierElement.dataset.occurrence];
let color = colorTheme.defaultColor;
let fontWeight;
let fontWeight;
if(idOcc) {
if(idOcc.sort.tag === 'TypeId') {
color = colorTheme.typeColor;
@ -102,7 +102,7 @@ function identifierStyle(identifierElement,
const idInfo = identifiers[identifierElement.dataset.identifier];
if(idInfo) {
if(isDefinedInCurrentModule(moduleName,path,idInfo)) {
color = colorTheme.topLevelIdFromCurrentModule;
color = colorTheme.topLevelIdFromCurrentModule;
} else if(idInfo.sort === "Internal" && idInfo.locationInfo.tag === "ExactLocation") {
const colorNumber = modulo(identifierElement.id,colorTheme.localIdentifierColor.length);
color = colorTheme.localIdentifierColor[colorNumber];
@ -111,7 +111,7 @@ function identifierStyle(identifierElement,
}
}
}
return "color:"+color+";"
+(fontWeight ? "font-weight:" + fontWeight : "")+";"
+(idOcc.isBinder ? "text-decoration:underline;" : "");
@ -122,16 +122,16 @@ function initializeIdentifiers (sourceCodeContainerElement,component) {
if(identifierElements.length > 0) {
const timeout = 250;//milliseconds
let timer = null;
identifierElements.forEach((identifierElement) => {
const cssText = identifierStyle(identifierElement,
component.get('identifiers'),
component.get('occurrences'),
component.get('occurrences'),
component.get('path'),
component.get('colorTheme'),
component.get('name'));
identifierElement.style.cssText = cssText;
//go to definition
@ -139,31 +139,31 @@ function initializeIdentifiers (sourceCodeContainerElement,component) {
if(timer) {
clearTimeout(timer);
}
if(!window.getSelection().isCollapsed) {
return;
}
const identifierInfo = component.get('identifiers')[identifierElement.dataset.identifier];
const identifierInfo = component.get('identifiers')[identifierElement.dataset.identifier];
const idOccurrenceInfo = component.get('occurrences')[identifierElement.dataset.occurrence];
const currentLineNumber = parseInt(identifierElement.parentNode.dataset.line);
if(idOccurrenceInfo.sort.tag === "ModuleId") {
goToDefinition(component.get('store'),
idOccurrenceInfo.sort.contents,
event.which,
currentLineNumber);
}
else {
if(identifierInfo && (event.which === 1 || event.which === 2)) {
else {
if(identifierInfo && (event.which === 1 || event.which === 2)) {
if(!idOccurrenceInfo.isBinder) {
goToDefinition(component.get('store'),
identifierInfo.locationInfo,
event.which,
currentLineNumber);
} else {
if(identifierInfo.sort === "External") {
if(identifierInfo.sort === "External") {
component.get('findReferences')(component.get('packageId'),
identifierInfo.externalId,
identifierInfo.demangledOccName,
@ -173,7 +173,7 @@ function initializeIdentifiers (sourceCodeContainerElement,component) {
}
}
}
}
}
identifierElement.onmouseover = () => {
highlightIdentifiers(sourceCodeContainerElement,identifierElement,true);
if(timer) {
@ -185,27 +185,27 @@ function initializeIdentifiers (sourceCodeContainerElement,component) {
const identifierOccurrence = component.get('occurrences')[identifierElement.dataset.occurrence];
console.log(identifierOccurrence);
console.log(identifierInfo);
component.set('selectedIdentifier',identifierElement);
component.set('currentLineNumber',parseInt(identifierElement.parentNode.dataset.line) || 1);
component.set('identifierInfo',identifierInfo);
component.set('identifierOccurrence',identifierOccurrence);
component.set('hasSelectedExpression',false);
component.set('isHoveredOverIdentifier',true);
});
},timeout);
};
identifierElement.onmouseout = () => {
highlightIdentifiers(sourceCodeContainerElement,identifierElement,false);
if(timer) {
clearTimeout(timer);
}
timer = setTimeout (() => {
Ember.run.next(component,() => {
Ember.run.next(component,() => {
component.set('isHoveredOverIdentifier',false);
});
},timeout);
@ -224,19 +224,19 @@ function contains (node, other) {
function initializeExpressionInfo(sourceCodeContainerElement,component) {
const lineElements = Array.prototype.slice.call(sourceCodeContainerElement.querySelectorAll("td.line-content"));
if(lineElements.length > 0) {
//Line numbers start with 1
let sourceCodeLines = [""];
lineElements.forEach((el) => {
sourceCodeLines.push(el.textContent);
});
const allowedNodeNames = ["#text","SPAN","TD"];
const allowedNodeNames = ["#text","SPAN","TD"];
let isLoading = false;
let shouldWait = false;
const timeout = 400;//milliseconds
const onmouseup = function() {
Ember.run.next(() => {
if(isLoading || shouldWait) {
@ -244,14 +244,14 @@ function initializeExpressionInfo(sourceCodeContainerElement,component) {
}
shouldWait = true;
setTimeout(() => {shouldWait = false;},timeout);
component.set('hasSelectedExpression',false);
const selection = window.getSelection();
const selection = window.getSelection();
//Selection of multiple lines inside a table doesn't work in Firefox
//https://bugzilla.mozilla.org/show_bug.cgi?id=365900
if(!(selection.anchorNode && selection.focusNode)
|| !contains(sourceCodeContainerElement,selection.anchorNode)
|| !contains(sourceCodeContainerElement,selection.focusNode)
@ -259,16 +259,16 @@ function initializeExpressionInfo(sourceCodeContainerElement,component) {
|| (allowedNodeNames.indexOf(selection.focusNode.nodeName) === -1)
|| selection.isCollapsed) {
return;
}
}
// Detects whether the selection is backwards
const detectionRange = document.createRange();
detectionRange.setStart(selection.anchorNode, selection.anchorOffset);
detectionRange.setEnd(selection.focusNode, selection.focusOffset);
const isBackward = detectionRange.collapsed;
let startNode,startNodeOffset,endNode,endNodeOffset;
if(isBackward) {
startNode = selection.focusNode;
startNodeOffset = selection.focusOffset;
@ -283,8 +283,8 @@ function initializeExpressionInfo(sourceCodeContainerElement,component) {
let lineStart,columnStart,lineEnd,columnEnd;
let infoWindowTargetElement;
//HTML inside source code container :
//<tr><td><span data-start="1" date-end="3">abc</span><span>...</span></td></tr>
//<tr>...</tr>
@ -292,17 +292,17 @@ function initializeExpressionInfo(sourceCodeContainerElement,component) {
const parent = startNode.parentNode;//<span>
columnStart = parseInt(parent.dataset.start) + startNodeOffset;
lineStart = parseInt(parent.parentNode.dataset.line);
if(startNodeOffset === startNode.textContent.length && parent.nextSibling === null) {
const tr = startNode.parentNode.parentNode.parentNode;// span -> td -> tr
//Skipping empty lines
let nextLine = tr.nextSibling;
let nextLine = tr.nextSibling;
while(nextLine.children[1].textContent === "") {
nextLine = nextLine.nextSibling;
}
infoWindowTargetElement = nextLine.children[1].children[0];
} else {
if(!(startNodeOffset === 0) && (parent.nextSibling)) {
infoWindowTargetElement = parent.nextSibling;
@ -320,7 +320,7 @@ function initializeExpressionInfo(sourceCodeContainerElement,component) {
nextLine = nextLine.nextSibling;
}
infoWindowTargetElement = nextLine.children[1].children[0];
} else if(startNode.nodeName === "TD") {
if(startNodeOffset > 0) {
const child = startNode.children[startNodeOffset-1];
@ -330,10 +330,10 @@ function initializeExpressionInfo(sourceCodeContainerElement,component) {
}
lineStart = parseInt(startNode.id.slice(2));
infoWindowTargetElement = startNode.children[0];
}
}
if(endNode.nodeName === "#text") {
columnEnd = parseInt(endNode.parentNode.dataset.start) + endNodeOffset;
columnEnd = parseInt(endNode.parentNode.dataset.start) + endNodeOffset;
lineEnd = parseInt(endNode.parentNode.parentNode.dataset.line);
} else if(endNode.nodeName === "SPAN") {
columnEnd = 1;
@ -341,22 +341,22 @@ function initializeExpressionInfo(sourceCodeContainerElement,component) {
} else if(endNode.nodeName === "TD"){
if(endNodeOffset > 0) {
const child = endNode.children[endNodeOffset-1];
columnEnd = parseInt(child.dataset.start);
columnEnd = parseInt(child.dataset.start);
} else {
columnEnd = 1;
}
lineEnd = parseInt(endNode.id.slice(2));
}
}
const loadExprPromise = component.get('store').loadExpressions(
component.get('packageId'),
component.get('path'),
component.get('path'),
lineStart,
columnStart,
lineEnd,
columnEnd);
isLoading = true;
loadExprPromise.then((expressions) => {
Ember.run.next(() => {
if(expressions && expressions.length > 0) {
@ -368,7 +368,7 @@ function initializeExpressionInfo(sourceCodeContainerElement,component) {
return 1;
}
});
const expressionsWithSourceCode = expressions.reduce((result,expression) => {
const object = Ember.copy(expression);
const srcSpan = buildSrcSpan(sourceCodeLines,
@ -387,15 +387,15 @@ function initializeExpressionInfo(sourceCodeContainerElement,component) {
component.set('expressions',expressionsWithSourceCode);
component.set('currentLineNumber',parseInt(infoWindowTargetElement.parentNode.dataset.line) || 1);
component.set('hasSelectedExpression',true);
}
}
isLoading = false;
});
});
});
});
};
sourceCodeContainerElement.addEventListener('mouseup',onmouseup);
component._onmouseup = onmouseup;
}
@ -418,10 +418,10 @@ export default Ember.Component.extend({
this.set('filteredDeclarations',filteredDeclarations);
});
}, 300);
}),
}),
identifierLocationInfo : Ember.computed('identifierInfo','identifierOccurrence',function() {
const idOcc = this.get('identifierOccurrence');
const idInfo = this.get('identifierInfo');
const idInfo = this.get('identifierInfo');
if(idOcc) {
if(idOcc.sort.tag === "ModuleId") {
return idOcc.sort.contents;
@ -470,10 +470,10 @@ export default Ember.Component.extend({
didReceiveAttrs() {
this.set('filteredDeclarations',this.get('declarations'));
},
didInsertElement() {
didInsertElement() {
this._super(...arguments);
const sourceCodeContainerElement = this.element.querySelector('.source-code-container');
sourceCodeContainerElement.innerHTML = this.get('html');
sourceCodeContainerElement.innerHTML = this.get('html');
this.sourceCodeContainerElement = sourceCodeContainerElement;
// Add links to Haskell language extensions docs
@ -493,7 +493,7 @@ export default Ember.Component.extend({
}
i = i + 1;
}
this.element.parentNode.scrollTop = 0;
const declarations = this.element.querySelector('.declarations-content');
this.set('query','');
@ -510,7 +510,7 @@ export default Ember.Component.extend({
this.cleanup();
},
actions : {
goToLine(lineNumber) {
goToLine(lineNumber) {
window.location.hash = "L"+lineNumber;
},
toggleShowDeclarations() {

View File

@ -1,7 +1,7 @@
import Ember from 'ember';
import {goToDefinition} from '../utils/go-to-definition';
export default Ember.Component.extend({
export default Ember.Component.extend({
store : Ember.inject.service('store'),
downloadedDocumentation : null,
didInsertElement () {
@ -26,25 +26,25 @@ export default Ember.Component.extend({
this.element.removeEventListener('mouseup',this._onmouseup);
}
},
//Naughty record selectors :
//Naughty record selectors :
//https://github.com/ghc/ghc/blob/ced2cb5e8fbf4493488d1c336da7b00d174923ce/compiler/typecheck/TcTyDecls.hs#L940-L961
isNaughtyRecSel : Ember.computed('identifierInfo',function () {
const idInfo = this.get('identifierInfo');
return idInfo ? (idInfo.details === "RecSelIdNaughty") : false;
return idInfo ? (idInfo.details === "RecSelIdNaughty") : false;
}),
isExternalIdentifier : Ember.computed('identifierInfo',function () {
const idInfo = this.get('identifierInfo');
return idInfo ? (idInfo.sort === "External") : false;
return idInfo ? (idInfo.sort === "External") : false;
}),
identifierObserver : Ember.observer('identifierInfo',function () {
this.set("downloadedDocumentation","");
const idInfo = this.get('identifierInfo');
if(idInfo) {
if(idInfo) {
const locationInfo = idInfo.locationInfo;
if(locationInfo.tag === "ApproximateLocation") {
const packageId = locationInfo.packageId.name + "-" + locationInfo.packageId.version;
const currentIdentifier = idInfo;
this.get('store').loadDefinitionSite(packageId,
locationInfo.moduleName,
locationInfo.componentId,
@ -52,10 +52,10 @@ export default Ember.Component.extend({
locationInfo.name)
.then((definitionSite) => {
Ember.run.next(this,() => {
if(currentIdentifier === this.get('identifierInfo')) {
if(currentIdentifier === this.get('identifierInfo')) {
this.set('downloadedDocumentation',definitionSite.documentation);
}})
}).catch(() => {
}).catch(() => {
this.get('store').loadHoogleDocs(packageId,
locationInfo.moduleName,
locationInfo.entity,

View File

@ -11,7 +11,7 @@ export default Ember.Component.extend({
}),
style : Ember.computed('identifierElement',function() {
const element = this.get('identifierElement');
if(element) {
if(element) {
return new Ember.String.htmlSafe("color:"+element.style.color);
}
}),
@ -44,7 +44,7 @@ export default Ember.Component.extend({
return (this.get('identifierInfo.sort') === "External");
}),
actions : {
goToDefinition (event) {
goToDefinition (event) {
goToDefinition(this.get('store'),
this.get('locationInfo'),
event.which,

View File

@ -10,34 +10,34 @@ function initialize(component) {
pageNumber = 1;
}
export default Component.extend({
export default Component.extend({
renderedElements : [],
init() {
this._super(...arguments);
initialize(this);
},
elementsObserver : observer('elements',function() {
elementsObserver : observer('elements',function() {
initialize(this);
const containerElement = document.getElementById(this.get('containerElementId'));
if(containerElement) {
if(containerElement) {
containerElement.scrollTop = 0;
}
}),
didInsertElement() {
const containerElement = document.getElementById(this.get('containerElementId'));
if(containerElement) {
const component = this;
const component = this;
containerElement.onscroll = function() {
const perPage = component.get('perPage');
const elements = component.get('elements');
if(!updating &&
(pageNumber * perPage < elements.length) &&
(containerElement.scrollTop + containerElement.offsetHeight
> component.element.offsetHeight - 100)) {
updating = true;
run.next(component,() => {
run.next(component,() => {
const newElements = elements.slice(pageNumber * perPage,(pageNumber + 1) * perPage);
component.get('renderedElements').pushObjects(newElements);
pageNumber ++;

View File

@ -8,27 +8,27 @@ function updatePosition(component) {
if(targetElement) {
const infoWindowHeight = component.element.offsetHeight;
const targetElementHeight = targetElement.offsetHeight;
const parent = targetElement.parentNode;//<td> element
const containerElement = document.querySelector("#" + component.get('containerElementId'));
const parent = targetElement.parentNode;//<td> element
const containerElement = document.querySelector("#" + component.get('containerElementId'));
//getBoundingClientRect() returns the smallest rectangle which contains
//the entire element, with read-only left, top, right, bottom, x, y, width,
//and height properties describing the overall border-box in pixels. Properties
//other than width and height are relative to the top-left of the *viewport*.
const targetTopViewport = targetElement.getBoundingClientRect().top;
let containerTopViewport;
if (containerElement) {
containerTopViewport = containerElement.getBoundingClientRect().top;
} else {
containerTopViewport = 0;
}
let infoWindowTop;
if(targetTopViewport < infoWindowHeight + containerTopViewport) {
//offsetTop is the number of pixels from the top of the closest relatively
//positioned parent element.
//positioned parent element.
infoWindowTop = targetElement.offsetTop + parent.offsetTop
+ targetElementHeight + 10 + "px";
} else {
@ -37,7 +37,7 @@ function updatePosition(component) {
}
const infoWindowLeft = targetElement.offsetLeft + parent.offsetLeft + "px";
component.$().css({
top:infoWindowTop,
left:infoWindowLeft
@ -54,16 +54,16 @@ export default Ember.Component.extend({
isFocused: false,
didInsertElement () {
const component = this;
const $headerElement = Ember.$(component.element.querySelector(".info-window-header"));
const $contentElement = Ember.$(component.element.querySelector(".info-window-content"));
const $infoWindowElement = Ember.$(component.element.querySelector(".info-window"));
const $infoWindowContainerElement = Ember.$(component.element);
this.$headerElement = $headerElement;
this.$contentElement = $contentElement;
this.$().resizable({
this.$headerElement = $headerElement;
this.$contentElement = $contentElement;
this.$().resizable({
handles: "n,w",
minHeight: 80,
minWidth: 400,
@ -74,10 +74,10 @@ export default Ember.Component.extend({
resizing = false;
},
resize : function() {
const containerHeight = $infoWindowContainerElement.height();
const containerHeight = $infoWindowContainerElement.height();
$infoWindowElement.css({
"height": containerHeight + 2 + "px"
});
});
$contentElement.css({
"max-height":(containerHeight - $headerElement.outerHeight(true)) + "px"
});
@ -104,7 +104,7 @@ export default Ember.Component.extend({
const element = document.elementFromPoint(event.clientX,event.clientY);
if(element && element.classList.contains('link')) {
return;
}
}
if(!resizing
&& !dragging
&& !this.get('isPinned')
@ -122,7 +122,7 @@ export default Ember.Component.extend({
if (this.get('isPinned')
|| this.get('isFocused')
|| this.get('isHoveredOverIdentifier')
|| this.get('hasSelectedExpression')) {
|| this.get('hasSelectedExpression')) {
return false;
} else {
return true;

View File

@ -1,14 +1,14 @@
import Ember from 'ember';
export default Ember.Component.extend({
store : Ember.inject.service('store'),
store : Ember.inject.service('store'),
highlightedItemIndex: -1,
items : [],
query: null,
didInsertElement() {
const $input = Ember.$(this.element).find(".search-input");
const $autocompleteContainer = Ember.$(this.element).find(".autocomplete-container");
this.$input = $input;
this.$autocompleteContainer = $autocompleteContainer;
const $autocompleteContainer = Ember.$(this.element).find(".autocomplete-container");
this.$input = $input;
this.$autocompleteContainer = $autocompleteContainer;
const width = $input.width() + 300;
$autocompleteContainer.css({
"width" : width+"px",
@ -23,9 +23,9 @@ export default Ember.Component.extend({
this.onDown();
} else if(e.which === 38) {
this.onUp();
}
}
});
$input.focusin(() => {
$input.focusin(() => {
this.showAutocompleteList();
});
$input.focusout(() => {
@ -105,7 +105,7 @@ export default Ember.Component.extend({
},
searchUrlObserver : Ember.observer('createSearchUrlFunction',function() {
this.notifyPropertyChange('query');
}),
}),
queryObserver : Ember.observer("query",function() {
if(this.get('query')) {
const perPage = this.get('maxItems') ? this.get('maxItems') : 10;

View File

@ -10,7 +10,7 @@ export default Ember.Component.extend({
return this.get('nestedLevel') + 1;
}),
actions : {
goToDefinition (event) {
goToDefinition (event) {
goToDefinition(this.get('store'),
this.get('instance.location'),
event.which,

View File

@ -8,10 +8,10 @@ function loadItems(store,component,url) {
component.set('next',result.linkHeader.next);
component.set('prev',result.linkHeader.prev);
component.set('last',result.linkHeader.last);
const pageMatch = url.match(/(&|\?)page=(\d+)/);
const perPageMatch = url.match(/(&|\?)per_page=(\d+)/);
const page = pageMatch ? pageMatch[2] : 1;
const perPage = perPageMatch ? perPageMatch[2] : 20;
@ -36,11 +36,11 @@ export default Ember.Component.extend({
}
},
urlObserver : Ember.observer('url',function () {
loadItems(this.get('store'),this,this.get('url'));
this.element.querySelector(".paginated-list-content").scrollTop = 0;
loadItems(this.get('store'),this,this.get('url'));
this.element.querySelector(".paginated-list-content").scrollTop = 0;
}),
actions : {
update(url) {
update(url) {
this.element.querySelector(".paginated-list-content").scrollTop = 0;
loadItems(this.get('store'),this,url);
}

View File

@ -24,7 +24,7 @@ export default Ember.Component.extend({
hidden:false,
hiddenByUser:false,
didInsertElement : function () {
this._super(...arguments);
this._super(...arguments);
Ember.run.next(this,() => {
const onresize = () => {
if(!this.get('hiddenByUser')) {
@ -50,7 +50,7 @@ export default Ember.Component.extend({
}
});
this.$alsoResizeElement = $alsoResizeElement;
if(window.innerWidth < 700) {
if(window.innerWidth < 700) {
this.set('hidden',true);
hide(this,false);
}

View File

@ -37,7 +37,7 @@ export default Ember.Component.extend({
}),
init() {
this._super(...arguments);
this.markdownConverter = new showdown.Converter();
this.markdownConverter = new showdown.Converter();
},
didInsertElement() {
const sourceCodeContainerElement = this.element.querySelector('.source-code-container');
@ -48,7 +48,7 @@ export default Ember.Component.extend({
this.cleanup();
},
cleanup() {
if(this._onhashchange) {
if(this._onhashchange) {
window.removeEventListener('hashchange',this._onhashchange);
}
if(this._onkeydown) {
@ -61,7 +61,7 @@ export default Ember.Component.extend({
pathObserver : Ember.observer('path',function() {
Ember.run.next(this,() => {
this.cleanup();
this.didInsertElement();
this.didInsertElement();
});
})
});

View File

@ -1,4 +1,4 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName : "span"
tagName : "span"
});

View File

@ -1,11 +1,11 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName : "span",
expandTypeSynonyms: false,
tagName : "span",
expandTypeSynonyms: false,
expandTypeSynonymsLabel : Ember.computed('expandTypeSynonyms',function() {
return this.get('expandTypeSynonyms') ? "Show type synonyms" : "Expand type synonyms";
}),
components : Ember.computed('type','expandTypeSynonyms',function() {
components : Ember.computed('type','expandTypeSynonyms',function() {
if(this.get('expandTypeSynonyms') && this.get('type.componentsExpanded')) {
return this.get('type.componentsExpanded');
} else {
@ -14,7 +14,7 @@ export default Ember.Component.extend({
}),
typeObserver : Ember.observer('type',function() {
this.set('expandTypeSynonyms',false);
}),
}),
actions : {
toggleExpandTypeSynonyms () {
this.toggleProperty('expandTypeSynonyms');

View File

@ -8,8 +8,8 @@ export default Ember.Controller.extend({
loadItemsFunction : null,
query : null,
searchMode : "currentPackage",
createSearchUrlFunction : Ember.computed("searchMode","model",function() {
const packageId = this.get('model.id');
createSearchUrlFunction : Ember.computed("searchMode","model",function() {
const packageId = this.get('model.id');
if(this.get('searchMode') === "currentPackage") {
return (query) => urls.identifierSearchUrl(packageId,query);
} else {

View File

@ -2,7 +2,7 @@ import Ember from 'ember';
export default Ember.Controller.extend({
modulesFiltered : Ember.computed('model','query',function () {
const query = this.get('query');
const modules = Object.keys(this.get('model.modules')).sort();
const modules = Object.keys(this.get('model.modules')).sort();
if(query) {
const regExp = new RegExp(query,"i");
return modules.filter((p) => p.search(regExp) != -1);

View File

@ -4,7 +4,7 @@ import {goToDefinition} from '../../utils/go-to-definition';
export default Ember.Controller.extend({
store : Ember.inject.service('store'),
actions : {
goToDefinition (locationInfo,event) {
goToDefinition (locationInfo,event) {
goToDefinition(this.get('store'),
locationInfo,
event.which,

View File

@ -3,10 +3,10 @@ import {goToDefinition} from '../utils/go-to-definition';
export default Ember.Controller.extend({
store : Ember.inject.service('store'),
queryObserver : Ember.observer("query",function() {
queryObserver : Ember.observer("query",function() {
Ember.run.debounce(this, () => {
const regExp = new RegExp(this.get('query'),"i");
const packages = this.get('model').filter((p) => p.name.search(regExp) != -1);
const packages = this.get('model').filter((p) => p.name.search(regExp) != -1);
Ember.run.next(() => {
this.set('packages',packages);
});

View File

@ -4,7 +4,7 @@ import {goToDefinition} from '../utils/go-to-definition';
export default Ember.Controller.extend({
store : Ember.inject.service('store'),
actions : {
goToDefinition (locationInfo,event) {
goToDefinition (locationInfo,event) {
goToDefinition(this.get('store'),
locationInfo,
event.which,

View File

@ -14,8 +14,8 @@ Router.map(function() {
});
});
this.route('search',{path:'/search/:query'});
});
this.route('bad-url', { path: '/*badurl' });
});
this.route('bad-url', { path: '/*badurl' });
});
export default Router;

View File

@ -8,7 +8,7 @@ export default Ember.Route.extend({
.catch((e) => {console.log(e);this.transitionTo("/package-not-found");});
},
setupController(controller, model) {
this._super(controller, model);
this._super(controller, model);
controller.set('bottomPanelVisible',false);
},
actions : {

View File

@ -1,7 +1,7 @@
import Ember from 'ember';
export default Ember.Route.extend({
afterModel : function (model,transition) {
transition.send("fileOpened",null);
export default Ember.Route.extend({
afterModel : function (model,transition) {
transition.send("fileOpened",null);
}
});

View File

@ -10,7 +10,7 @@ export default Ember.Route.extend({
url: urls.identifierSearchUrl(this.modelFor('package').id,params.query)+"?per_page=20"
};
},
afterModel () {
afterModel () {
const onmouseup = (event) => {
// This makes links in documentation clickable
if(event.target.dataset.location) {
@ -26,7 +26,7 @@ export default Ember.Route.extend({
}
};
this._onmouseup = onmouseup;
document.addEventListener('mouseup',onmouseup);
document.addEventListener('mouseup',onmouseup);
},
deactivate() {
if(this._onmouseup) {

View File

@ -3,25 +3,25 @@ import Ember from 'ember';
export default Ember.Route.extend({
store : Ember.inject.service(),
model : function (params) {
const packageInfo = this.modelFor('package');
if(packageInfo.modules[params.filePath]) {
const packageInfo = this.modelFor('package');
if(packageInfo.modules[params.filePath]) {
return this.get('store').loadHaskellModule(packageInfo.id,params.filePath)
.catch((e) => {console.log(e);this.transitionTo("/not-found");});
.catch((e) => {console.log(e);this.transitionTo("/not-found");});
} else {
return this.get('store').loadFile(packageInfo.id,params.filePath)
.then((result) => {
.then((result) => {
document.title = packageInfo.id;
return result;
})
.catch((e) => {console.log(e);this.transitionTo("/not-found");});
}
},
afterModel (model) {
afterModel (model) {
document.title = model.id + " - " + this.modelFor('package').id;
},
actions : {
didTransition : function () {
this.send("fileOpened",this.currentModel.id);
}
didTransition : function () {
this.send("fileOpened",this.currentModel.id);
}
}
});

View File

@ -1,7 +1,7 @@
import Ember from 'ember';
export default Ember.Route.extend({
afterModel : function (model,transition) {
transition.send("fileOpened",null);
export default Ember.Route.extend({
afterModel : function (model,transition) {
transition.send("fileOpened",null);
}
});

View File

@ -11,12 +11,12 @@ export default Ember.Route.extend({
};
},
setupController(controller, model) {
this._super(controller, model);
this._super(controller, model);
controller.set('createSearchUrlFunction',(query) => {
return urls.globalIdentifiersUrl(query);
});
},
afterModel () {
afterModel () {
const onmouseup = (event) => {
// This makes links in documentation clickable
if(event.target.dataset.location) {
@ -32,11 +32,11 @@ export default Ember.Route.extend({
}
};
this._onmouseup = onmouseup;
document.addEventListener('mouseup',onmouseup);
document.addEventListener('mouseup',onmouseup);
},
deactivate() {
if(this._onmouseup) {
document.removeEventListener('mouseup',this._onmouseup);
}
}
}
});

View File

@ -14,7 +14,7 @@ export default Ember.Service.extend({
},
colorTheme : themes["darkTheme"],
settingsObserver : Ember.observer("colorTheme",function() {
if(localStorage) {
if(localStorage) {
localStorage.setItem("colorThemeId",this.get('colorTheme').id);
}
})

View File

@ -44,7 +44,7 @@ function parseLinkHeader(header) {
export default Ember.Service.extend({
init() {
init() {
this.packages = {};
this.files = {};
this.haskellModules = {};
@ -69,12 +69,12 @@ export default Ember.Service.extend({
},
loadFile(packageId,filePath) {
const fileId = packageId + "/" + filePath;
const file = this.files[fileId];
const file = this.files[fileId];
if(file) {
return new RSVP.Promise((resolve) => {resolve(file);});
} else {
const url = urls.fileUrl(packageId,filePath);
return Ember.$.get({url:url,dataType:"text"}).then((text) => {
const url = urls.fileUrl(packageId,filePath);
return Ember.$.get({url:url,dataType:"text"}).then((text) => {
const file = {};
file.text = text;
file.packageId = packageId;
@ -85,7 +85,7 @@ export default Ember.Service.extend({
});
}
},
loadHaskellModule(packageId,filePath) {
loadHaskellModule(packageId,filePath) {
const moduleId = packageId + "/" + filePath ;
const module = this.haskellModules[moduleId];
if(module) {
@ -93,7 +93,7 @@ export default Ember.Service.extend({
} else {
const url = urls.haskellModuleUrl(packageId,filePath);
return Ember.$.getJSON(url).then((module) => {
module.packageId = packageId;
module.packageId = packageId;
module.isHaskellModule = true;
this.haskellModules[moduleId] = module;
return module;
@ -112,23 +112,23 @@ export default Ember.Service.extend({
return definitionSite;
});
}
},
},
loadExpressions(packageId,modulePath,lineStart,columnStart,lineEnd,columnEnd) {
const id = packageId + "/" + encodeURIComponent(modulePath)
+ "/" + lineStart + "/" + columnStart + "/" + lineEnd + "/" + columnEnd;
const exprs = this.expressions[id];
if(exprs) {
return new RSVP.Promise((resolve)=>{resolve(exprs);});
return new RSVP.Promise((resolve)=>{resolve(exprs);});
} else {
const url = urls.expressionsUrl(packageId,modulePath,lineStart,columnStart,lineEnd,columnEnd);
return Ember.$.getJSON(url).then((exprs) => {
const url = urls.expressionsUrl(packageId,modulePath,lineStart,columnStart,lineEnd,columnEnd);
return Ember.$.getJSON(url).then((exprs) => {
this.expressions[id] = exprs;
return exprs;
});
});
}
},
loadFromUrlPaginated(url) {
return Ember.$.getJSON(url).then((items,textStatus,jqXHR) => {
loadFromUrlPaginated(url) {
return Ember.$.getJSON(url).then((items,textStatus,jqXHR) => {
const linkHeaderText = jqXHR.getResponseHeader('Link');
const totalCountHeaderText = jqXHR.getResponseHeader('x-total-count');
const linkHeader = parseLinkHeader(linkHeaderText);
@ -141,7 +141,7 @@ export default Ember.Service.extend({
});
},
loadGlobalReferences(externalId) {
const globalReferences = this.globalReferences[externalId];
const globalReferences = this.globalReferences[externalId];
if(globalReferences) {
return new RSVP.Promise((resolve) => {resolve(globalReferences);});
} else {

View File

@ -45,14 +45,14 @@ li {
.documentation {
margin-top:10px;
li {
list-style: disc outside none;
list-style: disc outside none;
}
ul {
padding-left:15px;
}
ol {
padding-left:15px;
}
}
}
.flex-container {
@ -73,7 +73,7 @@ li {
.header {
flex: none;
padding:5px;
img {
img {
float:left;
}
}
@ -140,7 +140,7 @@ li {
margin-top:20px;
}
.package-header-filename {
.package-header-filename {
white-space: nowrap;
margin-left: 35px;
}
@ -184,13 +184,13 @@ ul.modules {
position:absolute;
top:0px;
right:-20px;
z-index:2;
z-index:2;
width:20px;
height:20px;
height:20px;
text-align:center;
vertical-align:middle;
a {
text-decoration:none;
text-decoration:none;
}
opacity:0.6;
display:none;
@ -218,10 +218,10 @@ ul.modules {
right : 0;
left : 300px;
overflow-x: auto;
overflow-y: auto;
overflow-y: auto;
}
.file-tree-container {
.file-tree-container {
overflow-x: hidden;
overflow-y: auto;
position: absolute;
@ -238,7 +238,7 @@ ul.modules {
right : 0;
left : 0;
overflow-x: auto;
overflow-y: auto;
overflow-y: auto;
}
.bottom-panel {
@ -248,7 +248,7 @@ ul.modules {
right : 0;
left : 0;
overflow-x: auto;
overflow-y: auto;
overflow-y: auto;
z-index:4;
}
@ -258,7 +258,7 @@ ul.modules {
right : 0;
left : 0;
height: 35px;
padding: 5px;
padding: 5px;
}
.bottom-panel-content {
@ -268,7 +268,7 @@ ul.modules {
right : 0;
left : 0;
overflow-x: auto;
overflow-y: auto;
overflow-y: auto;
}
.bottom-panel-header-options {
@ -279,9 +279,9 @@ ul.modules {
white-space:nowrap;
}
.highlighted-identifier {
.highlighted-identifier {
border-radius: 3px;
box-shadow: 0 0 0 1px #B4B4B4;
box-shadow: 0 0 0 1px #B4B4B4;
}
.identifier {
@ -312,7 +312,7 @@ td.line-content {
$source-code-font:Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
.source-code {
.source-code {
font-family: $source-code-font;
white-space:pre;
line-height:1.25;
@ -332,12 +332,12 @@ code,pre {
}
.source-code-font {
font-family: $source-code-font;
font-family: $source-code-font;
line-height:1.25;
}
.source-code-snippet {
padding: 4px;
padding: 4px;
text-decoration:none !important;
display:block;
}
@ -360,7 +360,7 @@ code,pre {
position:fixed;
top:150px;
right:15px;
width: 450px;
width: 450px;
z-index:1;
div {
margin : 5px;
@ -369,7 +369,7 @@ code,pre {
.declarations-header {
opacity:0.9;
height:50px;
height:50px;
}
.declarations-content {
@ -380,7 +380,7 @@ code,pre {
right:0px;
max-height:500px;
overflow-y:auto;
overflow-x:hidden;
overflow-x:hidden;
}
@media screen and (max-width: 1500px) {
@ -395,28 +395,28 @@ code,pre {
z-index:10;
}
.info-window-header {
.info-window-header {
margin:5px;
width: 100%;
cursor: move;
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
cursor: -webkit-grab;
}
.info-window-content {
.info-window-content {
max-height:200px;
overflow-x:auto;
overflow-y:auto;
overflow-y:auto;
}
.info-window-options {
margin-right:10px;
margin-left:10px;
float:right;
float:right;
}
.ui-draggable-dragging .info-window-header {
cursor: grabbing;
cursor: -moz-grabbing;

View File

@ -1,4 +1,4 @@
<div class="container">
<div class="container">
<div style="margin-top:10px">
<h1>Not found</h1>
<div><a href="/">Main page</a></div>

View File

@ -1,14 +1,14 @@
<div class="source-code-container"></div>
{{#if declarations}}
<div class="declarations">
<div class="declarations-header">
<div class="declarations-header">
<div class="input-group">
{{input class="form-control" value=query placeholder="Identifier"}}<a class="hide-declarations" href="#" {{action "toggleShowDeclarations"}}>{{showDeclarationsLabel}}</a>
</div>
</div>
{{#if showDeclarations}}
<div id="declarations-content" class="declarations-content">
<ul>
<div id="declarations-content" class="declarations-content">
<ul>
{{#infinite-list containerElementId="declarations-content" elements=filteredDeclarations perPage=30 as |declaration|}}
<li class="declaration">
<div class="declaration">

View File

@ -2,7 +2,7 @@
<span class="source-code-font break-word identifier-menu-item" style={{style}}>{{#if identifierInfo.demangledOccName}}{{identifierInfo.demangledOccName}}{{else}}{{name}}{{/if}}</span>
{{#unless isBinder}}
{{#if location}}
<span class="identifier-menu-item">{{location}}</span>
<span class="identifier-menu-item">{{location}}</span>
<span class="link identifier-menu-item" onmouseup={{action "goToDefinition"}}>Go to definition</span>
{{/if}}
{{/unless}}

View File

@ -1,4 +1,4 @@
<div class="paginated-list-header">
<div class="paginated-list-header">
<span>Found {{total}} {{{foundWhere}}}</span>
{{#if (or next prev)}}
&nbsp;
@ -10,8 +10,8 @@
{{#if next}}<button button class="btn btn-outline-secondary btn-sm" {{action "update" next.href}}>&gt;</button>{{/if}}
{{#if last}}<button button class="btn btn-outline-secondary btn-sm" {{action "update" last.href}}>&gt;&gt;</button>{{/if}}
</span>
{{/if}}
{{/if}}
</div>
<div class="paginated-list-content">
{{yield items}}
{{yield items}}
</div>

View File

@ -1,6 +1,6 @@
<div class="flex-container">
<div class="package-header">
<span class="package-header-package-name">{{#link-to 'package' model}}{{model.id}}{{/link-to}}</span>
<span class="package-header-package-name">{{#link-to 'package' model}}{{model.id}}{{/link-to}}</span>
<span class="package-header-input">
{{#input-with-autocomplete
onSubmit=(action 'searchIdentifier')
@ -11,7 +11,7 @@
placeholder="Identifier" as |identifier|}}
<span class="source-code-font">{{identifier.demangledOccName}} :: {{type-signature-text components=identifier.idType.components}}</span>
<div class="module-name">
<b>{{identifier.locationInfo.packageId.name}}-{{identifier.locationInfo.packageId.version}}</b>
<b>{{identifier.locationInfo.packageId.name}}-{{identifier.locationInfo.packageId.version}}</b>
{{#if identifier.locationInfo.modulePath}}
{{identifier.locationInfo.modulePath}}
{{else}}
@ -29,7 +29,7 @@
value="allPackages"
groupValue=searchMode}}
<span>in all packages</span>
{{/radio-button}}
{{/radio-button}}
{{#if currentFile}}
<span class="package-header-filename">
{{currentFile}}
@ -66,7 +66,7 @@
</span>
{{/if}}
</div>
<div class="references">
<div class="references">
{{#paginated-list url=referencesUrl foundWhere=(concat "in <b>" packageId "</b>") as |files|}}
<ul>
{{#each files as |file|}}

View File

@ -1,12 +1,12 @@
<div class="package-modules">
<div class="module-search-input">
{{input class="form-control" type="text" value=query placeholder="Module name"}}
</div>
{{input class="form-control" type="text" value=query placeholder="Module name"}}
</div>
<ul class="modules">
{{#each modulesFiltered as |module|}}
<li>
<a href="/package/{{model.id}}/show/{{module}}">{{module}}</a>
</li>
{{/each}}
</ul>
</ul>
</div>

View File

@ -1,11 +1,11 @@
{{#if model.isHaskellModule}}
{{#if model.isHaskellModule}}
{{haskell-module
path=model.id
name=model.name
packageId=model.packageId
componentId=model.componentId
html=model.sourceCodeHtml
identifiers=model.identifiers
identifiers=model.identifiers
occurrences=model.occurrences
colorTheme=settings.colorTheme
declarations=model.declarations

View File

@ -1,6 +1,6 @@
<div class="flex-container container">
<div style="position:relative;height:100%">
<div class="absolute-container">
<div class="absolute-container">
<div class="global-identifier-search-form">
{{#input-with-autocomplete
onSubmit=(action 'searchIdentifier')

View File

@ -15,13 +15,13 @@ function fixDots(string) {
}
}
export const urls = {
export const urls = {
packageInfoUrl : function(packageId) {
return config.APP.staticUrlPrefix+"/"+packageId+"/"+config.APP.haskellCodeExplorerDirectory+"/packageInfo.json";
},
fileUrl : function(packageId,filePath) {
return config.APP.staticUrlPrefix+"/"+packageId+"/"+filePath;
},
},
haskellModuleUrl : function (packageId,filePath) {
return config.APP.staticUrlPrefix+"/"+packageId+"/"+config.APP.haskellCodeExplorerDirectory+"/"+encodeURIComponent(encodeURIComponent(filePath))+ ".json";
},

View File

@ -1,6 +1,6 @@
function colorThemeToCss(colorTheme) {
const css = `
body {
body {
color: ${colorTheme.defaultColor} !important;
background-color: ${colorTheme.backgroundColor} !important;
}
@ -31,7 +31,7 @@ function colorThemeToCss(colorTheme) {
}
.declarations-header {
background-color: ${colorTheme.navigationPanelColor} !important;
border: 1px solid ${colorTheme.borderColor} !important;
border: 1px solid ${colorTheme.borderColor} !important;
}
li.declaration {
border-bottom: 1px solid ${colorTheme.borderColor} !important;
@ -73,19 +73,19 @@ function colorThemeToCss(colorTheme) {
border-left: 1px solid ${colorTheme.borderColor} !important;
border-right: 1px solid ${colorTheme.borderColor} !important;
}
ul.autocomplete-items > li {
ul.autocomplete-items > li {
border-bottom: 1px solid ${colorTheme.borderColor} !important;
}
ul.autocomplete-items > li:hover {
ul.autocomplete-items > li:hover {
background-color: ${colorTheme.highlightedLineColor} !important;
}
ul.autocomplete-items > li.highlighted {
ul.autocomplete-items > li.highlighted {
background-color: ${colorTheme.highlightedLineColor} !important;
}
.source-code-snippet {
color: ${colorTheme.defaultColor} !important;
border-bottom: 1px solid ${colorTheme.borderColor} !important;
}
}
.source-code-snippet:hover {
background-color: ${colorTheme.highlightedLineColor} !important;
}
@ -94,7 +94,7 @@ function colorThemeToCss(colorTheme) {
border-top: 1px solid ${colorTheme.borderColor} !important;
}
.bottom-panel-header {
border-bottom: 1px solid ${colorTheme.borderColor} !important;
border-bottom: 1px solid ${colorTheme.borderColor} !important;
}
.paginated-list-header {
border-bottom: 1px solid ${colorTheme.borderColor} !important;
@ -118,7 +118,7 @@ function colorThemeToCss(colorTheme) {
}
.references-packages {
border-right:1px solid ${colorTheme.borderColor} !important;
}`;
}`;
return css;
}
@ -150,14 +150,14 @@ const lightTheme = {
name: "Light theme",
description: "Light theme (Github based)",
defaultColor: "#24292e",
backgroundColor: "#ffffff",
backgroundColor: "#ffffff",
typeColor: "#005cc5",
literalColor: "#032f62",
topLevelIdFromCurrentModule : "#6f42c1",
localIdentifierColor: ["#005C31",
"#2BCE48","#808080","#8F7C00",
"#C20088","#FFA405","#ffa8bb","#426600","#FF0010",
"#09d7d8","#00998F","#990000","#FF5005"],
"#09d7d8","#00998F","#990000","#FF5005"],
menuColor: "#f2f4f8",
menuLinkColor : "#24292e",
infoWindowColor: "#f2f4f8",
@ -171,7 +171,7 @@ function updateColorThemeCss (colorTheme) {
const newStyle = document.createElement('style');
newStyle.type = 'text/css';
newStyle.innerHTML = colorThemeToCss(colorTheme);
newStyle.id = 'color-theme';
newStyle.id = 'color-theme';
const oldStyle = document.querySelector("style#color-theme");
if(oldStyle) {
oldStyle.parentElement.removeChild(oldStyle);
@ -186,6 +186,6 @@ const themes = {
export {
updateColorThemeCss,
colorThemeToCss,
themes
colorThemeToCss,
themes
}

View File

@ -25,10 +25,10 @@ function openUrl(buttonId,url) {
return false;
}
function saveCurrentLocation(currentLineNumber) {
function saveCurrentLocation(currentLineNumber) {
if(currentLineNumber) {
const url = window.location.origin + window.location.pathname + "#L" + currentLineNumber;
if(location.href != url) {
const url = window.location.origin + window.location.pathname + "#L" + currentLineNumber;
if(location.href != url) {
window.location.hash = "#L" + currentLineNumber;
}
}
@ -43,7 +43,7 @@ function goToDefinition(store,locationInfo,buttonId,currentLineNumber) {
openUrl(buttonId,url);
} else if((locationInfo.tag === "ApproximateLocation") &&
(locationInfo.moduleName.indexOf("Paths_") !== 0)) {
const packageId = locationInfo.packageId.name+"-"+locationInfo.packageId.version;
const packageId = locationInfo.packageId.name+"-"+locationInfo.packageId.version;
if(locationInfo.entity === "Mod") {
store.loadDefinitionSite(packageId,
locationInfo.moduleName,
@ -55,7 +55,7 @@ function goToDefinition(store,locationInfo,buttonId,currentLineNumber) {
openUrl(buttonId,"/package/" + packageId + "/show/" + defSite.location.modulePath);
}).catch(() => {
openUrl(buttonId,hackageUrl(packageId,locationInfo));
});
});
} else {
store.loadDefinitionSite(packageId,
locationInfo.moduleName,
@ -78,10 +78,10 @@ function goToDefinition(store,locationInfo,buttonId,currentLineNumber) {
saveCurrentLocation(currentLineNumber);
openUrl(buttonId,hackageUrl(packageId,locationInfo));
});
}
}
} else {
alert('No location info');
}
}
}
export {

View File

@ -198,7 +198,7 @@ const extensions = {
"InterruptibleFFI": {
"description": "Enable interruptible FFI.",
"link": "https://haskell.org/ghc/docs/latest/html/users_guide/ffi-chap.html#interruptible-foreign-calls"
},
},
"KindSignatures": {
"description": "Allow an explicit kind signature giving the kind of types over which a type variable ranges.",
"link": "https://www.haskell.org/ghc/docs/latest/html/users_guide/glasgow_exts.html#ghc-flag--XKindSignatures"
@ -314,7 +314,7 @@ const extensions = {
"PatternGuards": {
"description": "Enable a form of guard which matches a pattern and binds variables.",
"link": "https://www.haskell.org/ghc/docs/latest/html/users_guide/glasgow_exts.html#ghc-flag--XPatternGuards"
},
},
"PatternSynonyms": {
"description": "Allow giving names to and abstracting over patterns.",
"link": "https://www.haskell.org/ghc/docs/latest/html/users_guide/glasgow_exts.html#ghc-flag--XPatternSynonyms"
@ -322,7 +322,7 @@ const extensions = {
"PolyKinds": {
"description": "Enable kind polymorphism.",
"link": "https://www.haskell.org/ghc/docs/latest/html/users_guide/glasgow_exts.html#ghc-flag--XPolyKinds"
},
},
"PostfixOperators": {
"description": "Relax the interpretation of left operator sections to allow unary postfix operators.",
"link": "https://www.haskell.org/ghc/docs/latest/html/users_guide/glasgow_exts.html#ghc-flag--XPostfixOperators"
@ -394,7 +394,7 @@ const extensions = {
"StarIsType": {
"description": "Have * refer to Type.",
"link":"https://ghc.haskell.org/trac/ghc/wiki/Migration/8.6#StarIsType"
},
"StaticPointers": {
"description": "Enable support for 'static pointers' (and the static keyword) to refer to globally stable names, even across different programs.",
@ -497,7 +497,7 @@ const extensions = {
const regexp = new RegExp(Object.keys(extensions).join("|"),"g");
function addLinksToLanguageExtensionsDocs(string) {
function addLinksToLanguageExtensionsDocs(string) {
return string.replace(regexp, function(match) {
const extension = extensions[match];
if(extensions) {

View File

@ -6,7 +6,7 @@ function initializeLineSelection(sourceCodeContainerElement,component) {
}
window.addEventListener("hashchange",onhashchange);
component._onhashchange = onhashchange;
let shiftPressed;
const onkeydown = function (event) {
if(event.keyCode === 16) { shiftPressed = true; }
@ -14,12 +14,12 @@ function initializeLineSelection(sourceCodeContainerElement,component) {
const onkeyup = function (event) {
if(event.keyCode === 16) { shiftPressed = false; }
};
document.addEventListener('keydown',onkeydown);
document.addEventListener('keyup',onkeyup);
component._onkeydown = onkeydown;
component._onkeyup = onkeyup;
let selectedLine1,selectedLine2;
lineNumbers.forEach((lineNumberElement) => {
lineNumberElement.onclick = function() {
@ -35,7 +35,7 @@ function initializeLineSelection(sourceCodeContainerElement,component) {
window.location.hash = "L"+selectedLine2+"-L"+selectedLine1;
}
}
} else {
} else {
selectedLine1 = number;
selectedLine2 = null;
highlightLines(sourceCodeContainerElement,selectedLine1,selectedLine1);
@ -43,11 +43,11 @@ function initializeLineSelection(sourceCodeContainerElement,component) {
}
}
});
const lines = highlightSelectedLines(sourceCodeContainerElement);
const lines = highlightSelectedLines(sourceCodeContainerElement);
if(lines.length) {
selectedLine1 = lines[0];
selectedLine2 = lines[1];
}
}
}
}
@ -85,18 +85,18 @@ function highlightSelectedLines (sourceCodeContainerElement) {
function scrollLineIntoView(lineElement,sourceCodeContainerElement) {
lineElement.parentNode.scrollIntoView();
const container = sourceCodeContainerElement.parentNode.parentNode;
const container = sourceCodeContainerElement.parentNode.parentNode;
const windowHeight = container.offsetHeight;
const fullHeight = sourceCodeContainerElement.offsetHeight;
if(fullHeight - container.scrollTop > windowHeight) {
if(fullHeight - container.scrollTop > windowHeight) {
container.scrollTop = container.scrollTop - (windowHeight/2 - 20);
}
}
function highlightLines(parentElement,startLine,endLine) {
function highlightLines(parentElement,startLine,endLine) {
const lineElements = Array.prototype.slice.call(parentElement.querySelectorAll("td.line-content"));
lineElements.forEach((lineElement) => {
lineElements.forEach((lineElement) => {
const number = parseInt(lineElement.id.substring(2)); //<td "id"="LC10">...</td>
if(number >= startLine && number <= endLine) {
lineElement.classList.add('highlighted-line');

View File

@ -19,7 +19,7 @@ module.exports = function(environment) {
},
pace: {
theme: 'minimal',
color: 'silver',
color: 'silver',
target: 'body',
elements: {
checkInterval: 100,

View File

@ -12,7 +12,7 @@ module.exports = function(defaults) {
includePolyfill: true
}
});
app.import('vendor/jquery-ui-1.12.1.custom/jquery-ui.min.js')// only draggable and resizable
app.import('vendor/jquery-ui-1.12.1.custom/jquery-ui.min.js')// only draggable and resizable
app.import('vendor/jquery-ui-1.12.1.custom/jquery-ui.structure.min.css')
app.import('node_modules/jstree/dist/jstree.min.js');
app.import('node_modules/jstree/dist/themes/default/style.min.css');

View File

@ -16,7 +16,7 @@ function usingProxy() {
module.exports = function(app) {
if (usingProxy()) { return; }
const globSync = require('glob').sync;
const mocks = globSync('./mocks/**/*.js', { cwd: __dirname }).map(require);
const proxies = globSync('./proxies/**/*.js', { cwd: __dirname }).map(require);

View File

@ -380,15 +380,15 @@ const testModuleInfo = {
module.exports = function(app) {
const express = require('express');
let packagesRouter = express.Router();
packagesRouter.get('/api/packages', function(req, res) {
packagesRouter.get('/api/packages', function(req, res) {
res.send(packages);
});
});
packagesRouter.get('/files/test-package-0.1.0.0/.haskell-code-explorer/packageInfo.json', function(req, res) {
res.send(testPackage);
});
packagesRouter.get('/files/test-package-0.1.0.0/.haskell-code-explorer/app%252FMain.hs.json', function(req, res) {
res.send(testModuleInfo);
});

View File

@ -5,7 +5,7 @@ module.exports = {
launch_in_ci: [
'Chrome'
],
launch_in_dev: [
launch_in_dev: [
'Chrome'
],
browser_args: {

View File

@ -5,17 +5,17 @@ import { setupApplicationTest } from 'ember-qunit';
module('Acceptance | haskell-module', function(hooks) {
setupApplicationTest(hooks);
//Test data is in 'server/mocks/packages.js'
test('visiting /package/test-package-0.1.0.0/show/app/Main.hs', async function(assert) {
await visit('/package/test-package-0.1.0.0/show/app/Main.hs');
assert.equal(currentURL(), '/package/test-package-0.1.0.0/show/app/Main.hs');
const lines = Array.from(find('tbody').children).map((tr) => {
return tr.children[1].innerText;
});
assert.deepEqual(lines,["module Main where",
"",
"import Lib",

View File

@ -5,16 +5,16 @@ import { setupApplicationTest } from 'ember-qunit';
module('Acceptance | package', function(hooks) {
setupApplicationTest(hooks);
//Test data is in 'server/mocks/packages.js'
test('visiting /package/test-package-0.1.0.0', async function(assert) {
await visit('/package/test-package-0.1.0.0');
assert.equal(currentURL(), '/package/test-package-0.1.0.0');
const moduleNames = Array.from(find('ul.modules').children).map((li) => {
return [li.innerText,li.children[0].getAttribute('href')];
});
});
assert.deepEqual(moduleNames,[["app/Main.hs","/package/test-package-0.1.0.0/show/app/Main.hs"],
["src/Lib.hs","/package/test-package-0.1.0.0/show/src/Lib.hs"],
["src/Types.hs","/package/test-package-0.1.0.0/show/src/Types.hs"],

View File

@ -4,7 +4,7 @@ import { setupApplicationTest } from 'ember-qunit';
module('Acceptance | packages', function(hooks) {
setupApplicationTest(hooks);
//Test data is in file 'server/mocks/packages.js'
test('visiting /', async function(assert) {
await visit('/');

View File

@ -25,7 +25,7 @@
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/test-support.js"></script>
<script src="{{rootURL}}assets/haskell-code-explorer.js"></script>
<script src="{{rootURL}}assets/tests.js"></script>
<script src="{{rootURL}}assets/tests.js"></script>
{{content-for "body-footer"}}
{{content-for "test-body-footer"}}

View File

@ -21,7 +21,7 @@ import GHC
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#else
, DataFamInstDecl(..)
#endif
#endif
, FamilyDecl(..)
, FieldOcc(..)
, FixitySig(..)
@ -33,7 +33,7 @@ import GHC
, HsPatSynDetails
#else
, HsPatSynDetails(..)
#endif
#endif
, HsRecField'(..)
, HsTupleSort(..)
, HsTyLit(..)
@ -43,7 +43,7 @@ import GHC
, IE(..)
, LHsBindLR
, LHsExpr
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#else
, LHsQTyVars(..)
#endif
@ -52,7 +52,7 @@ import GHC
, LSig
, LTyClDecl
, Located
, HsBracket(..)
, HsBracket(..)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
, HsMatchContext(..)
, Match(..)
@ -83,7 +83,7 @@ import HsExtension (GhcRn)
import HaskellCodeExplorer.GhcUtils (hsPatSynDetails, ieLocNames)
import Prelude hiding (span)
import TysWiredIn
( nilDataConName
( nilDataConName
, tupleTyConName
, typeNatKind
, typeSymbolKind
@ -97,7 +97,7 @@ import SrcLoc
, srcLocFile
, srcLocLine
, SrcSpan(..)
)
)
data NameOccurrence
= NameOccurrence { locatedName :: Located (Maybe Name)
, description :: T.Text
@ -125,7 +125,7 @@ namesFromRenamedSource =
tyFamilyEqNames `extQ`
tyFamilyDefEqNames `extQ`
dataFamInstDeclNames `extQ`
#endif
#endif
conDeclNames `extQ`
importNames `extQ`
hsTyVarBndrNames `extQ`
@ -159,18 +159,18 @@ fieldOccName isBinder (FieldOcc (L span _) name) =
conDeclFieldNames :: ConDeclField GhcRn -> [NameOccurrence]
#else
conDeclFieldNames :: ConDeclField Name -> [NameOccurrence]
#endif
#endif
conDeclFieldNames ConDeclField {..} =
map (fieldOccName True . unLoc) cd_fld_names
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
conDeclFieldNames _ = []
#endif
conDeclFieldNames _ = []
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
hsRecFieldExprNames :: HsRecField' (FieldOcc GhcRn) (LHsExpr GhcRn) -> [NameOccurrence]
#else
hsRecFieldExprNames :: HsRecField' (FieldOcc Name) (LHsExpr Name) -> [NameOccurrence]
#endif
#endif
hsRecFieldExprNames HsRecField {..} = [fieldOccName False $ unLoc hsRecFieldLbl]
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
@ -182,19 +182,19 @@ hsRecAmbFieldExprNames HsRecField {..} =
let (L span recField) = hsRecFieldLbl
mbName =
case recField of
Ambiguous _ _ -> Nothing
Ambiguous _ _ -> Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,3,0)
Unambiguous name _ -> Just name
_ -> Nothing
#else
Unambiguous _ name -> Just name
#endif
#endif
in [ NameOccurrence
{ locatedName = L span mbName
, description = "AmbiguousFieldOcc"
, isBinder = False
}
]
]
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
hsRecFieldPatNames :: HsRecField' (FieldOcc GhcRn) (LPat GhcRn) -> [NameOccurrence]
@ -261,7 +261,7 @@ hsExprNames (L _span (HsRecFld (Ambiguous (L span _) _name))) =
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsExprNames (L span (HsRnBracketOut _ (VarBr _ quote name) _)) =
#else
hsExprNames (L span (HsRnBracketOut (VarBr quote name) _)) =
@ -292,20 +292,20 @@ hsExprNames _ = []
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
matchGroupNames :: MatchGroup GhcRn (LHsExpr GhcRn) -> [NameOccurrence]
#else
matchGroupNames :: MatchGroup Name (LHsExpr Name) -> [NameOccurrence]
matchGroupNames :: MatchGroup Name (LHsExpr Name) -> [NameOccurrence]
#endif
matchGroupNames =
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
mapMaybe (fmap toNameOcc . matchContextName . m_ctxt . unLoc) .
#else
mapMaybe (fmap toNameOcc . matchFixityName . m_fixity . unLoc) .
#endif
unLoc . mg_alts
where
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
--matchContextName :: HsMatchContext Name -> Maybe (Located Name)
matchContextName (FunRhs name _ _bool) = Just name
matchContextName _ = Nothing
matchContextName _ = Nothing
#else
--matchFixityName :: MatchFixity Name -> Maybe (Located Name)
matchFixityName NonFunBindMatch = Nothing
@ -314,7 +314,7 @@ matchGroupNames =
--toNameOcc :: Located Name -> NameOccurrence
toNameOcc n =
NameOccurrence
{locatedName = Just <$> n, description = "Match", isBinder = True}
{locatedName = Just <$> n, description = "Match", isBinder = True}
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
bindNames :: LHsBindLR GhcRn GhcRn -> [NameOccurrence]
@ -384,7 +384,7 @@ patNames (L _span (ConPatIn name _)) =
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
patNames (L _span (AsPat _ name _)) =
#else
patNames (L _span (AsPat name _)) =
@ -395,7 +395,7 @@ patNames (L _span (AsPat name _)) =
, isBinder = True
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
patNames (L _span (NPlusKPat _ name _ _ _ _)) =
#else
patNames (L _span (NPlusKPat name _ _ _ _ _)) =
@ -428,9 +428,9 @@ sigNames (L _span (TypeSig names _)) =
, isBinder = False
})
names
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNames (L _span (PatSynSig _ names _)) = map (\name -> NameOccurrence (Just <$> name) "PatSynSig" False) names
sigNames (L _span (PatSynSig _ names _)) = map (\name -> NameOccurrence (Just <$> name) "PatSynSig" False) names
#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
sigNames (L _span (PatSynSig names _)) = map (\name -> NameOccurrence (Just <$> name) "PatSynSig" False) names
#else
@ -490,7 +490,7 @@ sigNames (L _span (SpecSig name _ _)) =
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNames (L _span (MinimalSig _ _ (L _ boolFormula))) =
#else
sigNames (L _span (MinimalSig _ (L _ boolFormula))) =
@ -516,9 +516,9 @@ sigNames (L _ _) = []
hsTypeNames :: LHsType GhcRn -> [NameOccurrence]
#else
hsTypeNames :: LHsType Name -> [NameOccurrence]
#endif
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTypeNames (L _span (HsTyVar _ _promoted name)) =
hsTypeNames (L _span (HsTyVar _ _promoted name)) =
#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
hsTypeNames (L _span (HsTyVar _promoted name)) =
#else
@ -530,7 +530,7 @@ hsTypeNames (L _span (HsTyVar name)) =
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTypeNames (L span (HsTyLit _ lit)) =
#else
hsTypeNames (L span (HsTyLit lit)) =
@ -545,7 +545,7 @@ hsTypeNames (L span (HsTyLit lit)) =
, kind = kind
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTypeNames (L _span (HsOpTy _ _ name _)) =
#else
hsTypeNames (L _span (HsOpTy _ name _)) =
@ -556,7 +556,7 @@ hsTypeNames (L _span (HsOpTy _ name _)) =
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTypeNames (L span (HsTupleTy _ tupleSort types))
#else
hsTypeNames (L span (HsTupleTy tupleSort types))
@ -575,7 +575,7 @@ hsTypeNames (L span (HsTupleTy tupleSort types))
}
]
| otherwise = []
--https://ghc.haskell.org/trac/ghc/ticket/13737
--https://ghc.haskell.org/trac/ghc/ticket/13737
--hsTypeNames (L span (HsExplicitListTy _kind types)) = ...
--hsTypeNames (L span (HsExplicitTupleTy _kind types)) = ...
hsTypeNames _ = []
@ -586,18 +586,18 @@ hsTyVarBndrNames :: HsTyVarBndr GhcRn -> [NameOccurrence]
#else
hsTyVarBndrNames :: HsTyVarBndr Name -> [NameOccurrence]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTyVarBndrNames (UserTyVar _ n) =
#else
hsTyVarBndrNames (UserTyVar n) =
#endif
#endif
[ NameOccurrence
{ locatedName = Just <$> n
, description = "UserTyVar"
, isBinder = True
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTyVarBndrNames (KindedTyVar _ n _) =
#else
hsTyVarBndrNames (KindedTyVar n _) =
@ -610,14 +610,14 @@ hsTyVarBndrNames (KindedTyVar n _) =
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTyVarBndrNames _ = []
#endif
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
tyClDeclNames :: LTyClDecl GhcRn -> [NameOccurrence]
#else
tyClDeclNames :: LTyClDecl Name -> [NameOccurrence]
#endif
#endif
tyClDeclNames (L _span DataDecl {..}) =
[ NameOccurrence
{ locatedName = Just <$> tcdLName
@ -692,7 +692,7 @@ dataEqNames FamEqn {feqn_tycon = tyCon} =
dataEqNames _ = []
#endif
#else
#else
tyFamilyEqNames :: TyFamEqn Name (HsTyPats Name) -> [NameOccurrence]
tyFamilyEqNames TyFamEqn {tfe_tycon = tyCon} =
[ NameOccurrence
@ -744,7 +744,7 @@ conDeclNames con =
, isBinder = True
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
_ -> []
#endif
@ -752,7 +752,7 @@ conDeclNames con =
foreignDeclNames :: ForeignDecl GhcRn -> [NameOccurrence]
#else
foreignDeclNames :: ForeignDecl Name -> [NameOccurrence]
#endif
#endif
foreignDeclNames decl =
[ NameOccurrence
{ locatedName = Just <$> fd_name decl
@ -766,7 +766,7 @@ roleAnnotationNames :: RoleAnnotDecl GhcRn -> [NameOccurrence]
#else
roleAnnotationNames :: RoleAnnotDecl Name -> [NameOccurrence]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
roleAnnotationNames (RoleAnnotDecl _ n _) =
#else
roleAnnotationNames (RoleAnnotDecl n _) =
@ -796,4 +796,4 @@ injectivityAnnotationNames (InjectivityAnn lhsName rhsNames) =
, description = "InjectivityAnn"
, isBinder = False
}

View File

@ -92,7 +92,7 @@ import HsSyn
, ListPatTc (..)
, OverLitTc (..)
, MatchGroupTc (..)
, NHsValBindsLR (..)
, NHsValBindsLR (..)
#endif
)
import HscTypes (TypeEnv, lookupTypeEnv)
@ -119,7 +119,7 @@ import Type
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
, nonDetCmpTypes
#else
, cmpTypes
, cmpTypes
#endif
, eqTypes
, eqType
@ -202,10 +202,10 @@ exprSort (ExplicitTuple _ args _)
exprSort (ExplicitTuple args _)
#endif
| null args = Simple
| otherwise = Composite
exprSort (ExplicitList _ _ args)
| otherwise = Composite
exprSort (ExplicitList _ _ args)
| null args = Simple
| otherwise = Composite
| otherwise = Composite
exprSort _ = Composite
@ -220,7 +220,7 @@ patSort (ListPat pats _ _)
#endif
| null pats = Simple
| otherwise = Composite
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
patSort (TuplePat _ pats _)
#else
patSort (TuplePat pats _ _)
@ -247,7 +247,7 @@ splitFunTySafe srcSpan astNode typ =
modify'
(\st -> st {astStateTypeErrors = typeError : astStateTypeErrors st})
return Nothing
-- | Splits a type of a function of two arguments, adds
-- 'TypeError' to 'ASTState' in case of a failure.
splitFunTy2Safe ::
@ -261,7 +261,7 @@ splitFunTy2Safe srcSpan astNode typ = do
Just (arg2, ty2) -> return $ Just (arg1, arg2, ty2)
Nothing -> return Nothing
Nothing -> return Nothing
-- | Returns result type of a function, adds 'TypeError' to
-- 'ASTState' in case of a failure.
funResultTySafe :: SrcSpan -> T.Text -> Type -> State ASTState (Maybe Type)
@ -313,7 +313,7 @@ addExprInfo span mbType descr sort = do
, isBinder = False
, instanceResolution = Nothing
, idOccType =
case mbHsWrapper of
case mbHsWrapper of
Just w -> mkType flags <$> (applyWrapper w <$> mbType)
Nothing -> mkType flags <$> mbType
, typeArguments = Nothing
@ -380,7 +380,7 @@ instance Ord InstTypes where
compare (InstTypes ts1) (InstTypes ts2) = cmpTypes ts1 ts2
#endif
-- | Creates an instance resolution tree
-- | Creates an instance resolution tree
traceInstanceResolution ::
Environment
-> Class
@ -398,7 +398,7 @@ traceInstanceResolution environment c ts = go c ts S.empty
(take clsTyVarCount types) of
Right (inst, instTypes) ->
-- A successful match is a ClsInst, together with the types at which
-- the dfun_id in the ClsInst should be instantiated
-- the dfun_id in the ClsInst should be instantiated
let instWithTypes = (is_dfun_name inst, InstTypes instTypes)
in if not $ S.member instWithTypes seenInstances
then let (typeVars, predTypes, _class, _types) =
@ -481,8 +481,8 @@ mkIdentifierInfo environment identifier mbNameFromRenamedSource =
[ HCE.packageIdToText currentPackageId
, HCE.getHaskellModuleName moduleName
, case nameSpace of
HCE.VarName -> T.pack $ show HCE.Val
HCE.DataName -> T.pack $ show HCE.Val
HCE.VarName -> T.pack $ show HCE.Val
HCE.DataName -> T.pack $ show HCE.Val
_ -> T.pack $ show HCE.Typ
, nameToText name
]
@ -493,7 +493,7 @@ mkIdentifierInfo environment identifier mbNameFromRenamedSource =
"|"
[ HCE.packageIdToText packageId
, HCE.getHaskellModuleName moduleName
, T.pack $ show entity
, T.pack $ show entity
, n
]
_ -> Nothing
@ -546,7 +546,7 @@ restoreHsWrapper action = do
wrapper <- astStateHsWrapper <$> get
res <- action
modify' $ \s -> s {astStateHsWrapper = wrapper}
return res
return res
tidyIdentifier :: Id -> State ASTState (Id, Maybe (Type, [Type]))
tidyIdentifier identifier = do
@ -575,7 +575,7 @@ tidyType typ = do
modify' (\s -> s {astStateTidyEnv = tidyEnv'})
return typ'
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldTypecheckedSource :: LHsBinds GhcTc -> State ASTState ()
#else
foldTypecheckedSource :: LHsBinds Id -> State ASTState ()
@ -633,7 +633,7 @@ foldLHsExpr (L span (HsOverLit OverLit {ol_type})) =
then Simple
else Composite)
return $ Just typ
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsExpr (L span (HsLit _ lit)) =
#else
foldLHsExpr (L span (HsLit lit)) =
@ -672,14 +672,14 @@ foldLHsExpr (L span expr@(HsLamCase _typ MG {..})) =
addExprInfo span (Just typ) "HsLamCase" (exprSort expr)
mapM_ foldLMatch $ unLoc mg_alts
return $ Just typ
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsExpr (L span expr@(HsApp _ fun arg)) = do
#else
foldLHsExpr (L span expr@(HsApp fun arg)) = do
#endif
funTy <- foldLHsExpr fun
_argTy <- foldLHsExpr arg
typ <- maybe (return Nothing) (funResultTySafe span "HsApp") funTy
typ <- maybe (return Nothing) (funResultTySafe span "HsApp") funTy
addExprInfo span typ "HsApp" (exprSort expr)
return typ
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
@ -691,18 +691,18 @@ foldLHsExpr (L span ex@(HsAppTypeOut expr _)) = do
typ <- foldLHsExpr expr
addExprInfo span typ "HsAppType" (exprSort ex)
return typ
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsExpr (L span expr@(OpApp _ left op right)) = do
#else
foldLHsExpr (L span expr@(OpApp left op _fixity right)) = do
#endif
opTyp <- foldLHsExpr op
typ <- maybe (return Nothing) (funResultTy2Safe span "HsApp") opTyp
typ <- maybe (return Nothing) (funResultTy2Safe span "HsApp") opTyp
_ <- foldLHsExpr left
_ <- foldLHsExpr right
addExprInfo span typ "OpApp" (exprSort expr)
return typ
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsExpr (L span e@(NegApp _ expr _syntaxExp)) = do
#else
foldLHsExpr (L span e@(NegApp expr _syntaxExp)) = do
@ -710,7 +710,7 @@ foldLHsExpr (L span e@(NegApp expr _syntaxExp)) = do
typ <- foldLHsExpr expr
addExprInfo span typ "NegApp" (exprSort e)
return typ
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsExpr (L _span (HsPar _ expr)) = foldLHsExpr expr
#else
foldLHsExpr (L _span (HsPar expr)) = foldLHsExpr expr
@ -722,7 +722,7 @@ foldLHsExpr (L span expr@(SectionL operand operator)) = do
#endif
opType <- foldLHsExpr operator
_ <- foldLHsExpr operand
mbTypes <- maybe (return Nothing) (splitFunTy2Safe span "SectionL") opType
mbTypes <- maybe (return Nothing) (splitFunTy2Safe span "SectionL") opType
let typ =
case mbTypes of
Just (_arg1, arg2, res) -> Just $ mkFunTy arg2 res
@ -736,7 +736,7 @@ foldLHsExpr (L span e@(SectionR operator operand)) = do
#endif
opType <- foldLHsExpr operator
_ <- foldLHsExpr operand
mbTypes <- maybe (return Nothing) (splitFunTy2Safe span "SectionR") opType
mbTypes <- maybe (return Nothing) (splitFunTy2Safe span "SectionR") opType
let typ =
case mbTypes of
Just (arg1, _arg2, res) -> Just $ mkFunTy arg1 res
@ -769,7 +769,7 @@ foldLHsExpr (L _span (ExplicitSum _ _ expr _types)) = do
#endif
-- TODO
_ <- foldLHsExpr expr
return Nothing
return Nothing
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsExpr (L span e@(HsCase _ expr (MG (MatchGroupTc {..}) mg_alts _))) =
@ -798,7 +798,7 @@ foldLHsExpr (L span e@(HsMultiIf typ grhss)) =
addExprInfo span (Just typ') "HsMultiIf" (exprSort e)
mapM_ foldLGRHS grhss
return $ Just typ'
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsExpr (L span e@(HsLet _ (L _ binds) expr)) = do
#else
foldLHsExpr (L span e@(HsLet (L _ binds) expr)) = do
@ -807,7 +807,7 @@ foldLHsExpr (L span e@(HsLet (L _ binds) expr)) = do
typ <- foldLHsExpr expr
addExprInfo span typ "HsLet" (exprSort e)
return typ
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsExpr (L span expr@(HsDo typ _context (L _ stmts))) =
#else
foldLHsExpr (L span expr@(HsDo _context (L _ stmts) typ)) =
@ -843,12 +843,12 @@ foldLHsExpr (L span e@(RecordCon (L _ _) _conLike conExpr binds)) = do
addExprInfo span mbConType "RecordCon" (exprSort e)
_ <- foldHsRecFields binds
return mbConType
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsExpr (L span e@(RecordUpd (RecordUpdTc cons _inputTys outTys _wrapper) expr binds)) =
#else
foldLHsExpr (L span e@(RecordUpd expr binds cons _inputTys outTys _wrapper)) =
#endif
restoreTidyEnv $ do
restoreTidyEnv $ do
-- cons is a non-empty list of DataCons that have all the upd'd fields
let typ = conLikeResTy (head cons) outTys
typ' <- tidyType typ
@ -879,7 +879,7 @@ foldLHsExpr (L span e@(ArithSeq postTcExpr _mbSyntaxExpr seqInfo)) = do
addExprInfo span typ "ArithSeq" (exprSort e)
return typ
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#else
#else
foldLHsExpr (L span e@(PArrSeq postTcExpr _seqInfo)) = do
typ <- foldLHsExpr (L (UnhelpfulSpan $ mkFastString "PArrSeq") postTcExpr)
addExprInfo span typ "ArithSeq" (exprSort e)
@ -914,7 +914,7 @@ foldLHsExpr (L span expr@(HsProc pat cmd)) = do
_ <- foldLHsCmdTop cmd
addExprInfo span Nothing "HsProc" (exprSort expr)
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
foldLHsExpr (L span e@(HsStatic _ expr)) = do
#else
foldLHsExpr (L span e@(HsStatic expr)) = do
@ -932,7 +932,7 @@ foldLHsExpr (L span e@(HsTick _ expr)) = do
typ <- foldLHsExpr expr
addExprInfo span typ "HsTick" (exprSort e)
return typ
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsExpr (L span e@(HsBinTick _ _ _ expr)) = do
#else
foldLHsExpr (L span e@(HsBinTick _ _ expr)) = do
@ -940,7 +940,7 @@ foldLHsExpr (L span e@(HsBinTick _ _ expr)) = do
typ <- foldLHsExpr expr
addExprInfo span typ "HsBinTick" (exprSort e)
return typ
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsExpr (L span e@(HsTickPragma _ _ _ _ expr)) = do
#else
foldLHsExpr (L span e@(HsTickPragma _ _ _ expr)) = do
@ -962,7 +962,7 @@ foldLHsExpr (L span (HsWrap wrapper expr)) =
Simple -> modify' (\s -> s {astStateHsWrapper = Just wrapper})
Composite -> return () -- Not sure if it is possible
typ <- foldLHsExpr (L span expr)
return $ applyWrapper wrapper <$> typ
return $ applyWrapper wrapper <$> typ
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldHsRecFields :: HsRecFields GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type)
@ -977,12 +977,12 @@ foldHsRecFields HsRecFields {..} = do
mapM_ foldLHsRecField $ userWritten rec_flds
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldLHsRecField :: LHsRecField GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type)
#else
foldLHsRecField :: LHsRecField Id (LHsExpr Id) -> State ASTState (Maybe Type)
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsRecField (L _span (HsRecField (L _idSpan (XFieldOcc _)) _ _)) = return Nothing
foldLHsRecField (L span (HsRecField (L idSpan (FieldOcc identifier _)) arg pun)) =
#else
@ -995,7 +995,7 @@ foldLHsRecField (L span (HsRecField (L idSpan (FieldOcc _ identifier)) arg pun))
unless pun $ void (foldLHsExpr arg)
return . Just . varType $ identifier'
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldLHsRecUpdField :: LHsRecUpdField GhcTc -> State ASTState (Maybe Type)
#else
foldLHsRecUpdField :: LHsRecUpdField Id -> State ASTState (Maybe Type)
@ -1023,7 +1023,7 @@ data TupArg
| TupArgMissing
deriving (Show, Eq)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldLHsTupArg :: LHsTupArg GhcTc -> State ASTState (Maybe Type, TupArg)
#else
foldLHsTupArg :: LHsTupArg Id -> State ASTState (Maybe Type, TupArg)
@ -1056,10 +1056,10 @@ foldLMatch (L _span Match {..}) = do
_ <- foldGRHSs m_grhss
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLMatch (L _span _) = return Nothing
foldLMatch (L _span _) = return Nothing
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldLMatchCmd :: LMatch GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type)
#else
foldLMatchCmd :: LMatch Id (LHsCmd Id) -> State ASTState (Maybe Type)
@ -1069,10 +1069,10 @@ foldLMatchCmd (L _span Match {..}) = do
_ <- foldGRHSsCmd m_grhss
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLMatchCmd (L _span _) = return Nothing
foldLMatchCmd (L _span _) = return Nothing
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldGRHSsCmd :: GRHSs GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type)
#else
foldGRHSsCmd :: GRHSs Id (LHsCmd Id) -> State ASTState (Maybe Type)
@ -1082,8 +1082,8 @@ foldGRHSsCmd GRHSs {..} = do
_ <- foldHsLocalBindsLR (unLoc grhssLocalBinds)
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldGRHSsCmd (_) = return Nothing
#endif
foldGRHSsCmd (_) = return Nothing
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldGRHSs :: GRHSs GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type)
@ -1095,7 +1095,7 @@ foldGRHSs GRHSs {..} = do
_ <- foldHsLocalBindsLR (unLoc grhssLocalBinds)
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldGRHSs (_) = return Nothing
foldGRHSs (_) = return Nothing
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
@ -1120,7 +1120,7 @@ foldLStmtLR (L _span (BindStmt pat body _ _ _)) = do
_ <- foldLPat pat
_ <- foldLHsExpr body
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLStmtLR (L span (BodyStmt _ body _ _)) = do
#else
foldLStmtLR (L span (BodyStmt body _ _ _)) = do
@ -1128,14 +1128,14 @@ foldLStmtLR (L span (BodyStmt body _ _ _)) = do
mbTyp <- foldLHsExpr body
addExprInfo span mbTyp "BodyStmt" Composite
return mbTyp
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLStmtLR (L _ (LetStmt _ (L _ binds))) = do
#else
foldLStmtLR (L _ (LetStmt (L _ binds))) = do
#endif
_ <- foldHsLocalBindsLR binds
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLStmtLR (L _ (ParStmt _ blocks _ _)) = do
#else
foldLStmtLR (L _ (ParStmt blocks _ _ _)) = do
@ -1143,7 +1143,7 @@ foldLStmtLR (L _ (ParStmt blocks _ _ _)) = do
mapM_ foldParStmtBlock blocks
return Nothing
foldLStmtLR (L _ TransStmt {..}) = do
mapM_ foldLStmtLR trS_stmts
mapM_ foldLStmtLR trS_stmts
_ <- maybe (return Nothing) foldLHsExpr trS_by
_ <- foldLHsExpr trS_using
return Nothing
@ -1162,7 +1162,7 @@ foldLStmtLR (L span (ApplicativeStmt args _ typ)) =
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldApplicativeArg :: ApplicativeArg GhcTc -> State ASTState (Maybe Type)
foldApplicativeArg :: ApplicativeArg GhcTc -> State ASTState (Maybe Type)
#elif MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldApplicativeArg :: ApplicativeArg GhcTc GhcTc -> State ASTState (Maybe Type)
#else
@ -1183,14 +1183,14 @@ foldApplicativeArg appArg =
_ <- foldLPat pat
_ <- foldLHsExpr expr
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
ApplicativeArgMany _ exprStmts _ pat -> do
#else
ApplicativeArgMany exprStmts _ pat -> do
#endif
mapM_ foldLStmtLR exprStmts
_ <- foldLPat pat
return Nothing
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldLStmtLRCmd ::
LStmtLR GhcTc GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type)
@ -1214,7 +1214,7 @@ foldLStmtLRCmd (L _ (BindStmt pat body _ _ _)) = do
_ <- foldLPat pat
_ <- foldLHsCmd body
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLStmtLRCmd (L span (BodyStmt _ body _ _)) = do
#else
foldLStmtLRCmd (L span (BodyStmt body _ _ _)) = do
@ -1222,14 +1222,14 @@ foldLStmtLRCmd (L span (BodyStmt body _ _ _)) = do
typ <- foldLHsCmd body
addExprInfo span typ "BodyStmt Cmd" Composite
return typ
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLStmtLRCmd (L _ (LetStmt _ (L _ binds))) = do
#else
foldLStmtLRCmd (L _ (LetStmt (L _ binds))) = do
#endif
_ <- foldHsLocalBindsLR binds
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLStmtLRCmd (L _ (ParStmt _ blocks _ _)) = do
#else
foldLStmtLRCmd (L _ (ParStmt blocks _ _ _)) = do
@ -1253,14 +1253,14 @@ foldLStmtLRCmd (L span (ApplicativeStmt args _ typ)) =
typ' <- tidyType typ
mapM_ (foldApplicativeArg . snd) args
addExprInfo span (Just typ') "ApplicativeStmt Cmd" Composite
return Nothing
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldLGRHS :: LGRHS GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type)
#else
foldLGRHS :: LGRHS Id (LHsExpr Id) -> State ASTState (Maybe Type)
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLGRHS (L _span (XGRHS _)) = return Nothing
foldLGRHS (L _span (GRHS _ guards body)) = do
#else
@ -1270,12 +1270,12 @@ foldLGRHS (L _span (GRHS guards body)) = do
mapM_ foldLStmtLR guards
return typ
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldLGRHSCmd :: LGRHS GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type)
#else
foldLGRHSCmd :: LGRHS Id (LHsCmd Id) -> State ASTState (Maybe Type)
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLGRHSCmd (L _span (XGRHS _)) = return Nothing
foldLGRHSCmd (L _span (GRHS _ guards body)) = do
#else
@ -1283,14 +1283,14 @@ foldLGRHSCmd (L _span (GRHS guards body)) = do
#endif
typ <- foldLHsCmd body
mapM_ foldLStmtLR guards
return typ
return typ
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldParStmtBlock :: ParStmtBlock GhcTc GhcTc -> State ASTState (Maybe Type)
#else
foldParStmtBlock :: ParStmtBlock Id Id -> State ASTState (Maybe Type)
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldParStmtBlock (XParStmtBlock _) = return Nothing
foldParStmtBlock (ParStmtBlock _ exprStmts _ids _syntaxExpr) = do
#else
@ -1299,12 +1299,12 @@ foldParStmtBlock (ParStmtBlock exprStmts _ids _syntaxExpr) = do
mapM_ foldLStmtLR exprStmts
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldHsLocalBindsLR :: HsLocalBindsLR GhcTc GhcTc -> State ASTState (Maybe Type)
#else
foldHsLocalBindsLR :: HsLocalBindsLR Id Id -> State ASTState (Maybe Type)
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldHsLocalBindsLR (XHsLocalBindsLR _) = return Nothing
foldHsLocalBindsLR (HsValBinds _ binds) = do
#else
@ -1315,26 +1315,26 @@ foldHsLocalBindsLR (HsValBinds binds) = do
foldHsLocalBindsLR HsIPBinds {} = return Nothing
foldHsLocalBindsLR EmptyLocalBinds {} = return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldHsValBindsLR :: HsValBindsLR GhcTc GhcTc -> State ASTState (Maybe Type)
#else
foldHsValBindsLR :: HsValBindsLR Id Id -> State ASTState (Maybe Type)
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldHsValBindsLR (ValBinds _ _binds _) = do
foldHsValBindsLR (ValBinds _ _binds _) = do
return Nothing
foldHsValBindsLR (XValBindsLR (NValBinds binds _)) = do
_ <- mapM_ (foldLHsBindsLR . snd) binds
return Nothing
#else
return Nothing
#else
foldHsValBindsLR (ValBindsIn _ _) = return Nothing
foldHsValBindsLR (ValBindsOut binds _) = do
mapM_ (foldLHsBindsLR . snd) binds
return Nothing
#endif
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldLHsBindsLR :: LHsBinds GhcTc -> State ASTState ()
#else
foldLHsBindsLR :: LHsBinds Id -> State ASTState ()
@ -1412,11 +1412,11 @@ foldLHsBindLR (L _ (PatSynBind PSB {..})) _ =
mapM_
(\(RecordPatSynField selId patVar) ->
addId selId >> addId patVar)
recs
recs
#endif
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldLPat :: LPat GhcTc -> State ASTState (Maybe Type)
#else
foldLPat :: LPat Id -> State ASTState (Maybe Type)
@ -1436,7 +1436,7 @@ foldLPat (L span pat@(WildPat typ)) = do
typ' <- tidyType typ
addExprInfo span (Just typ') "WildPat" (patSort pat)
return $ Just typ'
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLPat (L span p@(LazyPat _ pat)) = do
#else
foldLPat (L span p@(LazyPat pat)) = do
@ -1454,12 +1454,12 @@ foldLPat (L span p@(AsPat (L idSpan identifier) pat)) = do
addExprInfo span (Just . varType $ identifier') "AsPat" (patSort p)
_ <- foldLPat pat
return . Just . varType $ identifier'
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLPat (L _span (ParPat _ pat)) = foldLPat pat
#else
foldLPat (L _span (ParPat pat)) = foldLPat pat
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLPat (L span p@(BangPat _ pat)) = do
#else
foldLPat (L span p@(BangPat pat)) = do
@ -1487,14 +1487,14 @@ foldLPat (L span pat@(TuplePat pats boxity types)) = do
mapM_ foldLPat pats
return $ Just typ'
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLPat (L _span (SumPat _ pat _ _)) = do
#else
foldLPat (L _span (SumPat pat _ _ _types)) = do
#endif
-- TODO
_ <- foldLPat pat
return Nothing
return Nothing
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#else
@ -1503,10 +1503,10 @@ foldLPat (L span pat@(PArrPat pats typ)) = do
addExprInfo span (Just typ') "PArrPat" (patSort pat)
mapM_ foldLPat pats
return $ Just typ'
#endif
#endif
foldLPat (L _span (ConPatIn _ _)) = return Nothing
foldLPat (L span pat@ConPatOut {..}) = do
let (L idSpan conLike) = pat_con
let (L idSpan conLike) = pat_con
conId =
case conLike of
RealDataCon dc -> dataConWorkId dc
@ -1518,7 +1518,7 @@ foldLPat (L span pat@ConPatOut {..}) = do
addExprInfo span (Just typ') "ConPatOut" (patSort pat)
_ <- foldHsConPatDetails pat_args
return . Just . varType $ identifier'
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLPat (L span p@(ViewPat typ expr pat)) = do
#else
foldLPat (L span p@(ViewPat expr pat typ)) = do
@ -1529,7 +1529,7 @@ foldLPat (L span p@(ViewPat expr pat typ)) = do
_ <- foldLHsExpr expr
return $ Just typ'
foldLPat (L _ SplicePat {}) = return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLPat (L span (LitPat _ hsLit)) = do
#else
foldLPat (L span (LitPat hsLit)) = do
@ -1543,7 +1543,7 @@ foldLPat (L span (LitPat hsLit)) = do
then Simple
else Composite)
return $ Just typ'
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLPat (L span pat@(NPat _ (L _spanLit (OverLit (OverLitTc {..}) _ _)) _ _)) = do
#else
foldLPat (L span pat@(NPat (L _spanLit OverLit {ol_type}) _ _ _)) = do
@ -1573,15 +1573,15 @@ foldLPat (L span pat@(NPlusKPat (L idSpan identifier) (L litSpan OverLit {ol_typ
foldLPat (L _span (SigPat typ pat)) = do
typ' <- tidyType typ
_ <- foldLPat pat
return $ Just typ'
return $ Just typ'
#else
foldLPat (L _span (SigPatIn _ _)) = return Nothing
foldLPat (L _span (SigPatIn _ _)) = return Nothing
foldLPat (L _span (SigPatOut pat typ)) = do
typ' <- tidyType typ
_ <- foldLPat pat
return $ Just typ'
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLPat (L span p@(CoPat _ _ pat typ)) = do
#else
foldLPat (L span p@(CoPat _ pat typ)) = do
@ -1589,9 +1589,9 @@ foldLPat (L span p@(CoPat _ pat typ)) = do
typ' <- tidyType typ
addExprInfo span (Just typ') "CoPat" (patSort p)
_ <- foldLPat (L span pat)
return Nothing
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldHsConPatDetails
:: HsConPatDetails GhcTc
-> State ASTState (Maybe Type)
@ -1599,7 +1599,7 @@ foldHsConPatDetails
foldHsConPatDetails
:: HsConPatDetails Id
-> State ASTState (Maybe Type)
#endif
#endif
foldHsConPatDetails (PrefixCon args) = do
mapM_ foldLPat args
return Nothing
@ -1639,15 +1639,15 @@ foldLHsRecFieldPat (L _ (HsRecField (L idSpan (FieldOcc _ identifier)) arg pun))
unless pun $ void $ foldLPat arg
return . Just . varType $ identifier'
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsRecFieldPat (L _ (HsRecField (L _idSpan (XFieldOcc _)) _arg _pun)) = return Nothing
#endif
foldLHsRecFieldPat (L _ (HsRecField (L _idSpan (XFieldOcc _)) _arg _pun)) = return Nothing
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foldLHsCmdTop :: LHsCmdTop GhcTc -> State ASTState (Maybe Type)
#else
foldLHsCmdTop :: LHsCmdTop Id -> State ASTState (Maybe Type)
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsCmdTop (L _span (XCmdTop _)) = return Nothing
foldLHsCmdTop (L span (HsCmdTop _ cmd)) = do
#else
@ -1662,7 +1662,7 @@ foldLHsCmd :: LHsCmd GhcTc -> State ASTState (Maybe Type)
#else
foldLHsCmd :: LHsCmd Id -> State ASTState (Maybe Type)
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsCmd (L _ (XCmd _)) = return Nothing
foldLHsCmd (L _ (HsCmdLam _ (XMatchGroup _))) = return Nothing
foldLHsCmd (L _ (HsCmdCase _ _ (XMatchGroup _))) = return Nothing
@ -1674,7 +1674,7 @@ foldLHsCmd (L _ (HsCmdArrApp expr1 expr2 _ _ _)) = do
_ <- foldLHsExpr expr2
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsCmd (L _ (HsCmdArrForm _ expr _ _ topCmds)) = do
#else
foldLHsCmd (L _ (HsCmdArrForm expr _ _ topCmds)) = do
@ -1700,7 +1700,7 @@ foldLHsCmd (L _ (HsCmdLam MG {..})) = do
#endif
mapM_ foldLMatchCmd $ unLoc mg_alts
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsCmd (L _ (HsCmdCase _ expr MG {..})) = do
#else
foldLHsCmd (L _ (HsCmdCase expr MG {..})) = do
@ -1715,7 +1715,7 @@ foldLHsCmd (L _ (HsCmdPar cmd)) = do
#endif
_ <- foldLHsCmd cmd
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsCmd (L _ (HsCmdIf _ _ expr cmd1 cmd2)) = do
#else
foldLHsCmd (L _ (HsCmdIf _ expr cmd1 cmd2)) = do
@ -1724,7 +1724,7 @@ foldLHsCmd (L _ (HsCmdIf _ expr cmd1 cmd2)) = do
_ <- foldLHsCmd cmd2
_ <- foldLHsExpr expr
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsCmd (L _ (HsCmdLet _ (L _ binds) cmd)) = do
#else
foldLHsCmd (L _ (HsCmdLet (L _ binds) cmd)) = do
@ -1732,17 +1732,17 @@ foldLHsCmd (L _ (HsCmdLet (L _ binds) cmd)) = do
_ <- foldLHsCmd cmd
_ <- foldHsLocalBindsLR binds
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsCmd (L _ (HsCmdDo _ stmts)) = do
#else
foldLHsCmd (L _ (HsCmdDo stmts _)) = do
#endif
mapM_ foldLStmtLRCmd $ unLoc stmts
return Nothing
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
foldLHsCmd (L span (HsCmdWrap _ _ cmd)) = do
#else
foldLHsCmd (L span (HsCmdWrap _ cmd)) = do
#endif
#endif
_ <- foldLHsCmd (L span cmd)
return Nothing

View File

@ -20,7 +20,7 @@ module HaskellCodeExplorer.GhcUtils
, occNameNameSpace
, identifierKey
, nameKey
, mbIdDetails
, mbIdDetails
-- * Syntax manipulation
, hsGroupVals
, hsPatSynDetails
@ -32,18 +32,18 @@ module HaskellCodeExplorer.GhcUtils
, isHsBoot
, moduleLocationInfo
, nameLocationInfo
, occNameLocationInfo
, nameDocumentation
, occNameLocationInfo
, nameDocumentation
, srcSpanToLineAndColNumbers
-- * Type-related functions
, tyThingToId
, tyThingToId
, tidyIdentifierType
, patSynId
, applyWrapper
, wrapperTypes
, tyVarsOfType
, wrapperTypes
, tyVarsOfType
, tyConsOfType
, updateOccNames
, updateOccNames
, mkType
-- * Documentation processing
, collectDocs
@ -80,7 +80,7 @@ import DynFlags ()
import FastString (mkFastString, unpackFS)
import GHC
( DynFlags
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
, HsDocString
#else
, HsDocString (..)
@ -91,12 +91,12 @@ import GHC
, SrcSpan(..)
, RealSrcSpan(..)
, ClsInstDecl(..)
, TyClDecl(..)
, HsDataDefn(..)
, TyClDecl(..)
, HsDataDefn(..)
, NewOrData(..)
, Id
, HsGroup(..)
, HsBindLR(..)
, HsGroup(..)
, HsBindLR(..)
, HsValBindsLR(..)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,1,0)
, HsPatSynDetails
@ -104,18 +104,18 @@ import GHC
, HsPatSynDetails(..)
#endif
, Located
, IE(..)
, IE(..)
, TyThing(..)
, LHsDecl
, LHsDecl
, HsDecl(..)
, DocDecl(..)
, DocDecl(..)
, ConDecl(..)
, HsConDetails(..)
, ConDeclField(..)
, HsConDetails(..)
, ConDeclField(..)
, DataFamInstDecl(..)
, LSig
, Sig(..)
, ForeignDecl(..)
, LSig
, Sig(..)
, ForeignDecl(..)
, FixitySig(..)
, tcdName
, collectHsBindBinders
@ -127,12 +127,12 @@ import GHC
, getConArgs
, unpackHDS
, NoExt(..)
, extFieldOcc
, extFieldOcc
#else
, getConDetails
, selectorFieldOcc
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
, tyClGroupTyClDecls
, LIEWrappedName
, hsGroupInstDecls
@ -157,10 +157,10 @@ import GHC
, isGoodSrcSpan
, isLocalId
, isDataFamilyDecl
, tyFamInstDeclName
, tyFamInstDeclName
, idType
, hsib_body
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#else
, tfe_pats
#endif
@ -169,7 +169,7 @@ import GHC
import qualified HaskellCodeExplorer.Types as HCE
import HscTypes (TypeEnv, lookupTypeEnv)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
import HsExtension (GhcRn,IdP)
#endif
import IdInfo (IdDetails(..))
@ -232,8 +232,8 @@ import Type
, mkInvForAllTys
#if !MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
, mkNamedBinder
#endif
, piResultTy
#endif
, piResultTy
, pprSigmaType
, splitFunTy_maybe
, tidyOpenType
@ -355,8 +355,8 @@ tyClDeclPrefix tyClDecl =
ClassDecl {} -> "class "
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
XTyClDecl _ -> ""
#endif
#endif
demangleOccName :: Name -> T.Text
demangleOccName name
| isDerivedOccName (nameOccName name) =
@ -382,7 +382,7 @@ demangleOccName name
| otherwise = occName
in removePrefix $ nameToText name
| otherwise = nameToText name
stringBufferToByteString :: StringBuffer -> BS.ByteString
stringBufferToByteString (StringBuffer buf len cur) =
BSI.fromForeignPtr buf cur len
@ -392,12 +392,12 @@ nameSort n =
if isExternalName n
then HCE.External
else HCE.Internal
occNameNameSpace :: OccName -> HCE.NameSpace
occNameNameSpace n
| isDataConNameSpace (occNameSpace n) = HCE.DataName
| isTvNameSpace (occNameSpace n) = HCE.TvName
| isValNameSpace (occNameSpace n) = HCE.VarName
| isValNameSpace (occNameSpace n) = HCE.VarName
| otherwise = HCE.TcClsName
-- Two 'Id''s may have different types even though they have the same 'Unique'.
@ -431,7 +431,7 @@ mbIdDetails v
CoVarId -> Just HCE.CoVarId
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
JoinId _ -> Just HCE.JoinId
#endif
#endif
mbIdDetails _ = Nothing
--------------------------------------------------------------------------------
@ -446,7 +446,7 @@ hsGroupVals :: HsGroup Name -> [GenLocated SrcSpan (HsBindLR Name Name)]
hsGroupVals hsGroup =
filter (isGoodSrcSpan . getLoc) $
case hs_valds hsGroup of
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
XValBindsLR (NValBinds binds _) -> concatMap (bagToList . snd) binds
#else
ValBindsOut binds _ -> concatMap (bagToList . snd) binds
@ -457,7 +457,7 @@ hsPatSynDetails :: HsPatSynDetails a -> [a]
hsPatSynDetails patDetails =
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
case patDetails of
InfixCon name1 name2 -> [name1, name2]
InfixCon name1 name2 -> [name1, name2]
PrefixCon fields -> fields
RecCon fields -> concatMap
(\field -> [recordPatSynSelectorId field, recordPatSynPatVar field])
@ -494,7 +494,7 @@ ieLocNames :: IE Name -> [Located Name]
ieLocNames (XIE _) = []
ieLocNames (IEVar _ n) =
#else
ieLocNames (IEVar n) =
ieLocNames (IEVar n) =
#endif
[unwrapName n]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
@ -533,7 +533,7 @@ lookupIdInTypeEnv typeEnv name = do
| isExternalName name = lookupTypeEnv typeEnv name
| otherwise = Nothing
case mbTyThing of
Just tyThing -> tyThingToId tyThing
Just tyThing -> tyThingToId tyThing
_ -> Nothing
lookupNameModuleAndPackage ::
@ -568,7 +568,7 @@ lookupNameModuleAndPackage flags currentPackageId name =
--------------------------------------------------------------------------------
isHsBoot :: HCE.HaskellModulePath -> Bool
isHsBoot = T.isSuffixOf "-boot" . HCE.getHaskellModulePath
isHsBoot = T.isSuffixOf "-boot" . HCE.getHaskellModulePath
moduleLocationInfo ::
DynFlags
@ -619,7 +619,7 @@ moduleLocationInfo flags moduleNameMap currentPackageId compId moduleName =
else HCE.ComponentId "lib")
Nothing -> currentPackageLocation
_ -> currentPackageLocation
isDefinedInCurrentModule ::
HCE.SourceCodeTransformation -> HCE.HaskellFilePath -> Bool
isDefinedInCurrentModule transformation file =
@ -628,7 +628,7 @@ isDefinedInCurrentModule transformation file =
HCE.getHaskellModulePath $
HCE.filePath (transformation :: HCE.SourceCodeTransformation)
in HCE.getHaskellFilePath file == modPath || (file `elem` includedFiles)
nameLocationInfo ::
DynFlags
-> HCE.PackageId
@ -660,7 +660,7 @@ nameLocationInfo flags currentPackageId compId transformation fileMap defSiteMap
eitherEnd =
HCE.fromOriginalLineNumber
transformation
(filePath, srcSpanEndLine srcSpan)
(filePath, srcSpanEndLine srcSpan)
in case (,) eitherStart eitherEnd of
(Right startLine,Right endLine) ->
let modulePath = HCE.filePath (transformation :: HCE.SourceCodeTransformation)
@ -739,7 +739,7 @@ mkLocatableEntity name mbInstanceHead
case occNameNameSpace . nameOccName $ name of
HCE.VarName -> HCE.Val
HCE.DataName -> HCE.Val
_ -> HCE.Typ
_ -> HCE.Typ
occNameLocationInfo ::
DynFlags
@ -823,9 +823,9 @@ lookupNameDocumentation name defSiteMap =
srcSpanToFilePath :: SrcSpan -> Maybe HCE.HaskellFilePath
srcSpanToFilePath (RealSrcSpan s) =
Just . HCE.HaskellFilePath . T.pack . normalise . unpackFS . srcSpanFile $ s
Just . HCE.HaskellFilePath . T.pack . normalise . unpackFS . srcSpanFile $ s
srcSpanToFilePath (UnhelpfulSpan _) = Nothing
srcSpanToLineAndColNumbers ::
HCE.SourceCodeTransformation
-> SrcSpan
@ -894,7 +894,7 @@ applyWrapper (WpEvLam v) t = mkFunTy (evVarPred v) t
applyWrapper (WpEvApp _ev) t = case splitFunTy_maybe t of
Just (_arg,res) -> res
Nothing -> t
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
applyWrapper (WpTyLam v) t = mkForAllTy v Required t
#else
applyWrapper (WpTyLam v) t = mkForAllTy (mkNamedBinder Invisible v) t
@ -929,10 +929,10 @@ mkType flags typ =
else Nothing)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
typeToText :: DynFlags -> Type -> T.Text
typeToText :: DynFlags -> Type -> T.Text
typeToText flags = T.pack . showSDoc flags . pprIfaceType . toIfaceType
#else
typeToText :: DynFlags -> Type -> T.Text
typeToText :: DynFlags -> Type -> T.Text
typeToText = toText
#endif
@ -947,7 +947,7 @@ toTypeComponents flags typ =
updateOccNames
(\unique occName -> ";," ++ occName ++ "," ++ unique ++ ";")
typ
-- Dirty but simple way to extract a list of TypeComponent from a type signature.
-- Dirty but simple way to extract a list of TypeComponent from a type signature.
-- Assumptions :
-- 1. Character ';' cannot appear anywhere in a type signature
-- 2. Character ',' cannot appear in an 'OccName'
@ -984,11 +984,11 @@ updateOccNames update = everywhere (mkT updateType)
(occNameSpace oldOccName)
(update unique (occNameString oldOccName))
in mkInternalName (nameUnique oldName) newOccName (nameSrcSpan oldName)
-- | This function doesn't look through type synonyms
tyConsOfType :: Type -> [Id]
tyConsOfType =
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
nonDetEltsUniqSet . everything unionUniqSets (emptyVarSet `mkQ` tyCon)
#else
uniqSetToList . everything unionUniqSets (emptyVarSet `mkQ` tyCon)
@ -999,7 +999,7 @@ tyConsOfType =
tyCon _ = emptyUniqSet
tyVarsOfType :: (Data a) => a -> [Id]
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
tyVarsOfType = nonDetEltsUniqSet . everything unionVarSet (emptyVarSet `mkQ` tyVar)
#else
tyVarsOfType = varSetElems . everything unionVarSet (emptyVarSet `mkQ` tyVar)
@ -1027,7 +1027,7 @@ collectDocs = go Nothing []
| Nothing <- prev = go Nothing (str : docs) ds
| Just decl <- prev = finished decl docs (go Nothing [str] ds)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
go prev docs (L _ (DocD _ (DocCommentPrev str)):ds) = go prev (str : docs) ds
#else
go prev docs (L _ (DocD (DocCommentPrev str)):ds) = go prev (str : docs) ds
@ -1043,9 +1043,9 @@ ungroup :: HsGroup Name -> [LHsDecl Name]
#endif
ungroup group_ =
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
mkDecls (tyClGroupTyClDecls . hs_tyclds) (TyClD NoExt) group_ ++
mkDecls (tyClGroupTyClDecls . hs_tyclds) (TyClD NoExt) group_ ++
#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
mkDecls (tyClGroupTyClDecls . hs_tyclds) TyClD group_ ++
mkDecls (tyClGroupTyClDecls . hs_tyclds) TyClD group_ ++
#else
mkDecls (tyClGroupConcat . hs_tyclds) TyClD group_ ++
#endif
@ -1054,17 +1054,17 @@ ungroup group_ =
mkDecls hs_derivds (DerivD NoExt) group_ ++
mkDecls hs_defds (DefD NoExt) group_ ++
mkDecls hs_fords (ForD NoExt) group_ ++
mkDecls hs_docs (DocD NoExt) group_ ++
mkDecls hs_docs (DocD NoExt) group_ ++
#else
mkDecls hs_derivds DerivD group_ ++
mkDecls hs_defds DefD group_ ++
mkDecls hs_fords ForD group_ ++
mkDecls hs_docs DocD group_ ++
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
mkDecls hsGroupInstDecls (InstD NoExt) group_ ++
#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
mkDecls hsGroupInstDecls InstD group_ ++
#else
mkDecls hs_instds InstD group_ ++
@ -1076,17 +1076,17 @@ ungroup group_ =
#else
mkDecls (typesigs . hs_valds) SigD group_ ++
mkDecls (valbinds . hs_valds) ValD group_
#endif
#endif
where
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
typesigs (XValBindsLR (NValBinds _ sigs)) = filter isUserLSig sigs
#else
typesigs (ValBindsOut _ sigs) = filter isUserLSig sigs
#endif
typesigs _ = []
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
valbinds (XValBindsLR (NValBinds binds _)) = concatMap (bagToList . snd) binds
#else
valbinds (ValBindsOut binds _) = concatMap (bagToList . snd) binds
@ -1107,7 +1107,7 @@ classDeclDocs :: TyClDecl Name -> [(LHsDecl Name, [HsDocString])]
classDeclDocs class_ = collectDocs . sortByLoc $ decls
where
decls = docs ++ defs ++ sigs ++ ats
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
docs = mkDecls tcdDocs (DocD NoExt) class_
defs = mkDecls (bagToList . tcdMeths) (ValD NoExt) class_
sigs = mkDecls tcdSigs (SigD NoExt) class_
@ -1136,7 +1136,7 @@ selectorDocs :: ConDecl GhcRn -> [(Name, [HsDocString], SrcSpan)]
selectorDocs :: ConDecl Name -> [(Name, [HsDocString], SrcSpan)]
#endif
selectorDocs con =
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
case getConArgs con of
#else
case getConDetails con of
@ -1159,7 +1159,7 @@ selectorDocs con =
flds
_ -> []
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
subordinateNamesWithDocs :: [GenLocated SrcSpan (HsDecl GhcRn)] -> [(Name, [HsDocString], SrcSpan)]
#else
subordinateNamesWithDocs :: [GenLocated SrcSpan (HsDecl Name)] -> [(Name, [HsDocString], SrcSpan)]
@ -1189,14 +1189,14 @@ subordinateNamesWithDocs =
InstD (DataFamInstD DataFamInstDecl {..}) ->
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
concatMap (conDeclDocs . unLoc) . dd_cons . feqn_rhs . hsib_body $ dfid_eqn
#else
concatMap (conDeclDocs . unLoc) . dd_cons $ dfid_defn
#endif
_ -> [])
isUserLSig :: LSig name -> Bool
isUserLSig (L _ TypeSig {}) = True
isUserLSig (L _ ClassOpSig {}) = True
@ -1239,8 +1239,8 @@ getMainDeclBinder (ForD ForeignExport {}) = []
getMainDeclBinder _ = []
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
sigNameNoLoc :: Sig pass -> [IdP pass]
#else
sigNameNoLoc :: Sig pass -> [IdP pass]
#else
sigNameNoLoc :: Sig name -> [name]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
@ -1293,7 +1293,7 @@ hsDocsToDocH flags rdrEnv =
#else
. parseParas
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
. concatMap unpackHDS
#else
. concatMap (unpackFS . (\(HsDocString s) -> s))
@ -1368,7 +1368,7 @@ rename dflags gre = rn
DocEmpty -> DocEmpty
DocString str -> DocString str
DocHeader (Header l t) -> DocHeader $ Header l (rn t)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
DocTable t -> DocTable (rn <$> t)
#endif
@ -1400,4 +1400,4 @@ makeAnchorId (f:r) = escape isAlpha f ++ concatMap (escape isLegal) r
isLegal ':' = True
isLegal '_' = True
isLegal '.' = True
isLegal c = isAscii c && isAlphaNum c
isLegal c = isAscii c && isAlphaNum c

View File

@ -74,13 +74,13 @@ import HsDecls
, InstDecl
, TyClDecl
#endif
, InstDecl(..)
, InstDecl(..)
, group_tyclds
, tyClDeclLName
, tcdName
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
, hsGroupInstDecls
#endif
#endif
)
import HsDoc(HsDocString)
import HsImpExp (IE(..), ImportDecl(..))
@ -101,9 +101,9 @@ import Module(Module(..))
import Name (Name, OccName, getSrcSpan, nameOccName, nameSrcSpan, nameUnique)
import Prelude hiding(id,span)
import RdrName(GlobalRdrEnv)
import SrcLoc (isOneLineSpan)
import SrcLoc (isOneLineSpan)
import TcRnTypes (tcVisibleOrphanMods, tcg_inst_env, tcg_rdr_env, tcg_type_env)
import qualified Text.Blaze.Html5 as H
import qualified Text.Blaze.Html5 as H
import qualified Text.Blaze.Html5.Attributes as A
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
import UniqDFM (eltsUDFM)
@ -118,14 +118,14 @@ type ModuleDependencies
= ( HM.HashMap HCE.HaskellFilePath HCE.HaskellModulePath
, HM.HashMap HCE.HaskellModulePath HCE.DefinitionSiteMap
, HM.HashMap HCE.HaskellModuleName (HM.HashMap HCE.ComponentId HCE.HaskellModulePath))
type ModuleGhcData
= ( DynFlags
, TypecheckedModule
, HomePackageTable
, ExternalPackageState
, ModSummary)
createModuleInfo ::
ModuleDependencies -- ^ Modules that have already been indexed
-> ModuleGhcData -- ^ Data types from GHC
@ -156,7 +156,7 @@ createModuleInfo (fileMap, defSiteMap, moduleNameMap) (flags, typecheckedModule,
currentModuleTyThings = typeEnvElts $ tcg_type_env tcGblEnv
homePackageTyThings =
concatMap (typeEnvElts . md_types . hm_details) $
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
eltsUDFM homePackageTable
#else
eltsUFM homePackageTable
@ -182,7 +182,7 @@ createModuleInfo (fileMap, defSiteMap, moduleNameMap) (flags, typecheckedModule,
currentPackageId
compId
defSiteMap
fileMap
fileMap
globalRdrEnv
transformation
modInfo
@ -316,7 +316,7 @@ createDefinitionSiteMap ::
-> HCE.SourceCodeTransformation
-> ModuleInfo
-> [Name]
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
-> HsGroup GhcRn
#else
-> HsGroup Name
@ -345,11 +345,11 @@ createDefinitionSiteMap flags currentPackageId compId defSiteMap fileMap globalR
mapMaybe
(\(L _n decl, docs) ->
case decl of
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
InstD _ (ClsInstD _ inst) -> Just (clsInstDeclSrcSpan inst, docs)
#else
#else
InstD (ClsInstD inst) -> Just (clsInstDeclSrcSpan inst, docs)
#endif
#endif
_ -> Nothing) $
instanceDeclsWithDocs
nameLocation :: Maybe SrcSpan -> Name -> HCE.LocationInfo
@ -432,7 +432,7 @@ createDefinitionSiteMap flags currentPackageId compId defSiteMap fileMap globalR
, map (\(n, _, _) -> n) allNamesWithDocumentation)
occNameToHtml ::
DynFlags
DynFlags
-> HCE.PackageId
-> HCE.ComponentId
-> (ModuleName, OccName)
@ -468,7 +468,7 @@ nameToHtml flags packageId compId transformation files defSiteMap name =
name
in H.span H.! H.dataAttribute "location" location H.! A.class_ "link" $
H.toHtml (nameToText name)
docWithNamesToHtml ::
DynFlags
-> HCE.PackageId
@ -485,7 +485,7 @@ docWithNamesToHtml flags packageId compId transformation fileMap defSiteMap =
createDeclarations ::
DynFlags
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
-> HsGroup GhcRn
#else
-> HsGroup Name
@ -507,9 +507,9 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation =
Nothing -> Nothing
-- | Top-level functions
--------------------------------------------------------------------------------
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
valToDeclarations :: GenLocated SrcSpan (HsBindLR GhcRn GhcRn) -> [HCE.Declaration]
#endif
#endif
valToDeclarations (L loc bind) =
map
(\name ->
@ -523,9 +523,9 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation =
vals = concatMap valToDeclarations $ hsGroupVals hsGroup
-- | Data, newtype, type, type family, data family or class declaration
--------------------------------------------------------------------------------
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
tyClToDeclaration :: GenLocated SrcSpan (TyClDecl GhcRn) -> HCE.Declaration
#endif
#endif
tyClToDeclaration (L loc tyClDecl) =
HCE.Declaration
HCE.TyClD
@ -539,9 +539,9 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation =
hsGroup
-- | Instances
--------------------------------------------------------------------------------
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
instToDeclaration :: GenLocated SrcSpan (InstDecl GhcRn) -> HCE.Declaration
#endif
#endif
instToDeclaration (L loc inst) =
HCE.Declaration
HCE.InstD
@ -550,7 +550,7 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation =
True
(lineNumber loc)
insts =
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
map instToDeclaration . filter (isGoodSrcSpan . getLoc) . hsGroupInstDecls $
#else
map instToDeclaration . filter (isGoodSrcSpan . getLoc) . hs_instds $
@ -558,10 +558,10 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation =
hsGroup
-- | Foreign functions
--------------------------------------------------------------------------------
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foreignFunToDeclaration ::
GenLocated SrcSpan (ForeignDecl GhcRn) -> HCE.Declaration
#endif
#endif
foreignFunToDeclaration (L loc fd) =
let name = unLoc $ fd_name fd
in HCE.Declaration
@ -590,14 +590,14 @@ foldAST environment typecheckedModule =
-- - type signatures
-- - type/data/newtype declarations
-- - class declarations
-- Both typechecked source and renamed source are used to populate
-- 'IdentifierInfoMap' and 'IdentifierOccurrenceMap'
(idInfoMap, idOccMap) =
L.foldl'
(addIdentifierToMaps environment astStateIdSrcSpanMap)
(HM.empty, astStateIdOccMap)
(namesFromRenamedSource renamed)
(namesFromRenamedSource renamed)
flags = envDynFlags environment
packageId = envPackageId environment
compId = envComponentId environment
@ -619,7 +619,7 @@ foldAST environment typecheckedModule =
case mbExported of
Just lieNames ->
mapMaybe
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
(\(L span ie,_) ->
#else
(\(L span ie) ->
@ -733,7 +733,7 @@ addIdentifierToMaps environment idSrcSpanMap idMaps@(idInfoMap, idOccMap) nameOc
lineNumber
startCol
endCol
Nothing -> idMaps
Nothing -> idMaps
addIdentifierToMaps _ _ idMaps _ = idMaps
addNameToMaps ::
@ -791,7 +791,7 @@ lookupIdByNameOccurrence ::
-> NameOccurrence
-> Maybe (Id, Maybe (Type, [Type]))
lookupIdByNameOccurrence environment idSrcSpanMap (NameOccurrence (L span mbName) _ _) =
case M.lookup span idSrcSpanMap of
case M.lookup span idSrcSpanMap of
Just (identifier, mbTypes) -> Just (identifier, mbTypes)
Nothing ->
case mbName of
@ -806,7 +806,7 @@ lookupIdByNameOccurrence environment idSrcSpanMap (NameOccurrence (L span mbName
Nothing -> Nothing
Nothing -> Nothing
lookupIdByNameOccurrence _ _ TyLitOccurrence {..} = Nothing
updateIdMap ::
Environment
-> [(Id, Maybe Name)]

View File

@ -54,7 +54,7 @@ import Distribution.Helper
, packageId
, runQuery
, sourceDirs
, compilerVersion
, compilerVersion
)
import DynFlags
( DynFlags(..)
@ -86,7 +86,7 @@ import GHC
, topSortModuleGraph
, typecheckModule
, moduleNameString
, moduleName
, moduleName
)
import GHC.Paths (libdir)
import GhcMonad (GhcT(..), liftIO)
@ -98,7 +98,7 @@ import Outputable (PprStyle, SDoc, neverQualify, showSDocForUser)
import Packages (initPackages)
import Prelude hiding (id)
import System.Directory
( doesFileExist
( doesFileExist
, findExecutable
, setCurrentDirectory
, getCurrentDirectory
@ -116,7 +116,7 @@ import System.FilePath
, takeExtension
, takeBaseName
, takeDirectory
, splitDirectories
, splitDirectories
)
import System.FilePath.Find (find,always,(==?),fileName)
import System.Process (readProcess)
@ -158,7 +158,7 @@ createPackageInfo packageDirectoryPath mbDistDirRelativePath sourceCodePreproces
[ "GHC version mismatch. haskell-code-indexer: "
, T.pack $ showVersion ghcVersion
, ", package: "
, T.pack $ showVersion packageCompilerVersion
, T.pack $ showVersion packageCompilerVersion
]
liftIO exitFailure
logInfoN $ T.append "Indexing " $ HCE.packageIdToText currentPackageId
@ -270,10 +270,10 @@ ghcVersion = makeVersion [8, 6, 5, 0]
#elif MIN_VERSION_GLASGOW_HASKELL(8,6,4,0)
ghcVersion :: Version
ghcVersion = makeVersion [8, 6, 4, 0]
#elif MIN_VERSION_GLASGOW_HASKELL(8,6,3,0)
#elif MIN_VERSION_GLASGOW_HASKELL(8,6,3,0)
ghcVersion :: Version
ghcVersion = makeVersion [8, 6, 3, 0]
#elif MIN_VERSION_GLASGOW_HASKELL(8,4,4,0)
#elif MIN_VERSION_GLASGOW_HASKELL(8,4,4,0)
ghcVersion :: Version
ghcVersion = makeVersion [8, 4, 4, 0]
#elif MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
@ -286,7 +286,7 @@ ghcVersion = makeVersion [8, 2, 2, 0]
ghcVersion :: Version
ghcVersion = makeVersion [8, 0, 2, 0]
#endif
buildDirectoryTree :: FilePath -> [FilePath] -> (FilePath -> Bool) -> IO HCE.DirTree
buildDirectoryTree path ignoreDirectories isHaskellModule = do
(_dir DT.:/ tree) <- DT.readDirectoryWith (const . return $ ()) path
@ -316,7 +316,7 @@ buildDirectoryTree path ignoreDirectories isHaskellModule = do
HCE.File name filePath (isHaskellModule filePath)
toDirTree (DT.Failed name err) =
HCE.File (name ++ " : " ++ show err) "" False
addTopLevelIdentifiersFromModule ::
HCE.Trie Char HCE.ExternalIdentifierInfo
-> HCE.ModuleInfo
@ -327,8 +327,8 @@ addTopLevelIdentifiersFromModule trieIdInfo HCE.ModuleInfo {..} =
HCE.insertToTrie S.insert (T.unpack demangledOccName) idInfo trie)
trieIdInfo
externalIds
addReferencesFromModule ::
addReferencesFromModule ::
HM.HashMap HCE.ExternalId (S.Set HCE.IdentifierSrcSpan)
-> HCE.ModuleInfo
-> HM.HashMap HCE.ExternalId (S.Set HCE.IdentifierSrcSpan)
@ -406,7 +406,7 @@ findDistDirectory packagePath = do
Left $
"Found multiple possible dist directories : \n" ++
show setupConfigPaths ++ " \nPlease specify --dist option"
eachIdentifierOccurrence ::
forall a.
a
@ -450,7 +450,7 @@ ghandleSync onError =
case fromException ex of
Just (asyncEx :: SomeAsyncException) -> throw asyncEx
_ -> onError ex)
indexBuildComponent ::
HCE.SourceCodePreprocessing -- ^ Before or after preprocessor
-> HCE.PackageId -- ^ Current package id
@ -588,7 +588,7 @@ indexBuildComponent sourceCodePreprocessing currentPackageId componentId deps@(f
return (indexedModules, (fileMap', defSiteMap', modNameMap')))
([], (fileMap, defSiteMap, modNameMap))
modSumWithPath
findHaskellModulePath ::
FilePath -> [FilePath] -> ModSummary -> IO (Maybe HCE.HaskellModulePath)
findHaskellModulePath buildDir srcDirs modSum =
@ -603,7 +603,7 @@ findHaskellModulePath buildDir srcDirs modSum =
else path
_ -> path
in case removeTmpDir <$> L.stripPrefix buildDir modulePath of
-- File is in the build directory
-- File is in the build directory
Just path
| takeExtension path == ".hs-boot" -> do
let possiblePaths = path : map (</> path) srcDirs

View File

@ -19,7 +19,7 @@ import HaskellCodeExplorer.Types
, HaskellModulePath(..)
, LinePragma(..)
, SourceCodeTransformation(..)
, haskellPreprocessorExtensions
, haskellPreprocessorExtensions
)
import System.FilePath (normalise,takeExtension,takeFileName)
@ -86,13 +86,13 @@ createSourceCodeTransformation currentModulePath originalSourceCode sourceCodeAf
-- | Parses line pragma
linePragmaParser :: AT.Parser (Int, Maybe T.Text)
linePragmaParser = pragma1 <|> pragma2
where
where
pragma1 :: AT.Parser (Int, Maybe T.Text)
pragma1 = parser "#" "line"
pragma2 :: AT.Parser (Int, Maybe T.Text)
pragma2 = parser "{-#" "LINE"
parser :: T.Text -> T.Text -> AT.Parser (Int, Maybe T.Text)
parser start line = do
_ <- AT.string start
@ -103,9 +103,9 @@ linePragmaParser = pragma1 <|> pragma2
_ <- AT.takeWhile (== ' ')
mbName <- (Just <$> fileName) <|> return Nothing
return (num, mbName)
fileName :: AT.Parser T.Text
fileName = AT.string "\"" *> AT.takeTill (== '\"') <* AT.string "\""
fileName = AT.string "\"" *> AT.takeTill (== '\"') <* AT.string "\""
data Line = FirstLine | LastLine Int | Pragma LinePragma deriving (Show,Eq)

View File

@ -36,7 +36,7 @@ import qualified Data.IntervalMap.Strict as IVM
import qualified Data.List as L
import Data.Maybe (fromMaybe, isJust)
import Data.Serialize (Get, Serialize(..))
import qualified Data.Set as S
import qualified Data.Set as S
import qualified Data.Text as T
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import Data.Text.Lazy (toStrict)
@ -51,8 +51,8 @@ import Documentation.Haddock.Types
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
, Table(..)
, TableCell(..)
, TableRow(..)
#endif
, TableRow(..)
#endif
)
import GHC.Generics (Generic)
import Prelude hiding (id)
@ -185,7 +185,7 @@ data ModuleInfo = ModuleInfo
-- ^ Information about each identifier in the module
, declarations :: [Declaration]
, definitionSiteMap :: DefinitionSiteMap
-- ^ Definition site of each top-level value, type, and type class instance
-- ^ Definition site of each top-level value, type, and type class instance
, externalIds :: [ExternalIdentifierInfo]
} deriving (Show, Eq, Generic, Data)
@ -226,7 +226,7 @@ haskellPreprocessorExtensions =
toCompactPackageInfo :: PackageInfo ModuleInfo -> PackageInfo CompactModuleInfo
toCompactPackageInfo PackageInfo {..} =
PackageInfo
{ id = id
{ id = id
, moduleMap = HM.map toCompactModuleInfo moduleMap
, moduleNameMap = moduleNameMap
, directoryTree = directoryTree
@ -322,11 +322,11 @@ instance Ord ExternalIdentifierInfo where
case compare (demangledOccName i1) (demangledOccName i2) of
GT -> GT
LT -> LT
EQ ->
EQ ->
compare
(internalId (i1 :: IdentifierInfo))
(internalId (i2 :: IdentifierInfo))
data ExpressionInfo = ExpressionInfo
{ description :: T.Text
, exprType :: Maybe Type
@ -372,7 +372,7 @@ data InstanceResolution =
, types :: [Type]
-- ^ Types at which type variables of a class are instantiated
, location :: LocationInfo
, instances :: [InstanceResolution]
, instances :: [InstanceResolution]
}
| Stop
deriving (Show,Eq,Ord,Generic,Data)
@ -426,7 +426,7 @@ fromOriginalLineNumber SourceCodeTransformation {fileIndex = index} (originalFil
, " in "
, T.pack $ show index
]
data Declaration = Declaration
{ sort :: DeclarationSort
, name :: T.Text
@ -563,7 +563,7 @@ instance NFData SourceCodeTransformation
instance NFData IdentifierInfo
instance NFData InternalId
instance NFData ExternalId
instance NFData ExternalIdentifierInfo
instance NFData ExternalIdentifierInfo
instance NFData InstanceResolution
instance NFData IdDetails
instance NFData NameSpace
@ -626,7 +626,7 @@ instance A.ToJSON ModuleInfo where
, ("occurrences", A.toJSON $ idOccurrencesHashMap idOccMap)
, ("declarations", A.toJSON declarations)
]
idOccurrencesHashMap ::
IM.IntMap [((Int, Int), IdentifierOccurrence)]
-> HM.HashMap T.Text IdentifierOccurrence
@ -638,7 +638,7 @@ idOccurrencesHashMap =
(\((startCol, endCol), occ) ->
(occurrenceLocationToText lineNum startCol endCol, occ))
occs) .
IM.toList
IM.toList
idOccurrenceList ::
IM.IntMap [((Int, Int), IdentifierOccurrence)]
@ -651,7 +651,7 @@ idOccurrenceList =
(\((startCol, endCol), occ) ->
(occurrenceLocationToText lineNum startCol endCol, occ))
occs) .
IM.toList
IM.toList
occurrenceLocationToText :: Int -> Int -> Int -> T.Text
occurrenceLocationToText lineNum startCol endCol =
@ -710,7 +710,7 @@ tokenize
-> [((Int, Int), a)] -- ^ Identifier locations
-- The end position is defined to be the column /after/ the end of the
-- span. That is, a span of (1,1)-(1,2) is one character long, and a
-- span of (1,1)-(1,1) is zero characters long.
-- span of (1,1)-(1,1) is zero characters long.
-> [(T.Text, (Int, Int), Maybe a)]
tokenize line =
L.reverse .
@ -807,14 +807,14 @@ docToHtml modToHtml idToHtml = toStrict . renderHtml . toH
in Html.table $
Html.thead (mapM_ (tableRowToH Html.th) hs) >>
Html.tbody (mapM_ (tableRowToH Html.td) bs)
#endif
#endif
instance A.ToJSON HaskellModuleName where
toJSON (HaskellModuleName name) = A.String name
instance A.ToJSON HaskellModulePath where
toJSON (HaskellModulePath path) = A.String path
instance A.ToJSON HaskellFilePath where
toJSON (HaskellFilePath path) = A.String path
toJSON (HaskellFilePath path) = A.String path
instance A.ToJSON LinePragma where
toJSON = A.genericToJSON omitNothingOptions
instance A.ToJSON FileLocation where
@ -824,7 +824,7 @@ instance A.ToJSON IdentifierInfo where
instance A.ToJSON InternalId where
toJSON (InternalId text) = A.toJSON text
instance A.ToJSON ExternalId where
toJSON (ExternalId text) = A.toJSON text
toJSON (ExternalId text) = A.toJSON text
instance A.ToJSON ExternalIdentifierInfo where
toJSON (ExternalIdentifierInfo info) = A.toJSON info
instance A.ToJSON InstanceResolution where
@ -842,7 +842,7 @@ instance A.ToJSON IdDetails where
toJSON = A.genericToJSON omitNothingOptions
instance A.ToJSON NameSpace where
toJSON = A.genericToJSON omitNothingOptions
instance A.ToJSON Declaration
instance A.ToJSON Declaration
instance A.ToJSON NameSort
instance A.ToJSON OccName where
toJSON (OccName name) = A.String name
@ -870,7 +870,7 @@ instance A.ToJSON Type where
toJSON = A.genericToJSON omitNothingOptions
instance A.ToJSON ExpressionInfo where
toJSON = A.genericToJSON omitNothingOptions
instance A.ToJSON DirTree
instance A.ToJSON DirTree
instance A.ToJSON DefinitionSite where
toJSON = A.genericToJSON omitNothingOptions
instance A.ToJSON IdentifierSrcSpan

View File

@ -106,7 +106,7 @@ packageInfoSpec currentDir = do
Just modInfo -> moduleInfoSpec modInfo
Nothing -> return ()
Left e -> runIO $ putStrLn e >> return ()
moduleInfoSpec :: ModuleInfo -> Spec
moduleInfoSpec modInfo =
describe "createModuleInfo" $ do
@ -136,7 +136,7 @@ moduleInfoSpec modInfo =
HCE.source (modInfo :: HCE.ModuleInfo) `shouldBe` sourceCodeLines
it "returns valid map of expressions" $
HCE.exprInfoMap (modInfo :: HCE.ModuleInfo) `shouldBe` testExprInfoMap
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
it "returns valid map of identifiers " $
let removeLocationInfo :: HCE.LocationInfo -> HCE.LocationInfo
removeLocationInfo _ = HCE.UnknownLocation ""
@ -148,9 +148,9 @@ moduleInfoSpec modInfo =
_ -> extId
cleanup :: HCE.IdentifierInfoMap -> HCE.IdentifierInfoMap
cleanup = U.transformBi removeLocationInfo . U.transformBi removePackageVersionFromExternalId
in
in
cleanup (HCE.idInfoMap (modInfo :: HCE.ModuleInfo)) `shouldBe` cleanup testIdInfoMap
#endif
#endif
it "returns valid map of identifier occurrences" $
HCE.idOccMap (modInfo :: HCE.ModuleInfo) `shouldBe` testIdOccMap
@ -208,7 +208,7 @@ buildAndIndexTestPackage currentDir = do
Nothing ->
return . Left $
"Cannot find stack executable. Stack executable is required to build the test package."
sourceCodeTransformationSpec :: FilePath -> Spec
sourceCodeTransformationSpec currentDir = do
sourceCodeAfterPreprocessor <-
@ -258,12 +258,12 @@ sourceCodeTransformationSpec currentDir = do
in fileIndex sourceCodeTransformation `shouldBe` index
describe "fromOriginalLineNumber" $ do
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File.hs", 1) (Right 1)
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File.hs", 4) (Right 4)
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File.hs", 4) (Right 4)
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File1.hs", 1) (Right 9)
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File1.hs", 2) (Right 10)
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File2.hs", 1) (Right 13)
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File2.hs", 3) (Right 15)
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File2.hs", 5) (Right 17)
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File2.hs", 5) (Right 17)
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File1.hs", 15) (Right 19)
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File1.hs", 16) (Right 20)
test fromOriginalLineNumber sourceCodeTransformation (HaskellFilePath "File3.hs", 1) (Right 27)
@ -663,7 +663,7 @@ testIdOccMap =
})
])
]
testIdInfoMap :: HM.HashMap InternalId IdentifierInfo
testIdInfoMap =
HM.fromList

View File

@ -26,8 +26,8 @@ test-suite test-package-test
type: exitcode-stdio-1.0
main-is: Spec.hs
hs-source-dirs:
test
test
build-depends:
base >=4.7 && <5
, test-package
, test-package
default-language: Haskell2010