Java Code Examples for org.eclipse.jdt.core.Signature#getQualifier()

The following examples show how to use org.eclipse.jdt.core.Signature#getQualifier() . 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: OrganizeImportsHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static void addImports(CompilationUnit root, ICompilationUnit unit, String[] favourites, ImportRewrite importRewrite, AST ast, ASTRewrite astRewrite, SimpleName node, boolean isMethod) throws JavaModelException {
	String name = node.getIdentifier();
	String[] imports = SimilarElementsRequestor.getStaticImportFavorites(unit, name, isMethod, favourites);
	if (imports.length > 1) {
		// See https://github.com/redhat-developer/vscode-java/issues/1472
		return;
	}
	for (int i = 0; i < imports.length; i++) {
		String curr = imports[i];
		String qualifiedTypeName = Signature.getQualifier(curr);
		String res = importRewrite.addStaticImport(qualifiedTypeName, name, isMethod, new ContextSensitiveImportRewriteContext(root, node.getStartPosition(), importRewrite));
		int dot = res.lastIndexOf('.');
		if (dot != -1) {
			String usedTypeName = importRewrite.addImport(qualifiedTypeName);
			Name newName = ast.newQualifiedName(ast.newName(usedTypeName), ast.newSimpleName(name));
			astRewrite.replace(node, newName, null);
		}
	}
}
 
Example 2
Source File: AbstractGWTPluginTestCase.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
public void addToTestProject() throws Exception {
  IProject testProject = Util.getWorkspaceRoot().getProject(TEST_PROJECT_NAME);
  if (!testProject.exists()) {
    throw new Exception("The test project does not exist");
  }

  IJavaProject javaProject = JavaCore.create(testProject);

  IPath srcPath = new Path("/" + TEST_PROJECT_NAME + "/src");
  IPackageFragmentRoot pckgRoot = javaProject.findPackageFragmentRoot(srcPath);

  String packageName = Signature.getQualifier(typeName);
  String cuName = Signature.getSimpleName(typeName) + ".java";

  // If the package fragment already exists, this call does nothing
  IPackageFragment pckg = pckgRoot.createPackageFragment(packageName, false, null);

  cu = pckg.createCompilationUnit(cuName, contents, true, null);
  JobsUtilities.waitForIdle();
}
 
Example 3
Source File: JavaProjectTestUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates an {@link ICompilationUnit} with the given fully qualified name and
 * code in the <code>javaProject</code>.
 * 
 * @param javaProject java project to host the new class
 * @param fullyQualifiedClassName fully qualified name for the class
 * @param source code for the classs
 * @return newly created {@link ICompilationUnit}
 * @throws JavaModelException
 */
public static ICompilationUnit createCompilationUnit(
    IJavaProject javaProject, String fullyQualifiedClassName, String source)
    throws JavaModelException {
  IPackageFragmentRoot root = javaProject.findPackageFragmentRoot(javaProject.getPath());
  if (root == null) {
    addRawClassPathEntry(javaProject,
        JavaCore.newSourceEntry(javaProject.getPath()));
    root = javaProject.findPackageFragmentRoot(javaProject.getPath());
  }

  String qualifier = Signature.getQualifier(fullyQualifiedClassName);
  IProgressMonitor monitor = new NullProgressMonitor();
  IPackageFragment packageFragment = root.createPackageFragment(qualifier,
      true, monitor);
  String name = Signature.getSimpleName(fullyQualifiedClassName);
  return packageFragment.createCompilationUnit(name + ".java", source, false,
      monitor);
}
 
Example 4
Source File: JavaProjectUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates an {@link ICompilationUnit} with the given fully qualified name and
 * code in the <code>javaProject</code>.
 *
 * @param javaProject java project to host the new class
 * @param fullyQualifiedClassName fully qualified name for the class
 * @param source code for the classs
 * @return newly created {@link ICompilationUnit}
 * @throws JavaModelException
 */
