• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JavaConventions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: validate

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
/**
 * Check if a string is a legal Java package name.
 */
public static IStatus validate(String packageName) {
  if (packageName == null) {
    return new Status(IStatus.ERROR, PLUGIN_ID, 45, "null package name", null);
  } else if (packageName.isEmpty()) { // default package is allowed
    return Status.OK_STATUS;
  } else if (packageName.endsWith(".")) { //$NON-NLS-1$
    // todo or allow this and strip the period
    return new Status(IStatus.ERROR, PLUGIN_ID, 46, 
        Messages.getString("package.ends.with.period", packageName), null); //$NON-NLS-1$
  } else if (containsWhitespace(packageName)) {
    // very weird condition because validatePackageName allows internal white space
    return new Status(IStatus.ERROR, PLUGIN_ID, 46, 
        Messages.getString("package.contains.whitespace", packageName), null); //$NON-NLS-1$
  } else {
    return JavaConventions.validatePackageName(
        packageName, JavaCore.VERSION_1_4, JavaCore.VERSION_1_4);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:22,代码来源:JavaPackageValidator.java


示例2: perform

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
  pm.beginTask(RefactoringCoreMessages.ClasspathChange_progress_message, 1);
  try {
    if (!JavaConventions.validateClasspath(fProject, fNewClasspath, fOutputLocation)
        .matches(IStatus.ERROR)) {
      IClasspathEntry[] oldClasspath = fProject.getRawClasspath();
      IPath oldOutputLocation = fProject.getOutputLocation();

      fProject.setRawClasspath(fNewClasspath, fOutputLocation, new SubProgressMonitor(pm, 1));

      return new ClasspathChange(fProject, oldClasspath, oldOutputLocation);
    } else {
      return new NullChange();
    }
  } finally {
    pm.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:ClasspathChange.java


示例3: validateMethodName

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
public static IStatus validateMethodName(String methodName) {
  String complianceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.compliance");
  String sourceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.source");
  IStatus nameStatus = JavaConventions.validateMethodName(methodName,
      sourceLevel, complianceLevel);

  if (!nameStatus.isOK()) {
    return nameStatus;
  }

  // The JavaConventions class doesn't seem to be flagging method names with
  // an uppercase first character, so we need to check it ourselves.
  if (!Character.isLowerCase(methodName.charAt(0))) {
    return StatusUtilities.newWarningStatus(
        "Method name should start with a lowercase letter.",
        CorePlugin.PLUGIN_ID);
  }

  return StatusUtilities.OK_STATUS;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:21,代码来源:JavaUtilities.java


示例4: 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;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:28,代码来源:ModuleUtils.java


示例5: createLibraryNameControls

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
private void createLibraryNameControls(Composite parent, int cols) {
	Label libraryNameLbl = new Label(parent, SWT.NONE);
	libraryNameLbl.setText("Library Name:");
	libraryNameLbl.setToolTipText("A class-name like identifier that will be used to generate the class file containing your functions");
	libraryNameLbl.setLayoutData(new GridData(SWT.FILL,SWT.TOP,false,false));
	libraryName = new Text(parent, SWT.BORDER);
	libraryName.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false,cols-1,1));
	libraryName.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e) {
			libraryNameStatus = JavaConventions.validateJavaTypeName(
					libraryName.getText(), JavaCore.VERSION_1_6, JavaCore.VERSION_1_6);
			doStatusUpdate();
		}
	});
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:17,代码来源:FunctionsLibraryInformationPage.java


示例6: createCategoryClassControls

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
private void createCategoryClassControls(Composite parent, int cols) {
	Label categoryClassLbl = new Label(parent, SWT.NONE);
	categoryClassLbl.setText("Category Class:");
	categoryClassLbl.setLayoutData(new GridData(SWT.FILL,SWT.TOP,false,false));
	categoryClassLbl.setToolTipText("The class that will represent the category. Usually automatically suggested");
	categoryClass = new Text(parent, 	SWT.BORDER);
	categoryClass.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false,cols-1,1));
	categoryClass.addModifyListener(new ModifyListener() {
		@Override
		public void modifyText(ModifyEvent e) {
			categoryClassStatus = JavaConventions.validateJavaTypeName(
					categoryClass.getText(), JavaCore.VERSION_1_6, JavaCore.VERSION_1_6);
			if(categoryClassStatus.isOK()){
				// Ensure Library Class is different from Category Class
				String libraryNameTxt = libraryName.getText();
				String categoryClassTxt = categoryClass.getText();
				if(categoryClassTxt.endsWith("."+libraryNameTxt) || categoryClassTxt.equals(libraryNameTxt)) {
					categoryClassStatus = 
							new Status(IStatus.ERROR, JaspersoftStudioPlugin.PLUGIN_ID, -1, "Category class can not be the same one of the Library itself", null);
				}
			}
			doStatusUpdate();
		}
	});
	AutoCompletionHelper.enableAutoCompletion(categoryClass, getExistingCategories());
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:27,代码来源:FunctionsLibraryInformationPage.java


