org.eclipse.jdt.core.NamingConventions Java Examples

The following examples show how to use org.eclipse.jdt.core.NamingConventions. 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: StubUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static String[][] suggestArgumentNamesWithProposals(IJavaProject project, String[] paramNames) {
	String[][] newNames= new String[paramNames.length][];
	ArrayList<String> takenNames= new ArrayList<String>();

	// Ensure that the code generation preferences are respected
	for (int i= 0; i < paramNames.length; i++) {
		String curr= paramNames[i];
		String baseName= NamingConventions.getBaseName(NamingConventions.VK_PARAMETER, curr, project);

		String[] proposedNames= getVariableNameSuggestions(NamingConventions.VK_PARAMETER, project, curr, 0, takenNames, true);
		if (!curr.equals(baseName)) {
			// make the existing name to favorite
			LinkedHashSet<String> updatedNames= new LinkedHashSet<String>();
			updatedNames.add(curr);
			for (int k= 0; k < proposedNames.length; k++) {
				updatedNames.add(proposedNames[k]);
			}
			proposedNames= updatedNames.toArray(new String[updatedNames.size()]);
		}
		newNames[i]= proposedNames;
		takenNames.add(proposedNames[0]);
	}
	return newNames;
}
 
Example #2
Source File: ExtractConstantRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return proposed variable names (may be empty, but not null).
 * The first proposal should be used as "best guess" (if it exists).
 */
public String[] guessConstantNames() {
	if (fGuessedConstNames == null) {
		try {
			Expression expression= getSelectedExpression().getAssociatedExpression();
			if (expression != null) {
				ITypeBinding binding= guessBindingForReference(expression);
				fGuessedConstNames= StubUtility.getVariableNameSuggestions(NamingConventions.VK_STATIC_FINAL_FIELD, fCu.getJavaProject(), binding, expression, Arrays.asList(getExcludedVariableNames()));
			}
		} catch (JavaModelException e) {
		}
		if (fGuessedConstNames == null)
			fGuessedConstNames= new String[0];
	}
	return fGuessedConstNames;
}
 
Example #3
Source File: ExtractTempRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return proposed variable names (may be empty, but not null). The first proposal should be used as "best guess" (if it exists).
 */
public String[] guessTempNames() {
	if (fGuessedTempNames == null) {
		try {
			Expression expression= getSelectedExpression().getAssociatedExpression();
			if (expression != null) {
				ITypeBinding binding= guessBindingForReference(expression);
				fGuessedTempNames= StubUtility.getVariableNameSuggestions(NamingConventions.VK_LOCAL, fCu.getJavaProject(), binding, expression, Arrays.asList(getExcludedVariableNames()));
			}
		} catch (JavaModelException e) {
		}
		if (fGuessedTempNames == null)
			fGuessedTempNames= new String[0];
	}
	return fGuessedTempNames;
}
 
Example #4
Source File: AbstractToStringGenerator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This method initializes all variables used in the process of generating <code>toString</code>
 * method.
 */
protected void initialize() {
	needMaxLenVariable= false;
	needCollectionToStringMethod= false;
	typesThatNeedArrayToStringMethod= new ArrayList<ITypeBinding>();

	checkNeedForHelperMethods();

	toStringMethod= fAst.newMethodDeclaration();
	toStringMethod.modifiers().addAll(ASTNodeFactory.newModifiers(fAst, Modifier.PUBLIC));
	toStringMethod.setName(fAst.newSimpleName(METHODNAME_TO_STRING));
	toStringMethod.setConstructor(false);
	toStringMethod.setReturnType2(fAst.newSimpleType(fAst.newName(TYPENAME_STRING)));

	Block body= fAst.newBlock();
	toStringMethod.setBody(body);
	
	fMaxLenVariableName= createNameSuggestion(MAX_LEN_VARIABLE_NAME, NamingConventions.VK_LOCAL);
}
 
