diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 56032ebb..11f372c4 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -980,6 +980,13 @@ HTTP: extensions: - .http +Hack: + type: programming + lexer: PHP + ace_mode: php + extensions: + - .hh + Haml: group: HTML type: markup diff --git a/samples/C++/bar.hh b/samples/C++/bar.hh new file mode 100644 index 00000000..a87343c2 --- /dev/null +++ b/samples/C++/bar.hh @@ -0,0 +1,10 @@ +class Bar +{ + protected: + + char *name; + + public: + + void hello(); +} diff --git a/samples/Hack/Assert.hh b/samples/Hack/Assert.hh new file mode 100644 index 00000000..c80fc87a --- /dev/null +++ b/samples/Hack/Assert.hh @@ -0,0 +1,55 @@ +( + (function(mixed): T) $fn, + mixed $x, + ): array { + if (is_array($x)) { + return array_map($fn, $x); + } + throw new AssertException('Expected an array'); + } +} diff --git a/samples/Hack/AssertRecipe.hh b/samples/Hack/AssertRecipe.hh new file mode 100644 index 00000000..e2f9eabd --- /dev/null +++ b/samples/Hack/AssertRecipe.hh @@ -0,0 +1,52 @@ +> + protected function getDescription(): ?string { + return 'When you have values with unknown types, it is useful to make '. + 'some runtime assertions and have the type checker understand. This '. + 'recipe demonstrates one approach.'; + } + + protected function getFilenames(): Vector { + return Vector { + 'Assert.php', + }; + } + + protected function getDocs(): Vector<(string, string)> { + return Vector{ + tuple ('Mixed Types', 'hack.annotations.mixedtypes'), + tuple ('Type Inference', 'hack.otherrulesandfeatures.typeinference'), + }; + } + + public function getDemoFilename(): string { + return 'demo.php'; + } + + public function getDemoResult(): string { + return assert_main(); + } + + public function getDemoXHP(): ?:xhp { + return null; + } +} diff --git a/samples/Hack/Controller.hh b/samples/Hack/Controller.hh new file mode 100644 index 00000000..a21aacb2 --- /dev/null +++ b/samples/Hack/Controller.hh @@ -0,0 +1,39 @@ +; + abstract protected function getJS(): Set; + abstract protected function getTitle(): string; + abstract protected function render(): :xhp; + + final protected function getHead(): :xhp { + $css = $this->getCSS()->toVector()->map( + ($css) ==> + ); + $js = $this->getJS()->toVector()->map( + ($js) ==>