Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afcc4e9
commit 3c05bf3
Showing
6 changed files
with
132 additions
and
62 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
11 changes: 11 additions & 0 deletions
11
...l/src/main/java/me/tomassetti/symbolsolver/model/declarations/ConstructorDeclaration.java
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,11 @@ | ||
package me.tomassetti.symbolsolver.model.declarations; | ||
|
||
/** | ||
* A declaration of a constructor. | ||
* | ||
* @author Federico Tomassetti | ||
*/ | ||
public interface ConstructorDeclaration extends MethodLikeDeclaration { | ||
|
||
boolean isDefaultMethod(); | ||
} |
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
60 changes: 60 additions & 0 deletions
60
...el/src/main/java/me/tomassetti/symbolsolver/model/declarations/MethodLikeDeclaration.java
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,60 @@ | ||
package me.tomassetti.symbolsolver.model.declarations; | ||
|
||
/** | ||
* @author Federico Tomassetti | ||
*/ | ||
public interface MethodLikeDeclaration extends Declaration, TypeParametrizable, HasAccessLevel { | ||
|
||
default String getQualifiedName() { | ||
return declaringType().getQualifiedName()+ "." + this.getName(); | ||
} | ||
|
||
default String getSignature() { | ||
StringBuffer sb = new StringBuffer(); | ||
sb.append(getName()); | ||
sb.append("("); | ||
for (int i=0; i<getNoParams(); i++) { | ||
if (i != 0) { | ||
sb.append(", "); | ||
} | ||
sb.append(getParam(i).describeType()); | ||
} | ||
sb.append(")"); | ||
return sb.toString(); | ||
} | ||
|
||
default String getQualifiedSignature() { | ||
return declaringType().getQualifiedName()+ "." + this.getSignature(); | ||
} | ||
|
||
/** | ||
* The type in which the method is declared. | ||
*/ | ||
TypeDeclaration declaringType(); | ||
|
||
int getNoParams(); | ||
|
||
ParameterDeclaration getParam(int i); | ||
|
||
/** | ||
* The last parameter can be variadic and sometimes it needs to be handled in a special way. | ||
*/ | ||
default ParameterDeclaration getLastParam() { | ||
if (getNoParams() == 0) { | ||
throw new UnsupportedOperationException("This method has no typeParametersValues, therefore it has no a last parameter"); | ||
} | ||
return getParam(getNoParams() - 1); | ||
} | ||
|
||
/** | ||
* Note that when a method has a variadic parameter it should have an array type. | ||
* @return | ||
*/ | ||
default boolean hasVariadicParameter() { | ||
if (getNoParams() == 0) { | ||
return false; | ||
} else { | ||
return getParam(getNoParams() - 1).isVariadic(); | ||
} | ||
} | ||
} |
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