Example #5
Source File: ExtractClassRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public ExtractClassRefactoring(ExtractClassDescriptor descriptor) {
	fDescriptor= descriptor;
	IType type= fDescriptor.getType();
	if (fDescriptor.getPackage() == null) {
		fDescriptor.setPackage(type.getPackageFragment().getElementName());
	}
	if (fDescriptor.getClassName() == null) {
		fDescriptor.setClassName(type.getElementName() + "Data"); //$NON-NLS-1$
	}
	if (fDescriptor.getFieldName() == null) {
		fDescriptor.setFieldName(StubUtility.getVariableNameSuggestions(NamingConventions.VK_INSTANCE_FIELD, type.getJavaProject(), "data", 0, null, true)[0]); //$NON-NLS-1$
	}
	if (fDescriptor.getFields() == null) {
		try {
			fDescriptor.setFields(ExtractClassDescriptor.getFields(type));
		} catch (JavaModelException e) {
			JavaPlugin.log(e);
		}
	}
	fVerification= new ExtractClassDescriptorVerification(descriptor);
}
 
Example #6
Source File: ExtractConstantRefactoring.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @return proposed variable names (may be empty, but not null). The first
 *         proposal should be used as "best guess" (if it exists).
 */
public String[] guessConstantNames() {
	if (fGuessedConstNames == null) {
		try {
			Expression expression = getSelectedExpression().getAssociatedExpression();
			if (expression != null) {
				ITypeBinding binding = guessBindingForReference(expression);
				fGuessedConstNames = StubUtility.getVariableNameSuggestions(NamingConventions.VK_STATIC_FINAL_FIELD, fCu.getJavaProject(), binding, expression, Arrays.asList(getExcludedVariableNames()));
			}
		} catch (JavaModelException e) {
		}
		if (fGuessedConstNames == null) {
			fGuessedConstNames = new String[0];
		}
	}
	return fGuessedConstNames;
}
 
Example #7
Source File: ExtractTempRefactoring.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @return proposed variable names (may be empty, but not null). The first
 *         proposal should be used as "best guess" (if it exists).
 */
public String[] guessTempNames() {
	if (fGuessedTempNames == null) {
		try {
			Expression expression = getSelectedExpression().getAssociatedExpression();
			if (expression != null) {
				ITypeBinding binding = guessBindingForReference(expression);
				fGuessedTempNames = StubUtility.getVariableNameSuggestions(NamingConventions.VK_LOCAL, fCu.getJavaProject(), binding, expression, Arrays.asList(getExcludedVariableNames()));
			}
		} catch (JavaModelException e) {
		}
		if (fGuessedTempNames == null) {
			fGuessedTempNames = new String[0];
		}
	}
	return fGuessedTempNames;
}
 
Example #8
Source File: JavaStatementPostfixContext.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public String[] suggestFieldName(String type, String[] excludes, boolean staticField, boolean finalField) throws IllegalArgumentException {
	int dim = 0;
	while (type.endsWith("[]")) {
		dim++;
		type = type.substring(0, type.length() - 2);
	}

	IJavaProject project = getJavaProject();
	
	int namingConventions = 0;
	if (staticField && finalField) {
		namingConventions = NamingConventions.VK_STATIC_FINAL_FIELD;
	} else if (staticField && !finalField) {
		namingConventions = NamingConventions.VK_STATIC_FIELD;
	} else {
		namingConventions = NamingConventions.VK_INSTANCE_FIELD;
	}
	
	if (project != null)
		return StubUtility.getVariableNameSuggestions(namingConventions, project, type, dim, Arrays.asList(excludes), true);

	return new String[] {Signature.getSimpleName(type).toLowerCase()};
}
 
Example #9
Source File: StubUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static int getFieldKind(int modifiers) {
	if (!Modifier.isStatic(modifiers))
		return NamingConventions.VK_INSTANCE_FIELD;

	if (!Modifier.isFinal(modifiers))
		return NamingConventions.VK_STATIC_FIELD;

	return NamingConventions.VK_STATIC_FINAL_FIELD;
}
 
