1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Merge branch 'master' into bump-tree-sitter

This commit is contained in:
Josh Vera 2018-07-23 19:55:21 -04:00 committed by GitHub
commit 7b025c6e49
72 changed files with 2755 additions and 92 deletions

View File

@ -0,0 +1,18 @@
---
type: cabal
name: type-aligned
version: 0.9.6
summary: Various type-aligned sequence data structures.
homepage: https://github.com/atzeus/type-aligned
license: bsd-3-clause
---
Copyright (c) 2014, Atze van der Ploeg
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the Atze van der Ploeg nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

View File

@ -6,6 +6,9 @@ import "ruby-terms.proto";
import "ruby-diffs.proto"; import "ruby-diffs.proto";
import "json-terms.proto"; import "json-terms.proto";
import "typescript-terms.proto"; import "typescript-terms.proto";
import "typescript-diffs.proto";
import "python-terms.proto";
import "python-diffs.proto";
import "types.proto"; import "types.proto";
import "error_details.proto"; import "error_details.proto";
@ -48,6 +51,7 @@ message ParseTreeResponse {
RubyResponse ruby = 1; RubyResponse ruby = 1;
JSONResponse json = 2; JSONResponse json = 2;
TypeScriptResponse typescript = 3; TypeScriptResponse typescript = 3;
PythonResponse python = 4;
} }
} }
@ -63,6 +67,10 @@ message TypeScriptResponse {
repeated typescript_terms.TypeScriptTerm terms = 1; repeated typescript_terms.TypeScriptTerm terms = 1;
} }
message PythonResponse {
repeated python_terms.PythonTerm terms = 1;
}
message SummarizeDiffRequest { message SummarizeDiffRequest {
repeated BlobPair blobPairs = 1; repeated BlobPair blobPairs = 1;
} }
@ -79,6 +87,8 @@ message DiffTreeRequest {
message DiffTreeResponse { message DiffTreeResponse {
oneof response_type { oneof response_type {
RubyDiffResponse ruby = 1; RubyDiffResponse ruby = 1;
PythonDiffResponse python = 2;
TypeScriptDiffResponse typescript = 3;
} }
} }
@ -86,6 +96,14 @@ message RubyDiffResponse {
repeated ruby_diffs.RubyDiff diffs = 1; repeated ruby_diffs.RubyDiff diffs = 1;
} }
message PythonDiffResponse {
repeated python_diffs.PythonDiff diffs = 1;
}
message TypeScriptDiffResponse {
repeated typescript_diffs.TypeScriptDiff diffs = 1;
}
message CallGraphRequest { message CallGraphRequest {
Project project = 1; Project project = 1;
} }

486
proto/python-diffs.proto Normal file
View File

