Skip to content

Commit

Permalink
Fix various bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
slietar committed Jun 29, 2023
1 parent 2d1abe2 commit 3bd945b
Show file tree
Hide file tree
Showing 21 changed files with 82 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/electron/forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
/^\/tmp(\/|$)/
],
afterCopy: [
setLanguages(['en'])
setLanguages(['en', 'en_US'])
]
},
makers: [
Expand Down
4 changes: 4 additions & 0 deletions app/shared/src/types/rich-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export type RichText = RichTextComponent[];
export type RichTextComponent = string | {
type: 'code';
value: RichText;
} | {
type: 'link';
url: string;
value: RichText;
} | {
type: 'strong';
value: RichText;
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/execution-inspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class ExecutionInspector extends Component<ExecutionInspectorProps, Execu

{blockAnalysis.isLeafBlockTerminal && (
<FeatureRoot>
<FeatureList features={leafBlockImpl.createFeatures!(leafPair.block, null, globalContext).map((feature) => ({
<FeatureList features={leafBlockImpl.createFeatures!(leafPair.block, leafPair.location, globalContext).map((feature) => ({
...feature,
accent: true
}))} />
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/report-inspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function ReportInspector(props: {
<>
{blockAnalysis.isLeafBlockTerminal && (
<FeatureRoot>
<FeatureList features={leafBlockImpl.createFeatures!(leafPair.block, null, globalContext).map((feature) => ({
<FeatureList features={leafBlockImpl.createFeatures!(leafPair.block, leafPair.location, globalContext).map((feature) => ({
...feature,
accent: true
}))} />
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/report-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export function ReportPanel(props: {
props.compilationAnalysis.errors.length +
props.compilationAnalysis.warnings.length +
(props.masterAnalysis?.errors.length ?? 0) +
(props.masterAnalysis?.warnings.length ?? 0)
(props.masterAnalysis?.warnings.length ?? 0) +
(props.masterAnalysis?.effects.length ?? 0)
) < 1) {
return (
<PanelPlaceholder message="Nothing to report" />
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Icon } from './icon';
export function Report(props: {
analysis: CompilationAnalysis | MasterAnalysis;
}) {
if ((props.analysis.errors.length + props.analysis.warnings.length) < 1) {
if ((props.analysis.errors.length + props.analysis.warnings.length + (('effects' in props.analysis) ? props.analysis.effects.length : 0)) < 1) {
return null;
}

Expand Down
2 changes: 2 additions & 0 deletions client/src/rich-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export function formatRichText(richText: RichText) {
switch (component.type) {
case 'code':
return <code key={index}>{formatRichText(component.value)}</code>
case 'link':
return <a href={component.url} key={index}>{formatRichText(component.value)}</a>
case 'strong':
return <strong key={index}>{formatRichText(component.value)}</strong>
}
Expand Down
16 changes: 16 additions & 0 deletions client/styles/components/_text-editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ div.hover-row.status-bar {
display: none !important;
}

@layer reset {
.monaco-editor, .monaco-editor * {
all: revert-layer;
}
}


// ---

Expand Down Expand Up @@ -126,6 +132,16 @@ $icons: (
}
}

.monaco-hover {
:is(h1, h2, h3, h4, h5, h6) {
margin: initial;
}

h4 {
text-transform: uppercase;
}
}

.monaco-action-bar:not(.vertical) .action-label:not(.disabled):hover {
background-color: rgba(184, 184, 184, 0.31);
}
10 changes: 10 additions & 0 deletions client/styles/components/diagnostics-report.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@
&Description {
grid-column: 2 / span 2;
margin-top: 0.2rem;

a {
display: inline;
text-decoration: underline;
text-underline-offset: 3px;
}

strong {
font-weight: 500;
}
}

&Source {
Expand Down
4 changes: 2 additions & 2 deletions host/pr1/fiber/master2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from ..report import ExperimentReportEvent
from ..eta import DurationTerm, Term
from ..analysis import DiagnosticAnalysis
from ..analysis import BaseAnalysis, DiagnosticAnalysis
from ..draft import DraftCompilation
from ..util.asyncio import wait_all
from ..host import logger
Expand Down Expand Up @@ -475,7 +475,7 @@ def send(self, event: ProgramExecEvent, *, lock: bool = False):
else:
self.master.update_soon()

def send_analysis(self, analysis: DiagnosticAnalysis, /):
def send_analysis(self, analysis: BaseAnalysis, /):
self._analysis += analysis
self.master.update_soon()

Expand Down
2 changes: 1 addition & 1 deletion host/pr1/input/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def analyze(self, obj: Any, key: LocatedString, context: 'AnalysisContext'):

if self._description or self._documentation or self._label:
analysis.hovers.append(LanguageServiceHover(
contents=([f"#### {self._label or key.upper()}"] + ([self._description] if self._description else list()) + (self._documentation or list())),
contents=([f"#### {self._label or key}"] + ([self._description] if self._description else list()) + (self._documentation or list())),
range=key_range
))

Expand Down
3 changes: 2 additions & 1 deletion host/pr1/input/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,12 @@ class FileDataRefType(Type):

def analyze(self, obj, /, context):
analysis, result = PrimitiveType(IOBase).analyze(obj, context.update(auto_expr=False))
assert isinstance(result, LocatedValue)

if isinstance(result, EllipsisType):
return analysis, Ellipsis

assert isinstance(result, LocatedValue)

match self.mode:
case 'read':
if not result.value.readable():
Expand Down
10 changes: 5 additions & 5 deletions host/pr1/master/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from ..analysis import BaseAnalysis, DiagnosticAnalysis
from ..error import Diagnostic, DiagnosticReference
from ..rich_text import RichText
from ..util.misc import Exportable, ExportableABC
from ..util.misc import ExportableABC


T_Exportable = TypeVar('T_Exportable', bound=Exportable)
T_DiagnosticOrEffect = TypeVar('T_DiagnosticOrEffect', Diagnostic, 'Effect')


@comserde.serializable
Expand Down Expand Up @@ -63,8 +63,8 @@ def export(self):

@comserde.serializable
@dataclass
class RuntimeMasterAnalysisItem(Generic[T_Exportable]):
value: T_Exportable
class RuntimeMasterAnalysisItem(Generic[T_DiagnosticOrEffect]):
value: T_DiagnosticOrEffect
_: KW_ONLY
author_path: list[int]
event_index: int
Expand Down Expand Up @@ -98,7 +98,7 @@ class MasterAnalysis(BaseAnalysis):
warnings: list[RuntimeMasterAnalysisItem[Diagnostic]] = field(default_factory=list)

def add_runtime(self, other: RuntimeAnalysis, /, author_path: list[int], event_index: int):
def add_items(items: list[T_Exportable]):
def add_items(items: list[T_DiagnosticOrEffect]):
return [RuntimeMasterAnalysisItem(item, author_path=author_path, event_index=event_index) for item in items]

self.effects += add_items(other.effects)
Expand Down
4 changes: 2 additions & 2 deletions host/pr1/procedure.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ class BaseClassProcess(ABC, Generic[T_ProcessData, T_ProcessLocation, T_ProcessP
name: str
namespace: PluginName

def duration(self, data: T_ProcessData) -> DurationTerm:
def duration(self, data: Any) -> DurationTerm:
return DurationTerm.unknown()

def import_point(self, raw_point: Any, /) -> T_ProcessPoint:
raise NotImplementedError

def export_data(self, data: T_ProcessData) -> Any:
def export_data(self, data: Any) -> Any:
...

@abstractmethod
Expand Down
20 changes: 20 additions & 0 deletions host/pr1/rich_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ def format(self):
return f"`{self.value.format()}`"


@dataclass(slots=True)
class RichTextLink(BaseRichTextExplicitComponent):
url: str
value: 'RichText'

def __init__(self, *components: RichTextComponent, url: str):
self.url = url
self.value = RichText(*components)

def export(self) -> object:
return {
"type": "link",
"url": self.url,
"value": self.value.export()
}

def format(self):
return f"\033]8;;{self.url}\033\\{self.value.format()}\033]8;;\033\\"

@dataclass(slots=True)
class RichTextStrong(BaseRichTextExplicitComponent):
value: 'RichText'
Expand Down Expand Up @@ -64,6 +83,7 @@ def format(self):
'RichText',
'RichTextCode',
'RichTextComponent',
'RichTextLink',
'RichTextStrong'
]

Expand Down
5 changes: 3 additions & 2 deletions host/pr1/staticanalysis/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ def evaluate_eval_expr(
case ast.Constant(None):
return StaticAnalysisAnalysis(), CompositeExprDef(node, instantiate_type_instance(NoneType))

case ast.Constant(bytes()):
return StaticAnalysisAnalysis(), CompositeExprDef(node, instantiate_type_instance(prelude_type_defs['bytes']))

case ast.Constant(float()):
return StaticAnalysisAnalysis(), CompositeExprDef(node, instantiate_type_instance(prelude_type_defs['float']))

Expand Down Expand Up @@ -360,8 +363,6 @@ def evaluate_eval_expr(
lambda nodes: transfer_node_location(node, ast.Subscript(nodes[0], nodes[1], ctx=ast.Load()))
)

return analysis, result

case ast.UnaryOp(op, operand):
analysis, operand_expr = evaluate_eval_expr(operand, foreign_symbols, prelude_symbols, context)

Expand Down
4 changes: 4 additions & 0 deletions host/pr1/staticanalysis/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def __mul__(self, other: int, /) -> int:
class bool:
...
class bytes:
def __add__(self, other: bytes, /) -> bytes:
...
class slice:
pass
Expand Down
2 changes: 2 additions & 0 deletions host/pr1/staticanalysis/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,15 @@ def type_values(self) -> TypeValues:

class PreludeTypeDefs(TypedDict):
bool: ClassDef
bytes: ClassDef
float: ClassDef
int: ClassDef
list: ClassDef
slice: ClassDef
str: ClassDef

class PreludeTypeInstances(TypedDict):
bytes: ClassDefWithTypeArgs
float: ClassDefWithTypeArgs
int: ClassDefWithTypeArgs
list: ClassDef
Expand Down
2 changes: 1 addition & 1 deletion units/amf/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dynamic = ["version"]
requires-python = ">3.11"

dependencies=[
"amf-rotary-valve~=0.1.0"
"amf-rotary-valve~=0.2.0"
]

[project.entry-points."pr1.units"]
Expand Down
2 changes: 1 addition & 1 deletion units/core/src/pr1_timer/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Process(am.BaseClassProcess[ProcessData, ProcessLocation, ProcessPoint]):
name = "_"
namespace = am.PluginName("timer")

def duration(self, data: am.Evaluable[PossiblyLocatedValue[ProcessData]], /):
def duration(self, data: am.Evaluable[PossiblyLocatedValue[ProcessData]]):
match data:
case am.EvaluableConstantValue(LocatedValue('forever')):
return am.DurationTerm.forever()
Expand Down
2 changes: 1 addition & 1 deletion units/okolab/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dynamic = ["version"]
requires-python = ">3.11"

dependencies=[
"okolab==0.2.0"
"okolab~=0.2.1"
]

[project.entry-points."pr1.units"]
Expand Down

0 comments on commit 3bd945b

Please sign in to comment.