com.togethersoft.openapi.sci
Interface SciReference

All Known Subinterfaces:
SciInheritance, SciReferenceExpression, SciThrowSpecifier, SciType, SciTypeExpression

public interface SciReference
extends SciObject

SciReference interface provides methods for working with references.


In the SCI model, references are:


Primitive datatypes are not considered references.


For example, in the following Java source code fragment, the references are
MyType1, someObject, someMethod and iTotal
(in the line with iTotal=1;):



MyType1 myFirstAttribute=null;
MyType2 mySecondAttribure=null;
int iTotal=0; // this is not a reference!
someObject.someMethod();
iTotal=1;

The referenced element can be obtained using the getReferencedElement method.


It is possible
to change a referenced element using the setReferencedElement method. For the example described above
, if the refToMyType2 is a reference to MyType2, and the
elementMyType1 is an SCI element representing MyType1, the code:



refToType2.setReferencedElement(elementMyType1)

will make the following changes in the source code:


MyType1 myFirstAttribute=null;
MyType1 mySecondAttribure=null;
...

Author:
TogetherSoft
Since: Together 3.0

Method Summary
 booleancanSetReferencedElement(SciElement element)
          Checks whether the specified element can be set as a target for this reference.
 booleancanSetReferenceText(String text)
          Checks whether the specified text can be set as the text for this reference.
 SciObjectgetOwner()
          Returns the owner of this reference.
 SciElementgetReferencedElement()
          Returns the SciElement this reference points to.
 StringgetReferenceText()
          Returns the string containing this reference text in source code.
 voidsetReferencedElement(SciElement element)
          Sets another SciElement for this reference to point to.
 voidsetReferenceText(String text)
          Sets this reference text to the specified value.

Methods inherited from interface com.togethersoft.openapi.sci.SciObject
canCut, canDelete, canReplace, copy, cut, delete, getContainingFile, getContainingScope, getLanguage, getPositions, getText, getUserProperty, isReadOnly, replace, setUserProperty

Method Detail

canSetReferencedElement

public boolean canSetReferencedElement(SciElement element)
Checks whether the specified element can be set as a target for this reference.
Parameters:
element the SciElement which needs to be set as a target for this reference
Returns: true if the specified element can be set as a target for this reference,
false otherwise

canSetReferenceText

public boolean canSetReferenceText(String text)
Checks whether the specified text can be set as the text for this reference.
Parameters:
text the string which needs to be set as the text for this reference
Returns: true if the specified text can be set as the text for this reference,
false otherwise

getOwner

public SciObject getOwner()
Returns the owner of this reference. For example, a class is the owner of its inheritances,
an operation is the owner of its throw specifiers, a member is the owner of its type, and so on. This call may
return null in particular situations if no appropriate owner is found. For example,
the type of expression returned by a call to getType() of SciExpression has no
owner because it has no physical representation in the source code.

This method is helpful when you obtain a reference object
Returns: the owner of this reference as SciObject.
Since:
Together 6.0
See Also:
SciReferenceVisitor#visitReference

getReferencedElement

public SciElement getReferencedElement()
Returns the SciElement this reference points to. If Together cannot find such an element
(for example, the file is not in the classpath), then returns null.
Returns: an SciElement this reference points to

getReferenceText

public String getReferenceText()
Returns the string containing this reference text in source code. This method returns the string
exactly as it was typed in the source code.
Returns: a string containing this reference text in the source code
See Also:
SciType.getCanonicalText()

setReferencedElement

public void setReferencedElement(SciElement element)
Sets another SciElement for this reference to point to.
Parameters:
element the SciElement which needs to be set as a target for this reference

setReferenceText

public void setReferenceText(String text)
Sets this reference text to the specified value. Sometimes it is necessary just to change
the text for this reference. This method is called automatically from the
setReferencedElement method.


Note the difference with SciType.setText
method when working with the SciType objects (SciType is a special kind
of a reference - a reference to a type).

Parameters:
text the string which needs to be set as the text for this reference
See Also:
setReferencedElement(com.togethersoft.openapi.sci.SciElement), SciType.setText(java.lang.String)