@ -0,0 +1,486 @@
// This file was generated by proto-gen. Do not edit by hand.
syntax = "proto3";
package github.semantic.python_diffs;
import "types.proto";
option java_package = "com.github.semantic.python_diffs";
option go_package = "github.com/semantic/python_diffs;python";
message PythonDiff {
oneof diff {
Merge merge = 1;
Delete delete = 2;
Insert insert = 3;
Replace replace = 4;
}
message Merge {
PythonSyntax syntax = 1;
}
message Delete {
PythonSyntax before = 1;
}
message Insert {
PythonSyntax after = 1;
}
message Replace {
PythonSyntax before = 1;
PythonSyntax after = 2;
}
}
message QualifiedName {
oneof sum {
QualifiedName qualifiedName = 1;
RelativeQualifiedName relativeQualifiedName = 2;
}
message QualifiedName {
repeated string paths = 1;
}
message RelativeQualifiedName {
string path = 1;
QualifiedName maybeQualifiedName = 2;
}
}
message Alias {
bytes aliasValue = 1;
bytes aliasName = 2;
}
message PythonSyntax {
oneof syntax {
Comment comment = 1;
Class class = 2;
Comprehension comprehension = 3;
Decorator decorator = 4;
Function function = 5;
Variable variable = 6;
Plus plus = 7;
Minus minus = 8;
Times times = 9;
DividedBy dividedBy = 10;
Modulo modulo = 11;
Power power = 12;
Negate negate = 13;
FloorDivision floorDivision = 14;
And and = 15;
Not not = 16;
Or or = 17;
XOr xOr = 18;
BAnd bAnd = 19;
BOr bOr = 20;
BXOr bXOr = 21;
LShift lShift = 22;
RShift rShift = 23;
Complement complement = 24;
Call call = 25;
LessThan lessThan = 26;
LessThanEqual lessThanEqual = 27;
GreaterThan greaterThan = 28;
GreaterThanEqual greaterThanEqual = 29;
Equal equal = 30;
StrictEqual strictEqual = 31;
Comparison comparison = 32;
Enumeration enumeration = 33;
ScopeResolution scopeResolution = 34;
MemberAccess memberAccess = 35;
Subscript subscript = 36;
Member member = 37;
Array array = 38;
Boolean boolean = 39;
Float float = 40;
Hash hash = 41;
Integer integer = 42;
KeyValue keyValue = 43;
Null null = 44;
Set set = 45;
String string = 46;
TextElement textElement = 47;
Tuple tuple = 48;
Redirect redirect = 49;
Assignment assignment = 50;
Break break = 51;
Catch catch = 52;
Continue continue = 53;
Else else = 54;
Finally finally = 55;
ForEach forEach = 56;
If if = 57;
Let let = 58;
NoOp noOp = 59;
Return return = 60;
Statements statements = 61;
Throw throw = 62;
Try try = 63;
While while = 64;
Yield yield = 65;
Ellipsis ellipsis = 66;
Import import = 67;
QualifiedImport qualifiedImport = 68;
QualifiedAliasedImport qualifiedAliasedImport = 69;
Context context = 70;
Empty empty = 71;
Error error = 72;
Identifier identifier = 73;
Annotation annotation = 74;
List list = 75;
}
}
message Comment {
string commentContent = 1;
}
message Class {
repeated PythonDiff classContext = 1;
PythonDiff classIdentifier = 2;
repeated PythonDiff classSuperclasses = 3;
PythonDiff classBody = 4;
}
message Comprehension {
PythonDiff comprehensionValue = 1;
PythonDiff comprehensionBody = 2;
}
message Decorator {
PythonDiff decoratorIdentifier = 1;
repeated PythonDiff decoratorParamaters = 2;
PythonDiff decoratorBody = 3;
}
message Function {
repeated PythonDiff functionContext = 1;
PythonDiff functionName = 2;
repeated PythonDiff functionParameters = 3;
PythonDiff functionBody = 4;
}
message Variable {
PythonDiff variableName = 1;
PythonDiff variableType = 2;
PythonDiff variableValue = 3;
}
message Plus {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message Minus {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message Times {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message DividedBy {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message Modulo {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message Power {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message Negate {
PythonDiff term = 1;
}
message FloorDivision {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message And {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message Not {
PythonDiff term = 1;
}
message Or {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message XOr {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message BAnd {
PythonDiff left = 1;
PythonDiff right = 2;
}
message BOr {
PythonDiff left = 1;
PythonDiff right = 2;
}
message BXOr {
PythonDiff left = 1;
PythonDiff right = 2;
}
message LShift {
PythonDiff left = 1;
PythonDiff right = 2;
}
message RShift {
PythonDiff left = 1;
PythonDiff right = 2;
}
message Complement {
PythonDiff value = 1;
}
message Call {
repeated PythonDiff callContext = 1;
PythonDiff callFunction = 2;
repeated PythonDiff callParams = 3;
PythonDiff callBlock = 4;
}
message LessThan {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message LessThanEqual {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message GreaterThan {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message GreaterThanEqual {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message Equal {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message StrictEqual {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message Comparison {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message Enumeration {
PythonDiff enumerationStart = 1;
PythonDiff enumerationEnd = 2;
PythonDiff enumerationStep = 3;
}
message ScopeResolution {
repeated PythonDiff scopes = 1;
}
message MemberAccess {
PythonDiff lhs = 1;
bytes rhs = 2;
}
message Subscript {
PythonDiff lhs = 1;
repeated PythonDiff rhs = 2;
}
message Member {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message Array {
repeated PythonDiff arrayElements = 1;
}
message Boolean {
bool booleanContent = 1;
}
message Float {
string floatContent = 1;
}
message Hash {
repeated PythonDiff hashElements = 1;
}
message Integer {
string integerContent = 1;
}
message KeyValue {
PythonDiff key = 1;
PythonDiff value = 2;
}
message Null { }
message Set {
repeated PythonDiff setElements = 1;
}
message String {
repeated PythonDiff stringElements = 1;
}
message TextElement {
string textElementContent = 1;
}
message Tuple {
repeated PythonDiff tupleContents = 1;
}
message Redirect {
PythonDiff lhs = 1;
PythonDiff rhs = 2;
}
message Assignment {
repeated PythonDiff assignmentContext = 1;
PythonDiff assignmentTarget = 2;
PythonDiff assignmentValue = 3;
}
message Break {
PythonDiff term = 1;
}
message Catch {
PythonDiff catchException = 1;
PythonDiff catchBody = 2;
}
message Continue {
PythonDiff term = 1;
}
message Else {
PythonDiff elseCondition = 1;
PythonDiff elseBody = 2;
}
message Finally {
PythonDiff term = 1;
}
message ForEach {
PythonDiff forEachBinding = 1;
PythonDiff forEachSubject = 2;
PythonDiff forEachBody = 3;
}
message If {
PythonDiff ifCondition = 1;
PythonDiff ifThenBody = 2;
PythonDiff ifElseBody = 3;
}
message Let {
PythonDiff letVariable = 1;
PythonDiff letValue = 2;
PythonDiff letBody = 3;
}
message NoOp {
PythonDiff value = 1;
}
message Return {
PythonDiff term = 1;
}
message Statements {
repeated PythonDiff statements = 1;
}
message Throw {
PythonDiff value = 1;
}
message Try {
PythonDiff tryBody = 1;
repeated PythonDiff tryCatch = 2;
}
message While {
PythonDiff whileCondition = 1;
PythonDiff whileBody = 2;
}
message Yield {
PythonDiff term = 1;
}
message Ellipsis { }
message Import {
QualifiedName importFrom = 1;
repeated Alias importSymbols = 2;
}
message QualifiedImport {
repeated string qualifiedImportFrom = 1;
}
message QualifiedAliasedImport {
QualifiedName qualifiedAliasedImportFrom = 1;
PythonDiff qualifiedAliasedImportAlias = 2;
}
message Context {
repeated PythonDiff contextTerms = 1;
PythonDiff contextSubject = 2;
}
message Empty { }
message Error {
repeated ErrorSite errorCallStack = 1;
repeated string errorExpected = 2;
string errorActual = 3;
repeated PythonDiff errorChildren = 4;
}
message Identifier {
bytes name = 1;
}
message Annotation {
PythonDiff annotationSubject = 1;
PythonDiff annotationType = 2;
}
message List {
repeated PythonDiff listContent = 1;
}

468
proto/python-terms.proto Normal file
View File

@ -0,0 +1,468 @@
// This file was generated by proto-gen. Do not edit by hand.
syntax = "proto3";
package github.semantic.python_terms;
import "types.proto";
option java_package = "com.github.semantic.python_terms";
option go_package = "github.com/semantic/python_terms;python";
message PythonTerm {
PythonSyntax syntax = 1;
}
message QualifiedName {
oneof sum {
QualifiedName qualifiedName = 1;
RelativeQualifiedName relativeQualifiedName = 2;
}
message QualifiedName {
repeated string paths = 1;
}
message RelativeQualifiedName {
string path = 1;
QualifiedName maybeQualifiedName = 2;
}
}
message Alias {
bytes aliasValue = 1;
bytes aliasName = 2;
}
message PythonSyntax {
oneof syntax {
Comment comment = 1;
Class class = 2;
Comprehension comprehension = 3;
Decorator decorator = 4;
Function function = 5;
Variable variable = 6;
Plus plus = 7;
Minus minus = 8;
Times times = 9;
DividedBy dividedBy = 10;
Modulo modulo = 11;
Power power = 12;
Negate negate = 13;
FloorDivision floorDivision = 14;
And and = 15;
Not not = 16;
Or or = 17;
XOr xOr = 18;
BAnd bAnd = 19;
BOr bOr = 20;
BXOr bXOr = 21;
LShift lShift = 22;
RShift rShift = 23;
Complement complement = 24;
Call call = 25;
LessThan lessThan = 26;
LessThanEqual lessThanEqual = 27;
GreaterThan greaterThan = 28;
GreaterThanEqual greaterThanEqual = 29;
Equal equal = 30;
StrictEqual strictEqual = 31;
Comparison comparison = 32;
Enumeration enumeration = 33;
ScopeResolution scopeResolution = 34;
MemberAccess memberAccess = 35;
Subscript subscript = 36;
Member member = 37;
Array array = 38;
Boolean boolean = 39;
Float float = 40;
Hash hash = 41;
Integer integer = 42;
KeyValue keyValue = 43;
Null null = 44;
Set set = 45;
String string = 46;
TextElement textElement = 47;
Tuple tuple = 48;
Redirect redirect = 49;
Assignment assignment = 50;
Break break = 51;
Catch catch = 52;
Continue continue = 53;
Else else = 54;
Finally finally = 55;
ForEach forEach = 56;
If if = 57;
Let let = 58;
NoOp noOp = 59;
Return return = 60;
Statements statements = 61;
Throw throw = 62;
Try try = 63;
While while = 64;
Yield yield = 65;
Ellipsis ellipsis = 66;
Import import = 67;
QualifiedImport qualifiedImport = 68;
QualifiedAliasedImport qualifiedAliasedImport = 69;
Context context = 70;
Empty empty = 71;
Error error = 72;
Identifier identifier = 73;
Annotation annotation = 74;
List list = 75;
}
}
message Comment {
string commentContent = 1;
}
message Class {
repeated PythonTerm classContext = 1;
PythonTerm classIdentifier = 2;
repeated PythonTerm classSuperclasses = 3;
PythonTerm classBody = 4;
}
message Comprehension {
PythonTerm comprehensionValue = 1;
PythonTerm comprehensionBody = 2;
}
message Decorator {
PythonTerm decoratorIdentifier = 1;
repeated PythonTerm decoratorParamaters = 2;
PythonTerm decoratorBody = 3;
}
message Function {
repeated PythonTerm functionContext = 1;
PythonTerm functionName = 2;
repeated PythonTerm functionParameters = 3;
PythonTerm functionBody = 4;
}
message Variable {
PythonTerm variableName = 1;
PythonTerm variableType = 2;
PythonTerm variableValue = 3;
}
message Plus {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message Minus {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message Times {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message DividedBy {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message Modulo {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message Power {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message Negate {
PythonTerm term = 1;
}
message FloorDivision {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message And {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message Not {
PythonTerm term = 1;
}
message Or {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message XOr {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message BAnd {
PythonTerm left = 1;
PythonTerm right = 2;
}
message BOr {
PythonTerm left = 1;
PythonTerm right = 2;
}
message BXOr {
PythonTerm left = 1;
PythonTerm right = 2;
}
message LShift {
PythonTerm left = 1;
PythonTerm right = 2;
}
message RShift {
PythonTerm left = 1;
PythonTerm right = 2;
}
message Complement {
PythonTerm value = 1;
}
message Call {
repeated PythonTerm callContext = 1;
PythonTerm callFunction = 2;
repeated PythonTerm callParams = 3;
PythonTerm callBlock = 4;
}
message LessThan {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message LessThanEqual {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message GreaterThan {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message GreaterThanEqual {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message Equal {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message StrictEqual {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message Comparison {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message Enumeration {
PythonTerm enumerationStart = 1;
PythonTerm enumerationEnd = 2;
PythonTerm enumerationStep = 3;
}
message ScopeResolution {
repeated PythonTerm scopes = 1;
}
message MemberAccess {
PythonTerm lhs = 1;
bytes rhs = 2;
}
message Subscript {
PythonTerm lhs = 1;
repeated PythonTerm rhs = 2;
}
message Member {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message Array {
repeated PythonTerm arrayElements = 1;
}
message Boolean {
bool booleanContent = 1;
}
message Float {
string floatContent = 1;
}
message Hash {
repeated PythonTerm hashElements = 1;
}
message Integer {
string integerContent = 1;
}
message KeyValue {
PythonTerm key = 1;
PythonTerm value = 2;
}
message Null { }
message Set {
repeated PythonTerm setElements = 1;
}
message String {
repeated PythonTerm stringElements = 1;
}
message TextElement {
string textElementContent = 1;
}
message Tuple {
repeated PythonTerm tupleContents = 1;
}
message Redirect {
PythonTerm lhs = 1;
PythonTerm rhs = 2;
}
message Assignment {
repeated PythonTerm assignmentContext = 1;
PythonTerm assignmentTarget = 2;
PythonTerm assignmentValue = 3;
}
message Break {
PythonTerm term = 1;
}
message Catch {
PythonTerm catchException = 1;
PythonTerm catchBody = 2;
}
message Continue {
PythonTerm term = 1;
}
message Else {
PythonTerm elseCondition = 1;
PythonTerm elseBody = 2;
}
message Finally {
PythonTerm term = 1;
}
message ForEach {
PythonTerm forEachBinding = 1;
PythonTerm forEachSubject = 2;
PythonTerm forEachBody = 3;
}
message If {
PythonTerm ifCondition = 1;
PythonTerm ifThenBody = 2;
PythonTerm ifElseBody = 3;
}
message Let {
PythonTerm letVariable = 1;
PythonTerm letValue = 2;
PythonTerm letBody = 3;
}
message NoOp {
PythonTerm value = 1;
}
message Return {
PythonTerm term = 1;
}
message Statements {
repeated PythonTerm statements = 1;
}
message Throw {
PythonTerm value = 1;
}
message Try {
PythonTerm tryBody = 1;
repeated PythonTerm tryCatch = 2;
}
message While {
PythonTerm whileCondition = 1;
PythonTerm whileBody = 2;
}
message Yield {
PythonTerm term = 1;
}
message Ellipsis { }
message Import {
QualifiedName importFrom = 1;
repeated Alias importSymbols = 2;
}
message QualifiedImport {
repeated string qualifiedImportFrom = 1;
}
message QualifiedAliasedImport {
QualifiedName qualifiedAliasedImportFrom = 1;
PythonTerm qualifiedAliasedImportAlias = 2;
}
message Context {
repeated PythonTerm contextTerms = 1;
PythonTerm contextSubject = 2;
}
message Empty { }
message Error {
repeated ErrorSite errorCallStack = 1;
repeated string errorExpected = 2;
string errorActual = 3;
repeated PythonTerm errorChildren = 4;
}
message Identifier {
bytes name = 1;
}
message Annotation {
PythonTerm annotationSubject = 1;
PythonTerm annotationType = 2;
}
message List {
repeated PythonTerm listContent = 1;
}

View File

@ -25,6 +25,8 @@ enum VertexType {
PACKAGE = 0; PACKAGE = 0;
MODULE = 1; MODULE = 1;
VARIABLE = 2; VARIABLE = 2;
METHOD = 3;
FUNCTION = 4;
} }
message BlobPair { message BlobPair {

View File

@ -0,0 +1,981 @@
// This file was generated by proto-gen. Do not edit by hand.
syntax = "proto3";
package github.semantic.typescript_diffs;
import "types.proto";
option java_package = "com.github.semantic.typescript_diffs";
option go_package = "github.com/semantic/typescript_diffs;typescript";
message TypeScriptDiff {
oneof diff {
Merge merge = 1;
Delete delete = 2;
Insert insert = 3;
Replace replace = 4;
}
message Merge {
TypeScriptSyntax syntax = 1;
}
message Delete {
TypeScriptSyntax before = 1;
}
message Insert {
TypeScriptSyntax after = 1;
}
message Replace {
TypeScriptSyntax before = 1;
TypeScriptSyntax after = 2;
}
}
message Alias {
bytes aliasValue = 1;
bytes aliasName = 2;
}
message ImportPath {
string unPath = 1;
IsRelative pathIsRelative = 2;
}
enum IsRelative {
Unknown = 0;
Relative = 1;
NonRelative = 2;
}
message TypeScriptSyntax {
oneof syntax {
Comment comment = 1;
HashBang hashBang = 2;
Class class = 3;
Function function = 4;
Method method = 5;
MethodSignature methodSignature = 6;
InterfaceDeclaration interfaceDeclaration = 7;
PublicFieldDefinition publicFieldDefinition = 8;
VariableDeclaration variableDeclaration = 9;
TypeAlias typeAlias = 10;
Plus plus = 11;
Minus minus = 12;
Times times = 13;
DividedBy dividedBy = 14;
Modulo modulo = 15;
Power power = 16;
Negate negate = 17;
FloorDivision floorDivision = 18;
BAnd bAnd = 19;
BOr bOr = 20;
BXOr bXOr = 21;
LShift lShift = 22;
RShift rShift = 23;
UnsignedRShift unsignedRShift = 24;
Complement complement = 25;
And and = 26;
Not not = 27;
Or or = 28;
XOr xOr = 29;
Call call = 30;
Cast cast = 31;
LessThan lessThan = 32;
LessThanEqual lessThanEqual = 33;
GreaterThan greaterThan = 34;
GreaterThanEqual greaterThanEqual = 35;
Equal equal = 36;
StrictEqual strictEqual = 37;
Comparison comparison = 38;
Enumeration enumeration = 39;
MemberAccess memberAccess = 40;
NonNullExpression nonNullExpression = 41;
ScopeResolution scopeResolution = 42;
SequenceExpression sequenceExpression = 43;
Subscript subscript = 44;
Member member = 45;
Delete delete = 46;
Void void = 47;
Typeof typeof = 48;
InstanceOf instanceOf = 49;
New new = 50;
Await await = 51;
Array array = 52;
Boolean boolean = 53;
Float float = 54;
Hash hash = 55;
Integer integer = 56;
KeyValue keyValue = 57;
Null null = 58;
String string = 59;
TextElement textElement = 60;
Regex regex = 61;
Assignment assignment = 62;
Break break = 63;
Catch catch = 64;
Continue continue = 65;
DoWhile doWhile = 66;
Else else = 67;
Finally finally = 68;
For for = 69;
ForEach forEach = 70;
If if = 71;
Match match = 72;
Pattern pattern = 73;
Retry retry = 74;
Return return = 75;
ScopeEntry scopeEntry = 76;
ScopeExit scopeExit = 77;
Statements statements = 78;
Throw throw = 79;
Try try = 80;
While while = 81;
Yield yield = 82;
AccessibilityModifier accessibilityModifier = 83;
Empty empty = 84;
Error error = 85;
Identifier identifier = 86;
Context context = 87;
Readonly readonly = 88;
TypeParameters typeParameters = 89;
TypeParameter typeParameter = 90;
Constraint constraint = 91;
ParenthesizedType parenthesizedType = 92;
DefaultType defaultType = 93;
PredefinedType predefinedType = 94;
TypeIdentifier typeIdentifier = 95;
NestedIdentifier nestedIdentifier = 96;
NestedTypeIdentifier nestedTypeIdentifier = 97;
GenericType genericType = 98;
TypeArguments typeArguments = 99;
TypePredicate typePredicate = 100;
CallSignature callSignature = 101;
ConstructSignature constructSignature = 102;
ArrayType arrayType = 103;
LookupType lookupType = 104;
FlowMaybeType flowMaybeType = 105;
TypeQuery typeQuery = 106;
IndexTypeQuery indexTypeQuery = 107;
ThisType thisType = 108;
ExistentialType existentialType = 109;
AbstractMethodSignature abstractMethodSignature = 110;
IndexSignature indexSignature = 111;
ObjectType objectType = 112;
LiteralType literalType = 113;
Union union = 114;
Intersection intersection = 115;
Module module = 116;
InternalModule internalModule = 117;
FunctionType functionType = 118;
Tuple tuple = 119;
Constructor constructor = 120;
TypeAssertion typeAssertion = 121;
ImportAlias importAlias = 122;
Debugger debugger = 123;
ShorthandPropertyIdentifier shorthandPropertyIdentifier = 124;
Super super = 125;
Undefined undefined = 126;
ClassHeritage classHeritage = 127;
AbstractClass abstractClass = 128;
ImplementsClause implementsClause = 129;
JsxElement jsxElement = 130;
JsxSelfClosingElement jsxSelfClosingElement = 131;
JsxOpeningElement jsxOpeningElement = 132;
JsxText jsxText = 133;
JsxClosingElement jsxClosingElement = 134;
JsxExpression jsxExpression = 135;
JsxAttribute jsxAttribute = 136;
JsxFragment jsxFragment = 137;
JsxNamespaceName jsxNamespaceName = 138;
OptionalParameter optionalParameter = 139;
RequiredParameter requiredParameter = 140;
RestParameter restParameter = 141;
PropertySignature propertySignature = 142;
AmbientDeclaration ambientDeclaration = 143;
EnumDeclaration enumDeclaration = 144;
ExtendsClause extendsClause = 145;
AmbientFunction ambientFunction = 146;
ImportRequireClause importRequireClause = 147;
ImportClause importClause = 148;
LabeledStatement labeledStatement = 149;
Annotation annotation = 150;
With with = 151;
ForOf forOf = 152;
This this = 153;
Update update = 154;
ComputedPropertyName computedPropertyName = 155;
Decorator decorator = 156;
Import import = 157;
QualifiedAliasedImport qualifiedAliasedImport = 158;
SideEffectImport sideEffectImport = 159;
DefaultExport defaultExport = 160;
QualifiedExport qualifiedExport = 161;
QualifiedExportFrom qualifiedExportFrom = 162;
JavaScriptRequire javaScriptRequire = 163;
List list = 164;
}
}
message Comment {
string commentContent = 1;
}
message HashBang {
string value = 1;
}
message Class {
repeated TypeScriptDiff classContext = 1;
TypeScriptDiff classIdentifier = 2;
repeated TypeScriptDiff classSuperclasses = 3;
TypeScriptDiff classBody = 4;
}
message Function {
repeated TypeScriptDiff functionContext = 1;
TypeScriptDiff functionName = 2;
repeated TypeScriptDiff functionParameters = 3;
TypeScriptDiff functionBody = 4;
}
message Method {
repeated TypeScriptDiff methodContext = 1;
TypeScriptDiff methodReceiver = 2;
TypeScriptDiff methodName = 3;
repeated TypeScriptDiff methodParameters = 4;
TypeScriptDiff methodBody = 5;
}
message MethodSignature {
repeated TypeScriptDiff methodSignatureContext = 1;
TypeScriptDiff methodSignatureName = 2;
repeated TypeScriptDiff methodSignatureParameters = 3;
}
message InterfaceDeclaration {
repeated TypeScriptDiff interfaceDeclarationContext = 1;
TypeScriptDiff interfaceDeclarationIdentifier = 2;
TypeScriptDiff interfaceDeclarationBody = 3;
}
message PublicFieldDefinition {
repeated TypeScriptDiff publicFieldContext = 1;
TypeScriptDiff publicFieldPropertyName = 2;
TypeScriptDiff publicFieldValue = 3;
}
message VariableDeclaration {
repeated TypeScriptDiff variableDeclarations = 1;
}
message TypeAlias {
repeated TypeScriptDiff typeAliasContext = 1;
TypeScriptDiff typeAliasIdentifier = 2;
TypeScriptDiff typeAliasKind = 3;
}
message Plus {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message Minus {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message Times {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message DividedBy {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message Modulo {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message Power {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message Negate {
TypeScriptDiff term = 1;
}
message FloorDivision {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message BAnd {
TypeScriptDiff left = 1;
TypeScriptDiff right = 2;
}
message BOr {
TypeScriptDiff left = 1;
TypeScriptDiff right = 2;
}
message BXOr {
TypeScriptDiff left = 1;
TypeScriptDiff right = 2;
}
message LShift {
TypeScriptDiff left = 1;
TypeScriptDiff right = 2;
}
message RShift {
TypeScriptDiff left = 1;
TypeScriptDiff right = 2;
}
message UnsignedRShift {
TypeScriptDiff left = 1;
TypeScriptDiff right = 2;
}
message Complement {
TypeScriptDiff value = 1;
}
message And {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message Not {
TypeScriptDiff term = 1;
}
message Or {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message XOr {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message Call {
repeated TypeScriptDiff callContext = 1;
TypeScriptDiff callFunction = 2;
repeated TypeScriptDiff callParams = 3;
TypeScriptDiff callBlock = 4;
}
message Cast {
TypeScriptDiff castSubject = 1;
TypeScriptDiff castType = 2;
}
message LessThan {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message LessThanEqual {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message GreaterThan {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message GreaterThanEqual {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message Equal {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message StrictEqual {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message Comparison {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message Enumeration {
TypeScriptDiff enumerationStart = 1;
TypeScriptDiff enumerationEnd = 2;
TypeScriptDiff enumerationStep = 3;
}
message MemberAccess {
TypeScriptDiff lhs = 1;
bytes rhs = 2;
}
message NonNullExpression {
TypeScriptDiff nonNullExpression = 1;
}
message ScopeResolution {
repeated TypeScriptDiff scopes = 1;
}
message SequenceExpression {
TypeScriptDiff firstExpression = 1;
TypeScriptDiff secondExpression = 2;
}
message Subscript {
TypeScriptDiff lhs = 1;
repeated TypeScriptDiff rhs = 2;
}
message Member {
TypeScriptDiff lhs = 1;
TypeScriptDiff rhs = 2;
}
message Delete {
TypeScriptDiff value = 1;
}
message Void {
TypeScriptDiff value = 1;
}
message Typeof {
TypeScriptDiff value = 1;
}
message InstanceOf {
TypeScriptDiff instanceOfSubject = 1;
TypeScriptDiff instanceOfObject = 2;
}
message New {
repeated TypeScriptDiff newSubject = 1;
}
message Await {
TypeScriptDiff awaitSubject = 1;
}
message Array {
repeated TypeScriptDiff arrayElements = 1;
}
message Boolean {
bool booleanContent = 1;
}
message Float {
string floatContent = 1;
}
message Hash {
repeated TypeScriptDiff hashElements = 1;
}
message Integer {
string integerContent = 1;
}
message KeyValue {
TypeScriptDiff key = 1;
TypeScriptDiff value = 2;
}
message Null { }
message String {
repeated TypeScriptDiff stringElements = 1;
}
message TextElement {
string textElementContent = 1;
}
message Regex {
string regexContent = 1;
}
message Assignment {
repeated TypeScriptDiff assignmentContext = 1;
TypeScriptDiff assignmentTarget = 2;
TypeScriptDiff assignmentValue = 3;
}
message Break {
TypeScriptDiff term = 1;
}
message Catch {
TypeScriptDiff catchException = 1;
TypeScriptDiff catchBody = 2;
}
message Continue {
TypeScriptDiff term = 1;
}
message DoWhile {
TypeScriptDiff doWhileCondition = 1;
TypeScriptDiff doWhileBody = 2;
}
message Else {
TypeScriptDiff elseCondition = 1;
TypeScriptDiff elseBody = 2;
}
message Finally {
TypeScriptDiff term = 1;
}
message For {
TypeScriptDiff forBefore = 1;
TypeScriptDiff forCondition = 2;
TypeScriptDiff forStep = 3;
TypeScriptDiff forBody = 4;
}
message ForEach {
TypeScriptDiff forEachBinding = 1;
TypeScriptDiff forEachSubject = 2;
TypeScriptDiff forEachBody = 3;
}
message If {
TypeScriptDiff ifCondition = 1;
TypeScriptDiff ifThenBody = 2;
TypeScriptDiff ifElseBody = 3;
}
message Match {
TypeScriptDiff matchSubject = 1;
TypeScriptDiff matchPatterns = 2;
}
message Pattern {
TypeScriptDiff value = 1;
TypeScriptDiff patternBody = 2;
}
message Retry {
TypeScriptDiff term = 1;
}
message Return {
TypeScriptDiff term = 1;
}
message ScopeEntry {
repeated TypeScriptDiff terms = 1;
}
message ScopeExit {
repeated TypeScriptDiff terms = 1;
}
message Statements {
repeated TypeScriptDiff statements = 1;
}
message Throw {
TypeScriptDiff value = 1;
}
message Try {
TypeScriptDiff tryBody = 1;
repeated TypeScriptDiff tryCatch = 2;
}
message While {
TypeScriptDiff whileCondition = 1;
TypeScriptDiff whileBody = 2;
}
message Yield {
TypeScriptDiff term = 1;
}
message AccessibilityModifier {
string contents = 1;
}
message Empty { }
message Error {
repeated ErrorSite errorCallStack = 1;
repeated string errorExpected = 2;
string errorActual = 3;
repeated TypeScriptDiff errorChildren = 4;
}
message Identifier {
bytes name = 1;
}
message Context {
repeated TypeScriptDiff contextTerms = 1;
TypeScriptDiff contextSubject = 2;
}
message Readonly { }
message TypeParameters {
repeated TypeScriptDiff terms = 1;
}
message TypeParameter {
TypeScriptDiff typeParameter = 1;
TypeScriptDiff typeParameterConstraint = 2;
TypeScriptDiff typeParameterDefaultType = 3;
}
message Constraint {
TypeScriptDiff constraintType = 1;
}
message ParenthesizedType {
TypeScriptDiff parenthesizedType = 1;
}
message DefaultType {
TypeScriptDiff defaultType = 1;
}
message PredefinedType {
string predefinedType = 1;
}
message TypeIdentifier {
string contents = 1;
}
message NestedIdentifier {
TypeScriptDiff left = 1;
TypeScriptDiff right = 2;
}
message NestedTypeIdentifier {
TypeScriptDiff left = 1;
TypeScriptDiff right = 2;
}
message GenericType {
TypeScriptDiff genericTypeIdentifier = 1;
TypeScriptDiff genericTypeArguments = 2;
}
message TypeArguments {
repeated TypeScriptDiff typeArguments = 1;
}
message TypePredicate {
TypeScriptDiff typePredicateIdentifier = 1;
TypeScriptDiff typePredicateType = 2;
}
message CallSignature {
TypeScriptDiff callSignatureTypeParameters = 1;
repeated TypeScriptDiff callSignatureParameters = 2;
TypeScriptDiff callSignatureType = 3;
}
message ConstructSignature {
TypeScriptDiff constructSignatureTypeParameters = 1;
repeated TypeScriptDiff constructSignatureParameters = 2;
TypeScriptDiff constructSignatureType = 3;
}
message ArrayType {
TypeScriptDiff arrayType = 1;
}
message LookupType {
TypeScriptDiff lookupTypeIdentifier = 1;
TypeScriptDiff lookupTypeKey = 2;
}
message FlowMaybeType {
TypeScriptDiff flowMaybeType = 1;
}
message TypeQuery {
TypeScriptDiff typeQuerySubject = 1;
}
message IndexTypeQuery {
TypeScriptDiff indexTypeQuerySubject = 1;
}
message ThisType {
string contents = 1;
}
message ExistentialType {
string contents = 1;
}
message AbstractMethodSignature {
repeated TypeScriptDiff abstractMethodSignatureContext = 1;
TypeScriptDiff abstractMethodSignatureName = 2;
repeated TypeScriptDiff abstractMethodSignatureParameters = 3;
}
message IndexSignature {
TypeScriptDiff indexSignatureSubject = 1;
TypeScriptDiff indexSignatureType = 2;
}
message ObjectType {
repeated TypeScriptDiff objectTypeElements = 1;
}
message LiteralType {
TypeScriptDiff literalTypeSubject = 1;
}
message Union {
TypeScriptDiff unionLeft = 1;
TypeScriptDiff unionRight = 2;
}
message Intersection {
TypeScriptDiff intersectionLeft = 1;
TypeScriptDiff intersectionRight = 2;
}
message Module {
TypeScriptDiff moduleIdentifier = 1;
repeated TypeScriptDiff moduleStatements = 2;
}
message InternalModule {
TypeScriptDiff internalModuleIdentifier = 1;
repeated TypeScriptDiff internalModuleStatements = 2;
}
message FunctionType {
TypeScriptDiff functionTypeParameters = 1;
repeated TypeScriptDiff functionFormalParameters = 2;
TypeScriptDiff functionType = 3;
}
message Tuple {
repeated TypeScriptDiff tupleElements = 1;
}
message Constructor {
TypeScriptDiff constructorTypeParameters = 1;
repeated TypeScriptDiff constructorFormalParameters = 2;
TypeScriptDiff constructorType = 3;
}
message TypeAssertion {
TypeScriptDiff typeAssertionParameters = 1;
TypeScriptDiff typeAssertionExpression = 2;
}
message ImportAlias {
TypeScriptDiff importAliasSubject = 1;
TypeScriptDiff importAlias = 2;
}
message Debugger { }
message ShorthandPropertyIdentifier {
string contents = 1;
}
message Super { }
message Undefined { }
message ClassHeritage {
TypeScriptDiff classHeritageExtendsClause = 1;
TypeScriptDiff implementsClause = 2;
}
message AbstractClass {
TypeScriptDiff abstractClassIdentifier = 1;
TypeScriptDiff abstractClassTypeParameters = 2;
repeated TypeScriptDiff classHeritage = 3;
TypeScriptDiff classBody = 4;
}
message ExtendsClause {
repeated TypeScriptDiff extendsClauses = 1;
}
message ImplementsClause {
repeated TypeScriptDiff implementsClauseTypes = 1;
}
message JsxElement {
TypeScriptDiff jsxOpeningElement = 1;
repeated TypeScriptDiff jsxElements = 2;
TypeScriptDiff jsxClosingElement = 3;
}
message JsxSelfClosingElement {
TypeScriptDiff jsxSelfClosingElementIdentifier = 1;
repeated TypeScriptDiff jsxSelfClosingElementAttributes = 2;
}
message JsxOpeningElement {
TypeScriptDiff jsxOpeningElementIdentifier = 1;
repeated TypeScriptDiff jsxAttributes = 2;
}
message JsxText {
string contents = 1;
}
message JsxClosingElement {
TypeScriptDiff jsxClosingElementIdentifier = 1;
}
message JsxExpression {
TypeScriptDiff jsxExpression = 1;
}
message JsxAttribute {
TypeScriptDiff jsxAttributeTarget = 1;
TypeScriptDiff jsxAttributeValue = 2;
}
message JsxFragment {
repeated TypeScriptDiff terms = 1;
}
message JsxNamespaceName {
TypeScriptDiff left = 1;
TypeScriptDiff right = 2;
}
message OptionalParameter {
repeated TypeScriptDiff optionalParameterContext = 1;
TypeScriptDiff optionalParameterSubject = 2;
}
message RequiredParameter {
repeated TypeScriptDiff requiredParameterContext = 1;
TypeScriptDiff requiredParameterSubject = 2;
}
message RestParameter {
repeated TypeScriptDiff restParameterContext = 1;
TypeScriptDiff restParameterSubject = 2;
}
message PropertySignature {
repeated TypeScriptDiff modifiers = 1;
TypeScriptDiff propertySignaturePropertyName = 2;
}
message AmbientDeclaration {
TypeScriptDiff ambientDeclarationBody = 1;
}
message EnumDeclaration {
TypeScriptDiff enumDeclarationIdentifier = 1;
repeated TypeScriptDiff enumDeclarationBody = 2;
}
message AmbientFunction {
repeated TypeScriptDiff ambientFunctionContext = 1;
TypeScriptDiff ambientFunctionIdentifier = 2;
repeated TypeScriptDiff ambientFunctionParameters = 3;
}
message ImportRequireClause {
TypeScriptDiff importRequireIdentifier = 1;
TypeScriptDiff importRequireSubject = 2;
}
message ImportClause {
repeated TypeScriptDiff importClauseElements = 1;
}
message LabeledStatement {
TypeScriptDiff labeledStatementIdentifier = 1;
TypeScriptDiff labeledStatementSubject = 2;
}
message Annotation {
TypeScriptDiff annotationType = 1;
}
message With {
TypeScriptDiff withExpression = 1;
TypeScriptDiff withBody = 2;
}
message ForOf {
TypeScriptDiff forOfBinding = 1;
TypeScriptDiff forOfSubject = 2;
TypeScriptDiff forOfBody = 3;
}
message This { }
message Update {
TypeScriptDiff updateSubject = 1;
}
message ComputedPropertyName {
TypeScriptDiff propertyName = 1;
}
message Decorator {
TypeScriptDiff decoratorTerm = 1;
}
message Import {
repeated Alias importSymbols = 1;
ImportPath importFrom = 2;
}
message QualifiedAliasedImport {
TypeScriptDiff qualifiedAliasedImportAlias = 1;
ImportPath qualifiedAliasedImportFrom = 2;
}
message SideEffectImport {
ImportPath sideEffectImportFrom = 1;
}
message DefaultExport {
TypeScriptDiff defaultExport = 1;
}
message QualifiedExport {
repeated Alias qualifiedExportSymbols = 1;
}
message QualifiedExportFrom {
ImportPath qualifiedExportFrom = 1;
repeated Alias qualifiedExportFromSymbols = 2;
}
message JavaScriptRequire {
TypeScriptDiff javascriptRequireIden = 1;
ImportPath javascriptRequireFrom = 2;
}
message List {
repeated TypeScriptDiff listContent = 1;
}

View File

@ -21,5 +21,5 @@ collectingTerms recur term = do
v <$ TermEvaluator (gc (roots <> valueRoots v)) v <$ TermEvaluator (gc (roots <> valueRoots v))
providingLiveSet :: (Effectful (m address value), Effects effects) => m address value (Reader (Live address) ': effects) a -> m address value effects a providingLiveSet :: (Effectful (m address value), PureEffects effects) => m address value (Reader (Live address) ': effects) a -> m address value effects a
providingLiveSet = runReader lowerBound providingLiveSet = runReader lowerBound

View File

@ -18,6 +18,7 @@ module Analysis.Abstract.Graph
import Algebra.Graph.Export.Dot hiding (vertexName) import Algebra.Graph.Export.Dot hiding (vertexName)
import Control.Abstract import Control.Abstract
import Data.Abstract.Address import Data.Abstract.Address
import Data.Abstract.Ref
import Data.Abstract.Declarations import Data.Abstract.Declarations
import Data.Abstract.Module (Module (moduleInfo), ModuleInfo (..)) import Data.Abstract.Module (Module (moduleInfo), ModuleInfo (..))
import Data.Abstract.Package (PackageInfo (..)) import Data.Abstract.Package (PackageInfo (..))
@ -26,19 +27,20 @@ import Data.Graph
import Data.Graph.Vertex import Data.Graph.Vertex
import Data.Record import Data.Record
import Data.Term import Data.Term
import qualified Data.Map as Map
import qualified Data.Text.Encoding as T import qualified Data.Text.Encoding as T
import Prologue hiding (project) import Prologue hiding (project)
style :: Style Vertex Builder style :: Style Vertex Builder
style = (defaultStyle (T.encodeUtf8Builder . vertexName)) style = (defaultStyle (T.encodeUtf8Builder . vertexIdentifier))
{ vertexAttributes = vertexAttributes { vertexAttributes = vertexAttributes
, edgeAttributes = edgeAttributes , edgeAttributes = edgeAttributes
} }
where vertexAttributes Package{} = [ "style" := "dashed", "shape" := "box" ] where vertexAttributes Package{} = [ "style" := "dashed", "shape" := "box" ]
vertexAttributes Module{} = [ "style" := "dotted, rounded", "shape" := "box" ] vertexAttributes Module{} = [ "style" := "dotted, rounded", "shape" := "box" ]
vertexAttributes Variable{..} = [ "tooltip" := T.encodeUtf8Builder (showSpan variableSpan), "style" := "rounded", "shape" := "box" ] vertexAttributes Variable{..} = [ "label" := T.encodeUtf8Builder (vertexName <> " (Variable)"), "tooltip" := T.encodeUtf8Builder (showSpan vertexSpan), "style" := "rounded", "shape" := "box" ]
vertexAttributes Method{..} = [ "tooltip" := T.encodeUtf8Builder (showSpan methodSpan) , "style" := "rounded", "shape" := "box" ] vertexAttributes Method{..} = [ "label" := T.encodeUtf8Builder (vertexName <> " (Method)"), "tooltip" := T.encodeUtf8Builder (showSpan vertexSpan) , "style" := "rounded", "shape" := "box" ]
vertexAttributes Function{..} = [ "tooltip" := T.encodeUtf8Builder (showSpan functionSpan), "style" := "rounded", "shape" := "box" ] vertexAttributes Function{..} = [ "label" := T.encodeUtf8Builder (vertexName <> " (Function)"), "tooltip" := T.encodeUtf8Builder (showSpan vertexSpan), "style" := "rounded", "shape" := "box" ]
edgeAttributes Package{} Module{} = [ "len" := "5.0", "style" := "dashed" ] edgeAttributes Package{} Module{} = [ "len" := "5.0", "style" := "dashed" ]
edgeAttributes Module{} Module{} = [ "len" := "5.0", "label" := "imports" ] edgeAttributes Module{} Module{} = [ "len" := "5.0", "label" := "imports" ]
edgeAttributes Variable{} Module{} = [ "len" := "5.0", "color" := "blue", "label" := "refers to symbol defined in" ] edgeAttributes Variable{} Module{} = [ "len" := "5.0", "color" := "blue", "label" := "refers to symbol defined in" ]
@ -48,6 +50,8 @@ style = (defaultStyle (T.encodeUtf8Builder . vertexName))
edgeAttributes Module{} Function{} = [ "len" := "2.0", "color" := "red", "label" := "defines" ] edgeAttributes Module{} Function{} = [ "len" := "2.0", "color" := "red", "label" := "defines" ]
edgeAttributes Module{} Method{} = [ "len" := "2.0", "color" := "red", "label" := "defines" ] edgeAttributes Module{} Method{} = [ "len" := "2.0", "color" := "red", "label" := "defines" ]
edgeAttributes Module{} _ = [ "len" := "2.0", "color" := "green", "label" := "calls" ] edgeAttributes Module{} _ = [ "len" := "2.0", "color" := "green", "label" := "calls" ]
edgeAttributes Variable{} Function{} = [ "len" := "2.0", "color" := "blue", "label" := "references" ]
edgeAttributes Variable{} Method{} = [ "len" := "2.0", "color" := "blue", "label" := "references" ]
edgeAttributes _ _ = [] edgeAttributes _ _ = []
@ -55,31 +59,45 @@ style = (defaultStyle (T.encodeUtf8Builder . vertexName))
graphingTerms :: ( Member (Reader ModuleInfo) effects graphingTerms :: ( Member (Reader ModuleInfo) effects
, Member (Env (Hole context (Located address))) effects , Member (Env (Hole context (Located address))) effects
, Member (State (Graph Vertex)) effects , Member (State (Graph Vertex)) effects
, Member (State (Map (Hole context (Located address)) Vertex)) effects
, Member (Resumable (EnvironmentError (Hole context (Located address)))) effects
, AbstractValue (Hole context (Located address)) value effects
, Member (Reader Vertex) effects , Member (Reader Vertex) effects
, HasField fields Span , HasField fields Span
, VertexDeclaration syntax , VertexDeclaration syntax
, Declarations1 syntax , Declarations1 syntax
, Ord address
, Ord context
, Foldable syntax , Foldable syntax
, Functor syntax , Functor syntax
, term ~ Term syntax (Record fields) , term ~ Term syntax (Record fields)
) )
=> SubtermAlgebra (Base term) term (TermEvaluator term (Hole context (Located address)) value effects a) => SubtermAlgebra (Base term) term (TermEvaluator term (Hole context (Located address)) value effects (ValueRef (Hole context (Located address))))
-> SubtermAlgebra (Base term) term (TermEvaluator term (Hole context (Located address)) value effects a) -> SubtermAlgebra (Base term) term (TermEvaluator term (Hole context (Located address)) value effects (ValueRef (Hole context (Located address))))
graphingTerms recur term@(In a syntax) = do graphingTerms recur term@(In a syntax) = do
definedInModule <- currentModule definedInModule <- currentModule
case toVertex a definedInModule (subterm <$> syntax) of case toVertex a definedInModule (subterm <$> syntax) of
Just (v@Function{}, _) -> recurWithContext v Just (v@Function{}, _) -> recurWithContext v
Just (v@Method{}, _) -> recurWithContext v Just (v@Method{}, _) -> recurWithContext v
Just (Variable{..}, name) -> do Just (v@Variable{..}, name) -> do
definedInModuleInfo <- maybe (ModuleInfo "unknown") (maybe (ModuleInfo "hole") addressModule . toMaybe) <$> TermEvaluator (lookupEnv name) variableDefinition v
variableDefinition (variableVertex variableName definedInModuleInfo variableSpan) maybeAddr <- TermEvaluator (lookupEnv name)
case maybeAddr of
Just a -> do
defined <- gets (Map.lookup a)
maybe (pure ()) (appendGraph . connect (vertex v) . vertex) defined
_ -> pure ()
recur term recur term
_ -> recur term _ -> recur term
where where
recurWithContext v = do recurWithContext v = do
variableDefinition v variableDefinition v
moduleInclusion v moduleInclusion v
local (const v) (recur term) local (const v) $ do
valRef <- recur term
addr <- TermEvaluator (Control.Abstract.address valRef)
modify' (Map.insert addr v)
pure valRef
-- | Add vertices to the graph for evaluated modules and the packages containing them. -- | Add vertices to the graph for evaluated modules and the packages containing them.
graphingPackages :: ( Member (Reader PackageInfo) effects graphingPackages :: ( Member (Reader PackageInfo) effects
@ -93,11 +111,11 @@ graphingPackages recur m =
-- | Add vertices to the graph for imported modules. -- | Add vertices to the graph for imported modules.
graphingModules :: forall term address value effects a graphingModules :: forall term address value effects a
. ( Effects effects . ( Member (Modules address) effects
, Member (Modules address) effects
, Member (Reader ModuleInfo) effects , Member (Reader ModuleInfo) effects
, Member (State (Graph Vertex)) effects , Member (State (Graph Vertex)) effects
, Member (Reader Vertex) effects , Member (Reader Vertex) effects
, PureEffects effects
) )
=> SubtermAlgebra Module term (TermEvaluator term address value effects a) => SubtermAlgebra Module term (TermEvaluator term address value effects a)
-> SubtermAlgebra Module term (TermEvaluator term address value effects a) -> SubtermAlgebra Module term (TermEvaluator term address value effects a)
@ -114,10 +132,10 @@ graphingModules recur m = do
-- | Add vertices to the graph for imported modules. -- | Add vertices to the graph for imported modules.
graphingModuleInfo :: forall term address value effects a graphingModuleInfo :: forall term address value effects a
. ( Effects effects . ( Member (Modules address) effects
, Member (Modules address) effects
, Member (Reader ModuleInfo) effects , Member (Reader ModuleInfo) effects
, Member (State (Graph ModuleInfo)) effects , Member (State (Graph ModuleInfo)) effects
, PureEffects effects
) )
=> SubtermAlgebra Module term (TermEvaluator term address value effects a) => SubtermAlgebra Module term (TermEvaluator term address value effects a)
-> SubtermAlgebra Module term (TermEvaluator term address value effects a) -> SubtermAlgebra Module term (TermEvaluator term address value effects a)
@ -167,5 +185,6 @@ appendGraph :: (Effectful m, Member (State (Graph v)) effects) => Graph v -> m e
appendGraph = modify' . (<>) appendGraph = modify' . (<>)
graphing :: (Effectful m, Effects effects) => m (State (Graph Vertex) ': effects) result -> m effects (Graph Vertex, result) graphing :: (Effectful m, Effects effects, Functor (m (State (Graph Vertex) : effects)))
graphing = runState mempty => m (State (Map (Hole context (Located address)) Vertex) ': State (Graph Vertex) ': effects) result -> m effects (Graph Vertex, result)
graphing = runState mempty . fmap snd . runState lowerBound

View File

@ -34,11 +34,11 @@ instance Member NonDet effects => Addressable Monovariant effects where
derefCell _ = traverse (foldMapA pure) . nonEmpty . toList derefCell _ = traverse (foldMapA pure) . nonEmpty . toList
-- | 'Located' addresses allocate & dereference using the underlying address, contextualizing addresses with the current 'PackageInfo' & 'ModuleInfo'. -- | 'Located' addresses allocate & dereference using the underlying address, contextualizing addresses with the current 'PackageInfo' & 'ModuleInfo'.
instance (Addressable address effects, Member (Reader ModuleInfo) effects, Member (Reader PackageInfo) effects) => Addressable (Located address) effects where instance (Addressable address effects, Member (Reader ModuleInfo) effects, Member (Reader PackageInfo) effects, Member (Reader Span) effects) => Addressable (Located address) effects where
type Cell (Located address) = Cell address type Cell (Located address) = Cell address
allocCell name = relocate (Located <$> allocCell name <*> currentPackage <*> currentModule) allocCell name = relocate (Located <$> allocCell name <*> currentPackage <*> currentModule <*> pure name <*> ask)
derefCell (Located loc _ _) = relocate . derefCell loc derefCell (Located loc _ _ _ _) = relocate . derefCell loc
instance (Addressable address effects, Ord context, Show context) => Addressable (Hole context address) effects where instance (Addressable address effects, Ord context, Show context) => Addressable (Hole context address) effects where
type Cell (Hole context address) = Cell address type Cell (Hole context address) = Cell address

View File

@ -70,6 +70,7 @@ data Env address m return where
PutEnv :: Environment address -> Env address m () PutEnv :: Environment address -> Env address m ()
Export :: Name -> Name -> Maybe address -> Env address m () Export :: Name -> Name -> Maybe address -> Env address m ()
instance PureEffect (Env address)
instance Effect (Env address) where instance Effect (Env address) where
handleState c dist (Request (Lookup name) k) = Request (Lookup name) (dist . (<$ c) . k) handleState c dist (Request (Lookup name) k) = Request (Lookup name) (dist . (<$ c) . k)
handleState c dist (Request (Bind name addr) k) = Request (Bind name addr) (dist . (<$ c) . k) handleState c dist (Request (Bind name addr) k) = Request (Bind name addr) (dist . (<$ c) . k)

View File

@ -159,10 +159,10 @@ data Allocator address value (m :: * -> *) return where
GC :: Live address -> Allocator address value m () GC :: Live address -> Allocator address value m ()
runAllocator :: ( Addressable address effects runAllocator :: ( Addressable address effects
, Effects effects
, Foldable (Cell address) , Foldable (Cell address)
, Member (Resumable (AddressError address value)) effects , Member (Resumable (AddressError address value)) effects
, Member (State (Heap address (Cell address) value)) effects , Member (State (Heap address (Cell address) value)) effects
, PureEffects effects
, Reducer value (Cell address value) , Reducer value (Cell address value)
, ValueRoots address value , ValueRoots address value
) )
@ -174,6 +174,7 @@ runAllocator = interpret $ \ eff -> case eff of
Assign addr value -> modifyHeap (heapInsert addr value) Assign addr value -> modifyHeap (heapInsert addr value)
GC roots -> modifyHeap (heapRestrict <*> reachable roots) GC roots -> modifyHeap (heapRestrict <*> reachable roots)
instance PureEffect (Allocator address value)
instance Effect (Allocator address value) where instance Effect (Allocator address value) where
handleState c dist (Request (Alloc name) k) = Request (Alloc name) (dist . (<$ c) . k) handleState c dist (Request (Alloc name) k) = Request (Alloc name) (dist . (<$ c) . k)
handleState c dist (Request (Deref addr) k) = Request (Deref addr) (dist . (<$ c) . k) handleState c dist (Request (Deref addr) k) = Request (Deref addr) (dist . (<$ c) . k)

View File

@ -58,6 +58,7 @@ data Modules address (m :: * -> *) return where
Resolve :: [FilePath] -> Modules address m (Maybe ModulePath) Resolve :: [FilePath] -> Modules address m (Maybe ModulePath)
List :: FilePath -> Modules address m [ModulePath] List :: FilePath -> Modules address m [ModulePath]
instance PureEffect (Modules address)
instance Effect (Modules address) where instance Effect (Modules address) where
handleState c dist (Request (Load path) k) = Request (Load path) (dist . (<$ c) . k) handleState c dist (Request (Load path) k) = Request (Load path) (dist . (<$ c) . k)
handleState c dist (Request (Lookup path) k) = Request (Lookup path) (dist . (<$ c) . k) handleState c dist (Request (Lookup path) k) = Request (Lookup path) (dist . (<$ c) . k)
@ -67,9 +68,9 @@ instance Effect (Modules address) where
sendModules :: Member (Modules address) effects => Modules address (Eff effects) return -> Evaluator address value effects return sendModules :: Member (Modules address) effects => Modules address (Eff effects) return -> Evaluator address value effects return
sendModules = send sendModules = send
runModules :: ( Effects effects runModules :: ( Member (Reader (ModuleTable (NonEmpty (Module (Environment address, address))))) effects
, Member (Reader (ModuleTable (NonEmpty (Module (Environment address, address))))) effects
, Member (Resumable (LoadError address)) effects , Member (Resumable (LoadError address)) effects
, PureEffects effects
) )
=> Set ModulePath => Set ModulePath
-> Evaluator address value (Modules address ': effects) a -> Evaluator address value (Modules address ': effects) a

View File

@ -12,6 +12,7 @@ import Data.Abstract.Name
import Data.Abstract.Package (PackageInfo) import Data.Abstract.Package (PackageInfo)
import Data.Monoid (Last(..)) import Data.Monoid (Last(..))
import Data.Semigroup.Reducer import Data.Semigroup.Reducer
import Data.Span
import Data.Set as Set import Data.Set as Set
import Prologue import Prologue
@ -35,6 +36,8 @@ data Located address = Located
{ address :: address { address :: address
, addressPackage :: {-# UNPACK #-} !PackageInfo , addressPackage :: {-# UNPACK #-} !PackageInfo
, addressModule :: !ModuleInfo , addressModule :: !ModuleInfo
, addressName :: Name
, addressSpan :: Span
} }
deriving (Eq, Ord, Show) deriving (Eq, Ord, Show)

View File

@ -115,7 +115,7 @@ taggedGraphToAdjacencyList = accumToAdj . adjMapToAccum . adjacencyMap . toGraph
accumToAdj (Acc vs es) = AdjacencyList (fromList vs) (fromList (toList es)) accumToAdj (Acc vs es) = AdjacencyList (fromList vs) (fromList (toList es))
vertexToPB :: V.Vertex -> Tag -> Vertex vertexToPB :: V.Vertex -> Tag -> Vertex
vertexToPB s = Vertex t (V.vertexName s) where vertexToPB s = Vertex t (V.vertexIdentifier s) where
t = case s of t = case s of
V.Package{} -> PACKAGE V.Package{} -> PACKAGE
V.Module{} -> MODULE V.Module{} -> MODULE

View File

@ -6,7 +6,7 @@ module Data.Graph.Vertex
, variableVertex , variableVertex
, methodVertex , methodVertex
, functionVertex , functionVertex
, vertexName , vertexIdentifier
, showSpan , showSpan
, VertexDeclaration (..) , VertexDeclaration (..)
, VertexDeclaration' (..) , VertexDeclaration' (..)
@ -30,11 +30,11 @@ import Prologue hiding (packageName)
-- | A vertex of some specific type. -- | A vertex of some specific type.
data Vertex data Vertex
= Package { packageName :: Text } = Package { vertexName :: Text }
| Module { moduleName :: Text } | Module { vertexName :: Text }
| Variable { variableName :: Text, variableModuleName :: Text, variableSpan :: Span } | Variable { vertexName :: Text, vertexModuleName :: Text, vertexSpan :: Span }
| Method { methodName :: Text, methodModuleName :: Text, methodSpan :: Span } | Method { vertexName :: Text, vertexModuleName :: Text, vertexSpan :: Span }
| Function { functionName :: Text, functionModuleName :: Text, functionSpan :: Span } | Function { vertexName :: Text, vertexModuleName :: Text, vertexSpan :: Span }
deriving (Eq, Ord, Show, Generic, Hashable) deriving (Eq, Ord, Show, Generic, Hashable)
packageVertex :: PackageInfo -> Vertex packageVertex :: PackageInfo -> Vertex
@ -53,14 +53,12 @@ functionVertex :: Text -> ModuleInfo -> Span -> Vertex
functionVertex name ModuleInfo{..} = Function name (T.pack modulePath) functionVertex name ModuleInfo{..} = Function name (T.pack modulePath)
instance ToJSON Vertex where instance ToJSON Vertex where
toJSON v = object [ "name" .= vertexName v, "type" .= vertexToType v ] toJSON v = object [ "name" .= vertexIdentifier v, "type" .= vertexToType v ]
vertexName :: Vertex -> Text vertexIdentifier :: Vertex -> Text
vertexName Package{..} = packageName <> " (Package)" vertexIdentifier v@Package{..} = vertexName <> " (" <> vertexToType v <> ")"
vertexName Module{..} = moduleName <> " (Module)" vertexIdentifier v@Module{..} = vertexName <> " (" <> vertexToType v <> ")"
vertexName Variable{..} = variableModuleName <> "::" <> variableName <> " (Variable)" vertexIdentifier v = vertexModuleName v <> "::" <> vertexName v <> " (" <> vertexToType v <> " " <> showSpan (vertexSpan v) <> ")"
vertexName Method{..} = methodModuleName <> "::" <> methodName <> " (Method)"
vertexName Function{..} = functionModuleName <> "::" <> functionName <> " (Function)"
showSpan :: Span -> Text showSpan :: Span -> Text
showSpan (Span (Pos a b) (Pos c d)) = T.pack $ showSpan (Span (Pos a b) (Pos c d)) = T.pack $
@ -69,11 +67,11 @@ showSpan (Span (Pos a b) (Pos c d)) = T.pack $
<> "[" <> show c <> ", " <> show d <> "]" <> "[" <> show c <> ", " <> show d <> "]"
vertexToType :: Vertex -> Text vertexToType :: Vertex -> Text
vertexToType Package{} = "package" vertexToType Package{} = "Package"
vertexToType Module{} = "module" vertexToType Module{} = "Module"
vertexToType Variable{} = "variable" vertexToType Variable{} = "Variable"
vertexToType Method{} = "method" vertexToType Method{} = "Method"
vertexToType Function{} = "function" vertexToType Function{} = "Function"
instance Lower Vertex where instance Lower Vertex where
lowerBound = Package "" lowerBound = Package ""

View File

@ -235,7 +235,7 @@ instance Show1 Retry where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable Retry instance Evaluatable Retry
newtype NoOp a = NoOp a newtype NoOp a = NoOp { value :: a }
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable, Named1, Message1) deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable, Named1, Message1)
instance Eq1 NoOp where liftEq = genericLiftEq instance Eq1 NoOp where liftEq = genericLiftEq

View File

@ -1,4 +1,5 @@
{-# LANGUAGE DataKinds, RankNTypes, TypeOperators #-} {-# LANGUAGE DataKinds, RankNTypes, TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-orphans #-} -- FIXME
module Language.Python.Assignment module Language.Python.Assignment
( assignment ( assignment
, Syntax , Syntax
@ -7,8 +8,12 @@ module Language.Python.Assignment
) where ) where
import Assigning.Assignment hiding (Assignment, Error) import Assigning.Assignment hiding (Assignment, Error)
import qualified Assigning.Assignment as Assignment
import Data.Abstract.Name (Name, name) import Data.Abstract.Name (Name, name)
import qualified Data.Diff as Diff
import qualified Data.List.NonEmpty as NonEmpty
import Data.Record import Data.Record
import Data.Sum
import Data.Syntax import Data.Syntax
( contextualize ( contextualize
, emptyTerm , emptyTerm
@ -21,11 +26,6 @@ import Data.Syntax
, parseError , parseError
, postContextualize , postContextualize
) )
import Language.Python.Grammar as Grammar
import Language.Python.Syntax as Python.Syntax
import qualified Assigning.Assignment as Assignment
import qualified Data.List.NonEmpty as NonEmpty
import Data.Sum
import qualified Data.Syntax as Syntax import qualified Data.Syntax as Syntax
import qualified Data.Syntax.Comment as Comment import qualified Data.Syntax.Comment as Comment
import qualified Data.Syntax.Declaration as Declaration import qualified Data.Syntax.Declaration as Declaration
@ -35,7 +35,10 @@ import qualified Data.Syntax.Statement as Statement
import qualified Data.Syntax.Type as Type import qualified Data.Syntax.Type as Type
import qualified Data.Term as Term import qualified Data.Term as Term
import qualified Data.Text as T import qualified Data.Text as T
import Language.Python.Grammar as Grammar
import Language.Python.Syntax as Python.Syntax
import Prologue import Prologue
import Proto3.Suite (Named (..), Named1 (..))
-- | The type of Python syntax. -- | The type of Python syntax.
@ -120,6 +123,15 @@ type Syntax =
type Term = Term.Term (Sum Syntax) (Record Location) type Term = Term.Term (Sum Syntax) (Record Location)
type Assignment = Assignment.Assignment [] Grammar type Assignment = Assignment.Assignment [] Grammar
instance Named1 (Sum Syntax) where
nameOf1 _ = "PythonSyntax"
instance Named (Term.Term (Sum Syntax) ()) where
nameOf _ = "PythonTerm"
instance Named (Diff.Diff (Sum Syntax) () ()) where
nameOf _ = "PythonDiff"
-- | Assignment from AST in Python's grammar onto a program in Python's syntax. -- | Assignment from AST in Python's grammar onto a program in Python's syntax.
assignment :: Assignment Term assignment :: Assignment Term
assignment = handleError $ makeTerm <$> symbol Module <*> children (Statement.Statements <$> manyTerm expression) <|> parseError assignment = handleError $ makeTerm <$> symbol Module <*> children (Statement.Statements <$> manyTerm expression) <|> parseError
@ -415,8 +427,8 @@ import' = makeTerm'' <$> symbol ImportStatement <*> children (manyTerm (aliase
identifierSource = (symbol Identifier <|> symbol Identifier') *> source identifierSource = (symbol Identifier <|> symbol Identifier') *> source
aliasIdentifier = (symbol Identifier <|> symbol Identifier') *> (name <$> source) <|> symbol DottedName *> (name <$> source) aliasIdentifier = (symbol Identifier <|> symbol Identifier') *> (name <$> source) <|> symbol DottedName *> (name <$> source)
makeNameAliasPair from (Just alias) = (from, alias) makeNameAliasPair from (Just alias) = Python.Syntax.Alias from alias
makeNameAliasPair from Nothing = (from, from) makeNameAliasPair from Nothing = Python.Syntax.Alias from from
assertStatement :: Assignment Term assertStatement :: Assignment Term
assertStatement = makeTerm <$> symbol AssertStatement <*> children (Expression.Call [] <$> (makeTerm <$> symbol AnonAssert <*> (Syntax.Identifier . name <$> source)) <*> manyTerm expression <*> emptyTerm) assertStatement = makeTerm <$> symbol AssertStatement <*> children (Expression.Call [] <$> (makeTerm <$> symbol AnonAssert <*> (Syntax.Identifier . name <$> source)) <*> manyTerm expression <*> emptyTerm)

View File

@ -1,5 +1,6 @@
{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveAnyClass #-}
{-# OPTIONS_GHC -Wno-missing-export-lists #-} {-# OPTIONS_GHC -Wno-missing-export-lists #-}
{-# OPTIONS_GHC -fno-warn-orphans #-} -- FIXME
module Language.Python.Syntax where module Language.Python.Syntax where
import Data.Abstract.Environment as Env import Data.Abstract.Environment as Env
@ -15,11 +16,24 @@ import Diffing.Algorithm
import GHC.Generics import GHC.Generics
import Prologue import Prologue
import System.FilePath.Posix import System.FilePath.Posix
import Proto3.Suite (Primitive(..), Message(..), Message1(..), Named1(..), Named(..), MessageField(..), DotProtoIdentifier(..), DotProtoPrimType(..), DotProtoType(..), messageField)
import qualified Proto3.Suite as Proto
import qualified Proto3.Wire.Encode as Encode
import qualified Proto3.Wire.Decode as Decode
data QualifiedName data QualifiedName
= QualifiedName (NonEmpty FilePath) = QualifiedName { paths :: NonEmpty FilePath }
| RelativeQualifiedName FilePath (Maybe QualifiedName) | RelativeQualifiedName { path :: FilePath, maybeQualifiedName :: Maybe QualifiedName }
deriving (Eq, Generic, Hashable, Ord, Show, ToJSON) deriving (Eq, Generic, Hashable, Ord, Show, ToJSON, Named, Message)
instance MessageField QualifiedName where
encodeMessageField num QualifiedName{..} = Encode.embedded num (encodeMessageField 1 paths)
encodeMessageField num RelativeQualifiedName{..} = Encode.embedded num (encodeMessageField 1 path <> encodeMessageField 2 maybeQualifiedName)
decodeMessageField = Decode.embedded'' (qualifiedName <|> relativeQualifiedName)
where
qualifiedName = QualifiedName <$> Decode.at decodeMessageField 1
relativeQualifiedName = RelativeQualifiedName <$> Decode.at decodeMessageField 1 <*> Decode.at decodeMessageField 2
protoType _ = messageField (Prim $ Named (Single (nameOf (Proxy @QualifiedName)))) Nothing
qualifiedName :: NonEmpty Text -> QualifiedName qualifiedName :: NonEmpty Text -> QualifiedName
qualifiedName xs = QualifiedName (T.unpack <$> xs) qualifiedName xs = QualifiedName (T.unpack <$> xs)
@ -86,20 +100,27 @@ resolvePythonModules q = do
-- | Import declarations (symbols are added directly to the calling environment). -- | Import declarations (symbols are added directly to the calling environment).
-- --
-- If the list of symbols is empty copy everything to the calling environment. -- If the list of symbols is empty copy everything to the calling environment.
data Import a = Import { importFrom :: QualifiedName, importSymbols :: ![(Name, Name)] } data Import a = Import { importFrom :: QualifiedName, importSymbols :: ![Alias] }
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Message1, Named1, Ord, Show, ToJSONFields1, Traversable)
instance Eq1 Import where liftEq = genericLiftEq instance Eq1 Import where liftEq = genericLiftEq
instance Ord1 Import where liftCompare = genericLiftCompare instance Ord1 Import where liftCompare = genericLiftCompare
instance Show1 Import where liftShowsPrec = genericLiftShowsPrec instance Show1 Import where liftShowsPrec = genericLiftShowsPrec
data Alias = Alias { aliasValue :: Name, aliasName :: Name }
deriving (Eq, Generic, Hashable, Ord, Show, Message, Named, ToJSON)
toTuple :: Alias -> (Name, Name)
toTuple Alias{..} = (aliasValue, aliasName)
-- from a import b -- from a import b
instance Evaluatable Import where instance Evaluatable Import where
-- from . import moduleY -- from . import moduleY
-- This is a bit of a special case in the syntax as this actually behaves like a qualified relative import. -- This is a bit of a special case in the syntax as this actually behaves like a qualified relative import.
eval (Import (RelativeQualifiedName n Nothing) [(name, _)]) = do eval (Import (RelativeQualifiedName n Nothing) [Alias{..}]) = do
path <- NonEmpty.last <$> resolvePythonModules (RelativeQualifiedName n (Just (qualifiedName (formatName name :| [])))) path <- NonEmpty.last <$> resolvePythonModules (RelativeQualifiedName n (Just (qualifiedName (formatName aliasValue :| []))))
rvalBox =<< evalQualifiedImport name path rvalBox =<< evalQualifiedImport aliasValue path
-- from a import b -- from a import b
-- from a import b as c -- from a import b as c
@ -119,7 +140,7 @@ instance Evaluatable Import where
where where
select importedEnv select importedEnv
| Prologue.null xs = importedEnv | Prologue.null xs = importedEnv
| otherwise = Env.overwrite xs importedEnv | otherwise = Env.overwrite (toTuple <$> xs) importedEnv
-- Evaluate a qualified import -- Evaluate a qualified import
@ -135,7 +156,19 @@ evalQualifiedImport name path = letrec' name $ \addr -> do
unit <$ makeNamespace name addr Nothing unit <$ makeNamespace name addr Nothing
newtype QualifiedImport a = QualifiedImport { qualifiedImportFrom :: NonEmpty FilePath } newtype QualifiedImport a = QualifiedImport { qualifiedImportFrom :: NonEmpty FilePath }
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Named1, Ord, Show, ToJSONFields1, Traversable)
instance Message1 QualifiedImport where
liftEncodeMessage _ _ QualifiedImport{..} = encodeMessageField 1 qualifiedImportFrom
liftDecodeMessage _ _ = QualifiedImport <$> Decode.at decodeMessageField 1
liftDotProto _ = [ Proto.DotProtoMessageField $ Proto.DotProtoField 1 (Repeated Proto.String) (Single "qualifiedImportFrom") [] Nothing ]
instance Named Prelude.String where nameOf _ = "string"
instance Message Prelude.String where
encodeMessage _ = encodePrimitive 1
decodeMessage _ = Decode.at (Decode.one decodePrimitive mempty) 1
dotProto = undefined
instance Eq1 QualifiedImport where liftEq = genericLiftEq instance Eq1 QualifiedImport where liftEq = genericLiftEq
instance Ord1 QualifiedImport where liftCompare = genericLiftCompare instance Ord1 QualifiedImport where liftCompare = genericLiftCompare
@ -156,7 +189,7 @@ instance Evaluatable QualifiedImport where
makeNamespace name addr Nothing makeNamespace name addr Nothing
data QualifiedAliasedImport a = QualifiedAliasedImport { qualifiedAliasedImportFrom :: QualifiedName, qualifiedAliasedImportAlias :: !a } data QualifiedAliasedImport a = QualifiedAliasedImport { qualifiedAliasedImportFrom :: QualifiedName, qualifiedAliasedImportAlias :: !a }
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Message1, Named1, Ord, Show, ToJSONFields1, Traversable)
instance Eq1 QualifiedAliasedImport where liftEq = genericLiftEq instance Eq1 QualifiedAliasedImport where liftEq = genericLiftEq
instance Ord1 QualifiedAliasedImport where liftCompare = genericLiftCompare instance Ord1 QualifiedAliasedImport where liftCompare = genericLiftCompare
@ -180,7 +213,7 @@ instance Evaluatable QualifiedAliasedImport where
-- | Ellipsis (used in splice expressions and alternatively can be used as a fill in expression, like `undefined` in Haskell) -- | Ellipsis (used in splice expressions and alternatively can be used as a fill in expression, like `undefined` in Haskell)
data Ellipsis a = Ellipsis data Ellipsis a = Ellipsis
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Message1, Named1, Ord, Show, ToJSONFields1, Traversable)
instance Eq1 Ellipsis where liftEq = genericLiftEq instance Eq1 Ellipsis where liftEq = genericLiftEq
instance Ord1 Ellipsis where liftCompare = genericLiftCompare instance Ord1 Ellipsis where liftCompare = genericLiftCompare
@ -190,8 +223,8 @@ instance Show1 Ellipsis where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable Ellipsis instance Evaluatable Ellipsis
data Redirect a = Redirect !a !a data Redirect a = Redirect { lhs :: a, rhs :: a }
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable) deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Message1, Named1, Ord, Show, ToJSONFields1, Traversable)
instance Eq1 Redirect where liftEq = genericLiftEq instance Eq1 Redirect where liftEq = genericLiftEq
instance Ord1 Redirect where liftCompare = genericLiftCompare instance Ord1 Redirect where liftCompare = genericLiftCompare

View File

@ -58,7 +58,7 @@ runParser parser blobSource = unsafeUseAsCStringLen (sourceBytes blobSource) $
-- | Parse 'Source' with the given 'TS.Language' and return its AST. -- | Parse 'Source' with the given 'TS.Language' and return its AST.
-- Returns Nothing if the operation timed out. -- Returns Nothing if the operation timed out.
parseToAST :: (Bounded grammar, Enum grammar, Member (Lift IO) effects, Member Trace effects, Effects effects) => Timeout -> Ptr TS.Language -> Blob -> Eff effects (Maybe (AST [] grammar)) parseToAST :: (Bounded grammar, Enum grammar, Member (Lift IO) effects, Member Trace effects, PureEffects effects) => Timeout -> Ptr TS.Language -> Blob -> Eff effects (Maybe (AST [] grammar))
parseToAST (Milliseconds s) language Blob{..} = bracket TS.ts_parser_new TS.ts_parser_delete $ \ parser -> do parseToAST (Milliseconds s) language Blob{..} = bracket TS.ts_parser_new TS.ts_parser_delete $ \ parser -> do
let parserTimeout = s * 1000 let parserTimeout = s * 1000

View File

@ -1,6 +1,7 @@
{-# LANGUAGE ConstraintKinds, GADTs, RankNTypes, ScopedTypeVariables #-} {-# LANGUAGE ConstraintKinds, GADTs, RankNTypes, ScopedTypeVariables #-}
module Semantic.Diff module Semantic.Diff
( runDiff ( runDiff
, runPythonDiff
, runRubyDiff , runRubyDiff
, runTypeScriptDiff , runTypeScriptDiff
, runJSONDiff , runJSONDiff
@ -27,6 +28,7 @@ import Serializing.Format
import qualified Language.TypeScript.Assignment as TypeScript import qualified Language.TypeScript.Assignment as TypeScript
import qualified Language.Ruby.Assignment as Ruby import qualified Language.Ruby.Assignment as Ruby
import qualified Language.JSON.Assignment as JSON import qualified Language.JSON.Assignment as JSON
import qualified Language.Python.Assignment as Python
runDiff :: (Member Distribute effs, Member (Exc SomeException) effs, Member (Lift IO) effs, Member Task effs, Member Telemetry effs) => DiffRenderer output -> [BlobPair] -> Eff effs Builder runDiff :: (Member Distribute effs, Member (Exc SomeException) effs, Member (Lift IO) effs, Member Task effs, Member Telemetry effs) => DiffRenderer output -> [BlobPair] -> Eff effs Builder
runDiff ToCDiffRenderer = withParsedBlobPairs (decorate . declarationAlgebra) (render . renderToCDiff) >=> serialize JSON runDiff ToCDiffRenderer = withParsedBlobPairs (decorate . declarationAlgebra) (render . renderToCDiff) >=> serialize JSON
@ -57,6 +59,17 @@ runTypeScriptDiff = flip distributeFor (\ (blobs :: BlobPair) -> do
diff <$ writeStat (Stat.count "diff.nodes" (bilength diff) languageTag) diff <$ writeStat (Stat.count "diff.nodes" (bilength diff) languageTag)
where languageTag = languageTagForBlobPair blobs where languageTag = languageTagForBlobPair blobs
runPythonDiff :: (Member Telemetry effs, Member (Lift IO) effs, Member Distribute effs, Member Task effs) => [BlobPair] -> Eff effs [Diff (Sum Python.Syntax) () ()]
runPythonDiff = flip distributeFor (\ (blobs :: BlobPair) -> do
terms <- distributeFor blobs (parse pythonParser)
diffs <- diffTerms blobs terms
pure (bimap (const ()) (const ()) diffs))
where
diffTerms blobs terms = time "diff" languageTag $ do
diff <- diff (runJoin terms)
diff <$ writeStat (Stat.count "diff.nodes" (bilength diff) languageTag)
where languageTag = languageTagForBlobPair blobs
runJSONDiff :: (Member Telemetry effs, Member (Lift IO) effs, Member Distribute effs, Member Task effs) => [BlobPair] -> Eff effs [Diff (Sum JSON.Syntax) () ()] runJSONDiff :: (Member Telemetry effs, Member (Lift IO) effs, Member Distribute effs, Member Task effs) => [BlobPair] -> Eff effs [Diff (Sum JSON.Syntax) () ()]
runJSONDiff = flip distributeFor (\ (blobs :: BlobPair) -> do runJSONDiff = flip distributeFor (\ (blobs :: BlobPair) -> do
terms <- distributeFor blobs (parse jsonParser) terms <- distributeFor blobs (parse jsonParser)

View File

@ -35,6 +35,7 @@ distributeFoldMap toTask inputs = fmap fold (distribute (fmap toTask inputs))
-- | Distribute effects run tasks concurrently. -- | Distribute effects run tasks concurrently.
newtype Distribute task output = Distribute (task output) newtype Distribute task output = Distribute (task output)
instance PureEffect Distribute
instance Effect Distribute where instance Effect Distribute where
handleState c dist (Request (Distribute task) k) = Request (Distribute (dist (task <$ c))) (dist . fmap k) handleState c dist (Request (Distribute task) k) = Request (Distribute (dist (task <$ c))) (dist . fmap k)

View File

@ -94,7 +94,7 @@ runCallGraph lang includePackages modules package = do
extractGraph (graph, _) = simplify graph extractGraph (graph, _) = simplify graph
runGraphAnalysis runGraphAnalysis
= runTermEvaluator @_ @(Hole (Maybe Name) (Located Monovariant)) @Abstract = runTermEvaluator @_ @(Hole (Maybe Name) (Located Monovariant)) @Abstract
. graphing . graphing @_ @_ @(Maybe Name) @Monovariant
. caching . caching
. runState (lowerBound @(Heap (Hole (Maybe Name) (Located Monovariant)) All Abstract)) . runState (lowerBound @(Heap (Hole (Maybe Name) (Located Monovariant)) All Abstract))
. runFresh 0 . runFresh 0

View File

@ -220,6 +220,7 @@ data Files (m :: * -> *) out where
FindFiles :: FilePath -> [String] -> [FilePath] -> Files m [FilePath] FindFiles :: FilePath -> [String] -> [FilePath] -> Files m [FilePath]
Write :: Destination -> B.Builder -> Files m () Write :: Destination -> B.Builder -> Files m ()
instance PureEffect Files
instance Effect Files where instance Effect Files where
handleState c dist (Request (Read source) k) = Request (Read source) (dist . (<$ c) . k) handleState c dist (Request (Read source) k) = Request (Read source) (dist . (<$ c) . k)
handleState c dist (Request (ReadProject rootDir dir language excludeDirs) k) = Request (ReadProject rootDir dir language excludeDirs) (dist . (<$ c) . k) handleState c dist (Request (ReadProject rootDir dir language excludeDirs) k) = Request (ReadProject rootDir dir language excludeDirs) (dist . (<$ c) . k)
@ -227,7 +228,7 @@ instance Effect Files where
handleState c dist (Request (Write destination builder) k) = Request (Write destination builder) (dist . (<$ c) . k) handleState c dist (Request (Write destination builder) k) = Request (Write destination builder) (dist . (<$ c) . k)
-- | Run a 'Files' effect in 'IO'. -- | Run a 'Files' effect in 'IO'.
runFiles :: (Member (Exc SomeException) effs, Member (Lift IO) effs, Effects effs) => Eff (Files ': effs) a -> Eff effs a runFiles :: (Member (Exc SomeException) effs, Member (Lift IO) effs, PureEffects effs) => Eff (Files ': effs) a -> Eff effs a
runFiles = interpret $ \ files -> case files of runFiles = interpret $ \ files -> case files of
Read (FromPath path) -> rethrowing (readBlobFromPath path) Read (FromPath path) -> rethrowing (readBlobFromPath path)
Read (FromHandle handle) -> rethrowing (readBlobsFromHandle handle) Read (FromHandle handle) -> rethrowing (readBlobsFromHandle handle)

View File

@ -1,6 +1,7 @@
{-# LANGUAGE GADTs, RankNTypes #-} {-# LANGUAGE GADTs, RankNTypes #-}
module Semantic.Parse module Semantic.Parse
( runParse ( runParse
, runPythonParse
, runRubyParse , runRubyParse
, runTypeScriptParse , runTypeScriptParse
, runJSONParse , runJSONParse
@ -24,6 +25,7 @@ import Serializing.Format
import qualified Language.Ruby.Assignment as Ruby import qualified Language.Ruby.Assignment as Ruby
import qualified Language.TypeScript.Assignment as TypeScript import qualified Language.TypeScript.Assignment as TypeScript
import qualified Language.JSON.Assignment as JSON import qualified Language.JSON.Assignment as JSON
import qualified Language.Python.Assignment as Python
runParse :: (Member Distribute effs, Member (Exc SomeException) effs, Member Task effs) => TermRenderer output -> [Blob] -> Eff effs Builder runParse :: (Member Distribute effs, Member (Exc SomeException) effs, Member Task effs) => TermRenderer output -> [Blob] -> Eff effs Builder
runParse JSONTermRenderer = withParsedBlobs (render . renderJSONTerm) >=> serialize JSON runParse JSONTermRenderer = withParsedBlobs (render . renderJSONTerm) >=> serialize JSON
@ -42,6 +44,11 @@ runTypeScriptParse = flip distributeFor (\ blob -> do
term <- parse typescriptParser blob term <- parse typescriptParser blob
pure (() <$ term)) pure (() <$ term))
runPythonParse :: (Member Distribute effs, Member Task effs) => [Blob] -> Eff effs [Term (Sum Python.Syntax) ()]
runPythonParse = flip distributeFor (\ blob -> do
term <- parse pythonParser blob
pure (() <$ term))
runJSONParse :: (Member Distribute effs, Member Task effs) => [Blob] -> Eff effs [Term (Sum JSON.Syntax) ()] runJSONParse :: (Member Distribute effs, Member Task effs) => [Blob] -> Eff effs [Term (Sum JSON.Syntax) ()]
runJSONParse = flip distributeFor (\ blob -> do runJSONParse = flip distributeFor (\ blob -> do
term <- parse jsonParser blob term <- parse jsonParser blob

View File

@ -44,11 +44,12 @@ data Resolution (m :: * -> *) output where
NodeJSResolution :: FilePath -> Text -> [FilePath] -> Resolution m (Map FilePath FilePath) NodeJSResolution :: FilePath -> Text -> [FilePath] -> Resolution m (Map FilePath FilePath)
NoResolution :: Resolution m (Map FilePath FilePath) NoResolution :: Resolution m (Map FilePath FilePath)
instance PureEffect Resolution
instance Effect Resolution where instance Effect Resolution where
handleState c dist (Request (NodeJSResolution path key paths) k) = Request (NodeJSResolution path key paths) (dist . (<$ c) . k) handleState c dist (Request (NodeJSResolution path key paths) k) = Request (NodeJSResolution path key paths) (dist . (<$ c) . k)
handleState c dist (Request NoResolution k) = Request NoResolution (dist . (<$ c) . k) handleState c dist (Request NoResolution k) = Request NoResolution (dist . (<$ c) . k)
runResolution :: (Member Files effs, Effects effs) => Eff (Resolution ': effs) a -> Eff effs a runResolution :: (Member Files effs, PureEffects effs) => Eff (Resolution ': effs) a -> Eff effs a
runResolution = interpret $ \ res -> case res of runResolution = interpret $ \ res -> case res of
NodeJSResolution dir prop excludeDirs -> nodeJSResolutionMap dir prop excludeDirs NodeJSResolution dir prop excludeDirs -> nodeJSResolutionMap dir prop excludeDirs
NoResolution -> pure Map.empty NoResolution -> pure Map.empty

View File

@ -154,7 +154,7 @@ runTaskWithConfig options logger statter task = do
queueStat statter stat queueStat statter stat
pure result pure result
runTraceInTelemetry :: (Member Telemetry effects, Effects effects) => Eff (Trace ': effects) a -> Eff effects a runTraceInTelemetry :: (Member Telemetry effects, PureEffects effects) => Eff (Trace ': effects) a -> Eff effects a
runTraceInTelemetry = interpret (\ (Trace str) -> writeLog Debug str []) runTraceInTelemetry = interpret (\ (Trace str) -> writeLog Debug str [])
@ -167,6 +167,7 @@ data Task (m :: * -> *) output where
Render :: Renderer input output -> input -> Task m output Render :: Renderer input output -> input -> Task m output
Serialize :: Format input -> input -> Task m Builder Serialize :: Format input -> input -> Task m Builder
instance PureEffect Task
instance Effect Task where instance Effect Task where
handleState c dist (Request (Parse parser blob) k) = Request (Parse parser blob) (dist . (<$ c) . k) handleState c dist (Request (Parse parser blob) k) = Request (Parse parser blob) (dist . (<$ c) . k)
handleState c dist (Request (Analyze run analysis) k) = Request (Analyze run analysis) (dist . (<$ c) . k) handleState c dist (Request (Analyze run analysis) k) = Request (Analyze run analysis) (dist . (<$ c) . k)
@ -176,7 +177,7 @@ instance Effect Task where
handleState c dist (Request (Serialize format input) k) = Request (Serialize format input) (dist . (<$ c) . k) handleState c dist (Request (Serialize format input) k) = Request (Serialize format input) (dist . (<$ c) . k)
-- | Run a 'Task' effect by performing the actions in 'IO'. -- | Run a 'Task' effect by performing the actions in 'IO'.
runTaskF :: (Member (Exc SomeException) effs, Member (Lift IO) effs, Member (Reader Config) effs, Member Telemetry effs, Member Trace effs, Effects effs) => Eff (Task ': effs) a -> Eff effs a runTaskF :: (Member (Exc SomeException) effs, Member (Lift IO) effs, Member (Reader Config) effs, Member Telemetry effs, Member Trace effs, PureEffects effs) => Eff (Task ': effs) a -> Eff effs a
runTaskF = interpret $ \ task -> case task of runTaskF = interpret $ \ task -> case task of
Parse parser blob -> runParser blob parser Parse parser blob -> runParser blob parser
Analyze interpret analysis -> pure (interpret analysis) Analyze interpret analysis -> pure (interpret analysis)
@ -197,7 +198,7 @@ data ParserCancelled = ParserTimedOut deriving (Show, Typeable)
instance Exception ParserCancelled instance Exception ParserCancelled
-- | Parse a 'Blob' in 'IO'. -- | Parse a 'Blob' in 'IO'.
runParser :: (Member (Exc SomeException) effs, Member (Lift IO) effs, Member (Reader Config) effs, Member Telemetry effs, Member Trace effs, Effects effs) => Blob -> Parser term -> Eff effs term runParser :: (Member (Exc SomeException) effs, Member (Lift IO) effs, Member (Reader Config) effs, Member Telemetry effs, Member Trace effs, PureEffects effs) => Blob -> Parser term -> Eff effs term
runParser blob@Blob{..} parser = case parser of runParser blob@Blob{..} parser = case parser of
ASTParser language -> ASTParser language ->
time "parse.tree_sitter_ast_parse" languageTag $ do time "parse.tree_sitter_ast_parse" languageTag $ do
@ -227,7 +228,7 @@ runParser blob@Blob{..} parser = case parser of
, Member (Reader Config) effs , Member (Reader Config) effs
, Member Telemetry effs , Member Telemetry effs
, Member Trace effs , Member Trace effs
, Effects effs , PureEffects effs
) )
=> (Source -> assignment (Term (Sum syntaxes) (Record Assignment.Location)) -> ast -> Either (Error.Error String) (Term (Sum syntaxes) (Record Assignment.Location))) => (Source -> assignment (Term (Sum syntaxes) (Record Assignment.Location)) -> ast -> Either (Error.Error String) (Term (Sum syntaxes) (Record Assignment.Location)))
-> Parser ast -> Parser ast

View File

@ -133,18 +133,19 @@ data Telemetry (m :: * -> *) output where
WriteStat :: Stat -> Telemetry m () WriteStat :: Stat -> Telemetry m ()
WriteLog :: Level -> String -> [(String, String)] -> Telemetry m () WriteLog :: Level -> String -> [(String, String)] -> Telemetry m ()
instance PureEffect Telemetry
instance Effect Telemetry where instance Effect Telemetry where
handleState c dist (Request (WriteStat stat) k) = Request (WriteStat stat) (dist . (<$ c) . k) handleState c dist (Request (WriteStat stat) k) = Request (WriteStat stat) (dist . (<$ c) . k)
handleState c dist (Request (WriteLog level message pairs) k) = Request (WriteLog level message pairs) (dist . (<$ c) . k) handleState c dist (Request (WriteLog level message pairs) k) = Request (WriteLog level message pairs) (dist . (<$ c) . k)
-- | Run a 'Telemetry' effect by expecting a 'Reader' of 'Queue's to write stats and logs to. -- | Run a 'Telemetry' effect by expecting a 'Reader' of 'Queue's to write stats and logs to.
runTelemetry :: (Member (Lift IO) effects, Effects effects) => LogQueue -> StatQueue -> Eff (Telemetry ': effects) a -> Eff effects a runTelemetry :: (Member (Lift IO) effects, PureEffects effects) => LogQueue -> StatQueue -> Eff (Telemetry ': effects) a -> Eff effects a
runTelemetry logger statter = interpret (\ t -> case t of runTelemetry logger statter = interpret (\ t -> case t of
WriteStat stat -> queueStat statter stat WriteStat stat -> queueStat statter stat
WriteLog level message pairs -> queueLogMessage logger level message pairs) WriteLog level message pairs -> queueLogMessage logger level message pairs)
-- | Run a 'Telemetry' effect by ignoring statting/logging. -- | Run a 'Telemetry' effect by ignoring statting/logging.
ignoreTelemetry :: Effects effs => Eff (Telemetry ': effs) a -> Eff effs a ignoreTelemetry :: PureEffects effs => Eff (Telemetry ': effs) a -> Eff effs a
ignoreTelemetry = interpret (\ t -> case t of ignoreTelemetry = interpret (\ t -> case t of
WriteStat{} -> pure () WriteStat{} -> pure ()
WriteLog{} -> pure ()) WriteLog{} -> pure ())

View File

@ -53,6 +53,7 @@ import qualified Data.Syntax.Directive as Directive
import qualified Data.Syntax.Statement as Statement import qualified Data.Syntax.Statement as Statement
import qualified Data.Syntax.Expression as Expression import qualified Data.Syntax.Expression as Expression
import qualified Language.Ruby.Syntax as Ruby.Syntax import qualified Language.Ruby.Syntax as Ruby.Syntax
import qualified Language.Python.Syntax as Python.Syntax
import qualified Data.Abstract.Name as Name import qualified Data.Abstract.Name as Name
import Data.Term import Data.Term
import Data.Text as T (Text, pack) import Data.Text as T (Text, pack)
@ -487,6 +488,15 @@ instance Listable1 Ruby.Syntax.Require where
instance Listable1 Ruby.Syntax.Send where instance Listable1 Ruby.Syntax.Send where
liftTiers tiers = liftCons4 (liftTiers tiers) (liftTiers tiers) (liftTiers tiers) (liftTiers tiers) Ruby.Syntax.Send liftTiers tiers = liftCons4 (liftTiers tiers) (liftTiers tiers) (liftTiers tiers) (liftTiers tiers) Ruby.Syntax.Send
instance Listable Python.Syntax.QualifiedName where
tiers = liftCons1 tiers1 Python.Syntax.QualifiedName \/ liftCons2 tiers tiers1 Python.Syntax.RelativeQualifiedName
instance Listable1 Python.Syntax.Import where
liftTiers tiers = cons2 Python.Syntax.Import
instance Listable Python.Syntax.Alias where
tiers = cons2 Python.Syntax.Alias
type ListableSyntax = Sum type ListableSyntax = Sum
'[ Comment.Comment '[ Comment.Comment

View File

@ -19,6 +19,7 @@ import Data.Diff (Diff)
import Data.Sum import Data.Sum
import Language.Ruby.Assignment (Syntax) import Language.Ruby.Assignment (Syntax)
import qualified Language.Ruby.Assignment as Ruby import qualified Language.Ruby.Assignment as Ruby
import qualified Language.Python.Syntax as Python
import Data.Functor.Classes import Data.Functor.Classes
import qualified Data.Syntax.Expression as Expression import qualified Data.Syntax.Expression as Expression

View File

@ -0,0 +1,5 @@
class Dinosaur {
void apply() {
(T1)a[0];
}
}

View File

@ -0,0 +1,5 @@
class Dinosaur {
void apply() {
anArray[2];
}
}

View File

@ -0,0 +1,17 @@
(Statements
(Class
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
{+(Subscript
{+(Identifier)+}
{+(Integer)+})+}
{-(Annotation
{-(Subscript
{-(Identifier)-}
{-(Integer)-})-}
{-(Identifier)-})-})))))

View File

@ -0,0 +1,17 @@
(Statements
(Class
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
{+(Annotation
{+(Subscript
{+(Identifier)+}
{+(Integer)+})+}
{+(Identifier)+})+}
{-(Subscript
{-(Identifier)-}
{-(Integer)-})-})))))

View File

@ -0,0 +1,14 @@
(Statements
(Class
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
(Annotation
(Subscript
(Identifier)
(Integer))
(Identifier)))))))

View File

@ -0,0 +1,12 @@
(Statements
(Class
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
(Subscript
(Identifier)
(Integer)))))))

View File

@ -0,0 +1,7 @@
class Dino {
void fn() {
for (File file : snap.index()) {
assert oldFile == null;
}
}
}

View File

@ -0,0 +1,5 @@
class Dino {
void fn() {
assert failure : "expecting non null";
}
}

View File

@ -0,0 +1,25 @@
(Statements
(Class
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
{+(AssertStatement
{+(Identifier)+}
{+(TextElement)+})+}
{-(ForEach
{-(Variable
{-(Identifier)-}
{-(Identifier)-})-}
{-(Call
{-(MemberAccess
{-(Identifier)-})-}
{-(Empty)-})-}
{-(Statements
{-(AssertStatement
{-(Equal
{-(Identifier)-}
{-(Null)-})-})-})-})-})))))

View File

@ -0,0 +1,25 @@
(Statements
(Class
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
{+(ForEach
{+(Variable
{+(Identifier)+}
{+(Identifier)+})+}
{+(Call
{+(MemberAccess
{+(Identifier)+})+}
{+(Empty)+})+}
{+(Statements
{+(AssertStatement
{+(Equal
{+(Identifier)+}
{+(Null)+})+})+})+})+}
{-(AssertStatement
{-(Identifier)-}
{-(TextElement)-})-})))))

View File

@ -0,0 +1,22 @@
(Statements
(Class
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
(ForEach
(Variable
(Identifier)
(Identifier))
(Call
(MemberAccess
(Identifier))
(Empty))
(Statements
(AssertStatement
(Equal
(Identifier)
(Null))))))))))

View File

@ -0,0 +1,12 @@
(Statements
(Class
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
(AssertStatement
(Identifier)
(TextElement)))))))

View File

@ -0,0 +1,9 @@
a ^ b;
a % b;
a << b;
a >> b;
a >>> b;
3 + 2;
3 - 2;
3 * 2;
9 / 3;

View File

@ -8,12 +8,3 @@ a && b;
a || b; a || b;
a & b; a & b;
a | b; a | b;
a ^ b;
a % b;
a << b;
a >> b;
a >>> b;
3 + 2;
3 - 2;
3 * 2;
9 / 3;

View File

@ -0,0 +1,59 @@
(Statements
{+(GreaterThan
{+(Identifier)+}
{+(Identifier)+})+}
{+(LessThan
{+(Identifier)+}
{+(Identifier)+})+}
{+(Equal
{+(Identifier)+}
{+(Identifier)+})+}
{+(GreaterThanEqual
{+(Identifier)+}
{+(Identifier)+})+}
{+(LessThanEqual
{+(Identifier)+}
{+(Identifier)+})+}
{+(Not
{+(Equal
{+(Identifier)+}
{+(Identifier)+})+})+}
{+(And
{+(Identifier)+}
{+(Identifier)+})+}
{+(Or
{+(Identifier)+}
{+(Identifier)+})+}
{+(BAnd
{+(Identifier)+}
{+(Identifier)+})+}
{+(BOr
{+(Identifier)+}
{+(Identifier)+})+}
{-(BXOr
{-(Identifier)-}
{-(Identifier)-})-}
{-(Modulo
{-(Identifier)-}
{-(Identifier)-})-}
{-(LShift
{-(Identifier)-}
{-(Identifier)-})-}
{-(RShift
{-(Identifier)-}
{-(Identifier)-})-}
{-(UnsignedRShift
{-(Identifier)-}
{-(Identifier)-})-}
{-(Plus
{-(Integer)-}
{-(Integer)-})-}
{-(Minus
{-(Integer)-}
{-(Integer)-})-}
{-(Times
{-(Integer)-}
{-(Integer)-})-}
{-(DividedBy
{-(Integer)-}
{-(Integer)-})-})

View File

@ -0,0 +1,59 @@
(Statements
{+(BXOr
{+(Identifier)+}
{+(Identifier)+})+}
{+(Modulo
{+(Identifier)+}
{+(Identifier)+})+}
{+(LShift
{+(Identifier)+}
{+(Identifier)+})+}
{+(RShift
{+(Identifier)+}
{+(Identifier)+})+}
{+(UnsignedRShift
{+(Identifier)+}
{+(Identifier)+})+}
{+(Plus
{+(Integer)+}
{+(Integer)+})+}
{+(Minus
{+(Integer)+}
{+(Integer)+})+}
{+(Times
{+(Integer)+}
{+(Integer)+})+}
{+(DividedBy
{+(Integer)+}
{+(Integer)+})+}
{-(GreaterThan
{-(Identifier)-}
{-(Identifier)-})-}
{-(LessThan
{-(Identifier)-}
{-(Identifier)-})-}
{-(Equal
{-(Identifier)-}
{-(Identifier)-})-}
{-(GreaterThanEqual
{-(Identifier)-}
{-(Identifier)-})-}
{-(LessThanEqual
{-(Identifier)-}
{-(Identifier)-})-}
{-(Not
{-(Equal
{-(Identifier)-}
{-(Identifier)-})-})-}
{-(And
{-(Identifier)-}
{-(Identifier)-})-}
{-(Or
{-(Identifier)-}
{-(Identifier)-})-}
{-(BAnd
{-(Identifier)-}
{-(Identifier)-})-}
{-(BOr
{-(Identifier)-}
{-(Identifier)-})-})

View File

@ -0,0 +1,28 @@
(Statements
(BXOr
(Identifier)
(Identifier))
(Modulo
(Identifier)
(Identifier))
(LShift
(Identifier)
(Identifier))
(RShift
(Identifier)
(Identifier))
(UnsignedRShift
(Identifier)
(Identifier))
(Plus
(Integer)
(Integer))
(Minus
(Integer)
(Integer))
(Times
(Integer)
(Integer))
(DividedBy
(Integer)
(Integer)))

View File

@ -0,0 +1,32 @@
(Statements
(GreaterThan
(Identifier)
(Identifier))
(LessThan
(Identifier)
(Identifier))
(Equal
(Identifier)
(Identifier))
(GreaterThanEqual
(Identifier)
(Identifier))
(LessThanEqual
(Identifier)
(Identifier))
(Not
(Equal
(Identifier)
(Identifier)))
(And
(Identifier)
(Identifier))
(Or
(Identifier)
(Identifier))
(BAnd
(Identifier)
(Identifier))
(BOr
(Identifier)
(Identifier)))

View File

@ -0,0 +1,5 @@
public class Point {
void dinosaur() {
Boolean example = false;
}
}

View File

@ -0,0 +1,18 @@
(Statements
(Class
(AccessibilityModifier)
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
(Statements
(Assignment
(Variable
(Identifier)
{ (Identifier)
->(Identifier) })
{ (Boolean)
->(Boolean) })))))))

View File

@ -0,0 +1,18 @@
(Statements
(Class
(AccessibilityModifier)
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
(Statements
(Assignment
(Variable
(Identifier)
{ (Identifier)
->(Identifier) })
{ (Boolean)
->(Boolean) })))))))

View File

@ -0,0 +1,16 @@
(Statements
(Class
(AccessibilityModifier)
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
(Statements
(Assignment
(Variable
(Identifier)
(Identifier))
(Boolean))))))))

View File

@ -0,0 +1,16 @@
(Statements
(Class
(AccessibilityModifier)
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
(Statements
(Assignment
(Variable
(Identifier)
(Identifier))
(Boolean))))))))

7
test/fixtures/java/corpus/Char.B.java vendored Normal file
View File

@ -0,0 +1,7 @@
class Point {
Char dinosaur() {
Char B = 'B';
if (x)
B;
}
}

View File

@ -0,0 +1,23 @@
(Statements
(Class
{-(AccessibilityModifier)-}
(Identifier)
(Statements
(Method
{+(Identifier)+}
{-(Void)-}
(Empty)
(Identifier)
(Statements
(Statements
(Assignment
(Variable
(Identifier)
{ (Identifier)
->(Identifier) })
{ (TextElement)
->(TextElement) }))
{+(If
{+(Identifier)+}
{+(Identifier)+}
{+(Empty)+})+})))))

View File

@ -0,0 +1,23 @@
(Statements
(Class
{+(AccessibilityModifier)+}
(Identifier)
(Statements
(Method
{+(Void)+}
{-(Identifier)-}
(Empty)
(Identifier)
(Statements
(Statements
(Assignment
(Variable
(Identifier)
{ (Identifier)
->(Identifier) })
{ (TextElement)
->(TextElement) }))
{-(If
{-(Identifier)-}
{-(Identifier)-}
{-(Empty)-})-})))))

View File

@ -0,0 +1,16 @@
(Statements
(Class
(AccessibilityModifier)
(Identifier)
(Statements
(Method
(Void)
(Empty)
(Identifier)
(Statements
(Statements
(Assignment
(Variable
(Identifier)
(Identifier))
(TextElement))))))))

View File

@ -0,0 +1,19 @@
(Statements
(Class
(Identifier)
(Statements
(Method
(Identifier)
(Empty)
(Identifier)
(Statements
(Statements
(Assignment
(Variable
(Identifier)
(Identifier))
(TextElement)))
(If
(Identifier)
(Identifier)
(Empty)))))))

View File

@ -0,0 +1,3 @@
class Dino {
}

View File

@ -0,0 +1,19 @@
(Statements
(Class
(Identifier)
(Statements
{-(Method
{-(Void)-}
{-(AccessibilityModifier)-}
{-(Empty)-}
{-(Identifier)-}
{-(Statements
{-(Call
{-(MemberAccess
{-(Identifier)-})-}
{-(New
{-(GenericType
{-(Identifier)-}
{-(Identifier)-})-}
{-(Statements)-})-}
{-(Empty)-})-})-})-})))

View File

@ -0,0 +1,19 @@
(Statements
(Class
(Identifier)
(Statements
{+(Method
{+(Void)+}
{+(AccessibilityModifier)+}
{+(Empty)+}
{+(Identifier)+}
{+(Statements
{+(Call
{+(MemberAccess
{+(Identifier)+})+}
{+(New
{+(GenericType
{+(Identifier)+}
{+(Identifier)+})+}
{+(Statements)+})+}
{+(Empty)+})+})+})+})))

View File

@ -0,0 +1,19 @@
(Statements
(Class
(Identifier)
(Statements
(Method
(Void)
(AccessibilityModifier)
(Empty)
(Identifier)
(Statements
(Call
(MemberAccess
(Identifier))
(New
(GenericType
(Identifier)
(Identifier))
(Statements))
(Empty)))))))

View File

@ -0,0 +1,4 @@
(Statements
(Class
(Identifier)
(Statements)))

View File

@ -0,0 +1 @@
// This is a single-line comment.

View File

@ -1,5 +1,3 @@
// This is a single-line comment.
/* This is /* This is
a multi-line a multi-line
comment */ comment */

View File

@ -0,0 +1,5 @@
(Statements
(Context
{ (Comment)
->(Comment) }
(Empty)))

View File

@ -0,0 +1,5 @@
(Statements
(Context
{ (Comment)
->(Comment) }
(Empty)))

View File

@ -0,0 +1,4 @@
(Statements
(Context
(Comment)
(Empty)))

View File

@ -0,0 +1,4 @@
(Statements
(Context
(Comment)
(Empty)))

2
vendor/effects vendored

@ -1 +1 @@
Subproject commit 0b6d04713b70e6b0551b841304fb44c9b1564e9b Subproject commit b78e9c6e77c89ab9c338aae9cf2e24d0e5f3abfc