Skip to content

Commit 1ba460d

Browse files
committed
Add CPP
1 parent 63e54f1 commit 1ba460d

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

plugins/hls-haddock-comments-plugin/hls-haddock-comments-plugin.cabal

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ author: Potato Hatsue
1010
maintainer: berberman@yandex.com
1111
category: Development
1212
build-type: Simple
13-
extra-source-files: LICENSE
13+
extra-source-files:
14+
include/ghc-api-version.h
15+
LICENSE
1416

1517
library
1618
exposed-modules: Ide.Plugin.HaddockComments
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef GHC_API_VERSION_H
2+
#define GHC_API_VERSION_H
3+
4+
#ifdef GHC_LIB
5+
#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc_lib(x,y,z)
6+
#else
7+
#define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc(x,y,z)
8+
#endif
9+
10+
#endif

plugins/hls-haddock-comments-plugin/src/Ide/Plugin/HaddockComments.hs

+6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE NamedFieldPuns #-}
23
{-# LANGUAGE OverloadedStrings #-}
34
{-# LANGUAGE RecordWildCards #-}
45
{-# LANGUAGE ViewPatterns #-}
56

7+
#include "ghc-api-version.h"
8+
69
module Ide.Plugin.HaddockComments where
710

811
import Control.Monad (join)
@@ -93,7 +96,10 @@ keyFromTyVar :: Int -> LHsType GhcPs -> [AnnKey]
9396
keyFromTyVar dep c@(L _ (HsFunTy _ x y))
9497
| dep <= 1 = mkAnnKey c : (keyFromTyVar (succ dep) x <> keyFromTyVar (succ dep) y)
9598
| otherwise = []
99+
#if MIN_GHC_API_VERSION(8,10,0)
96100
keyFromTyVar dep (L _ (HsForAllTy _ _ _ x)) = keyFromTyVar dep x
101+
#else
102+
keyFromTyVar dep (L _ (HsForAllTy _ _ x)) = keyFromTyVar dep x
97103
keyFromTyVar dep (L _ (HsQualTy _ _ x)) = keyFromTyVar dep x
98104
keyFromTyVar dep (L _ (HsParTy _ x)) = keyFromTyVar (succ dep) x
99105
keyFromTyVar dep (L _ (HsBangTy _ _ x)) = keyFromTyVar dep x

0 commit comments

Comments
 (0)