Skip to content

Commit

Permalink
Add CPP
Browse files Browse the repository at this point in the history
  • Loading branch information
berberman committed Dec 15, 2020
1 parent 63e54f1 commit 8e0fda4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ author: Potato Hatsue
maintainer: berberman@yandex.com
category: Development
build-type: Simple
extra-source-files: LICENSE
extra-source-files:
include/ghc-api-version.h
LICENSE

library
exposed-modules: Ide.Plugin.HaddockComments
Expand Down
10 changes: 10 additions & 0 deletions plugins/hls-haddock-comments-plugin/include/ghc-api-version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef GHC_API_VERSION_H
#define GHC_API_VERSION_H

#ifdef GHC_LIB
#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc_lib(x,y,z)
#else
#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc(x,y,z)
#endif

#endif
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ViewPatterns #-}

#include "ghc-api-version.h"

module Ide.Plugin.HaddockComments where

import Control.Monad (join)
Expand Down Expand Up @@ -93,7 +96,11 @@ keyFromTyVar :: Int -> LHsType GhcPs -> [AnnKey]
keyFromTyVar dep c@(L _ (HsFunTy _ x y))
| dep <= 1 = mkAnnKey c : (keyFromTyVar (succ dep) x <> keyFromTyVar (succ dep) y)
| otherwise = []
#if MIN_GHC_API_VERSION(8,10,0)
keyFromTyVar dep (L _ (HsForAllTy _ _ _ x)) = keyFromTyVar dep x
#else
keyFromTyVar dep (L _ (HsForAllTy _ _ x)) = keyFromTyVar dep x
#endif
keyFromTyVar dep (L _ (HsQualTy _ _ x)) = keyFromTyVar dep x
keyFromTyVar dep (L _ (HsParTy _ x)) = keyFromTyVar (succ dep) x
keyFromTyVar dep (L _ (HsBangTy _ _ x)) = keyFromTyVar dep x
Expand Down

0 comments on commit 8e0fda4

Please sign in to comment.