本文整理汇总了Java中org.eclipse.jdt.core.JavaConventions类的典型用法代码示例。如果您正苦于以下问题:Java JavaConventions类的具体用法?Java JavaConventions怎么用?Java JavaConventions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaConventions类属于org.eclipse.jdt.core包,在下文中一共展示了JavaConventions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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);
}
示例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);
}