Example #10
Source File: StubUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the kind of the given binding.
 * 
 * @param binding variable binding
 * @return one of the <code>NamingConventions.VK_*</code> constants
 * @since 3.5
 */
private static int getKind(IVariableBinding binding) {
	if (binding.isField())
		return getFieldKind(binding.getModifiers());

	if (binding.isParameter())
		return NamingConventions.VK_PARAMETER;

	return NamingConventions.VK_LOCAL;
}
 
Example #11
Source File: StubUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static String[] suggestArgumentNames(IJavaProject project, IMethodBinding binding) {
	int nParams= binding.getParameterTypes().length;

	if (nParams > 0) {
		try {
			IMethod method= (IMethod)binding.getMethodDeclaration().getJavaElement();
			if (method != null) {
				String[] paramNames= method.getParameterNames();
				if (paramNames.length == nParams) {
					String[] namesArray= EMPTY;
					ArrayList<String> newNames= new ArrayList<String>(paramNames.length);
					// Ensure that the code generation preferences are respected
					for (int i= 0; i < paramNames.length; i++) {
						String curr= paramNames[i];
						String baseName= NamingConventions.getBaseName(NamingConventions.VK_PARAMETER, curr, method.getJavaProject());
						if (!curr.equals(baseName)) {
							// make the existing name the favorite
							newNames.add(curr);
						} else {
							newNames.add(suggestArgumentName(project, curr, namesArray));
						}
						namesArray= newNames.toArray(new String[newNames.size()]);
					}
					return namesArray;
				}
			}
		} catch (JavaModelException e) {
			// ignore
		}
	}
	String[] names= new String[nParams];
	for (int i= 0; i < names.length; i++) {
		names[i]= "arg" + i; //$NON-NLS-1$
	}
	return names;
}
 
Example #12
Source File: JdtVariableCompletions.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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:
			throw new IllegalStateException("unhandled enum const"+varType);
	}
}
 
Example #13
Source File: StubUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static String[] getFieldNameSuggestions(IJavaProject project, String baseName, int dimensions, int modifiers, String[] excluded) {
	if (Flags.isFinal(modifiers) && Flags.isStatic(modifiers)) {
		return getVariableNameSuggestions(NamingConventions.VK_STATIC_FINAL_FIELD, project, baseName, dimensions, new ExcludedCollection(excluded), true);
	} else if (Flags.isStatic(modifiers)) {
		return getVariableNameSuggestions(NamingConventions.VK_STATIC_FIELD, project, baseName, dimensions, new ExcludedCollection(excluded), true);
	}
	return getVariableNameSuggestions(NamingConventions.VK_INSTANCE_FIELD, project, baseName, dimensions, new ExcludedCollection(excluded), true);
}
 
Example #14
Source File: StubUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static String getBaseNameFromLocationInParent(Expression assignedExpression, List<Expression> arguments, IMethodBinding binding) {
	if (binding == null)
		return null;

	ITypeBinding[] parameterTypes= binding.getParameterTypes();
	if (parameterTypes.length != arguments.size()) // beware of guessed method bindings
		return null;

	int index= arguments.indexOf(assignedExpression);
	if (index == -1)
		return null;

	ITypeBinding expressionBinding= assignedExpression.resolveTypeBinding();
	if (expressionBinding != null && !expressionBinding.isAssignmentCompatible(parameterTypes[index]))
		return null;

	try {
		IJavaElement javaElement= binding.getJavaElement();
		if (javaElement instanceof IMethod) {
			IMethod method= (IMethod)javaElement;
			if (method.getOpenable().getBuffer() != null) { // avoid dummy names and lookup from Javadoc
				String[] parameterNames= method.getParameterNames();
				if (index < parameterNames.length) {
					return NamingConventions.getBaseName(NamingConventions.VK_PARAMETER, parameterNames[index], method.getJavaProject());
				}
			}
		}
	} catch (JavaModelException e) {
		// ignore
	}
	return null;
}
 