public static ICompilationUnit createCompilationUnit(
    IJavaProject javaProject, String fullyQualifiedClassName, String source)
    throws JavaModelException {
  IPackageFragmentRoot root = javaProject.findPackageFragmentRoot(javaProject.getPath());
  if (root == null) {
    addRawClassPathEntry(javaProject,
        JavaCore.newSourceEntry(javaProject.getPath()));
    root = javaProject.findPackageFragmentRoot(javaProject.getPath());
  }

  String qualifier = Signature.getQualifier(fullyQualifiedClassName);
  IProgressMonitor monitor = new NullProgressMonitor();
  IPackageFragment packageFragment = root.createPackageFragment(qualifier,
      true, monitor);
  String name = Signature.getSimpleName(fullyQualifiedClassName);
  ICompilationUnit cu = packageFragment.createCompilationUnit(name + ".java",
      source, false, monitor);
  JobsUtilities.waitForIdle();
  return cu;
}
 
Example 5
Source File: NLSHintHelper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static IStorage getResourceBundle(IJavaProject javaProject, AccessorClassReference accessorClassReference) throws JavaModelException {
	String resourceBundle= accessorClassReference.getResourceBundleName();
	if (resourceBundle == null)
		return null;

	String resourceName= Signature.getSimpleName(resourceBundle) + NLSRefactoring.PROPERTY_FILE_EXT;
	String packName= Signature.getQualifier(resourceBundle);
	ITypeBinding accessorClass= accessorClassReference.getBinding();

	if (accessorClass.isFromSource())
		return getResourceBundle(javaProject, packName, resourceName);
	else if (accessorClass.getJavaElement() != null)
		return getResourceBundle((IPackageFragmentRoot)accessorClass.getJavaElement().getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT), packName, resourceName);

	return null;
}
 
Example 6
Source File: ModuleUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Finds a particular GWT module by its fully-qualified name.
 *
 * @param javaProject project in which to search for modules
 * @param qualifiedName fully-qualified module name
 * @param includeJars indicates whether to include JAR files in search
 * @return the module, if found; otherwise <code>null</code>
 */
public static IModule findModule(IJavaProject javaProject, String qualifiedName, final boolean includeJars) {
  final String modulePckg = Signature.getQualifier(qualifiedName);
  final String simpleName = Signature.getSimpleName(qualifiedName);

  return visitFragments(javaProject, includeJars, new IPackageFragmentVisitor<IModule>() {
    @Override
    public IModule visit(IPackageFragment pckg) throws JavaModelException {
      // Look for the package fragment matching the module qualifier
      if (modulePckg.equals(pckg.getElementName())) {
        for (Object resource : pckg.getNonJavaResources()) {
          IModule module = create(resource, includeJars);
          // Now compare the resource name to the module name
          if (module != null && module.getSimpleName().equals(simpleName)) {
            return module;
          }
        }
      }

      return null;
    }
  });
}
 
Example 7
Source File: CompletionProposalDescriptionProvider.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private void createLabelWithTypeAndDeclaration(CompletionProposal proposal, CompletionItem item) {
	char[] name= proposal.getCompletion();
	if (!isThisPrefix(name)) {
		name= proposal.getName();
	}
	StringBuilder buf= new StringBuilder();

	buf.append(name);
	item.setInsertText(buf.toString());
	char[] typeName= Signature.getSignatureSimpleName(proposal.getSignature());
	if (typeName.length > 0) {
		buf.append(VAR_TYPE_SEPARATOR);
		buf.append(typeName);
	}
	item.setLabel(buf.toString());

	char[] declaration= proposal.getDeclarationSignature();
	StringBuilder detailBuf = new StringBuilder();
	if (declaration != null) {
		setDeclarationSignature(item, String.valueOf(declaration));
		declaration= Signature.getSignatureSimpleName(declaration);
		if (declaration.length > 0) {
			if (proposal.getRequiredProposals() != null) {
				String declaringType= extractDeclaringTypeFQN(proposal);
				String qualifier= Signature.getQualifier(declaringType);
				if (qualifier.length() > 0) {
					detailBuf.append(qualifier);
					detailBuf.append('.');
				}
			}
			detailBuf.append(declaration);
		}
	}
	if (detailBuf.length() > 0) {
		detailBuf.append('.');
	}
	detailBuf.append(buf);
	item.setDetail(detailBuf.toString());
	setName(item,String.valueOf(name));
}
 
Example 8
Source File: CompletionProposalLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
StyledString createLabelWithTypeAndDeclaration(CompletionProposal proposal) {
	char[] name= proposal.getCompletion();
	if (!isThisPrefix(name))
		name= proposal.getName();

	StyledString buf= new StyledString();
	buf.append(name);
	char[] typeName= Signature.getSignatureSimpleName(proposal.getSignature());
	if (typeName.length > 0) {
		buf.append(VAR_TYPE_SEPARATOR);
		buf.append(typeName);
	}
	char[] declaration= proposal.getDeclarationSignature();
	if (declaration != null) {
		declaration= Signature.getSignatureSimpleName(declaration);
		if (declaration.length > 0) {
			buf.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER);
			if (proposal.getRequiredProposals() != null) {
				String declaringType= extractDeclaringTypeFQN(proposal);
				String qualifier= Signature.getQualifier(declaringType);
				if (qualifier.length() > 0) {
					buf.append(qualifier, StyledString.QUALIFIER_STYLER);
					buf.append('.', StyledString.QUALIFIER_STYLER);
				}
			}
			buf.append(declaration, StyledString.QUALIFIER_STYLER);
		}
	}

	return Strings.markJavaElementLabelLTR(buf);
}
 
Example 9
Source File: CompletionProposalLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a display label for the given method proposal. The display label
 * consists of:
 * <ul>
 *   <li>the method name</li>
 *   <li>the parameter list (see {@link #createParameterList(CompletionProposal)})</li>
 *   <li>the upper bound of the return type (see {@link SignatureUtil#getUpperBound(String)})</li>
 *   <li>the raw simple name of the declaring type</li>
 * </ul>
 * <p>
 * Examples:
 * For the <code>get(int)</code> method of a variable of type <code>List<? extends Number></code>, the following
 * display name is returned: <code>get(int index)  Number - List</code>.<br>
 * For the <code>add(E)</code> method of a variable of type <code>List<? super Number></code>, the following
 * display name is returned: <code>add(Number o)  void - List</code>.<br>
 * </p>
 *
 * @param methodProposal the method proposal to display
 * @return the display label for the given method proposal
 */
StyledString createMethodProposalLabel(CompletionProposal methodProposal) {
	StyledString nameBuffer= new StyledString();

	// method name
	nameBuffer.append(methodProposal.getName());

	// parameters
	nameBuffer.append('(');
	appendUnboundedParameterList(nameBuffer, methodProposal);
	nameBuffer.append(')');

	// return type
	if (!methodProposal.isConstructor()) {
		// TODO remove SignatureUtil.fix83600 call when bugs are fixed
		char[] returnType= createTypeDisplayName(SignatureUtil.getUpperBound(Signature.getReturnType(SignatureUtil.fix83600(methodProposal.getSignature()))));
		nameBuffer.append(RETURN_TYPE_SEPARATOR);
		nameBuffer.append(returnType);
	}

	// declaring type
	nameBuffer.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER);
	String declaringType= extractDeclaringTypeFQN(methodProposal);

	if (methodProposal.getRequiredProposals() != null) {
		String qualifier= Signature.getQualifier(declaringType);
		if (qualifier.length() > 0) {
			nameBuffer.append(qualifier, StyledString.QUALIFIER_STYLER);
			nameBuffer.append('.', StyledString.QUALIFIER_STYLER);
		}
	}

	declaringType= Signature.getSimpleName(declaringType);
	nameBuffer.append(declaringType, StyledString.QUALIFIER_STYLER);
	return Strings.markJavaElementLabelLTR(nameBuffer);
}
 
Example 10
Source File: NLSHintHelper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static IStorage getResourceBundle(ICompilationUnit compilationUnit) throws JavaModelException {
	IJavaProject project= compilationUnit.getJavaProject();
	if (project == null)
		return null;

	String name= getResourceBundleName(compilationUnit);
	if (name == null)
		return null;

	String packName= Signature.getQualifier(name);
	String resourceName= Signature.getSimpleName(name) + NLSRefactoring.PROPERTY_FILE_EXT;

	return getResourceBundle(project, packName, resourceName);
}
 
Example 11
Source File: ModuleCompletionProcessor.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean matches(String input) {
  String packageName = Signature.getQualifier(this.prefixCompareString);
  if (!input.toLowerCase().startsWith(packageName.toLowerCase())) {
    return false;
  }
  return super.matches(input);
}
 
Example 12
Source File: ModuleUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Validates a fully-qualified module name. Module names are validated like fully-qualified Java
 * type names; the package should be made up of lower-case segments that are valid Java
 * identifiers, and the name should be a camel-cased valid Java identifier.
 *
 * @param qualifiedName fully-qualified 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 validateQualifiedModuleName(String qualifiedName) {
  // Validate the module package name according to Java conventions
  String pckg = Signature.getQualifier(qualifiedName);
  if (!Util.isValidPackageName(pckg)) {
    return Util.newErrorStatus("The module package name is invalid");
  }

  return validateSimpleModuleName(Signature.getSimpleName(qualifiedName));
}
 
Example 13
Source File: EntryPointModulesSelectionBlock.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public String getText(Object element) {
  String qualifiedModuleName = (String) element;
  String moduleName = Signature.getSimpleName(qualifiedModuleName);
  String packageName = Signature.getQualifier(qualifiedModuleName);
  return moduleName + " - " + packageName;
}
 
Example 14
Source File: CompletionProposalDescriptionProvider.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Updates a display label for the given method proposal to item. The display label
 * consists of:
 * <ul>
 *   <li>the method name</li>
 *   <li>the parameter list (see {@link #createParameterList(CompletionProposal)})</li>
 *   <li>the upper bound of the return type (see {@link SignatureUtil#getUpperBound(String)})</li>
 *   <li>the raw simple name of the declaring type</li>
 * </ul>
 * <p>
 * Examples:
 * For the <code>get(int)</code> method of a variable of type <code>List<? extends Number></code>, the following
 * display name is returned: <code>get(int index)  Number - List</code>.<br>
 * For the <code>add(E)</code> method of a variable of type <code>List<? super Number></code>, the following
 * display name is returned: <code>add(Number o)  void - List</code>.<br>
 * </p>
 *
 * @param methodProposal the method proposal to display
 * @param item to update
 */
private void createMethodProposalLabel(CompletionProposal methodProposal, CompletionItem item) {
	StringBuilder description = this.createMethodProposalDescription(methodProposal);
	item.setLabel(description.toString());
	item.setInsertText(String.valueOf(methodProposal.getName()));

	// declaring type
	StringBuilder typeInfo = new StringBuilder();
	String declaringType= extractDeclaringTypeFQN(methodProposal);

	if (methodProposal.getRequiredProposals() != null) {
		String qualifier= Signature.getQualifier(declaringType);
		if (qualifier.length() > 0) {
			typeInfo.append(qualifier);
			typeInfo.append('.');
		}
	}

	declaringType= Signature.getSimpleName(declaringType);
	typeInfo.append(declaringType);
	StringBuilder detail = new StringBuilder();
	if (typeInfo.length() > 0) {
		detail.append(typeInfo);
		detail.append('.');
	}
	detail.append(description);
	item.setDetail(detail.toString());

	setSignature(item, String.valueOf(methodProposal.getSignature()));
	setDeclarationSignature(item, String.valueOf(methodProposal.getDeclarationSignature()));
	setName(item, String.valueOf(methodProposal.getName()));

}
 
Example 15
Source File: AbstractModule.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public String getPackageName() {
  return Signature.getQualifier(getQualifiedName());
}
 
Example 16
Source File: JavaTypeCompletionProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void accept(CompletionProposal proposal) {
	switch (proposal.getKind()) {
		case CompletionProposal.PACKAGE_REF :
			char[] packageName= proposal.getDeclarationSignature();
			if (TypeFilter.isFiltered(packageName))
				return;
			addAdjustedCompletion(
					new String(packageName),
					new String(proposal.getCompletion()),
					proposal.getReplaceStart(),
					proposal.getReplaceEnd(),
					proposal.getRelevance(),
					JavaPluginImages.DESC_OBJS_PACKAGE);
			return;

		case CompletionProposal.TYPE_REF :
			char[] signature= proposal.getSignature();
			char[] fullName= Signature.toCharArray(signature);
			if (TypeFilter.isFiltered(fullName))
				return;
			StringBuffer buf= new StringBuffer();
			buf.append(Signature.getSimpleName(fullName));
			if (buf.length() == 0)
				return; // this is the dummy class, whose $ have been converted to dots
			char[] typeQualifier= Signature.getQualifier(fullName);
			if (typeQualifier.length > 0) {
				buf.append(JavaElementLabels.CONCAT_STRING);
				buf.append(typeQualifier);
			}
			String name= buf.toString();

			// Only fully qualify if it's a top level type:
			boolean fullyQualify= fFullyQualify && CharOperation.equals(proposal.getDeclarationSignature(), typeQualifier);

			ImageDescriptor typeImageDescriptor;
			switch (Signature.getTypeSignatureKind(signature)) {
				case Signature.TYPE_VARIABLE_SIGNATURE :
					typeImageDescriptor= JavaPluginImages.DESC_OBJS_TYPEVARIABLE;
					break;
				case Signature.CLASS_TYPE_SIGNATURE :
					typeImageDescriptor= JavaElementImageProvider.getTypeImageDescriptor(false, false, proposal.getFlags(), false);
					break;
				default :
					typeImageDescriptor= null;
			}

			addAdjustedTypeCompletion(
					name,
					new String(proposal.getCompletion()),
					proposal.getReplaceStart(),
					proposal.getReplaceEnd(),
					proposal.getRelevance(),
					typeImageDescriptor,
					fullyQualify ? new String(fullName) : null);
			return;

		case CompletionProposal.KEYWORD:
			if (! fEnableBaseTypes)
				return;
			String keyword= new String(proposal.getName());
			if ( (fEnableVoid && VOID.equals(keyword)) || (fEnableBaseTypes && BASE_TYPES.contains(keyword)) )
				addAdjustedCompletion(
						keyword,
						new String(proposal.getCompletion()),
						proposal.getReplaceStart(),
						proposal.getReplaceEnd(),
						proposal.getRelevance(),
						null);
			return;

		default :
			return;
	}

}
 
Example 17
Source File: TypeInfoRequestorAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public String getEnclosingName() {
	return Signature.getQualifier(fMatch.getTypeQualifiedName());
}
 
Example 18
Source File: UnresolvedElementsSubProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
private static void addStaticImportFavoriteProposals(IInvocationContext context, SimpleName node, boolean isMethod,
		Collection<ChangeCorrectionProposal> proposals) throws JavaModelException {
	IJavaProject project= context.getCompilationUnit().getJavaProject();
	if (JavaModelUtil.is50OrHigher(project)) {
		String[] favourites = PreferenceManager.getPrefs(context.getCompilationUnit().getResource())
				.getJavaCompletionFavoriteMembers();
		if (favourites.length == 0) {
			return;
		}

		CompilationUnit root= context.getASTRoot();
		AST ast= root.getAST();

		String name= node.getIdentifier();
		String[] staticImports= SimilarElementsRequestor.getStaticImportFavorites(context.getCompilationUnit(), name, isMethod, favourites);
		for (int i= 0; i < staticImports.length; i++) {
			String curr= staticImports[i];

			ImportRewrite importRewrite = CodeStyleConfiguration.createImportRewrite(root, true);
			ASTRewrite astRewrite= ASTRewrite.create(ast);

			String label;
			String qualifiedTypeName= Signature.getQualifier(curr);
			String elementLabel= BasicElementLabels.getJavaElementName(JavaModelUtil.concatenateName(Signature.getSimpleName(qualifiedTypeName), name));

			String res= importRewrite.addStaticImport(qualifiedTypeName, name, isMethod, new ContextSensitiveImportRewriteContext(root, node.getStartPosition(), importRewrite));
			int dot= res.lastIndexOf('.');
			if (dot != -1) {
				String usedTypeName= importRewrite.addImport(qualifiedTypeName);
				Name newName= ast.newQualifiedName(ast.newName(usedTypeName), ast.newSimpleName(name));
				astRewrite.replace(node, newName, null);
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_change_to_static_import_description, elementLabel);
			} else {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_add_static_import_description, elementLabel);
			}

			ASTRewriteCorrectionProposal proposal = new ASTRewriteCorrectionProposal(label, CodeActionKind.QuickFix,
					context.getCompilationUnit(), astRewrite, IProposalRelevance.ADD_STATIC_IMPORT);
			proposal.setImportRewrite(importRewrite);
			proposals.add(proposal);
		}
	}
}
 
Example 19
Source File: UnresolvedElementsSubProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private static void addStaticImportFavoriteProposals(IInvocationContext context, SimpleName node, boolean isMethod, Collection<ICommandAccess> proposals) throws JavaModelException {
	IJavaProject project= context.getCompilationUnit().getJavaProject();
	if (JavaModelUtil.is50OrHigher(project)) {
		String pref= PreferenceConstants.getPreference(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, project);
		String[] favourites= pref.split(";"); //$NON-NLS-1$
		if (favourites.length == 0) {
			return;
		}

		CompilationUnit root= context.getASTRoot();
		AST ast= root.getAST();
		
		String name= node.getIdentifier();
		String[] staticImports= SimilarElementsRequestor.getStaticImportFavorites(context.getCompilationUnit(), name, isMethod, favourites);
		for (int i= 0; i < staticImports.length; i++) {
			String curr= staticImports[i];
			
			ImportRewrite importRewrite= StubUtility.createImportRewrite(root, true);
			ASTRewrite astRewrite= ASTRewrite.create(ast);
			
			String label;
			String qualifiedTypeName= Signature.getQualifier(curr);
			String elementLabel= BasicElementLabels.getJavaElementName(JavaModelUtil.concatenateName(Signature.getSimpleName(qualifiedTypeName), name));
			
			String res= importRewrite.addStaticImport(qualifiedTypeName, name, isMethod, new ContextSensitiveImportRewriteContext(root, node.getStartPosition(), importRewrite));
			int dot= res.lastIndexOf('.');
			if (dot != -1) {
				String usedTypeName= importRewrite.addImport(qualifiedTypeName);
				Name newName= ast.newQualifiedName(ast.newName(usedTypeName), ast.newSimpleName(name));
				astRewrite.replace(node, newName, null);
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_change_to_static_import_description, elementLabel);
			} else {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_add_static_import_description, elementLabel);
			}

			Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL);
			ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), astRewrite, IProposalRelevance.ADD_STATIC_IMPORT, image);
			proposal.setImportRewrite(importRewrite);
			proposals.add(proposal);
		}
	}
}