Java Code Examples for org.eclipse.jface.text.templates.TemplateVariable#setUnambiguous()
The following examples show how to use
org.eclipse.jface.text.templates.TemplateVariable#setUnambiguous() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImportsVariableResolver.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public List<String> resolveValues(TemplateVariable variable, XtextTemplateContext xtextTemplateContext) { variable.setUnambiguous(true); variable.setValue(""); //$NON-NLS-1$ if (xtextTemplateContext instanceof XbaseTemplateContext) { XbaseTemplateContext xbaseCtx = (XbaseTemplateContext) xtextTemplateContext; List<?> params = variable.getVariableType().getParams(); if (params.size() > 0) { for (Iterator<?> iterator = params.iterator(); iterator.hasNext();) { String typeName = (String) iterator.next(); xbaseCtx.addImport(typeName); } } } return new ArrayList<String>(); }
Example 2
Source File: TabStopVariableResolver.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void resolve(TemplateVariable variable, TemplateContext context) { if (!variable.getVariableType().getParams().isEmpty()) { String[] values = (String[]) variable.getVariableType().getParams().toArray(new String[0]); variable.setValues(values); variable.setUnambiguous(false); variable.setResolved(true); } else { super.resolve(variable, context); setEvaluationString(variable.getName()); } }
Example 3
Source File: ImportsResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void resolve(TemplateVariable variable, TemplateContext context) { variable.setUnambiguous(true); variable.setValue(""); //$NON-NLS-1$ if (context instanceof JavaContext) { JavaContext jc= (JavaContext) context; List<String> params= variable.getVariableType().getParams(); if (params.size() > 0) { for (Iterator<String> iterator= params.iterator(); iterator.hasNext();) { String typeName= iterator.next(); jc.addImport(typeName); } } } else { super.resolve(variable, context); } }
Example 4
Source File: StaticImportResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void resolve(TemplateVariable variable, TemplateContext context) { variable.setUnambiguous(true); variable.setValue(""); //$NON-NLS-1$ if (context instanceof JavaContext) { JavaContext jc= (JavaContext) context; List<String> params= variable.getVariableType().getParams(); if (params.size() > 0) { for (Iterator<String> iterator= params.iterator(); iterator.hasNext();) { String qualifiedMemberName= iterator.next(); jc.addStaticImport(qualifiedMemberName); } } } else { super.resolve(variable, context); } }
Example 5
Source File: AbstractJavaContextType.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void resolve(TemplateVariable variable, TemplateContext context) { if (variable instanceof MultiVariable) { JavaContext jc= (JavaContext) context; JavaVariable jv= (JavaVariable) variable; Variable[] iterables= getVariables(jc); if (iterables.length > 0) { jv.setChoices(iterables); jc.markAsUsed(iterables[0].getName()); if (iterables.length > 1) variable.setUnambiguous(false); else variable.setUnambiguous(isUnambiguous(context)); return; } } super.resolve(variable, context); }
Example 6
Source File: AbstractTemplateVariableResolver.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void resolve(TemplateVariable variable, TemplateContext templateContext) { XtextTemplateContext castedContext = (XtextTemplateContext) templateContext; List<String> names = resolveValues(variable, castedContext); String[] bindings = names.toArray(new String[names.size()]); if (bindings.length != 0) variable.setValues(bindings); if (bindings.length > 1) variable.setUnambiguous(false); else variable.setUnambiguous(isUnambiguous(castedContext)); variable.setResolved(true); }
Example 7
Source File: EnvironmentVariableVariableResolver.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void resolve(TemplateVariable variable, TemplateContext context) { if (context instanceof DocumentSnippetTemplateContext) { DocumentSnippetTemplateContext documentSnippetTemplateContext = (DocumentSnippetTemplateContext) context; Template template = documentSnippetTemplateContext.getTemplate(); if (template instanceof SnippetTemplate) { SnippetTemplate snippetTemplate = (SnippetTemplate) template; CommandElement snippet = snippetTemplate.getCommandElement(); Map<String, String> environment = snippet.getEnvironment(); String name = variable.getName(); String value = environment.get(name); if (value == null) { if (!variable.getVariableType().getParams().isEmpty()) { String[] values = (String[]) variable.getVariableType().getParams().toArray(new String[0]); variable.setValues(values); variable.setUnambiguous(false); } else { super.resolve(variable, context); } } else { variable.setValues(new String[] { value }); } variable.setResolved(true); } } }
Example 8
Source File: LinkResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void resolve(TemplateVariable variable, TemplateContext context) { variable.setUnambiguous(false); if (variable instanceof JavaVariable) { JavaContext jc= (JavaContext) context; JavaVariable jv= (JavaVariable) variable; List<String> params= variable.getVariableType().getParams(); if (params.size() > 0) { fProposals= new String[params.size()]; int i= 0; for (Iterator<String> iterator= params.iterator(); iterator.hasNext();) { String param= iterator.next(); fProposals[i]= param; i++; } jv.setChoices(fProposals); jv.setCurrentChoice(fProposals[0]); jc.markAsUsed(jv.getDefaultValue()); } else { fProposals= new String[] { variable.getDefaultValue() }; super.resolve(variable, context); return; } } else super.resolve(variable, context); }
Example 9
Source File: AbstractJavaContextType.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void resolve(TemplateVariable variable, TemplateContext context) { if (variable instanceof MultiVariable) { JavaContext jc= (JavaContext) context; MultiVariable mv= (MultiVariable) variable; Variable[] iterables= getVariablesInContextScope(jc); if (iterables.length > 0) { for (int i= 0; i < iterables.length; i++) mv.setChoices(iterables[i], iterables[i].getMemberTypeNames()); TemplateVariable master= jc.getTemplateVariable(fMasterName); if (master instanceof MultiVariable) { final MultiVariable masterMv= (MultiVariable) master; jc.addDependency(masterMv, mv); mv.setKey(masterMv.getCurrentChoice()); } if (iterables.length > 1 || iterables.length == 1 && mv.getChoices().length > 1) variable.setUnambiguous(false); else variable.setUnambiguous(isUnambiguous(context)); return; } } super.resolve(variable, context); }
Example 10
Source File: AbstractJavaContextType.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void resolve(TemplateVariable variable, TemplateContext context) { if (variable instanceof MultiVariable) { JavaContext jc= (JavaContext) context; MultiVariable mv= (MultiVariable) variable; Variable[] iterables= getLocalVariables(jc); if (iterables.length > 0) { for (int i= 0; i < iterables.length; i++) { String[] elements= jc.suggestVariableNames(iterables[i].getMemberTypeNames()[0]); mv.setChoices(iterables[i], elements); } TemplateVariable master= jc.getTemplateVariable(fMasterName); if (master instanceof MultiVariable) { final MultiVariable masterMv= (MultiVariable) master; jc.addDependency(masterMv, mv); mv.setKey(masterMv.getCurrentChoice()); } jc.markAsUsed(mv.getDefaultValue()); if (iterables.length > 1 || iterables.length == 1 && mv.getChoices().length > 1) variable.setUnambiguous(false); else variable.setUnambiguous(isUnambiguous(context)); return; } } super.resolve(variable, context); }
Example 11
Source File: AbstractVariableResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void resolve(TemplateVariable variable, TemplateContext context) { if (variable instanceof JavaVariable) { JavaContext jc= (JavaContext) context; JavaVariable jv= (JavaVariable) variable; List<String> params= variable.getVariableType().getParams(); if (params.size() == 0) { fVariables= getVisibleVariables(fDefaultType, jc); jv.setParamType(fDefaultType); } else if (params.size() == 1) { String type= params.get(0); fVariables= getVisibleVariables(type, jc); jv.setParamType(type); } else { ArrayList<Variable> variables= new ArrayList<Variable>(); for (Iterator<String> iterator= params.iterator(); iterator.hasNext();) { variables.addAll(Arrays.asList(getVisibleVariables(iterator.next(), jc))); } fVariables= variables.toArray(new Variable[variables.size()]); //set to default type, a template which references to the type //of _the_ parameter will not correctly work anyway jv.setParamType(fDefaultType); } if (fVariables.length > 0) { jv.setChoices(fVariables); jc.markAsUsed(jv.getDefaultValue()); } else { super.resolve(variable, context); return; } if (fVariables.length > 1) variable.setUnambiguous(false); else variable.setUnambiguous(isUnambiguous(context)); } else super.resolve(variable, context); }