Example #15
Source File: StubUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static String[] getDefaultVariableNameSuggestions(int variableKind, Collection<String> excluded) {
	String prop= variableKind == NamingConventions.VK_STATIC_FINAL_FIELD ? "X" : "x"; //$NON-NLS-1$//$NON-NLS-2$
	String name= prop;
	int i= 1;
	while (excluded.contains(name)) {
		name= prop + i++;
	}
	return new String[] { name };
}
 
Example #16
Source File: NewMethodCorrectionProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private String evaluateParameterName(List<String> takenNames, Expression argNode, Type type, String key) {
	IJavaProject project= getCompilationUnit().getJavaProject();
	String[] names= StubUtility.getVariableNameSuggestions(NamingConventions.VK_PARAMETER, project, type, argNode, takenNames);
	for (int i= 0; i < names.length; i++) {
		addLinkedPositionProposal(key, names[i], null);
	}
	String favourite= names[0];
	takenNames.add(favourite);
	return favourite;
}
 
Example #17
Source File: StringBuilderGenerator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void initialize() {
	super.initialize();
	fBuilderVariableName= createNameSuggestion(getContext().is50orHigher() ? "builder" : "buffer", NamingConventions.VK_LOCAL); //$NON-NLS-1$ //$NON-NLS-2$
	fBuffer= new StringBuffer();
	VariableDeclarationFragment fragment= fAst.newVariableDeclarationFragment();
	fragment.setName(fAst.newSimpleName(fBuilderVariableName));
	ClassInstanceCreation classInstance= fAst.newClassInstanceCreation();
	Name typeName= addImport(getContext().is50orHigher() ? "java.lang.StringBuilder" : "java.lang.StringBuffer"); //$NON-NLS-1$ //$NON-NLS-2$
	classInstance.setType(fAst.newSimpleType(typeName));
	fragment.setInitializer(classInstance);
	VariableDeclarationStatement vStatement= fAst.newVariableDeclarationStatement(fragment);
	vStatement.setType(fAst.newSimpleType((Name)ASTNode.copySubtree(fAst, typeName)));
	toStringMethod.getBody().statements().add(vStatement);
}
 
Example #18
Source File: JavaContext.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private String[] suggestVariableName(String type, String[] excludes) throws IllegalArgumentException {
	int dim=0;
	while (type.endsWith("[]")) {//$NON-NLS-1$
		dim++;
		type= type.substring(0, type.length() - 2);
	}

	IJavaProject project= getJavaProject();
	if (project != null)
		return StubUtility.getVariableNameSuggestions(NamingConventions.VK_LOCAL, project, type, dim, Arrays.asList(excludes), true);

	// fallback if we lack proper context: roll-our own lowercasing
	return new String[] {Signature.getSimpleName(type).toLowerCase()};
}
 
Example #19
Source File: JdtVariableCompletions.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public String[] getVariableProposals(String simpleTypeName, boolean isPlural, EObject ctx, VariableType varType, Set<String> excludedNames) {
	if (!org.eclipse.xtext.util.Strings.isEmpty(simpleTypeName)) {
		IJavaProject javaProject = null;
		if (ctx != null && ctx.eResource() != null && ctx.eResource().getResourceSet() != null)
			javaProject = javaProjectProvider.getJavaProject(ctx.eResource().getResourceSet());
		return NamingConventions.suggestVariableNames(getVariableKind(varType),
				NamingConventions.BK_TYPE_NAME, simpleTypeName, javaProject, isPlural?1:0, excludedNames.toArray(new String[excludedNames.size()]), false);
	}
	return new String[0];
}
 
Example #20
Source File: ExtractFieldRefactoring.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @return proposed field names (may be empty, but not null). The first proposal
 *         should be used as "best guess" (if it exists).
 */
public String[] guessFieldNames() {
	if (fGuessedFieldNames == null) {
		try {
			Expression expression = getSelectedExpression().getAssociatedExpression();
			if (expression != null) {
				ITypeBinding binding = guessBindingForReference(expression);
				int modifiers = getModifiers();
				int variableKind;
				if (Flags.isFinal(modifiers) && Flags.isStatic(modifiers)) {
					variableKind = NamingConventions.VK_STATIC_FINAL_FIELD;
				} else if (Flags.isStatic(modifiers)) {
					variableKind = NamingConventions.VK_STATIC_FIELD;
				} else {
					variableKind = NamingConventions.VK_INSTANCE_FIELD;
				}

				fGuessedFieldNames = StubUtility.getVariableNameSuggestions(variableKind, fCu.getJavaProject(), binding, expression, Arrays.asList(getExcludedFieldNames()));
			}
		} catch (JavaModelException e) {
		}
		if (fGuessedFieldNames == null) {
			fGuessedFieldNames = new String[0];
		}
	}
	return fGuessedFieldNames;
}
 
Example #21
Source File: ParameterObjectFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private MethodDeclaration createSetter(ParameterInfo pi, String declaringType, CompilationUnitRewrite cuRewrite) throws CoreException {
	AST ast= cuRewrite.getAST();
	ICompilationUnit cu= cuRewrite.getCu();
	IJavaProject project= cu.getJavaProject();

	MethodDeclaration methodDeclaration= ast.newMethodDeclaration();
	String fieldName= pi.getNewName();
	String setterName= getSetterName(pi, ast, project);
	String lineDelim= StubUtility.getLineDelimiterUsed(cu);
	String bareFieldname= NamingConventions.getBaseName(NamingConventions.VK_INSTANCE_FIELD, fieldName, project);
	String paramName= StubUtility.suggestArgumentName(project, bareFieldname, null);
	if (createComments(project)) {
		String comment= CodeGeneration.getSetterComment(cu, declaringType, setterName, fieldName, pi.getNewTypeName(), paramName, bareFieldname, lineDelim);
		if (comment != null)
			methodDeclaration.setJavadoc((Javadoc) cuRewrite.getASTRewrite().createStringPlaceholder(comment, ASTNode.JAVADOC));
	}
	methodDeclaration.setName(ast.newSimpleName(setterName));
	methodDeclaration.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
	SingleVariableDeclaration variable= ast.newSingleVariableDeclaration();
	variable.setType(importBinding(pi.getNewTypeBinding(), cuRewrite));
	variable.setName(ast.newSimpleName(paramName));
	methodDeclaration.parameters().add(variable);
	Block block= ast.newBlock();
	methodDeclaration.setBody(block);
	boolean useThis= StubUtility.useThisForFieldAccess(project);
	if (useThis || fieldName.equals(paramName)) {
		fieldName= "this." + fieldName; //$NON-NLS-1$
	}
	String bodyContent= CodeGeneration.getSetterMethodBodyContent(cu, declaringType, setterName, fieldName, paramName, lineDelim);
	ASTNode setterBody= cuRewrite.getASTRewrite().createStringPlaceholder(bodyContent, ASTNode.EXPRESSION_STATEMENT);
	block.statements().add(setterBody);
	return methodDeclaration;
}
 
Example #22
Source File: ParameterObjectFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private MethodDeclaration createGetter(ParameterInfo pi, String declaringType, CompilationUnitRewrite cuRewrite) throws CoreException {
	AST ast= cuRewrite.getAST();
	ICompilationUnit cu= cuRewrite.getCu();
	IJavaProject project= cu.getJavaProject();

	MethodDeclaration methodDeclaration= ast.newMethodDeclaration();
	String fieldName= pi.getNewName();
	String getterName= getGetterName(pi, ast, project);
	String lineDelim= StubUtility.getLineDelimiterUsed(cu);
	String bareFieldname= NamingConventions.getBaseName(NamingConventions.VK_INSTANCE_FIELD, fieldName, project);
	if (createComments(project)) {
		String comment= CodeGeneration.getGetterComment(cu, declaringType, getterName, fieldName, pi.getNewTypeName(), bareFieldname, lineDelim);
		if (comment != null)
			methodDeclaration.setJavadoc((Javadoc) cuRewrite.getASTRewrite().createStringPlaceholder(comment, ASTNode.JAVADOC));
	}
	methodDeclaration.setName(ast.newSimpleName(getterName));
	methodDeclaration.setReturnType2(importBinding(pi.getNewTypeBinding(), cuRewrite));
	methodDeclaration.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
	Block block= ast.newBlock();
	methodDeclaration.setBody(block);
	boolean useThis= StubUtility.useThisForFieldAccess(project);
	if (useThis) {
		fieldName= "this." + fieldName; //$NON-NLS-1$
	}
	String bodyContent= CodeGeneration.getGetterMethodBodyContent(cu, declaringType, getterName, fieldName, lineDelim);
	ASTNode getterBody= cuRewrite.getASTRewrite().createStringPlaceholder(bodyContent, ASTNode.EXPRESSION_STATEMENT);
	block.statements().add(getterBody);
	return methodDeclaration;
}
 
Example #23
Source File: NewMethodCorrectionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private String evaluateParameterName(List<String> takenNames, Expression argNode, Type type, String key) {
	IJavaProject project= getCompilationUnit().getJavaProject();
	String[] names = StubUtility.getVariableNameSuggestions(NamingConventions.VK_PARAMETER, project, type, argNode,
			takenNames);
	String favourite= names[0];
	takenNames.add(favourite);
	return favourite;
}
 
Example #24
Source File: StubUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static String suggestArgumentName(IJavaProject project, String baseName, String[] excluded) {
	return suggestVariableName(NamingConventions.VK_PARAMETER, project, baseName, 0, excluded);
}
 
Example #25
Source File: AssignToVariableAssistProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private String[] suggestFieldNames(ITypeBinding binding, Expression expression, int modifiers) {
	IJavaProject project= getCompilationUnit().getJavaProject();
	int varKind= Modifier.isStatic(modifiers) ? NamingConventions.VK_STATIC_FIELD : NamingConventions.VK_INSTANCE_FIELD;
	return StubUtility.getVariableNameSuggestions(varKind, project, binding, expression, getUsedVariableNames());
}
 
Example #26
Source File: AssignToVariableAssistProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private String[] suggestLocalVariableNames(ITypeBinding binding, Expression expression) {
	IJavaProject project= getCompilationUnit().getJavaProject();
	return StubUtility.getVariableNameSuggestions(NamingConventions.VK_LOCAL, project, binding, expression, getUsedVariableNames());
}
 
Example #27
Source File: AdvancedQuickAssistProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private static String[] suggestLocalVariableNames(ICompilationUnit cu, ITypeBinding binding, List<String> excluded) {
	return StubUtility.getVariableNameSuggestions(NamingConventions.VK_LOCAL, cu.getJavaProject(), binding, null, excluded);
}
 
Example #28
Source File: GetterSetterUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static String getSetterName(IJavaProject project, String fieldName, int flags, boolean isBoolean, String[] excludedNames){
	boolean useIs= StubUtility.useIsForBooleanGetters(project);
	return NamingConventions.suggestSetterName(project, fieldName, flags, useIs && isBoolean, excludedNames);
}
 
Example #29
Source File: GetterSetterUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static String getGetterName(IJavaProject project, String fieldName, int flags, boolean isBoolean, String[] excludedNames){
	return NamingConventions.suggestGetterName(project, fieldName, flags, isBoolean, excludedNames);
}
 
Example #30
Source File: AssignToVariableAssistProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
private String[] suggestLocalVariableNames(ITypeBinding binding, Expression expression) {
	IJavaProject project= getCompilationUnit().getJavaProject();
	return StubUtility.getVariableNameSuggestions(NamingConventions.VK_LOCAL, project, binding, expression, getUsedVariableNames(fNodesToAssign.get(0)));
}