String tagName = region.getTagName();
if (tagName != null && tagName.equals("url") && region.hasAttribute("type") && !region.isDynamicAttributeValue("type")) {
String type = region.getAttributeValue("type");
if (type != null && ( type.equals(WGADesignStructureHelper.SCRIPT_TYPE_CSS) || type.equals(WGADesignStructureHelper.SCRIPT_TYPE_JS)) ) {
WGADesignStructureHelper designHelper = new WGADesignStructureHelper(activeFile);
VersionCompliance versionCompliance = WGADesignStructureHelper.getWGAVersionCompliance(activeFile);
IContainer designRoot = designHelper.getDesignRoot();
String medium = WGADesignStructureHelper.determineMediaKey(activeFile);
ResourceIndexManager rsm = Plugin.getDefault().getResourceIndexManager();
if (rsm != null) {
// the path to the file which we are currently editing
IPath pathOfEditedFile = activeFile.getParent().getProjectRelativePath();
// the path of the medium of the current file
IPath mediumPath = designHelper.getTmlRoot().getFolder(new Path(medium)).getProjectRelativePath();
pathOfEditedFile = pathOfEditedFile.removeFirstSegments(mediumPath.segmentCount());
Iterator<String> scriptPaths = rsm.getScriptPaths(designRoot, type).iterator();
while (scriptPaths.hasNext()) {
String scriptPath = scriptPaths.next();
// scriptfile path
IPath scriptFile = new Path(scriptPath).removeFileExtension();
// path of the current file
IPath currentFilePath = scriptFile.removeLastSegments(1);
// removing the path of the selected medium
currentFilePath = currentFilePath.removeFirstSegments(mediumPath.segmentCount());
// removing the path of the elected medium
scriptFile = scriptFile.removeFirstSegments(mediumPath.segmentCount());
IPath tmp = null;
if (currentFilePath.segmentCount() >= pathOfEditedFile.segmentCount()) {
int a = currentFilePath.segmentCount();
int b = pathOfEditedFile.segmentCount();
tmp = currentFilePath.removeLastSegments(a - b);
if (tmp.equals(pathOfEditedFile)) {
currentFilePath = scriptFile.removeFirstSegments(tmp.segmentCount());
references.add("::" + currentFilePath.toString().replaceAll("\\/", ":"));
} else {
String reference = scriptFile.toString().replaceAll("\\/", ":");
if (versionCompliance != null && versionCompliance.toWGAVersion() != null && versionCompliance.toWGAVersion().isAtLeast(5, 4)) {
if (reference.startsWith("overlay:") && pathOfEditedFile.toString().contains("overlay")) {
reference = reference.substring("overlay:".length());
} else if (pathOfEditedFile.toString().contains("overlay")) {
reference = reference + "@base";
}
}
references.add(reference);
}
} else {
String reference = scriptFile.toString().replaceAll("\\/", ":");
if (versionCompliance != null && versionCompliance.toWGAVersion() != null && versionCompliance.toWGAVersion().isAtLeast(5, 4)) {
if (reference.startsWith("overlay:") && pathOfEditedFile.toString().contains("overlay")) {
reference = reference.substring("overlay:".length());
} else if (pathOfEditedFile.toString().contains("overlay")) {
reference = reference + "@base";
}