new ProjectScope(file.getProject()), ClickPlugin.PLUGIN_ID);
String vars = store.getString(ClickPlugin.PREF_VELOCITY_VARS);
if(vars != null && vars.length() > 0){
preferenceObjects = VariableModel.deserialize(vars);
for(int i=0;i<preferenceObjects.size();i++){
VariableModel model = preferenceObjects.get(i);
if(matchString.startsWith("$" + model.name + ".") || matchString.startsWith("${" + model.name + ".")){
IType type = findType((String)model.type);
if(type != null){
return processType(type, result, matchString, offset);
}
}
}
}
}
Map<String, TemplateObject> fields = extractPageFields();
for(Iterator<Map.Entry<String, TemplateObject>> ite = fields.entrySet().iterator(); ite.hasNext();){
Map.Entry<String, TemplateObject> entry = ite.next();
String name = entry.getKey();
if(matchString.startsWith("$" + name + ".") || matchString.startsWith("${" + name + ".")){
TemplateObject obj = (TemplateObject)entry.getValue();
if(obj.getType()!=null){
return processType(obj.getType(), result, matchString, offset);
}
}
}
if(format==null){
registerProposal(result, offset, matchString, "$format", "$format", IMAGE_VAR);
} else {
registerProposal(result, offset, matchString,
"$format", "$format - " + format.getFullyQualifiedName(), IMAGE_VAR);
}
// for page class fields
for(Iterator<Map.Entry<String, TemplateObject>> ite = fields.entrySet().iterator(); ite.hasNext();){
Map.Entry<String, TemplateObject> entry = ite.next();
String name = entry.getKey();
TemplateObject obj = (TemplateObject)entry.getValue();
registerProposal(result, offset, matchString,
"$" + name, "$" + name + " - " + obj.getTypeName(), IMAGE_FIELD);
}
// #set($xxxx)
String source = textViewer.getDocument().get().substring(0, offset);
Matcher matcher = PATTERN_SET.matcher(source);
while(matcher.find()){
String name = matcher.group(1);
registerProposal(result, offset, matchString, "$" + name, "$" + name, IMAGE_VAR);
}
// #macro(xxxx)
matcher = PATTERN_MACRO.matcher(source);
while(matcher.find()){
String name = matcher.group(1);
registerProposal(result, offset, matchString, "#" + name + "()", name, IMAGE_DIRECTIVE);
}
readMacroVM(result, offset, matchString);
registerProposal(result, offset, matchString, "$imports", "$imports - PageImports", IMAGE_VAR);
registerProposal(result, offset, matchString, "$context", "$context - String", IMAGE_VAR);
registerProposal(result, offset, matchString, "$messages", "$messages - Map", IMAGE_VAR);
registerProposal(result, offset, matchString, "$path", "$path - String", IMAGE_VAR);
registerProposal(result, offset, matchString, "$request", "$request - HttpServletRequest", IMAGE_VAR);
registerProposal(result, offset, matchString, "$response", "$response - HttpServletResponse", IMAGE_VAR);
registerProposal(result, offset, matchString, "$session", "$session - SessionMap", IMAGE_VAR);
if(preferenceObjects != null){
for(int i=0;i<preferenceObjects.size();i++){
VariableModel model = (VariableModel) preferenceObjects.get(i);
registerProposal(result, offset, matchString,
"$" + model.name, "$" + model.name + " - " + model.type, IMAGE_VAR);
}
}