本文整理汇总了Java中org.eclipse.jdt.core.JavaConventions.validateJavaTypeName方法的典型用法代码示例。如果您正苦于以下问题:Java JavaConventions.validateJavaTypeName方法的具体用法?Java JavaConventions.validateJavaTypeName怎么用?Java JavaConventions.validateJavaTypeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.JavaConventions
的用法示例。
在下文中一共展示了JavaConventions.validateJavaTypeName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateSimpleModuleName
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
* Validates a simple module name. The name should be a camel-cased valid Java identifier.
*
* @param simpleName the simple module name
* @return a status object with code <code>IStatus.OK</code> if the given name is valid, otherwise
* a status object indicating what is wrong with the name
*/
public static IStatus validateSimpleModuleName(String simpleName) {
String complianceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.compliance");
String sourceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.source");
// Make sure that the simple name does not have any dots in it. We need
// to do this validation before passing the simpleName to JavaConventions,
// because validateTypeName accepts both simple and fully-qualified type
// names.
if (simpleName.indexOf('.') != -1) {
return Util.newErrorStatus("Module name should not contain dots.");
}
// Validate the module name according to Java type name conventions
IStatus nameStatus = JavaConventions.validateJavaTypeName(simpleName, complianceLevel, sourceLevel);
if (nameStatus.matches(IStatus.ERROR)) {
return Util.newErrorStatus("The module name is invalid");
}
return Status.OK_STATUS;
}
示例2: doValidation
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
* Validates the entered type or member and updates the status.
*/
private void doValidation() {
StatusInfo status= new StatusInfo();
String newText= fNameDialogField.getText();
if (newText.length() == 0) {
status.setError(""); //$NON-NLS-1$
} else {
IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
if (val.matches(IStatus.ERROR)) {
if (fIsEditingMember)
status.setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_invalidMemberName);
else
status.setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_invalidTypeName);
} else {
if (doesExist(newText)) {
status.setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_entryExists);
}
}
}
updateStatus(status);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:ExpandWithConstructorsConfigurationBlock.java
示例3: doValidation
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private void doValidation() {
StatusInfo status= new StatusInfo();
String newText= fNameDialogField.getText();
if (newText.length() == 0) {
status.setError(""); //$NON-NLS-1$
} else {
IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
if (val.matches(IStatus.ERROR)) {
if (fIsEditingMember)
status.setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_invalidMemberName);
else
status.setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_invalidTypeName);
} else {
if (doesExist(newText)) {
status.setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_entryExists);
}
}
}
updateStatus(status);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:CodeAssistFavoritesConfigurationBlock.java
示例4: doValidation
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private void doValidation() {
StatusInfo status= new StatusInfo();
String newText= fNameDialogField.getText();
if (newText.length() == 0) {
status.setError(""); //$NON-NLS-1$
} else {
if (newText.equals("*")) { //$NON-NLS-1$
if (doesExist("", fIsStatic)) { //$NON-NLS-1$
status.setError(PreferencesMessages.ImportOrganizeInputDialog_error_entryExists);
}
} else {
IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
if (val.matches(IStatus.ERROR)) {
status.setError(PreferencesMessages.ImportOrganizeInputDialog_error_invalidName);
} else {
if (doesExist(newText, fIsStatic)) {
status.setError(PreferencesMessages.ImportOrganizeInputDialog_error_entryExists);
}
}
}
}
updateStatus(status);
}
示例5: validate
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private void validate() {
if (projectData.packageName.trim().isEmpty()) {
setErrorMessage("Package name must not be empty");
setPageComplete(false);
return;
}
IStatus validPackageName = JavaConventions.validatePackageName(projectData.packageName, "1.5", "1.5");
if (!validPackageName.isOK()) {
setErrorMessage("Package name is invalid");
setPageComplete(false);
return;
}
if (projectData.androidSelected) {
String androidValidation = validateAndroidPackageName(projectData.packageName);
if (androidValidation != null) {
setErrorMessage(androidValidation);
setPageComplete(false);
return;
}
}
if (projectData.mainClassName.trim().isEmpty()) {
setErrorMessage("Main class name must not be empty");
setPageComplete(false);
return;
}
IStatus validClassName = JavaConventions.validateJavaTypeName(projectData.mainClassName, "1.5", "1.5");
if (!validClassName.isOK()) {
setErrorMessage("Main class name is invalid");
setPageComplete(false);
return;
}
setErrorMessage(null);
setPageComplete(true);
}
示例6: validate
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private void validate() {
if (projectData.packageName.trim().isEmpty()) {
setErrorMessage("Package name must not be empty");
setPageComplete(false);
return;
}
IStatus validPackageName = JavaConventions.validatePackageName(projectData.packageName, "1.5", "1.5");
if (!validPackageName.isOK()) {
setErrorMessage("Package name is invalid");
setPageComplete(false);
return;
}
if (projectData.mainClassName.trim().isEmpty()) {
setErrorMessage("Main class name must not be empty");
setPageComplete(false);
return;
}
IStatus validClassName = JavaConventions.validateJavaTypeName(projectData.mainClassName, "1.5", "1.5");
if (!validClassName.isOK()) {
setErrorMessage("Main class name is invalid");
setPageComplete(false);
return;
}
setErrorMessage(null);
setPageComplete(true);
}
示例7: 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
示例8: validateJavaTypeName
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
private static IStatus validateJavaTypeName(String text, IJavaProject project) {
if (project == null || !project.exists()) {
return JavaConventions.validateJavaTypeName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
}
return JavaConventionsUtil.validateJavaTypeName(text, project);
}
示例9: validate
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
@Override
public IStatus validate(final String input) {
return JavaConventions.validateJavaTypeName(input, TypeTextValidator.JAVA_VERSION,
TypeTextValidator.JAVA_VERSION);
}
示例10: validateJavaTypeName
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#validateJavaTypeName(String, String, String)
*/
public static IStatus validateJavaTypeName(String name, IJavaElement context) {
String[] sourceComplianceLevels = getSourceComplianceLevels(context);
return JavaConventions.validateJavaTypeName(name, sourceComplianceLevels[0], sourceComplianceLevels[1]);
}
示例11: validateJavaTypeName
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#validateJavaTypeName(String, String, String)
*/
public static IStatus validateJavaTypeName(String name, IJavaElement context) {
String[] sourceComplianceLevels = getSourceComplianceLevels(context);
return JavaConventions.validateJavaTypeName(
name, sourceComplianceLevels[0], sourceComplianceLevels[1]);
}
示例12: validateJavaTypeName
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#validateJavaTypeName(String, String, String)
*/
public static IStatus validateJavaTypeName(String name, IJavaElement context) {
String[] sourceComplianceLevels= getSourceComplianceLevels(context);
return JavaConventions.validateJavaTypeName(name, sourceComplianceLevels[0], sourceComplianceLevels[1]);
}
示例13: validateClassFileName
import org.eclipse.jdt.core.JavaConventions; //导入方法依赖的package包/类
/**
* @param name
* @param context
* @return a status indicating whether the supplied class name is valid for
* the supplied Java element
*/
public static IStatus validateClassFileName(String name, IJavaElement context) {
String[] sourceComplianceLevels = getSourceComplianceLevels(context);
return JavaConventions.validateJavaTypeName(name, sourceComplianceLevels[0],
sourceComplianceLevels[1]);
}