Available Methods
- isError ( )
- getID ( )
- getSourceStart ( )
- UnusedPrivateField ( )
- getSourceEnd ( )
- IllegalRedefinitionToNonNullParameter ( )
- JavadocDuplicateThrowsClassName ( )
- UndefinedType ( )
- RedundantNullDefaultAnnotationType ( )
- LocalVariableIsNeverUsed ( )
- CannotOverrideAStaticMethodWithAnInstanceMethod ( )
- UndefinedMethod ( )
- Task ( )
- JavadocUnexpectedTag ( )
- EnumConstantMustImplementAbstractMethod ( )
- ImportNotFound ( )
- UndefinedName ( )
- ArgumentIsNeverUsed ( )
- IllegalModifierCombinationFinalVolatileForField ( )
- AmbiguousType ( )
- CannotImportPackage ( )
- JavadocInvalidTag ( )
- IllegalDefinitionToNonNullParameter ( )
- ForbiddenReference ( )
- NonStaticFieldFromStaticInvocation ( )
- UnusedTypeParameter ( )
- UnnecessaryCast ( )
- MissingOverrideAnnotationForInterfaceMethodImplementation ( )
- NonStaticAccessToStaticMethod ( )
- IllegalModifierForVariable ( )
- MethodReducesVisibility ( )
- IllegalModifierForInterfaceMethod ( )
- RequiredNonNullButProvidedNull ( )
- ParsingErrorMergeTokens ( )
- ShouldReturnValue ( )
- FieldHidingField ( )
- ArgumentHidingField ( )
- UnqualifiedFieldAccess ( )
- UnterminatedString ( )
- LocalVariableHidingLocalVariable ( )
- UnusedPrivateConstructor ( )
- InvalidUsageOfForeachStatements ( )
- DuplicateNestedType ( )
- MissingEnumConstantCase ( )
- UnusedImport ( )
- DuplicateField ( )
- ConflictingImport ( )
- NotVisibleField ( )
- DuplicateBlankFinalFieldInitialization ( )
- IllegalModifierForEnumConstructor ( )
- IllegalModifierForConstructor ( )
- PackageIsNotExpectedPackage ( )
- NonExternalizedStringLiteral ( )
- JavadocAmbiguousType ( )
- ReturnTypeMismatch ( )
- IllegalModifierForEnum ( )
- InvalidInput ( )
- NullSourceString ( )
- UnresolvedVariable ( )
- IllegalReturnNullityRedefinition ( )
- UseEnumAsAnIdentifier ( )
- UnexpectedStaticModifierForField ( )
- IllegalModifierForMemberEnum ( )
- EnumAbstractMethodMustBeImplemented ( )
- MethodCanBePotentiallyStatic ( )
- TypeMissingDeprecatedAnnotation ( )
- RedundantSpecificationOfTypeArguments ( )
- IncompatibleExceptionInThrowsClause ( )
- UnhandledWarningToken ( )
- NonStaticOrAlienTypeReceiver ( )
- ParsingErrorInsertToCompletePhrase ( )
- ParsingErrorNoSuggestion ( )
- UnhandledExceptionInDefaultConstructor ( )
- RawTypeReference ( )
- UndefinedAnnotationMember ( )
- AbstractMethodMustBeImplemented ( )
Related Classes
- java.util.Arrays
- java.io.File
- java.io.InputStream
- java.util.Iterator
- java.util.Locale
- org.eclipse.core.runtime.CoreException
- org.eclipse.core.runtime.NullProgressMonitor
- org.eclipse.jdt.core.dom.CompilationUnit
- org.eclipse.jdt.core.IJavaProject
- org.eclipse.jdt.core.JavaModelException
- org.eclipse.jdt.core.ICompilationUnit
- org.eclipse.jdt.core.dom.SimpleName
- org.eclipse.jdt.core.dom.ASTNode
- org.eclipse.jdt.core.dom.Modifier
- org.eclipse.jdt.core.IPackageFragment
- org.eclipse.jdt.core.dom.ITypeBinding
- org.eclipse.jdt.internal.compiler.impl.CompilerOptions
- org.eclipse.jdt.core.dom.IMethodBinding
- org.eclipse.ltk.core.refactoring.RefactoringStatus
- org.eclipse.jdt.core.search.IJavaSearchConstants
- org.eclipse.jdt.core.dom.BodyDeclaration
- org.eclipse.lsp4j.TextDocumentIdentifier
- org.eclipse.jdt.internal.compiler.env.ICompilationUnit
- org.eclipse.lsp4j.Range
- org.eclipse.lsp4j.jsonrpc.messages.Either
Java Code Examples for org.eclipse.jdt.core.compiler.IProblem#NonStaticAccessToStaticMethod
The following examples show how to use
org.eclipse.jdt.core.compiler.IProblem#NonStaticAccessToStaticMethod .
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: StaticAccessQuickFixTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
@Test public void testNonStaticAccessToStaticMethod() throws Exception { int problem = IProblem.NonStaticAccessToStaticMethod; IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); // Referenced from: https://www.intertech.com/Blog/a-static-method-should-be-accessed-in-a-static-way/ StringBuilder bufA = new StringBuilder(); bufA.append("package test1;\n"); bufA.append("public class HelloWorld {\n"); bufA.append(" public static void sayHello() {\n"); bufA.append(" System.out.println(\"Hello!\");\n"); bufA.append(" }\n"); bufA.append(" public static void main(String[] args) {\n"); bufA.append(" HelloWorld hw = new HelloWorld();\n"); bufA.append(" hw.sayHello();\n"); bufA.append(" }\n"); bufA.append("}"); ICompilationUnit cu = pack1.createCompilationUnit("HelloWorld.java", bufA.toString(), false, null); bufA = new StringBuilder(); bufA.append("package test1;\n"); bufA.append("public class HelloWorld {\n"); bufA.append(" public void sayHello() {\n"); bufA.append(" System.out.println(\"Hello!\");\n"); bufA.append(" }\n"); bufA.append(" public static void main(String[] args) {\n"); bufA.append(" HelloWorld hw = new HelloWorld();\n"); bufA.append(" hw.sayHello();\n"); bufA.append(" }\n"); bufA.append("}"); Expected e1 = new Expected("Remove 'static' modifier of 'sayHello()'", bufA.toString()); bufA = new StringBuilder(); bufA.append("package test1;\n"); bufA.append("public class HelloWorld {\n"); bufA.append(" public static void sayHello() {\n"); bufA.append(" System.out.println(\"Hello!\");\n"); bufA.append(" }\n"); bufA.append(" public static void main(String[] args) {\n"); bufA.append(" HelloWorld hw = new HelloWorld();\n"); bufA.append(" HelloWorld.sayHello();\n"); bufA.append(" }\n"); bufA.append("}"); Expected e2 = new Expected("Change access to static using 'HelloWorld' (declaring type)", bufA.toString()); assertCodeActions(cu, e1, e2); }
Example 2
Source File: CodeStyleFix.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static boolean isNonStaticAccess(IProblemLocation problem) { return (problem.getProblemId() == IProblem.NonStaticAccessToStaticField || problem.getProblemId() == IProblem.NonStaticAccessToStaticMethod || problem.getProblemId() == IProblem.NonStaticOrAlienTypeReceiver); }