List of usage examples for org.eclipse.jdt.core NamingConventions VK_LOCAL
int VK_LOCAL
To view the source code for org.eclipse.jdt.core NamingConventions VK_LOCAL.
Click Source Link
From source file:org.codehaus.groovy.eclipse.refactoring.core.convert.AssignStatementToNewLocalRefactoring.java
License:Apache License
private TextEdit createEdit(IDocument doc, Expression expression) { TextEdit edit = new MultiTextEdit(); String candidate;// w ww. j a va 2 s .c o m if (expression instanceof ConstantExpression) { candidate = ((ConstantExpression) expression).getText(); } else if (expression instanceof VariableExpression) { candidate = ((VariableExpression) expression).getName(); } else if (expression instanceof ClassExpression) { candidate = ((ClassExpression) expression).getType().getNameWithoutPackage(); } else if (expression instanceof MethodCallExpression) { candidate = ((MethodCallExpression) expression).getMethodAsString(); } else if (expression instanceof StaticMethodCallExpression) { candidate = ((StaticMethodCallExpression) expression).getMethod(); } else if (expression instanceof MapExpression) { candidate = "map"; } else if (expression instanceof ListExpression) { candidate = "list"; } else { candidate = "temp"; } Set<Variable> vars = ASTTools.getVariablesInScope(unit.getModuleNode(), expression); String[] variableNames = new String[vars.size()]; int i = 0; for (Variable v : vars) { variableNames[i] = v.getName(); i++; } String[] names = NamingConventions.suggestVariableNames(NamingConventions.VK_LOCAL, NamingConventions.BK_NAME, candidate, null, 0, variableNames, true); edit.addChild(new InsertEdit(expression.getStart(), "def " + names[0] + " = ")); // add 4 for "def ". newOffset = expression.getStart() + 4; newLength = names[0].length(); return edit; }
From source file:org.codehaus.groovy.eclipse.refactoring.core.extract.ExtractGroovyLocalRefactoring.java
License:Apache License
public String[] guessLocalNames() { String text = getBaseNameFromExpression(getSelectedFragment()); return NamingConventions.suggestVariableNames(NamingConventions.VK_LOCAL, NamingConventions.BK_NAME, text, unit.getJavaProject(), 0, null, true); }
From source file:org.eclipse.xtext.common.types.xtext.ui.JdtVariableCompletions.java
License:Open Source License
protected int getVariableKind(VariableType varType) { switch (varType) { case INSTANCE_FIELD: return NamingConventions.VK_INSTANCE_FIELD; case LOCAL_VAR: return NamingConventions.VK_LOCAL; case PARAMETER: return NamingConventions.VK_PARAMETER; case STATIC_FIELD: return NamingConventions.VK_STATIC_FINAL_FIELD; default://from w w w. j a v a2s. com throw new IllegalStateException("unhandled enum const" + varType); } }