示例7: validatePage

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
@Override
protected boolean validatePage() {
	if (!super.validatePage())
		return false;
	IStatus status = JavaConventions.validatePackageName(getProjectName(), JavaCore.VERSION_1_5,
			JavaCore.VERSION_1_5);
	if (!status.isOK()) {
		if (status.matches(IStatus.WARNING)) {
			setMessage(status.getMessage(), IStatus.WARNING);
			return true;
		}
		setErrorMessage(Messages.WizardNewtxtUMLProjectCreationPage_ErrorMessageProjectName + status.getMessage());
		return false;
	}
	setErrorMessage(null);
	setMessage(null);
	return true;
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:19,代码来源:NewTxtUMLProjectWizardPage.java


示例8: perform

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
	pm.beginTask(RefactoringCoreMessages.ClasspathChange_progress_message, 1);
	try {
		if (!JavaConventions.validateClasspath(fProject, fNewClasspath, fOutputLocation).matches(IStatus.ERROR)) {
			IClasspathEntry[] oldClasspath= fProject.getRawClasspath();
			IPath oldOutputLocation= fProject.getOutputLocation();

			fProject.setRawClasspath(fNewClasspath, fOutputLocation, new SubProgressMonitor(pm, 1));

			return new ClasspathChange(fProject, oldClasspath, oldOutputLocation);
		} else {
			return new NullChange();
		}
	} finally {
		pm.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:ClasspathChange.java


示例9: commitClassPath

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
public static void commitClassPath(List<CPListElement> newEntries, IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
	if (monitor == null)
		monitor= new NullProgressMonitor();

	monitor.beginTask("", 2); //$NON-NLS-1$

	try {
		IClasspathEntry[] entries= convert(newEntries);
		IPath outputLocation= project.getOutputLocation();

		IJavaModelStatus status= JavaConventions.validateClasspath(project, entries, outputLocation);
		if (!status.isOK())
			throw new JavaModelException(status);
		
		BuildPathSupport.setEEComplianceOptions(project, newEntries);
		project.setRawClasspath(entries, outputLocation, new SubProgressMonitor(monitor, 2));
	} finally {
		monitor.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:ClasspathModifier.java


示例10: 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


示例11: open

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
@Override
public int open() {
	if (getInitialPattern() == null) {
		IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow();
		if (window != null) {
			ISelection selection= window.getSelectionService().getSelection();
			if (selection instanceof ITextSelection) {
				String text= ((ITextSelection) selection).getText();
				if (text != null) {
					text= text.trim();
					if (text.length() > 0 && JavaConventions.validateJavaTypeName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3).isOK()) {
						setInitialPattern(text, FULL_SELECTION);
					}
				}
			}
		}
	}
	return super.open();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:FilteredTypesSelectionDialog.java


示例12: 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(PreferencesMessages.TypeFilterInputDialog_error_enterName);
	} else {
		newText= newText.replace('*', 'X').replace('?', 'Y');
		IStatus val= JavaConventions.validatePackageName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
		if (val.matches(IStatus.ERROR)) {
			status.setError(Messages.format(PreferencesMessages.TypeFilterInputDialog_error_invalidName, val.getMessage()));
		} else {
			if (fExistingEntries.contains(newText)) {
				status.setError(PreferencesMessages.TypeFilterInputDialog_error_entryExists);
			}
		}
	}
	updateStatus(status);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:TypeFilterInputDialog.java


示例13: 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


示例14: 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


示例15: 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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:ImportOrganizeInputDialog.java


示例16: loadFromProperties

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
private List<ImportOrderEntry> loadFromProperties(Properties properties) {
	ArrayList<ImportOrderEntry> res= new ArrayList<ImportOrderEntry>();
	int nEntries= properties.size();
	for (int i= 0 ; i < nEntries; i++) {
		String curr= properties.getProperty(String.valueOf(i));
		if (curr != null) {
			ImportOrderEntry entry= ImportOrderEntry.fromSerialized(curr);
			if (entry.name.length() == 0 || !JavaConventions.validatePackageName(entry.name, JavaCore.VERSION_1_3, JavaCore.VERSION_1_5).matches(IStatus.ERROR)) {
				res.add(entry);
			} else {
				return null;
			}
		} else {
			return res;
		}
	}
	return res;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:ImportOrganizeConfigurationBlock.java


示例17: updateBuildPathStatus

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
private void updateBuildPathStatus() {
	List<CPListElement> elements= fClassPathList.getElements();
	IClasspathEntry[] entries= new IClasspathEntry[elements.size()];

	for (int i= elements.size()-1 ; i >= 0 ; i--) {
		CPListElement currElement= elements.get(i);
		entries[i]= currElement.getClasspathEntry();
	}

	IJavaModelStatus status= JavaConventions.validateClasspath(fCurrJProject, entries, fOutputLocationPath);
	if (!status.isOK()) {
		fBuildPathStatus.setError(status.getMessage());
		return;
	}
	fBuildPathStatus.setOK();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:BuildPathsBlock.java


示例18: validateName

import org.eclipse.jdt.core.JavaConventions; //导入依赖的package包/类
/**
 * Validate name.
 *
 * @return the i status
 */
public String validateName() {
	final String name = getDependencyName();
	if (origin != null && name.equals(origin.getName())) {
		return null;
	}
	for (ManifestItem o : input) {
		if (name.equals(o.getName())) {
			return Messages.NewDependencyItemDialog_existCheckMessage;
		}
	}
       // Bundle-SymbolicName could include dash (-) and other characters
       if (!this.type.equals(ManifestItem.REQUIRE_BUNDLE)) {
           final IStatus status = JavaConventions.validatePackageName(name);
           if (!status.isOK()) {
               return status.getMessage();
           }
       }
	return null;
}
 
开发者ID:Talend,项目名称:tesb-studio-se,代码行数:25,代码来源:NewOrEditDependencyDialog.java


示例19: 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);
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:41,代码来源:ConfigureSampleClassPage.java


示例20: 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);
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:32,代码来源:ConfigureDesktopClassPage.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Accepted类代码示例发布时间:2022-05-21
下一篇:
Java ColorAdjust类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap