Codota Logo
org.eclipse.jdt.core
Code IndexAdd Codota to your IDE (free)

How to use org.eclipse.jdt.core

Best Java code snippets using org.eclipse.jdt.core (Showing top 20 results out of 945)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
origin: org.projectlombok/lombok

public static IMethod[] removeGeneratedMethods(IMethod[] methods) throws Exception {
  List<IMethod> result = new ArrayList<IMethod>();
  for (IMethod m : methods) {
    if (m.getNameRange().getLength() > 0 && !m.getNameRange().equals(m.getSourceRange())) result.add(m);
  }
  return result.size() == methods.length ? methods : result.toArray(new IMethod[result.size()]);
}

origin: org.projectlombok/lombok

public static org.eclipse.jdt.core.dom.AbstractTypeDeclaration findTypeDeclaration(IType searchType, List<?> nodes) {
  for (Object object : nodes) {
    if (object instanceof org.eclipse.jdt.core.dom.AbstractTypeDeclaration) {
      org.eclipse.jdt.core.dom.AbstractTypeDeclaration typeDeclaration = (org.eclipse.jdt.core.dom.AbstractTypeDeclaration) object;
      if (typeDeclaration.getName().toString().equals(searchType.getElementName()))
        return typeDeclaration;
    }
  }
  return null;
}

origin: aws/aws-sdk-java

/**
 * Creates a JavaCodeFormatter using the default formatter options and
 * optionally applying user provided options on top.
 *
 * @param overrideOptions user provided options to apply on top of defaults
 */
public JavaCodeFormatter(final Map<String, Object> overrideOptions) {
  Map formatterOptions = new HashMap<>(DEFAULT_FORMATTER_OPTIONS);
  if (overrideOptions != null) {
    formatterOptions.putAll(overrideOptions);
  }
  this.codeFormatter = ToolFactory.createCodeFormatter(formatterOptions,
      ToolFactory.M_FORMAT_EXISTING);
}
origin: org.projectlombok/lombok

public static org.eclipse.jdt.core.dom.MethodDeclaration getRealMethodDeclarationNode(org.eclipse.jdt.core.IMethod sourceMethod, org.eclipse.jdt.core.dom.CompilationUnit cuUnit) throws JavaModelException {
  MethodDeclaration methodDeclarationNode = ASTNodeSearchUtil.getMethodDeclarationNode(sourceMethod, cuUnit);
  if (isGenerated(methodDeclarationNode)) {
    IType declaringType = sourceMethod.getDeclaringType();
    Stack<IType> typeStack = new Stack<IType>();
    while (declaringType != null) {
      typeStack.push(declaringType);
      declaringType = declaringType.getDeclaringType();
    org.eclipse.jdt.core.dom.AbstractTypeDeclaration typeDeclaration = findTypeDeclaration(rootType, cuUnit.types());
    while (!typeStack.isEmpty() && typeDeclaration != null) {
      typeDeclaration = findTypeDeclaration(typeStack.pop(), typeDeclaration.bodyDeclarations());
      String methodName = sourceMethod.getElementName();
      for (Object declaration : typeDeclaration.bodyDeclarations()) {
        if (declaration instanceof org.eclipse.jdt.core.dom.MethodDeclaration) {
          org.eclipse.jdt.core.dom.MethodDeclaration methodDeclaration = (org.eclipse.jdt.core.dom.MethodDeclaration) declaration;
          if (methodDeclaration.getName().toString().equals(methodName)) {
            return methodDeclaration;
origin: eclipse/eclipse.jdt.ls

@Override
protected IResource getModifiedResource() {
  IJavaElement elem= JavaCore.create(fHandle);
  if (elem != null) {
    return elem.getResource();
  }
  return null;
}
origin: eclipse/buildship

@Override
public String getSimpleName() {
  IType declaringType = this.method.getDeclaringType();
  return declaringType.getElementName() + "#" + this.method.getElementName();
}
origin: eclipse/eclipse.jdt.ls

@Override
public IProject[] getProjects() {
  return new IProject[] {fUnit.getJavaProject().getProject() };
}
@Override
origin: org.eclipse/org.eclipse.jdt.debug.ui

/**
 * Returns the element at the given position in the given type
 */
protected static IJavaElement getElementAt(IType type, int pos) throws JavaModelException {
  if (type.isBinary()) {
    return type.getClassFile().getElementAt(pos);
  }
  return type.getCompilationUnit().getElementAt(pos);
}

origin: eclipse/eclipse.jdt.ls

@Override
public IProject[] getProjects() {
  return new IProject[] { fClassFile.getJavaProject().getProject() };
}
@Override
origin: eclipse/eclipse.jdt.ls

private boolean accept(int offset, IMember member) throws JavaModelException {
  ISourceRange nameRange = member.getNameRange();
  if (nameRange == null) {
    return false;
  }
  int srcOffset = nameRange.getOffset();
  return srcOffset > offset;
}
origin: eclipse/eclipse.jdt.ls

private static boolean isNestedInterfaceOrAnnotation(IMember member) throws JavaModelException{
  return member.getElementType() == IJavaElement.TYPE &&
      member.getDeclaringType() != null &&
      ((IType) member).isInterface();
}
origin: eclipse/eclipse.jdt.ls

private boolean isDeprecated(IJavaElement element) throws JavaModelException {
  if (element instanceof ITypeRoot) {
    return Flags.isDeprecated(((ITypeRoot) element).findPrimaryType().getFlags());
  }
  return false;
}
origin: org.eclipse/org.eclipse.jdt.ui

CompilationUnitReorgChange(ICompilationUnit cu, IPackageFragment dest, INewNameQuery newNameQuery) {
  fCuHandle= cu.getHandleIdentifier();
  fNewPackageHandle= dest.getHandleIdentifier();
  fNewNameQuery= newNameQuery;
  fOldPackageHandle= cu.getParent().getHandleIdentifier();
}
origin: org.eclipse.jdt/org.eclipse.jdt.ui

public IJavaProject getProject() {
  if (fSelectionCompilationUnit != null)
    return fSelectionCompilationUnit.getJavaProject();
  if (fSelectionClassFile != null)
    return fSelectionClassFile.getJavaProject();
  if (fTargetMethod != null)
    return fTargetMethod.getJavaProject();
  return null;
}
origin: org.projectlombok/lombok

  in = annotatable.getAnnotations();
} catch (Exception e) {
  return out;
  boolean found = false;
  for (IAnnotation i : in) {
    String name = i.getElementName();
    int li = name.lastIndexOf('.');
    if (li > -1) name = name.substring(li + 1);
origin: org.projectlombok/lombok

public static SearchMatch[] removeGenerated(SearchMatch[] returnValue) {
  List<SearchMatch> result = new ArrayList<SearchMatch>();
  for (int j = 0; j < returnValue.length; j++) {
    SearchMatch searchResult = returnValue[j];
    if (searchResult.getElement() instanceof IField) {
      IField field = (IField) searchResult.getElement();
      
      // can not check for value=lombok because annotation is
      // not fully resolved
      IAnnotation annotation = field.getAnnotation("Generated");
      if (annotation != null) {
        // Method generated at field location, skip
        continue;
      }
      
    }
    result.add(searchResult);
  }
  return result.toArray(new SearchMatch[result.size()]);
}

origin: stackoverflow.com

 ICompilationUnit cu = ... // an ICompilationUnit to rename

RefactoringContribution contribution =
  RefactoringCore.getRefactoringContribution(IJavaRefactorings .RENAME_COMPILATION_UNIT);
RenameJavaElementDescriptor descriptor =
  (RenameJavaElementDescriptor) contribution.createDescriptor();
descriptor.setProject(cu.getResource().getProject().getName( ));
descriptor.setNewName("NewClass"); // new name for a Class
descriptor.setJavaElement(cu);

RefactoringStatus status = new RefactoringStatus();
try {
  Refactoring refactoring = descriptor.createRefactoring(status);

  IProgressMonitor monitor = new NullProgressMonitor();
  refactoring.checkInitialConditions(monitor);
  refactoring.checkFinalConditions(monitor);
  Change change = refactoring.createChange(monitor);
  change.perform(monitor);

} catch (CoreException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
} catch (Exception e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
}
origin: eclipse/eclipse.jdt.ls

  public static boolean isSourceAvailable(ISourceReference sourceReference) {
    try {
      return SourceRange.isAvailable(sourceReference.getSourceRange());
    } catch (JavaModelException e) {
      return false;
    }
  }
}
origin: org.projectlombok/lombok

public static SearchResultGroup[] createFakeSearchResult(SearchResultGroup[] returnValue,
    Object/*
         * org.eclipse.jdt.internal.corext.refactoring.rename.
         * RenameFieldProcessor
         */ processor) throws Exception {
  if (returnValue == null || returnValue.length == 0) {
    // if no matches were found, check if Data annotation is present on the class
    Field declaredField = processor.getClass().getDeclaredField("fField");
    if (declaredField != null) {
      declaredField.setAccessible(true);
      SourceField fField = (SourceField) declaredField.get(processor);
      IAnnotation dataAnnotation = fField.getDeclaringType().getAnnotation("Data");
      if (dataAnnotation != null) {
        // add fake item, to make refactoring checks pass
        return new SearchResultGroup[] {new SearchResultGroup(null, new SearchMatch[1])};
      }
    }
  }
  return returnValue;
}

origin: eclipse/eclipse.jdt.ls

  @Override
  public int compare(IMember o1, IMember o2){
    try{
      return o1.getNameRange().getOffset() - o2.getNameRange().getOffset();
    } catch (JavaModelException e){
      return 0;
    }
  }
};
org.eclipse.jdt.core

Most used classes

  • JavaCore
    The plug-in runtime class for the Java model plug-in containing the core (UI-free) support for Java
  • IJavaProject
    A Java project represents a view of a project resource in terms of Java elements such as package fra
  • IClasspathEntry
    An entry on a Java project classpath identifying one or more package fragment roots. A classpath ent
  • CompilationUnit
    Java compilation unit AST node type. This is the type of the root of an AST. The source range for th
  • MethodDeclaration
    Method declaration AST node type. A method declaration is the union of a method declaration and a co
  • IType,
  • IProblem,
  • IPackageFragmentRoot,
  • IJavaElement,
  • TypeDeclaration,
  • ASTNode,
  • SimpleName,
  • Name,
  • IPackageFragment,
  • Type,
  • ICompilationUnit,
  • FieldDeclaration,
  • SingleVariableDeclaration,
  • VariableDeclarationFragment
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now