当前位置: 首页>>代码示例>>Java>>正文


Java JavaConventions.validateIdentifier方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.JavaConventions.validateIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Java JavaConventions.validateIdentifier方法的具体用法?Java JavaConventions.validateIdentifier怎么用?Java JavaConventions.validateIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.JavaConventions的用法示例。


在下文中一共展示了JavaConventions.validateIdentifier方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateIdentifiers

import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private IStatus validateIdentifiers(String[] values, boolean prefix) {
	for (int i= 0; i < values.length; i++) {
		String val= values[i];
		if (val.length() == 0) {
			if (prefix) {
				return new StatusInfo(IStatus.ERROR, PreferencesMessages.NameConventionConfigurationBlock_error_emptyprefix);
			} else {
				return new StatusInfo(IStatus.ERROR, PreferencesMessages.NameConventionConfigurationBlock_error_emptysuffix);
			}
		}
		String name= prefix ? val + "x" : "x" + val; //$NON-NLS-2$ //$NON-NLS-1$
		IStatus status= JavaConventions.validateIdentifier(name, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
		if (status.matches(IStatus.ERROR)) {
			if (prefix) {
				return new StatusInfo(IStatus.ERROR, Messages.format(PreferencesMessages.NameConventionConfigurationBlock_error_invalidprefix, val));
			} else {
				return new StatusInfo(IStatus.ERROR, Messages.format(PreferencesMessages.NameConventionConfigurationBlock_error_invalidsuffix, val));
			}
		}
	}
	return new StatusInfo();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:NameConventionConfigurationBlock.java

示例2: isFieldStringValueValid

import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private boolean isFieldStringValueValid(String value) {
    IStatus status = JavaConventions.validateIdentifier(value);
    if (status.isOK()) {
        return true;
    }
    setErrorMessage(status.getMessage());
    setValid(false);
    return false;
}
 
开发者ID:maximeAudrain,项目名称:jenerate,代码行数:10,代码来源:JenerateBasePreferencePage.java

示例3: updateModel

import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
protected final void updateModel(DialogField field) {
	if (field == fNameConventionList) {
		for (int i= 0; i < fNameConventionList.getSize(); i++) {
			NameConventionEntry entry= fNameConventionList.getElement(i);
			setValue(entry.suffixkey, entry.suffix);
			setValue(entry.prefixkey, entry.prefix);
		}
	} else if (field == fExceptionName) {
		String name= fExceptionName.getText();

		setValue(PREF_EXCEPTION_NAME, name);

		// validation
		IStatus status = JavaConventions.validateIdentifier(name, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
		if (!status.isOK()) {
			fContext.statusChanged(status);
		} else {
			fContext.statusChanged(new StatusInfo());
		}
	} else if (field == fUseKeywordThisBox) {
		setValue(PREF_KEYWORD_THIS, fUseKeywordThisBox.isSelected());
	} else if (field == fUseIsForBooleanGettersBox) {
		setValue(PREF_IS_FOR_GETTERS, fUseIsForBooleanGettersBox.isSelected());
	} else if (field == fUseOverrideAnnotation) {
		setValue(PREF_USE_OVERRIDE_ANNOT, fUseOverrideAnnotation.isSelected());
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:NameConventionConfigurationBlock.java

示例4: validateRefactoring

import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
protected void validateRefactoring() {
	List<String> names= new ArrayList<String>();
	boolean oneChecked= false;
	setMessage(null);
	setErrorMessage(null);
	setPageComplete(true);
	IJavaProject project= fProcessor.getMethod().getJavaProject();
	String sourceLevel= project.getOption(JavaCore.COMPILER_SOURCE, true);
	String compliance= project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
	List<ParameterInfo> parameterInfos= fProcessor.getParameterInfos();
	for (Iterator<ParameterInfo> iter= parameterInfos.iterator(); iter.hasNext();) {
		ParameterInfo pi= iter.next();
		if (names.contains(pi.getNewName())) {
			setErrorMessage(Messages.format(RefactoringMessages.IntroduceParameterObjectWizard_parametername_check_notunique, BasicElementLabels.getJavaElementName(pi.getNewName())));
			setPageComplete(false);
			return;
		}
		names.add(pi.getNewName());
		IStatus validateIdentifier= JavaConventions.validateIdentifier(pi.getNewName(), sourceLevel, compliance);
		if (isErrorMessage(validateIdentifier))
			return;
		if (pi.isCreateField())
			oneChecked= true;
	}
	if (!oneChecked) {
		setErrorMessage(RefactoringMessages.IntroduceParameterObjectWizard_parametername_check_atleastoneparameter);
		setPageComplete(false);
		return;
	}
	IStatus validateJavaTypeName= JavaConventions.validateJavaTypeName(fProcessor.getClassName(), sourceLevel, compliance);
	if (isErrorMessage(validateJavaTypeName))
		return;
	if (fProcessor.getClassName().indexOf('.') != -1) {
		setErrorMessage(RefactoringMessages.IntroduceParameterObjectWizard_dot_not_allowed_error);
		setPageComplete(false);
	}
	if (!"".equals(fProcessor.getPackage())) { //$NON-NLS-1$
		IStatus validatePackageName= JavaConventions.validatePackageName(fProcessor.getPackage(), sourceLevel, compliance);
		if (isErrorMessage(validatePackageName))
			return;
	}
	try {
		IType type= project.findType(fProcessor.getNewTypeName());
		if (type != null) {
			String packageLabel= JavaElementLabels.getElementLabel(type.getPackageFragment(), JavaElementLabels.ALL_DEFAULT);
			if (fProcessor.isCreateAsTopLevel()) {
				setErrorMessage(Messages.format(RefactoringMessages.IntroduceParameterObjectWizard_type_already_exists_in_package_info,
						new Object[] { BasicElementLabels.getJavaElementName(fProcessor.getClassName()), packageLabel }));
				setPageComplete(false);
				return;
			} else {
				setErrorMessage(Messages.format(RefactoringMessages.IntroduceParameterObjectWizard_parametername_check_alreadyexists,
						new Object[] { BasicElementLabels.getJavaElementName(fProcessor.getClassName()), BasicElementLabels.getFileName(type.getCompilationUnit()) }));
				setPageComplete(false);
				return;
			}
		}
	} catch (JavaModelException e) {
		// Don't care. The error will popup later anyway..
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:62,代码来源:IntroduceParameterObjectWizard.java

示例5: validateIdentifier

import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
 * @param name
 *            the name to validate
 * @param context
 *            an {@link IJavaElement} or <code>null</code>
 * @return validation status in <code>context</code>'s project or in the
 *         workspace
 *
 * @see JavaConventions#validateIdentifier(String, String, String)
 */
public static IStatus validateIdentifier(String name, IJavaElement context) {
	String[] sourceComplianceLevels = getSourceComplianceLevels(context);
	return JavaConventions.validateIdentifier(name, sourceComplianceLevels[0], sourceComplianceLevels[1]);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:15,代码来源:JavaConventionsUtil.java

示例6: validateIdentifier

import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
 * @param name the name to validate
 * @param context an {@link IJavaElement} or <code>null</code>
 * @return validation status in <code>context</code>'s project or in the workspace
 * @see JavaConventions#validateIdentifier(String, String, String)
 */
public static IStatus validateIdentifier(String name, IJavaElement context) {
  String[] sourceComplianceLevels = getSourceComplianceLevels(context);
  return JavaConventions.validateIdentifier(
      name, sourceComplianceLevels[0], sourceComplianceLevels[1]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:JavaConventionsUtil.java

示例7: validateIdentifier

import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
 * @param name the name to validate
 * @param context an {@link IJavaElement} or <code>null</code>
 * @return validation status in <code>context</code>'s project or in the workspace
 *
 * @see JavaConventions#validateIdentifier(String, String, String)
 */
public static IStatus validateIdentifier(String name, IJavaElement context) {
	String[] sourceComplianceLevels= getSourceComplianceLevels(context);
	return JavaConventions.validateIdentifier(name, sourceComplianceLevels[0], sourceComplianceLevels[1]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:JavaConventionsUtil.java


注:本文中的org.eclipse.jdt.core.JavaConventions.validateIdentifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。