-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mostly doc changes to ClassDeclaration/ConstructorDeclaration
Part of #750
- Loading branch information
1 parent
62887e9
commit 4d7306d
Showing
7 changed files
with
146 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/ceylon/language/meta/declaration/ClassWithConstructorsDeclaration.ceylon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ceylon.language { AnnotationType = Annotation } | ||
import ceylon.language.meta.model { | ||
Class, | ||
MemberClass, | ||
AppliedType = Type, | ||
IncompatibleTypeException, | ||
TypeApplicationException | ||
} | ||
|
||
|
||
"""The declaration model of a class that has constructors. For example: | ||
class Point { | ||
shared new(Float x, Float y) { | ||
// ... | ||
} | ||
shared new polar(Float r, Float theta) { | ||
// ... | ||
} | ||
shared new origin { | ||
// ... | ||
} | ||
} | ||
Such classes may not have a default (unnamed) constructor, | ||
so [[defaultConstructor|ClassDeclaration.defaultConstructor]] | ||
has optional type. | ||
""" | ||
see(`interface ClassWithInitializerDeclaration`) | ||
shared sealed interface ClassWithConstructorsDeclaration | ||
satisfies ClassDeclaration { | ||
} |
46 changes: 46 additions & 0 deletions
46
src/ceylon/language/meta/declaration/ClassWithInitializerDeclaration.ceylon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import ceylon.language { AnnotationType = Annotation } | ||
import ceylon.language.meta.model { | ||
Class, | ||
MemberClass, | ||
AppliedType = Type, | ||
IncompatibleTypeException, | ||
TypeApplicationException | ||
} | ||
|
||
|
||
|
||
"""The declaration model of a class that has a parameter list rather than | ||
explicit constructors. For example: | ||
class Color(Integer rgba) { | ||
} | ||
Such classes have a meaningful parameter list and for abstraction purposes | ||
have a single [[defaultConstructor]] representing the | ||
class' parameter list and the class initializer code. | ||
This "constructor" will have the same | ||
[[SharedAnnotation]], [[DeprecationAnnotation]] | ||
and [[ThrownExceptionAnnotation]] | ||
annotations as the class, but will have no | ||
other annotations. | ||
""" | ||
see(`interface ClassWithConstructorsDeclaration`) | ||
shared sealed interface ClassWithInitializerDeclaration | ||
satisfies ClassDeclaration { | ||
|
||
"A CallableConstructorDeclaration representing the class initializer." | ||
shared actual formal CallableConstructorDeclaration defaultConstructor; | ||
|
||
"The list of parameter declarations for this class." | ||
shared actual formal FunctionOrValueDeclaration[] parameterDeclarations; | ||
|
||
"A singleton sequence containing the [[defaultConstructor]]." | ||
shared actual default Sequence<CallableConstructorDeclaration> constructorDeclarations() | ||
=> Singleton(defaultConstructor); | ||
|
||
shared actual default CallableConstructorDeclaration? getConstructorDeclaration(String name) | ||
=> if (name.empty) then defaultConstructor else null; | ||
|
||
shared actual formal CallableConstructorDeclaration[] annotatedConstructorDeclarations<Annotation>() | ||
given Annotation satisfies AnnotationType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters