| Previous CloneSet | Next CloneSet | Back to Main Report |
| Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
|---|---|---|---|---|
| 63 | 2 | 3 | 0.959 | class_body_declaration |
| Clone Abstraction | Parameter Bindings |
| Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
|---|---|---|---|
| 1 | 63 | 68 | plugins/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java |
| 2 | 63 | 138 | plugins/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java |
| ||||
/* Answer true if the receiver is visible to the type provided by the scope.
* InvocationSite implements isSuperAccess() to provide additional information
* if the receiver is protected.
*
* NOTE: Cannot invoke this method with a compilation unit scope.
*/
public final boolean canBeSeenByForCodeSnippet(FieldBinding fieldBinding, TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
if (fieldBinding.isPublic()) return true;
ReferenceBinding invocationType = (ReferenceBinding) receiverType;
if (invocationType == fieldBinding.declaringClass) return true;
if (fieldBinding.isProtected()) {
// answer true if the invocationType is the declaringClass or they are in the same package
// OR the invocationType is a subclass of the declaringClass
// AND the receiverType is the invocationType or its subclass
// OR the field is a static field accessed directly through a type
if (invocationType == fieldBinding.declaringClass) return true;
if (invocationType.fPackage == fieldBinding.declaringClass.fPackage) return true;
if (fieldBinding.declaringClass.isSuperclassOf(invocationType)) {
if (invocationSite.isSuperAccess()) return true;
// receiverType can be an array binding in one case... see if you can change it
if (receiverType instanceof ArrayBinding)
return false;
if (invocationType == receiverType || invocationType.isSuperclassOf((ReferenceBinding) receiverType))
return true;
if (fieldBinding.isStatic())
return true; // see 1FMEPDL - return invocationSite.isTypeAccess();
}
return false;
}
if (fieldBinding.isPrivate()) {
// answer true if the receiverType is the declaringClass
// AND the invocationType and the declaringClass have a common enclosingType
if (receiverType != fieldBinding.declaringClass) return false;
if (invocationType != fieldBinding.declaringClass) {
ReferenceBinding outerInvocationType = invocationType;
ReferenceBinding temp = outerInvocationType.enclosingType();
while (temp != null) {
outerInvocationType = temp;
temp = temp.enclosingType();
}
ReferenceBinding outerDeclaringClass = fieldBinding.declaringClass;
temp = outerDeclaringClass.enclosingType();
while (temp != null) {
outerDeclaringClass = temp;
temp = temp.enclosingType();
}
if (outerInvocationType != outerDeclaringClass) return false;
}
return true;
}
// isDefault()
if (invocationType.fPackage != fieldBinding.declaringClass.fPackage) return false;
// receiverType can be an array binding in one case... see if you can change it
if (receiverType instanceof ArrayBinding)
return false;
ReferenceBinding type = (ReferenceBinding) receiverType;
PackageBinding declaringPackage = fieldBinding.declaringClass.fPackage;
do {
if (fieldBinding.declaringClass == type) return true;
if (declaringPackage != type.fPackage) return false;
}
while ( (type = type.superclass()) != null);
return false;
}
|
| ||||
/* Answer true if the receiver is visible to the type provided by the scope.
* InvocationSite implements isSuperAccess() to provide additional information
* if the receiver is protected.
*
* NOTE: Cannot invoke this method with a compilation unit scope.
*/
public final boolean canBeSeenByForCodeSnippet(MethodBinding methodBinding, TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
if (methodBinding.isPublic()) return true;
ReferenceBinding invocationType = (ReferenceBinding) receiverType;
if (invocationType == methodBinding.declaringClass && invocationType == receiverType) return true;
if (methodBinding.isProtected()) {
// answer true if the invocationType is the declaringClass or they are in the same package
// OR the invocationType is a subclass of the declaringClass
// AND the receiverType is the invocationType or its subclass
// OR the method is a static method accessed directly through a type
if (invocationType == methodBinding.declaringClass) return true;
if (invocationType.fPackage == methodBinding.declaringClass.fPackage) return true;
if (methodBinding.declaringClass.isSuperclassOf(invocationType)) {
if (invocationSite.isSuperAccess()) return true;
// receiverType can be an array binding in one case... see if you can change it
if (receiverType instanceof ArrayBinding)
return false;
if (invocationType == receiverType || invocationType.isSuperclassOf((ReferenceBinding) receiverType))
return true;
if (methodBinding.isStatic())
return true; // see 1FMEPDL - return invocationSite.isTypeAccess();
}
return false;
}
if (methodBinding.isPrivate()) {
// answer true if the receiverType is the declaringClass
// AND the invocationType and the declaringClass have a common enclosingType
if (receiverType != methodBinding.declaringClass) return false;
if (invocationType != methodBinding.declaringClass) {
ReferenceBinding outerInvocationType = invocationType;
ReferenceBinding temp = outerInvocationType.enclosingType();
while (temp != null) {
outerInvocationType = temp;
temp = temp.enclosingType();
}
ReferenceBinding outerDeclaringClass = methodBinding.declaringClass;
temp = outerDeclaringClass.enclosingType();
while (temp != null) {
outerDeclaringClass = temp;
temp = temp.enclosingType();
}
if (outerInvocationType != outerDeclaringClass) return false;
}
return true;
}
// isDefault()
if (invocationType.fPackage != methodBinding.declaringClass.fPackage) return false;
// receiverType can be an array binding in one case... see if you can change it
if (receiverType instanceof ArrayBinding)
return false;
ReferenceBinding type = (ReferenceBinding) receiverType;
PackageBinding declaringPackage = methodBinding.declaringClass.fPackage;
do {
if (methodBinding.declaringClass == type) return true;
if (declaringPackage != type.fPackage) return false;
}
while ( (type = type.superclass()) != null);
return false;
}
|
| |||
/* Answer true if the receiver is visible to the type provided by the scope.
* InvocationSite implements isSuperAccess() to provide additional information
* if the receiver is protected.
*
* NOTE: Cannot invoke this method with a compilation unit scope.
*/
public final boolean canBeSeenByForCodeSnippet( [[#variableb450f860]] [[#variableb450f7e0]], TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
if ( [[#variableb450f7e0]].isPublic())
return true;
ReferenceBinding invocationType = (ReferenceBinding) receiverType;
if ( [[#variableb450f760]])
return true;
if ( [[#variableb450f7e0]].isProtected()) {
// answer true if the invocationType is the declaringClass or they are in the same package
// OR the invocationType is a subclass of the declaringClass
// AND the receiverType is the invocationType or its subclass
// OR the field is a static field accessed directly through a type
// OR the method is a static method accessed directly through a type
if (invocationType == [[#variableb450f7e0]].declaringClass)
return true;
if (invocationType.fPackage == [[#variableb450f7e0]].declaringClass.fPackage)
return true;
if ( [[#variableb450f7e0]].declaringClass.isSuperclassOf(invocationType)) {
if (invocationSite.isSuperAccess())
return true;
// receiverType can be an array binding in one case... see if you can change it
if (receiverType instanceof ArrayBinding)
return false;
if (invocationType == receiverType || invocationType.isSuperclassOf((ReferenceBinding) receiverType))
return true;
if ( [[#variableb450f7e0]].isStatic())
return true; // see 1FMEPDL - return invocationSite.isTypeAccess();
}
return false;
}
if ( [[#variableb450f7e0]].isPrivate()) {
// answer true if the receiverType is the declaringClass
// AND the invocationType and the declaringClass have a common enclosingType
if (receiverType != [[#variableb450f7e0]].declaringClass)
return false;
if (invocationType != [[#variableb450f7e0]].declaringClass) {
ReferenceBinding outerInvocationType = invocationType;
ReferenceBinding temp = outerInvocationType.enclosingType();
while (temp != null) {
outerInvocationType = temp;
temp = temp.enclosingType();
}
ReferenceBinding outerDeclaringClass = [[#variableb450f7e0]].declaringClass;
temp = outerDeclaringClass.enclosingType();
while (temp != null) {
outerDeclaringClass = temp;
temp = temp.enclosingType();
}
if (outerInvocationType != outerDeclaringClass)
return false;
}
return true;
}
// isDefault()
if (invocationType.fPackage != [[#variableb450f7e0]].declaringClass.fPackage)
return false;
// receiverType can be an array binding in one case... see if you can change it
if (receiverType instanceof ArrayBinding)
return false;
ReferenceBinding type = (ReferenceBinding) receiverType;
PackageBinding declaringPackage = [[#variableb450f7e0]].declaringClass.fPackage;
do {
if ( [[#variableb450f7e0]].declaringClass == type)
return true;
if (declaringPackage != type.fPackage)
return false;
}
while ((type = type.superclass()) != null);
return false;
}
|
| CloneAbstraction |
| Parameter Index | Clone Instance | Parameter Name | Value |
|---|---|---|---|
| 1 | 1 | [[#b450f860]] | FieldBinding |
| 1 | 2 | [[#b450f860]] | MethodBinding |
| 2 | 1 | [[#b450f7e0]] | fieldBinding |
| 2 | 2 | [[#b450f7e0]] | methodBinding |
| 3 | 1 | [[#b450f760]] | invocationType == fieldBinding.declaringClass |
| 3 | 2 | [[#b450f760]] | invocationType == methodBinding.declaringClass && invocationType == receiverType |