}
// This text region must be of type PhpScriptRegion:
if (tRegion != null
&& tRegion.getType() == PHPRegionContext.PHP_CONTENT) {
IPhpScriptRegion phpScriptRegion = (IPhpScriptRegion) tRegion;
try {
// Set default starting position to the beginning of the
// PhpScriptRegion:
int startOffset = container.getStartOffset()
+ phpScriptRegion.getStart();
// Now, search backwards for the statement start (in this
// PhpScriptRegion):
ITextRegion startTokenRegion;
if (documentOffset == startOffset) {
startTokenRegion = phpScriptRegion.getPhpToken(0);
} else {
startTokenRegion = phpScriptRegion.getPhpToken(offset
- startOffset - 1);
}
// If statement start is at the beginning of the PHP script
// region:
while (true) {
if (startTokenRegion.getStart() == 0) {
return false;
}
if (startTokenRegion.getType() == PHPRegionTypes.PHP_CURLY_OPEN) {
// Calculate starting position of the statement (it
// should go right after this startTokenRegion):
// startOffset += startTokenRegion.getEnd();
TextSequence statementText1 = getStatementText(startOffset
+ startTokenRegion.getStart() - 1);
startTokenRegion = phpScriptRegion
.getPhpToken(startTokenRegion.getStart()
- statementText1.length());
if (startTokenRegion != null
&& startTokenRegion.getType() == PHPRegionTypes.PHP_USE) {
String[] types = statementText1.toString().trim()
.substring(3).trim().split(","); //$NON-NLS-1$
useTypes = new ArrayList<String>();
for (String type : types) {
useTypes.add(type.trim());
}
return true;
} else {
return false;
}
} else if (startTokenRegion.getType() == PHPRegionTypes.PHP_CURLY_CLOSE) {
return false;
}
startTokenRegion = phpScriptRegion
.getPhpToken(startTokenRegion.getStart() - 1);
}
} catch (BadLocationException e) {
}