mirror of
https://github.com/github/semantic.git
synced 2024-11-29 21:52:59 +03:00
Merge pull request #518 from github/bump-semantic-source
Bump semantic-source
This commit is contained in:
commit
7b588d89c5
6
.github/workflows/haskell.yml
vendored
6
.github/workflows/haskell.yml
vendored
@ -31,19 +31,19 @@ jobs:
|
|||||||
name: Cache ~/.cabal/packages
|
name: Cache ~/.cabal/packages
|
||||||
with:
|
with:
|
||||||
path: ~/.cabal/packages
|
path: ~/.cabal/packages
|
||||||
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-packages
|
key: ${{ runner.os }}-${{ matrix.ghc }}-v1-cabal-packages
|
||||||
|
|
||||||
- uses: actions/cache@v1
|
- uses: actions/cache@v1
|
||||||
name: Cache ~/.cabal/store
|
name: Cache ~/.cabal/store
|
||||||
with:
|
with:
|
||||||
path: ~/.cabal/store
|
path: ~/.cabal/store
|
||||||
key: ${{ runner.os }}-${{ matrix.ghc }}-v10-cabal-store
|
key: ${{ runner.os }}-${{ matrix.ghc }}-v11-cabal-store
|
||||||
|
|
||||||
- uses: actions/cache@v1
|
- uses: actions/cache@v1
|
||||||
name: Cache dist-newstyle
|
name: Cache dist-newstyle
|
||||||
with:
|
with:
|
||||||
path: dist-newstyle
|
path: dist-newstyle
|
||||||
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ matrix.cabal }}-semantic-dist
|
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ matrix.cabal }}-v1-semantic-dist
|
||||||
|
|
||||||
# - name: hlint
|
# - name: hlint
|
||||||
# run: |
|
# run: |
|
||||||
|
@ -82,12 +82,13 @@ Available options:
|
|||||||
| 3 | TypeScript | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 🚧 | |
|
| 3 | TypeScript | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 🚧 | |
|
||||||
| 4 | Python | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 🚧 | |
|
| 4 | Python | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 🚧 | |
|
||||||
| 5 | Go | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 🚧 | |
|
| 5 | Go | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 🚧 | |
|
||||||
| | PHP | 🚧 | 🚧 | 🚧 | 🚧| 🚧 | | | |
|
| | PHP | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | | | |
|
||||||
| | Java | 🚧 | N/A | 🚧 | 🚧 | ✅ | | | |
|
| | Java | 🚧 | N/A | 🚧 | 🚧 | ✅ | | | |
|
||||||
| | JSON | ✅ | N/A | ✅ | N/A | N/A | N/A | N/A| |
|
| | JSON | ✅ | N/A | ✅ | N/A | N/A | N/A | N/A| |
|
||||||
| | JSX | ✅ | ✅ | ✅ | 🔶 | | | | |
|
| | JSX | ✅ | ✅ | ✅ | 🔶 | | | | |
|
||||||
| | Haskell | 🚧 | 🚧 | 🚧 | 🔶 | 🚧 | | | |
|
| | Haskell | 🚧 | 🚧 | 🚧 | 🔶 | 🚧 | | | |
|
||||||
| | Markdown | 🚧 | 🚧 | 🚧 | 🚧 | N/A | N/A | N/A | |
|
| | Markdown | 🚧 | 🚧 | 🚧 | 🚧 | N/A | N/A | N/A | |
|
||||||
|
| | CodeQL | 🚧 | N/A | 🚧 | 🚧 | 🚧 | | | |
|
||||||
|
|
||||||
* ✅ — Supported
|
* ✅ — Supported
|
||||||
* 🔶 — Partial support
|
* 🔶 — Partial support
|
||||||
|
106
script/build-and-upload
Executable file
106
script/build-and-upload
Executable file
@ -0,0 +1,106 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Usage: script/build-and-upload PROJECT_NAME
|
||||||
|
# where PROJECT_NAME is one of the packages present in this repo:
|
||||||
|
# semantic-source, etc.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PROJECT="$1"
|
||||||
|
ROOT_DIR="$(dirname "$0")/.."
|
||||||
|
CABAL_PATH="$ROOT_DIR/$PROJECT/$PROJECT.cabal"
|
||||||
|
|
||||||
|
if [ -z "$PROJECT" ]
|
||||||
|
then echo "USAGE: build_and_upload PROJECT_NAME"; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$CABAL_PATH" ]
|
||||||
|
then echo "Couldn't find .cabal file at $CABAL_PATH; is $PROJECT a valid package?"; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
cabal v2-build "$PROJECT"
|
||||||
|
TGZ_LOC="$(cabal v2-sdist "$PROJECT" | tail -n 1)"
|
||||||
|
DOCS_LOC="$(cabal v2-haddock --haddock-for-hackage "$PROJECT" | tail -n 1)"
|
||||||
|
PACKAGE_VERSION="$(basename "$TGZ_LOC" .tar.gz)"
|
||||||
|
|
||||||
|
if [ ! -f "$TGZ_LOC" ]
|
||||||
|
then echo "Bug in build_and_upload: $PACKAGE_FN doesn't point to a valid path"; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set +x
|
||||||
|
|
||||||
|
echo "You are planning to upload '$PACKAGE_VERSION'."
|
||||||
|
read -rp "Is this correct? [y/n] " choice
|
||||||
|
if [ "$choice" != "y" ]
|
||||||
|
then echo "Aborting."; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Attempting to build $PACKAGE_VERSION from source"
|
||||||
|
TEMP_PATH=$(mktemp -d)
|
||||||
|
tar -xvf "$TGZ_LOC" -C "$TEMP_PATH"
|
||||||
|
|
||||||
|
set -x
|
||||||
|
(
|
||||||
|
cd "$TEMP_PATH/$PACKAGE_VERSION"
|
||||||
|
pwd
|
||||||
|
|
||||||
|
cabal v2-update
|
||||||
|
cabal v2-build --disable-optimization
|
||||||
|
)
|
||||||
|
set +x
|
||||||
|
|
||||||
|
if wget -q --spider "https://hackage.haskell.org/package/$PACKAGE_VERSION"
|
||||||
|
then
|
||||||
|
echo "The package $PACKAGE_VERSION already exists on Hackage."
|
||||||
|
echo "If you need to upload code changes, then bump the version number in $PROJECT/$PROJECT.cabal, make a PR, and run this script again."
|
||||||
|
echo "Otherwise, if you need _only_ to loosen existing constraints in $PROJECT.cabal file, then you can create a new revision of this package on Hackage."
|
||||||
|
echo "You'll need to make your changes by hand. Be sure to click the 'Review changes' button to check your work."
|
||||||
|
read -rp "Do you want to open a browser so as to do this? [y/N]" choice
|
||||||
|
if [ "$choice" == "y" ]
|
||||||
|
then
|
||||||
|
echo "Opening…"
|
||||||
|
sleep 1
|
||||||
|
open "https://hackage.haskell.org/package/$PACKAGE_VERSION/$PROJECT.cabal/edit"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Aborting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "******************"
|
||||||
|
echo "Uploading packages"
|
||||||
|
echo "******************"
|
||||||
|
|
||||||
|
echo -n "Hackage username: "
|
||||||
|
read HACKAGE_USER
|
||||||
|
echo
|
||||||
|
echo -n "Hackage password: "
|
||||||
|
read -s HACKAGE_PASS
|
||||||
|
|
||||||
|
cabal upload --username="$HACKAGE_USER" --password="$HACKAGE_PASS" "$TGZ_LOC"
|
||||||
|
cabal upload --username="$HACKAGE_USER" --password="$HACKAGE_PASS" --documentation "$DOCS_LOC"
|
||||||
|
|
||||||
|
URL="https://hackage.haskell.org/package/$PACKAGE_VERSION/candidate"
|
||||||
|
|
||||||
|
echo "Opening candidate URL in browser…"
|
||||||
|
sleep 1
|
||||||
|
open "$URL"
|
||||||
|
|
||||||
|
echo "About to upload final version. Do you want to proceed?"
|
||||||
|
echo "Full-fledged package uploads cannot be undone!"
|
||||||
|
read -rp "Type 'yes' to continue. " choice
|
||||||
|
if [ "$choice" != "yes" ]
|
||||||
|
then echo "Aborting."; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
cabal upload --username="$HACKAGE_USER" --password="$HACKAGE_PASS" --publish "$TGZ_LOC"
|
||||||
|
cabal upload --username="$HACKAGE_USER" --password="$HACKAGE_PASS" --publish --documentation "$DOCS_LOC"
|
||||||
|
|
||||||
|
echo "Tagging $PACKAGE_VERSION"
|
||||||
|
git tag "$PACKAGE_VERSION"
|
||||||
|
git push --tags
|
@ -74,7 +74,7 @@ library
|
|||||||
, pathtype ^>= 0.8.1
|
, pathtype ^>= 0.8.1
|
||||||
, prettyprinter >= 1.2 && < 2
|
, prettyprinter >= 1.2 && < 2
|
||||||
, prettyprinter-ansi-terminal ^>= 1.1.1
|
, prettyprinter-ansi-terminal ^>= 1.1.1
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, semilattices
|
, semilattices
|
||||||
, terminal-size ^>= 0.3
|
, terminal-size ^>= 0.3
|
||||||
, text ^>= 1.2.3.1
|
, text ^>= 1.2.3.1
|
||||||
|
@ -7,7 +7,6 @@ module Analysis.File
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Maybe (fromJust, listToMaybe)
|
import Data.Maybe (fromJust, listToMaybe)
|
||||||
import Data.Semilattice.Lower
|
|
||||||
import GHC.Stack
|
import GHC.Stack
|
||||||
import Source.Language as Language
|
import Source.Language as Language
|
||||||
import Source.Span
|
import Source.Span
|
||||||
@ -30,4 +29,4 @@ fileLanguage :: File a -> Language
|
|||||||
fileLanguage = Language.forPath . filePath
|
fileLanguage = Language.forPath . filePath
|
||||||
|
|
||||||
fromPath :: Path.PartClass.AbsRel ar => Path.File ar -> File Language
|
fromPath :: Path.PartClass.AbsRel ar => Path.File ar -> File Language
|
||||||
fromPath p = File (Path.toAbsRel p) lowerBound (Language.forPath p)
|
fromPath p = File (Path.toAbsRel p) (point (Pos 0 0)) (Language.forPath p)
|
||||||
|
@ -61,7 +61,7 @@ library
|
|||||||
, filepath ^>= 1.4.1
|
, filepath ^>= 1.4.1
|
||||||
, fused-effects ^>= 1.0
|
, fused-effects ^>= 1.0
|
||||||
, tree-sitter ^>= 0.9.0.0
|
, tree-sitter ^>= 0.9.0.0
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, template-haskell ^>= 2.15
|
, template-haskell ^>= 2.15
|
||||||
, bytestring ^>= 0.10.8.2
|
, bytestring ^>= 0.10.8.2
|
||||||
, optparse-applicative >= 0.14.3 && < 0.16
|
, optparse-applicative >= 0.14.3 && < 0.16
|
||||||
|
@ -55,7 +55,7 @@ library
|
|||||||
, prettyprinter >= 1.2.1 && < 2
|
, prettyprinter >= 1.2.1 && < 2
|
||||||
, prettyprinter-ansi-terminal ^>= 1.1.1
|
, prettyprinter-ansi-terminal ^>= 1.1.1
|
||||||
, semantic-analysis ^>= 0
|
, semantic-analysis ^>= 0
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, text ^>= 1.2.3.1
|
, text ^>= 1.2.3.1
|
||||||
, trifecta >= 2 && < 2.2
|
, trifecta >= 2 && < 2.2
|
||||||
, unordered-containers ^>= 0.2.10
|
, unordered-containers ^>= 0.2.10
|
||||||
|
@ -26,7 +26,7 @@ common haskell
|
|||||||
, parsers ^>= 0.12.10
|
, parsers ^>= 0.12.10
|
||||||
, semantic-ast
|
, semantic-ast
|
||||||
, semantic-core ^>= 0.0
|
, semantic-core ^>= 0.0
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, semantic-tags ^>= 0.0
|
, semantic-tags ^>= 0.0
|
||||||
, template-haskell ^>= 2.15
|
, template-haskell ^>= 2.15
|
||||||
, text ^>= 1.2.3
|
, text ^>= 1.2.3
|
||||||
|
@ -26,7 +26,7 @@ common haskell
|
|||||||
, parsers ^>= 0.12.10
|
, parsers ^>= 0.12.10
|
||||||
, semantic-ast
|
, semantic-ast
|
||||||
, semantic-core ^>= 0.0
|
, semantic-core ^>= 0.0
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, semantic-tags ^>= 0.0
|
, semantic-tags ^>= 0.0
|
||||||
, template-haskell ^>= 2.15
|
, template-haskell ^>= 2.15
|
||||||
, text ^>= 1.2.3
|
, text ^>= 1.2.3
|
||||||
|
@ -26,7 +26,7 @@ common haskell
|
|||||||
, parsers ^>= 0.12.10
|
, parsers ^>= 0.12.10
|
||||||
, semantic-ast
|
, semantic-ast
|
||||||
, semantic-core ^>= 0.0
|
, semantic-core ^>= 0.0
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, semantic-tags ^>= 0.0
|
, semantic-tags ^>= 0.0
|
||||||
, template-haskell ^>= 2.15
|
, template-haskell ^>= 2.15
|
||||||
, text ^>= 1.2.3
|
, text ^>= 1.2.3
|
||||||
|
@ -43,7 +43,7 @@ executable semantic-parse
|
|||||||
build-depends: base
|
build-depends: base
|
||||||
, semantic-ast
|
, semantic-ast
|
||||||
, tree-sitter ^>= 0.9.0.0
|
, tree-sitter ^>= 0.9.0.0
|
||||||
, semantic-source
|
, semantic-source ^>= 0.1.0
|
||||||
, tree-sitter-python ^>= 0.9.0.1
|
, tree-sitter-python ^>= 0.9.0.1
|
||||||
, bytestring
|
, bytestring
|
||||||
, optparse-applicative
|
, optparse-applicative
|
||||||
|
@ -26,7 +26,7 @@ common haskell
|
|||||||
, parsers ^>= 0.12.10
|
, parsers ^>= 0.12.10
|
||||||
, semantic-ast
|
, semantic-ast
|
||||||
, semantic-core ^>= 0.0
|
, semantic-core ^>= 0.0
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, semantic-tags ^>= 0.0
|
, semantic-tags ^>= 0.0
|
||||||
, template-haskell ^>= 2.15
|
, template-haskell ^>= 2.15
|
||||||
, text ^>= 1.2.3
|
, text ^>= 1.2.3
|
||||||
|
@ -27,7 +27,7 @@ common haskell
|
|||||||
, semantic-analysis ^>= 0
|
, semantic-analysis ^>= 0
|
||||||
, semantic-ast
|
, semantic-ast
|
||||||
, semantic-core ^>= 0.0
|
, semantic-core ^>= 0.0
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, semantic-tags ^>= 0.0
|
, semantic-tags ^>= 0.0
|
||||||
, semantic-scope-graph ^>= 0.0
|
, semantic-scope-graph ^>= 0.0
|
||||||
, semilattices ^>= 0
|
, semilattices ^>= 0
|
||||||
|
@ -33,7 +33,6 @@ import Data.List.NonEmpty (NonEmpty (..))
|
|||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
import qualified Data.ScopeGraph as ScopeGraph
|
import qualified Data.ScopeGraph as ScopeGraph
|
||||||
import Data.Semilattice.Lower
|
|
||||||
import Data.Traversable
|
import Data.Traversable
|
||||||
import GHC.Records
|
import GHC.Records
|
||||||
import GHC.TypeLits
|
import GHC.TypeLits
|
||||||
@ -42,7 +41,7 @@ import Language.Python.Patterns
|
|||||||
import Scope.Graph.Convert (Result (..), complete, todo)
|
import Scope.Graph.Convert (Result (..), complete, todo)
|
||||||
import Scope.Types
|
import Scope.Types
|
||||||
import Source.Loc (Loc)
|
import Source.Loc (Loc)
|
||||||
import Source.Span (Span, span_)
|
import Source.Span (Span, Pos (..), span_, point)
|
||||||
|
|
||||||
-- This typeclass is internal-only, though it shares the same interface
|
-- This typeclass is internal-only, though it shares the same interface
|
||||||
-- as the one defined in semantic-scope-graph. The somewhat-unconventional
|
-- as the one defined in semantic-scope-graph. The somewhat-unconventional
|
||||||
@ -197,7 +196,7 @@ instance ToScopeGraph Py.FunctionDefinition where
|
|||||||
{ Props.kind = ScopeGraph.Parameter
|
{ Props.kind = ScopeGraph.Parameter
|
||||||
, Props.relation = ScopeGraph.Default
|
, Props.relation = ScopeGraph.Default
|
||||||
, Props.associatedScope = Nothing
|
, Props.associatedScope = Nothing
|
||||||
, Props.span = lowerBound
|
, Props.span = point (Pos 0 0)
|
||||||
}
|
}
|
||||||
let param (Py.Parameter (Prj (Py.Identifier pann pname))) = Just (pann, Name.name pname)
|
let param (Py.Parameter (Prj (Py.Identifier pann pname))) = Just (pann, Name.name pname)
|
||||||
param _ = Nothing
|
param _ = Nothing
|
||||||
|
@ -26,7 +26,7 @@ common haskell
|
|||||||
, parsers ^>= 0.12.10
|
, parsers ^>= 0.12.10
|
||||||
, semantic-ast
|
, semantic-ast
|
||||||
, semantic-core ^>= 0.0
|
, semantic-core ^>= 0.0
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, semantic-tags ^>= 0.0
|
, semantic-tags ^>= 0.0
|
||||||
, template-haskell ^>= 2.15
|
, template-haskell ^>= 2.15
|
||||||
, text ^>= 1.2.3
|
, text ^>= 1.2.3
|
||||||
|
@ -47,7 +47,7 @@ library
|
|||||||
, lens
|
, lens
|
||||||
, pathtype
|
, pathtype
|
||||||
, semantic-analysis
|
, semantic-analysis
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, semilattices
|
, semilattices
|
||||||
, text ^>= 1.2.3.1
|
, text ^>= 1.2.3.1
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
|
@ -37,7 +37,7 @@ instance HasSpan (Info scopeAddress) where
|
|||||||
{-# INLINE span_ #-}
|
{-# INLINE span_ #-}
|
||||||
|
|
||||||
instance Lower (Info scopeAddress) where
|
instance Lower (Info scopeAddress) where
|
||||||
lowerBound = Info lowerBound lowerBound lowerBound Public lowerBound lowerBound Nothing
|
lowerBound = Info lowerBound lowerBound lowerBound Public (point (Pos 0 0)) lowerBound Nothing
|
||||||
|
|
||||||
instance AbstractHole (Info address) where
|
instance AbstractHole (Info address) where
|
||||||
hole = lowerBound
|
hole = lowerBound
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
# 0.1.0.0
|
||||||
|
|
||||||
|
- Adds `CodeQL` language constructor.
|
||||||
|
- Bumps `lingo-haskell` to 0.3.2.
|
||||||
|
- Removes Span and Pos lower bound instances. This makes callers responsible for defining whether Span / Pos are 0 or 1 indexed.
|
||||||
|
|
||||||
# 0.0.2.0
|
# 0.0.2.0
|
||||||
|
|
||||||
- Adds `Source.Language`.
|
- Adds `Source.Language`.
|
||||||
|
@ -55,7 +55,7 @@ library
|
|||||||
, containers ^>= 0.6.2
|
, containers ^>= 0.6.2
|
||||||
, generic-monoid ^>= 0.1.0.0
|
, generic-monoid ^>= 0.1.0.0
|
||||||
, hashable >= 1.2.7 && < 1.4
|
, hashable >= 1.2.7 && < 1.4
|
||||||
, lingo ^>= 0.3
|
, lingo ^>= 0.3.2.0
|
||||||
, pathtype ^>= 0.8.1
|
, pathtype ^>= 0.8.1
|
||||||
, semilattices ^>= 0.0.0.3
|
, semilattices ^>= 0.0.0.3
|
||||||
, text ^>= 1.2.3.1
|
, text ^>= 1.2.3.1
|
||||||
|
@ -33,11 +33,12 @@ data Language
|
|||||||
| JSON
|
| JSON
|
||||||
| JSX
|
| JSX
|
||||||
| Markdown
|
| Markdown
|
||||||
|
| PHP
|
||||||
| Python
|
| Python
|
||||||
| Ruby
|
| Ruby
|
||||||
| TypeScript
|
| TypeScript
|
||||||
| PHP
|
|
||||||
| TSX
|
| TSX
|
||||||
|
| CodeQL
|
||||||
deriving (Eq, Generic, Ord, Read, Show, Bounded, Hashable, ToJSON, Enum)
|
deriving (Eq, Generic, Ord, Read, Show, Bounded, Hashable, ToJSON, Enum)
|
||||||
|
|
||||||
-- | Reifies a proxied type-level 'Language' to a value.
|
-- | Reifies a proxied type-level 'Language' to a value.
|
||||||
@ -47,6 +48,9 @@ class SLanguage (lang :: Language) where
|
|||||||
instance SLanguage 'Unknown where
|
instance SLanguage 'Unknown where
|
||||||
reflect _ = Unknown
|
reflect _ = Unknown
|
||||||
|
|
||||||
|
instance SLanguage 'CodeQL where
|
||||||
|
reflect _ = CodeQL
|
||||||
|
|
||||||
instance SLanguage 'Go where
|
instance SLanguage 'Go where
|
||||||
reflect _ = Go
|
reflect _ = Go
|
||||||
|
|
||||||
@ -68,6 +72,9 @@ instance SLanguage 'JSX where
|
|||||||
instance SLanguage 'Markdown where
|
instance SLanguage 'Markdown where
|
||||||
reflect _ = Markdown
|
reflect _ = Markdown
|
||||||
|
|
||||||
|
instance SLanguage 'PHP where
|
||||||
|
reflect _ = PHP
|
||||||
|
|
||||||
instance SLanguage 'Python where
|
instance SLanguage 'Python where
|
||||||
reflect _ = Python
|
reflect _ = Python
|
||||||
|
|
||||||
@ -77,9 +84,6 @@ instance SLanguage 'Ruby where
|
|||||||
instance SLanguage 'TypeScript where
|
instance SLanguage 'TypeScript where
|
||||||
reflect _ = TypeScript
|
reflect _ = TypeScript
|
||||||
|
|
||||||
instance SLanguage 'PHP where
|
|
||||||
reflect _ = PHP
|
|
||||||
|
|
||||||
instance FromJSON Language where
|
instance FromJSON Language where
|
||||||
parseJSON = withText "Language" $ \l ->
|
parseJSON = withText "Language" $ \l ->
|
||||||
pure $ textToLanguage l
|
pure $ textToLanguage l
|
||||||
@ -106,6 +110,7 @@ forPath path =
|
|||||||
languageToText :: Language -> T.Text
|
languageToText :: Language -> T.Text
|
||||||
languageToText = \case
|
languageToText = \case
|
||||||
Unknown -> "Unknown"
|
Unknown -> "Unknown"
|
||||||
|
CodeQL -> "CodeQL"
|
||||||
Go -> "Go"
|
Go -> "Go"
|
||||||
Haskell -> "Haskell"
|
Haskell -> "Haskell"
|
||||||
Java -> "Java"
|
Java -> "Java"
|
||||||
@ -113,14 +118,15 @@ languageToText = \case
|
|||||||
JSON -> "JSON"
|
JSON -> "JSON"
|
||||||
JSX -> "JSX"
|
JSX -> "JSX"
|
||||||
Markdown -> "Markdown"
|
Markdown -> "Markdown"
|
||||||
|
PHP -> "PHP"
|
||||||
Python -> "Python"
|
Python -> "Python"
|
||||||
Ruby -> "Ruby"
|
Ruby -> "Ruby"
|
||||||
TypeScript -> "TypeScript"
|
TypeScript -> "TypeScript"
|
||||||
TSX -> "TSX"
|
TSX -> "TSX"
|
||||||
PHP -> "PHP"
|
|
||||||
|
|
||||||
textToLanguage :: T.Text -> Language
|
textToLanguage :: T.Text -> Language
|
||||||
textToLanguage = \case
|
textToLanguage = \case
|
||||||
|
"CodeQL" -> CodeQL
|
||||||
"Go" -> Go
|
"Go" -> Go
|
||||||
"Haskell" -> Haskell
|
"Haskell" -> Haskell
|
||||||
"Java" -> Java
|
"Java" -> Java
|
||||||
@ -128,9 +134,9 @@ textToLanguage = \case
|
|||||||
"JSON" -> JSON
|
"JSON" -> JSON
|
||||||
"JSX" -> JSX
|
"JSX" -> JSX
|
||||||
"Markdown" -> Markdown
|
"Markdown" -> Markdown
|
||||||
|
"PHP" -> PHP
|
||||||
"Python" -> Python
|
"Python" -> Python
|
||||||
"Ruby" -> Ruby
|
"Ruby" -> Ruby
|
||||||
"TypeScript" -> TypeScript
|
"TypeScript" -> TypeScript
|
||||||
"TSX" -> TSX
|
"TSX" -> TSX
|
||||||
"PHP" -> PHP
|
|
||||||
_ -> Unknown
|
_ -> Unknown
|
||||||
|
@ -25,7 +25,7 @@ library
|
|||||||
build-depends:
|
build-depends:
|
||||||
base >= 4.13 && < 5
|
base >= 4.13 && < 5
|
||||||
, fused-effects ^>= 1.0
|
, fused-effects ^>= 1.0
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, text ^>= 1.2.3.1
|
, text ^>= 1.2.3.1
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
@ -26,7 +26,7 @@ common haskell
|
|||||||
, parsers ^>= 0.12.10
|
, parsers ^>= 0.12.10
|
||||||
, semantic-ast
|
, semantic-ast
|
||||||
, semantic-core ^>= 0.0
|
, semantic-core ^>= 0.0
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, semantic-tags ^>= 0.0
|
, semantic-tags ^>= 0.0
|
||||||
, template-haskell ^>= 2.15
|
, template-haskell ^>= 2.15
|
||||||
, text ^>= 1.2.3
|
, text ^>= 1.2.3
|
||||||
|
@ -26,7 +26,7 @@ common haskell
|
|||||||
, parsers ^>= 0.12.10
|
, parsers ^>= 0.12.10
|
||||||
, semantic-ast
|
, semantic-ast
|
||||||
, semantic-core ^>= 0.0
|
, semantic-core ^>= 0.0
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, semantic-tags ^>= 0.0
|
, semantic-tags ^>= 0.0
|
||||||
, template-haskell ^>= 2.15
|
, template-haskell ^>= 2.15
|
||||||
, text ^>= 1.2.3
|
, text ^>= 1.2.3
|
||||||
|
@ -59,7 +59,7 @@ common dependencies
|
|||||||
, fused-effects-exceptions ^>= 1
|
, fused-effects-exceptions ^>= 1
|
||||||
, fused-effects-resumable ^>= 0.1
|
, fused-effects-resumable ^>= 0.1
|
||||||
, hashable >= 1.2.7 && < 1.4
|
, hashable >= 1.2.7 && < 1.4
|
||||||
, tree-sitter ^>= 0.9.0.0
|
, tree-sitter ^>= 0.9.0.1
|
||||||
, mtl ^>= 2.2.2
|
, mtl ^>= 2.2.2
|
||||||
, network ^>= 2.8.0.0
|
, network ^>= 2.8.0.0
|
||||||
, pathtype ^>= 0.8.1
|
, pathtype ^>= 0.8.1
|
||||||
@ -69,7 +69,7 @@ common dependencies
|
|||||||
, safe-exceptions ^>= 0.1.7.0
|
, safe-exceptions ^>= 0.1.7.0
|
||||||
, semantic-analysis ^>= 0
|
, semantic-analysis ^>= 0
|
||||||
, semantic-ast
|
, semantic-ast
|
||||||
, semantic-source ^>= 0.0.2
|
, semantic-source ^>= 0.1.0
|
||||||
, semilattices ^>= 0.0.0.3
|
, semilattices ^>= 0.0.0.3
|
||||||
, streaming ^>= 0.2.2.0
|
, streaming ^>= 0.2.2.0
|
||||||
, text ^>= 1.2.3.1
|
, text ^>= 1.2.3.1
|
||||||
|
@ -77,7 +77,7 @@ import Data.Semilattice.Lower
|
|||||||
import Data.Set (Set)
|
import Data.Set (Set)
|
||||||
import GHC.Generics (Generic1)
|
import GHC.Generics (Generic1)
|
||||||
import GHC.Stack
|
import GHC.Stack
|
||||||
import Source.Span (Span)
|
import Source.Span (Pos (..), Span, point)
|
||||||
|
|
||||||
|
|
||||||
-- | Evaluates an action locally the scope and frame of the given frame address.
|
-- | Evaluates an action locally the scope and frame of the given frame address.
|
||||||
@ -191,7 +191,7 @@ define :: ( HasCallStack
|
|||||||
-> Evaluator term address value m ()
|
-> Evaluator term address value m ()
|
||||||
define declaration rel accessControl def = withCurrentCallStack callStack $ do
|
define declaration rel accessControl def = withCurrentCallStack callStack $ do
|
||||||
-- TODO: This span is still wrong.
|
-- TODO: This span is still wrong.
|
||||||
declare declaration rel accessControl lowerBound Unknown Nothing
|
declare declaration rel accessControl (point (Pos 1 1)) Unknown Nothing
|
||||||
slot <- lookupSlot declaration
|
slot <- lookupSlot declaration
|
||||||
value <- def
|
value <- def
|
||||||
assign slot value
|
assign slot value
|
||||||
|
@ -40,7 +40,6 @@ import Control.Monad.IO.Class
|
|||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
import Data.Functor.Classes
|
import Data.Functor.Classes
|
||||||
import Data.Maybe.Exts
|
import Data.Maybe.Exts
|
||||||
import Data.Semilattice.Lower
|
|
||||||
import Data.Set (Set)
|
import Data.Set (Set)
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
import GHC.Generics (Generic1)
|
import GHC.Generics (Generic1)
|
||||||
@ -147,7 +146,7 @@ runLoadErrorWith f = raiseHandler $ With.runResumable (runEvaluator . f)
|
|||||||
throwLoadError :: Has (Resumable (BaseError (LoadError address value))) sig m
|
throwLoadError :: Has (Resumable (BaseError (LoadError address value))) sig m
|
||||||
=> LoadError address value resume
|
=> LoadError address value resume
|
||||||
-> m resume
|
-> m resume
|
||||||
throwLoadError err@(ModuleNotFoundError name) = throwResumable $ BaseError (ModuleInfo name "Unknown" mempty) lowerBound err
|
throwLoadError err@(ModuleNotFoundError name) = throwResumable $ BaseError (ModuleInfo name "Unknown" mempty) (point (Pos 1 1)) err
|
||||||
-- TODO: Might be able to get rest of ModuleInfo from the env ^.
|
-- TODO: Might be able to get rest of ModuleInfo from the env ^.
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ import Data.Abstract.BaseError
|
|||||||
import qualified Data.Abstract.ScopeGraph as ScopeGraph
|
import qualified Data.Abstract.ScopeGraph as ScopeGraph
|
||||||
import Data.Map.Strict as Map
|
import Data.Map.Strict as Map
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Semilattice.Lower
|
|
||||||
import Data.Traversable
|
import Data.Traversable
|
||||||
import GHC.Stack
|
import GHC.Stack
|
||||||
|
import Source.Span (Pos (..), point)
|
||||||
|
|
||||||
defineBuiltIn :: ( HasCallStack
|
defineBuiltIn :: ( HasCallStack
|
||||||
, Has (Deref value) sig m
|
, Has (Deref value) sig m
|
||||||
@ -47,11 +47,11 @@ defineBuiltIn declaration rel accessControl value = withCurrentCallStack callSta
|
|||||||
let lexicalEdges = Map.singleton Lexical [ currentScope' ]
|
let lexicalEdges = Map.singleton Lexical [ currentScope' ]
|
||||||
associatedScope <- newPreludeScope lexicalEdges
|
associatedScope <- newPreludeScope lexicalEdges
|
||||||
-- TODO: This span is still wrong.
|
-- TODO: This span is still wrong.
|
||||||
declare declaration rel accessControl lowerBound ScopeGraph.Unknown (Just associatedScope)
|
declare declaration rel accessControl (point (Pos 1 1)) ScopeGraph.Unknown (Just associatedScope)
|
||||||
|
|
||||||
withScope associatedScope $ do
|
withScope associatedScope $ do
|
||||||
param <- gensym
|
param <- gensym
|
||||||
declare (Declaration param) ScopeGraph.Gensym accessControl lowerBound ScopeGraph.Unknown Nothing
|
declare (Declaration param) ScopeGraph.Gensym accessControl (point (Pos 1 1)) ScopeGraph.Unknown Nothing
|
||||||
|
|
||||||
slot <- lookupSlot declaration
|
slot <- lookupSlot declaration
|
||||||
value <- builtIn associatedScope value
|
value <- builtIn associatedScope value
|
||||||
|
@ -35,11 +35,10 @@ import Data.Functor.Classes
|
|||||||
import Data.List.NonEmpty (nonEmpty)
|
import Data.List.NonEmpty (nonEmpty)
|
||||||
import Data.Scientific (Scientific)
|
import Data.Scientific (Scientific)
|
||||||
import Data.Semigroup.Foldable
|
import Data.Semigroup.Foldable
|
||||||
import Data.Semilattice.Lower
|
|
||||||
import Data.Sum
|
import Data.Sum
|
||||||
import Data.Text
|
import Data.Text
|
||||||
import GHC.Stack
|
import GHC.Stack
|
||||||
import Source.Span (HasSpan (..))
|
import Source.Span (HasSpan (..), Pos (..), point)
|
||||||
|
|
||||||
import Analysis.Name as X
|
import Analysis.Name as X
|
||||||
import Control.Abstract hiding (Load, String)
|
import Control.Abstract hiding (Load, String)
|
||||||
@ -229,7 +228,7 @@ defineSelf :: ( Has (State (ScopeGraph address)) sig m
|
|||||||
=> Evaluator term address value m ()
|
=> Evaluator term address value m ()
|
||||||
defineSelf = do
|
defineSelf = do
|
||||||
let self = Declaration __self
|
let self = Declaration __self
|
||||||
declare self ScopeGraph.Prelude Public lowerBound ScopeGraph.Unknown Nothing
|
declare self ScopeGraph.Prelude Public (point (Pos 1 1)) ScopeGraph.Unknown Nothing
|
||||||
slot <- lookupSlot self
|
slot <- lookupSlot self
|
||||||
assign slot =<< object =<< currentFrame
|
assign slot =<< object =<< currentFrame
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ import Data.Blob
|
|||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
import Data.Language
|
import Data.Language
|
||||||
import Data.Maybe.Exts
|
import Data.Maybe.Exts
|
||||||
import Data.Semilattice.Lower
|
|
||||||
import Semantic.IO
|
import Semantic.IO
|
||||||
import qualified Source.Source as Source
|
import qualified Source.Source as Source
|
||||||
|
import Source.Span
|
||||||
import qualified System.Path as Path
|
import qualified System.Path as Path
|
||||||
|
|
||||||
-- | Deprecated: this has very weird semantics.
|
-- | Deprecated: this has very weird semantics.
|
||||||
@ -44,7 +44,7 @@ readProjectFromPaths maybeRoot path lang excludeDirs = do
|
|||||||
blobs <- liftIO $ traverse (readBlobFromFile' . toFile) paths
|
blobs <- liftIO $ traverse (readBlobFromFile' . toFile) paths
|
||||||
pure $ Project rootDir blobs lang excludeDirs
|
pure $ Project rootDir blobs lang excludeDirs
|
||||||
where
|
where
|
||||||
toFile path = File path lowerBound lang
|
toFile path = File path (point (Pos 1 1)) lang
|
||||||
exts = extensionsForLanguage lang
|
exts = extensionsForLanguage lang
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import Data.Functor.Classes.Generic
|
|||||||
import Data.Hashable.Lifted
|
import Data.Hashable.Lifted
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Data.Maybe.Exts
|
import Data.Maybe.Exts
|
||||||
import Data.Semilattice.Lower
|
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
import Data.Traversable
|
import Data.Traversable
|
||||||
import GHC.Generics (Generic1)
|
import GHC.Generics (Generic1)
|
||||||
@ -106,7 +105,7 @@ instance Evaluatable Method where
|
|||||||
|
|
||||||
params <- withScope associatedScope $ do
|
params <- withScope associatedScope $ do
|
||||||
-- TODO: Should we give `self` a special Relation?
|
-- TODO: Should we give `self` a special Relation?
|
||||||
declare (Declaration __self) ScopeGraph.Prelude ScopeGraph.Public lowerBound ScopeGraph.Unknown Nothing
|
declare (Declaration __self) ScopeGraph.Prelude ScopeGraph.Public (point (Pos 1 1)) ScopeGraph.Unknown Nothing
|
||||||
for methodParameters $ \paramNode -> declareMaybeName (declaredName paramNode) Default ScopeGraph.Public (paramNode^.span_) ScopeGraph.Parameter Nothing
|
for methodParameters $ \paramNode -> declareMaybeName (declaredName paramNode) Default ScopeGraph.Public (paramNode^.span_) ScopeGraph.Parameter Nothing
|
||||||
|
|
||||||
addr <- lookupSlot (Declaration name)
|
addr <- lookupSlot (Declaration name)
|
||||||
|
@ -19,10 +19,10 @@ import Data.Hashable
|
|||||||
import Data.Hashable.Lifted
|
import Data.Hashable.Lifted
|
||||||
import Data.JSON.Fields
|
import Data.JSON.Fields
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Data.Semilattice.Lower
|
|
||||||
import Diffing.Algorithm
|
import Diffing.Algorithm
|
||||||
import GHC.Generics (Generic, Generic1)
|
import GHC.Generics (Generic, Generic1)
|
||||||
import Language.TypeScript.Resolution
|
import Language.TypeScript.Resolution
|
||||||
|
import Source.Span
|
||||||
|
|
||||||
data Import a = Import { importSymbols :: ![Alias], importFrom :: ImportPath }
|
data Import a = Import { importSymbols :: ![Alias], importFrom :: ImportPath }
|
||||||
deriving (Declarations1, Diffable, Foldable, FreeVariables1, Functor, Generic1, Hashable1, ToJSONFields1, Traversable)
|
deriving (Declarations1, Diffable, Foldable, FreeVariables1, Functor, Generic1, Hashable1, ToJSONFields1, Traversable)
|
||||||
@ -50,7 +50,7 @@ instance Evaluatable Import where
|
|||||||
for_ symbols $ \Alias{..} ->
|
for_ symbols $ \Alias{..} ->
|
||||||
-- TODO: Need an easier way to get the span of an Alias. It's difficult because we no longer have a term.
|
-- TODO: Need an easier way to get the span of an Alias. It's difficult because we no longer have a term.
|
||||||
-- Even if we had one we'd have to evaluate it at the moment.
|
-- Even if we had one we'd have to evaluate it at the moment.
|
||||||
insertImportReference (Reference aliasName) lowerBound ScopeGraph.Identifier (Declaration aliasValue) scopeAddress
|
insertImportReference (Reference aliasName) (point (Pos 1 1)) ScopeGraph.Identifier (Declaration aliasValue) scopeAddress
|
||||||
|
|
||||||
-- Create edges from the current scope/frame to the import scope/frame.
|
-- Create edges from the current scope/frame to the import scope/frame.
|
||||||
insertImportEdge scopeAddress
|
insertImportEdge scopeAddress
|
||||||
@ -110,7 +110,7 @@ instance Evaluatable QualifiedExport where
|
|||||||
withScope exportScope .
|
withScope exportScope .
|
||||||
for_ exportSymbols $ \Alias{..} -> do
|
for_ exportSymbols $ \Alias{..} -> do
|
||||||
-- TODO: Replace Alias in QualifedExport with terms and use a real span
|
-- TODO: Replace Alias in QualifedExport with terms and use a real span
|
||||||
reference (Reference aliasName) lowerBound ScopeGraph.Identifier (Declaration aliasValue)
|
reference (Reference aliasName) (point (Pos 1 1)) ScopeGraph.Identifier (Declaration aliasValue)
|
||||||
|
|
||||||
-- Create an export edge from a new scope to the qualifed export's scope.
|
-- Create an export edge from a new scope to the qualifed export's scope.
|
||||||
unit
|
unit
|
||||||
@ -140,7 +140,7 @@ instance Evaluatable QualifiedExportFrom where
|
|||||||
withScopeAndFrame moduleFrame .
|
withScopeAndFrame moduleFrame .
|
||||||
for_ exportSymbols $ \Alias{..} -> do
|
for_ exportSymbols $ \Alias{..} -> do
|
||||||
-- TODO: Replace Alias with terms in QualifiedExportFrom and use a real span below.
|
-- TODO: Replace Alias with terms in QualifiedExportFrom and use a real span below.
|
||||||
insertImportReference (Reference aliasName) lowerBound ScopeGraph.Identifier (Declaration aliasValue) exportScope
|
insertImportReference (Reference aliasName) (point (Pos 1 1)) ScopeGraph.Identifier (Declaration aliasValue) exportScope
|
||||||
|
|
||||||
insertExportEdge exportScope
|
insertExportEdge exportScope
|
||||||
insertFrameLink ScopeGraph.Export (Map.singleton exportScope exportFrame)
|
insertFrameLink ScopeGraph.Export (Map.singleton exportScope exportFrame)
|
||||||
|
@ -1,4 +1,15 @@
|
|||||||
{-# LANGUAGE AllowAmbiguousTypes, DataKinds, FlexibleContexts, FlexibleInstances, LambdaCase, MultiParamTypeClasses, RecordWildCards, ScopedTypeVariables, TupleSections, TypeApplications, TypeFamilies, UndecidableInstances #-}
|
{-# LANGUAGE AllowAmbiguousTypes #-}
|
||||||
|
{-# LANGUAGE DataKinds #-}
|
||||||
|
{-# LANGUAGE FlexibleContexts #-}
|
||||||
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||||
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
{-# LANGUAGE TupleSections #-}
|
||||||
|
{-# LANGUAGE TypeApplications #-}
|
||||||
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
|
{-# LANGUAGE UndecidableInstances #-}
|
||||||
module Semantic.Api.TOCSummaries
|
module Semantic.Api.TOCSummaries
|
||||||
( diffSummary
|
( diffSummary
|
||||||
, legacyDiffSummary
|
, legacyDiffSummary
|
||||||
@ -8,7 +19,7 @@ module Semantic.Api.TOCSummaries
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Analysis.Decorator (decoratorWithAlgebra)
|
import Analysis.Decorator (decoratorWithAlgebra)
|
||||||
import Analysis.TOCSummary (Declaration(..), HasDeclaration, Kind(..), declarationAlgebra, formatKind)
|
import Analysis.TOCSummary (Declaration (..), HasDeclaration, Kind (..), declarationAlgebra, formatKind)
|
||||||
import Control.Applicative (liftA2)
|
import Control.Applicative (liftA2)
|
||||||
import Control.Effect.Error
|
import Control.Effect.Error
|
||||||
import Control.Effect.Parse
|
import Control.Effect.Parse
|
||||||
@ -22,13 +33,12 @@ import Data.Edit
|
|||||||
import Data.Either (partitionEithers)
|
import Data.Either (partitionEithers)
|
||||||
import Data.Function (on)
|
import Data.Function (on)
|
||||||
import Data.Functor.Foldable (Base, Recursive)
|
import Data.Functor.Foldable (Base, Recursive)
|
||||||
import Data.Language (Language, LanguageMode(..), PerLanguageModes)
|
import Data.Language (Language, LanguageMode (..), PerLanguageModes)
|
||||||
import Data.Map (Map)
|
import Data.Map (Map)
|
||||||
import qualified Data.Map.Monoidal as Map
|
import qualified Data.Map.Monoidal as Map
|
||||||
import Data.Maybe (mapMaybe)
|
import Data.Maybe (mapMaybe)
|
||||||
import Data.ProtoLens (defMessage)
|
import Data.ProtoLens (defMessage)
|
||||||
import Data.Semilattice.Lower
|
import Data.Term (IsTerm (..), TermF)
|
||||||
import Data.Term (IsTerm(..), TermF)
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Diffing.Algorithm.SES as SES
|
import qualified Diffing.Algorithm.SES as SES
|
||||||
import Diffing.Interpreter (DiffTerms)
|
import Diffing.Interpreter (DiffTerms)
|
||||||
@ -43,6 +53,7 @@ import Semantic.Task as Task
|
|||||||
import Serializing.Format
|
import Serializing.Format
|
||||||
import Source.Loc as Loc
|
import Source.Loc as Loc
|
||||||
import Source.Source as Source
|
import Source.Source as Source
|
||||||
|
import Source.Span
|
||||||
import qualified Tags.Tag as Tag
|
import qualified Tags.Tag as Tag
|
||||||
import qualified Tags.Tagging.Precise as Tagging
|
import qualified Tags.Tagging.Precise as Tagging
|
||||||
|
|
||||||
@ -55,7 +66,7 @@ legacyDiffSummary = distributeFoldMap go
|
|||||||
go :: (Has (Error SomeException) sig m, Has Parse sig m, Has (Reader PerLanguageModes) sig m, Has Telemetry sig m, MonadIO m) => BlobPair -> m Summaries
|
go :: (Has (Error SomeException) sig m, Has Parse sig m, Has (Reader PerLanguageModes) sig m, Has Telemetry sig m, MonadIO m) => BlobPair -> m Summaries
|
||||||
go blobPair = asks summarizeTermParsers >>= \ p -> parsePairWith p (fmap (uncurry (flip Summaries) . bimap toMap toMap . partitionEithers) . summarizeTerms) blobPair
|
go blobPair = asks summarizeTermParsers >>= \ p -> parsePairWith p (fmap (uncurry (flip Summaries) . bimap toMap toMap . partitionEithers) . summarizeTerms) blobPair
|
||||||
`catchError` \(SomeException e) ->
|
`catchError` \(SomeException e) ->
|
||||||
pure $ Summaries mempty (toMap [ErrorSummary (T.pack (show e)) lowerBound lang])
|
pure $ Summaries mempty (toMap [ErrorSummary (T.pack (show e)) (point (Pos 1 1)) lang])
|
||||||
where path = T.pack $ pathKeyForBlobPair blobPair
|
where path = T.pack $ pathKeyForBlobPair blobPair
|
||||||
lang = languageForBlobPair blobPair
|
lang = languageForBlobPair blobPair
|
||||||
|
|
||||||
|
@ -86,6 +86,10 @@ import Source.Span
|
|||||||
import qualified System.Path as Path
|
import qualified System.Path as Path
|
||||||
import Text.Show.Pretty (ppShow)
|
import Text.Show.Pretty (ppShow)
|
||||||
|
|
||||||
|
-- TODO: this should be zero-indexed (https://github.com/github/semantic/issues/263)
|
||||||
|
initialSpan :: Span
|
||||||
|
initialSpan = point (Pos 1 1)
|
||||||
|
|
||||||
data GraphType = ImportGraph | CallGraph
|
data GraphType = ImportGraph | CallGraph
|
||||||
|
|
||||||
isPathPrefixOf :: Path.AbsRelDir -> Path.AbsRelFile -> Bool
|
isPathPrefixOf :: Path.AbsRelDir -> Path.AbsRelFile -> Bool
|
||||||
@ -192,8 +196,8 @@ runCallGraph lang includePackages modules package
|
|||||||
. resumingResolutionError
|
. resumingResolutionError
|
||||||
. resumingAddressError
|
. resumingAddressError
|
||||||
. raiseHandler (runReader (packageInfo package))
|
. raiseHandler (runReader (packageInfo package))
|
||||||
. raiseHandler (runReader (lowerBound @Span))
|
. raiseHandler (runReader initialSpan)
|
||||||
. raiseHandler (runState (lowerBound @Span))
|
. raiseHandler (runState initialSpan)
|
||||||
. raiseHandler (runReader (lowerBound @ControlFlowVertex))
|
. raiseHandler (runReader (lowerBound @ControlFlowVertex))
|
||||||
. providingLiveSet
|
. providingLiveSet
|
||||||
. runModuleTable
|
. runModuleTable
|
||||||
@ -255,8 +259,8 @@ runImportGraph lang package f
|
|||||||
. runModuleTable
|
. runModuleTable
|
||||||
. runModules (ModuleTable.modulePaths (packageModules package))
|
. runModules (ModuleTable.modulePaths (packageModules package))
|
||||||
. raiseHandler (runReader (packageInfo package))
|
. raiseHandler (runReader (packageInfo package))
|
||||||
. raiseHandler (runState (lowerBound @Span))
|
. raiseHandler (runState initialSpan)
|
||||||
. raiseHandler (runReader (lowerBound @Span))
|
. raiseHandler (runReader initialSpan)
|
||||||
. raiseHandler (runState (lowerBound @(ScopeGraph (Hole (Maybe Name) Precise))))
|
. raiseHandler (runState (lowerBound @(ScopeGraph (Hole (Maybe Name) Precise))))
|
||||||
. runAllocator
|
. runAllocator
|
||||||
$ evaluate lang (graphingModuleInfo (runDomainEffects (evalTerm id))) (snd <$> ModuleTable.toPairs (packageModules package))
|
$ evaluate lang (graphingModuleInfo (runDomainEffects (evalTerm id))) (snd <$> ModuleTable.toPairs (packageModules package))
|
||||||
@ -318,8 +322,8 @@ parsePythonPackage parser project = do
|
|||||||
. runModuleTable
|
. runModuleTable
|
||||||
. runModules lowerBound
|
. runModules lowerBound
|
||||||
. raiseHandler (runReader (PackageInfo (Data.Abstract.Evaluatable.name "setup") lowerBound))
|
. raiseHandler (runReader (PackageInfo (Data.Abstract.Evaluatable.name "setup") lowerBound))
|
||||||
. raiseHandler (runState (lowerBound @Span))
|
. raiseHandler (runState initialSpan)
|
||||||
. raiseHandler (runReader (lowerBound @Span))
|
. raiseHandler (runReader initialSpan)
|
||||||
. raiseHandler (runState (lowerBound @(ScopeGraph (Hole (Maybe Name) Precise))))
|
. raiseHandler (runState (lowerBound @(ScopeGraph (Hole (Maybe Name) Precise))))
|
||||||
. runAllocator
|
. runAllocator
|
||||||
|
|
||||||
|
@ -41,14 +41,13 @@ import Data.Graph.Algebraic (topologicalSort)
|
|||||||
import qualified Data.Language as Language
|
import qualified Data.Language as Language
|
||||||
import Data.List (uncons)
|
import Data.List (uncons)
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Semilattice.Lower
|
|
||||||
import Data.Sum
|
import Data.Sum
|
||||||
import Parsing.Parser
|
import Parsing.Parser
|
||||||
import Semantic.Analysis
|
import Semantic.Analysis
|
||||||
import Semantic.Config
|
import Semantic.Config
|
||||||
import Semantic.Graph
|
import Semantic.Graph
|
||||||
import Semantic.Task
|
import Semantic.Task
|
||||||
import Source.Span (HasSpan (..))
|
import Source.Span (HasSpan (..), Pos (..), point)
|
||||||
import System.Exit (die)
|
import System.Exit (die)
|
||||||
import System.FilePath.Posix (takeDirectory)
|
import System.FilePath.Posix (takeDirectory)
|
||||||
import qualified System.Path as Path
|
import qualified System.Path as Path
|
||||||
@ -85,11 +84,12 @@ evaluateProject' session proxy parser paths = do
|
|||||||
trace $ "evaluating with load order: " <> show (map (modulePath . moduleInfo) modules)
|
trace $ "evaluating with load order: " <> show (map (modulePath . moduleInfo) modules)
|
||||||
pure (package, modules)
|
pure (package, modules)
|
||||||
(package, modules) <- either (die . displayException) pure res
|
(package, modules) <- either (die . displayException) pure res
|
||||||
|
let initialSpan = point (Pos 1 1)
|
||||||
pure (runModuleTable
|
pure (runModuleTable
|
||||||
(runModules (ModuleTable.modulePaths (packageModules package))
|
(runModules (ModuleTable.modulePaths (packageModules package))
|
||||||
(raiseHandler (runReader (packageInfo package))
|
(raiseHandler (runReader (packageInfo package))
|
||||||
(raiseHandler (evalState (lowerBound @Span))
|
(raiseHandler (evalState initialSpan)
|
||||||
(raiseHandler (runReader (lowerBound @Span))
|
(raiseHandler (runReader initialSpan)
|
||||||
(evaluate proxy (runDomainEffects (evalTerm (withTermSpans (^. span_)))) modules))))))
|
(evaluate proxy (runDomainEffects (evalTerm (withTermSpans (^. span_)))) modules))))))
|
||||||
|
|
||||||
parseFile, parseFileQuiet :: Parser term -> FilePath -> IO term
|
parseFile, parseFileQuiet :: Parser term -> FilePath -> IO term
|
||||||
@ -97,7 +97,7 @@ parseFile parser = runTask' . (parse parser <=< readBlob . fileForPath)
|
|||||||
parseFileQuiet parser = runTaskQuiet . (parse parser <=< readBlob . fileForPath)
|
parseFileQuiet parser = runTaskQuiet . (parse parser <=< readBlob . fileForPath)
|
||||||
|
|
||||||
fileForPath :: FilePath -> File Language.Language
|
fileForPath :: FilePath -> File Language.Language
|
||||||
fileForPath (Path.absRel -> p) = File p lowerBound (Language.forPath p)
|
fileForPath (Path.absRel -> p) = File p (point (Pos 1 1)) (Language.forPath p)
|
||||||
|
|
||||||
runTask', runTaskQuiet :: ParseC TaskC a -> IO a
|
runTask', runTaskQuiet :: ParseC TaskC a -> IO a
|
||||||
runTask' task = runTaskWithOptions debugOptions (asks configTreeSitterParseTimeout >>= \ timeout -> runParse timeout task) >>= either (die . displayException) pure
|
runTask' task = runTaskWithOptions debugOptions (asks configTreeSitterParseTimeout >>= \ timeout -> runParse timeout task) >>= either (die . displayException) pure
|
||||||
|
@ -76,6 +76,7 @@ import Semantic.Util as X
|
|||||||
import Source.Range as X hiding (end, point, start)
|
import Source.Range as X hiding (end, point, start)
|
||||||
import Source.Source as X (Source)
|
import Source.Source as X (Source)
|
||||||
import Source.Span as X hiding (HasSpan (..), end, point, start)
|
import Source.Span as X hiding (HasSpan (..), end, point, start)
|
||||||
|
import qualified Source.Span
|
||||||
import System.Exit (die)
|
import System.Exit (die)
|
||||||
import qualified System.Path as Path
|
import qualified System.Path as Path
|
||||||
import Test.Hspec as X (Spec, SpecWith, around, context, describe, it, parallel, pendingWith, runIO, xit)
|
import Test.Hspec as X (Spec, SpecWith, around, context, describe, it, parallel, pendingWith, runIO, xit)
|
||||||
@ -84,6 +85,9 @@ import Test.Hspec.LeanCheck as X
|
|||||||
import Test.LeanCheck as X
|
import Test.LeanCheck as X
|
||||||
import Unsafe.Coerce (unsafeCoerce)
|
import Unsafe.Coerce (unsafeCoerce)
|
||||||
|
|
||||||
|
instance Lower X.Span where
|
||||||
|
lowerBound = Source.Span.point (Pos 1 1)
|
||||||
|
|
||||||
runBuilder :: Builder -> ByteString
|
runBuilder :: Builder -> ByteString
|
||||||
runBuilder = toStrict . toLazyByteString
|
runBuilder = toStrict . toLazyByteString
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user