Example usage for org.eclipse.jdt.internal.compiler.env AccessRestriction getProblemId

List of usage examples for org.eclipse.jdt.internal.compiler.env AccessRestriction getProblemId

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.env AccessRestriction getProblemId.

Prototype

public int getProblemId() 

Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.search.TypeNameMatchRequestorWrapper.java

License:Open Source License

public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames,
        String path, AccessRestriction access) {

    // Get type/*from   ww w  .  j  a v a 2s  .  c  om*/
    try {
        IType type = null;
        if (this.handleFactory != null) {
            //todo openable
            Openable openable = null;//this.handleFactory.createOpenable(path, this.scope);
            if (openable == null)
                return;
            switch (openable.getElementType()) {
            case IJavaElement.COMPILATION_UNIT:
                ICompilationUnit cu = (ICompilationUnit) openable;
                if (enclosingTypeNames != null && enclosingTypeNames.length > 0) {
                    type = cu.getType(new String(enclosingTypeNames[0]));
                    for (int j = 1, l = enclosingTypeNames.length; j < l; j++) {
                        type = type.getType(new String(enclosingTypeNames[j]));
                    }
                    type = type.getType(new String(simpleTypeName));
                } else {
                    type = cu.getType(new String(simpleTypeName));
                }
                break;
            case IJavaElement.CLASS_FILE:
                type = ((IClassFile) openable).getType();
                break;
            }
        } else {
            int separatorIndex = path.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR);
            type = separatorIndex == -1
                    ? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames)
                    : createTypeFromJar(path, separatorIndex);
        }

        // Accept match if the type has been found
        if (type != null) {
            // hierarchy scopes require one more check:
            if (!(this.scope instanceof org.eclipse.jdt.internal.core.search.HierarchyScope)
                    || ((HierarchyScope) this.scope).enclosesFineGrained(type)) {

                // Create the match
                final JavaSearchTypeNameMatch match = new JavaSearchTypeNameMatch(type, modifiers);

                // Update match accessibility
                if (access != null) {
                    switch (access.getProblemId()) {
                    case IProblem.ForbiddenReference:
                        match.setAccessibility(IAccessRule.K_NON_ACCESSIBLE);
                        break;
                    case IProblem.DiscouragedReference:
                        match.setAccessibility(IAccessRule.K_DISCOURAGED);
                        break;
                    }
                }

                // Accept match
                this.requestor.acceptTypeNameMatch(match);
            }
        }
    } catch (JavaModelException e) {
        // skip
    }
}

From source file:org.codehaus.groovy.eclipse.codeassist.processors.GroovyProposalTypeSearchRequestor.java

License:Apache License

public void acceptConstructor(int modifiers, char[] simpleTypeName, int parameterCount, char[] signature,
        char[][] parameterTypes, char[][] parameterNames, int typeModifiers, char[] packageName, int extraFlags,
        String path, AccessRestriction accessRestriction) {

    if (shouldAcceptConstructors) {

        // does not check cancellation for every types to avoid performance
        // loss/*from   w  w w .  j  a  va2  s  . c o  m*/
        if ((this.foundConstructorsCount % (CHECK_CANCEL_FREQUENCY)) == 0)
            checkCancel();
        this.foundConstructorsCount++;

        if ((typeModifiers & ClassFileConstants.AccEnum) != 0)
            return;

        int accessibility = IAccessRule.K_ACCESSIBLE;
        if (accessRestriction != null) {
            switch (accessRestriction.getProblemId()) {
            case IProblem.ForbiddenReference:
                // forbidden references are removed
                return;
            case IProblem.DiscouragedReference:
                // discouraged references have lower priority
                accessibility = IAccessRule.K_DISCOURAGED;
                break;
            }
        }

        if (signature == null) {
            // signature = Signature.createArraySignature(typeSignature,
            // arrayCount)
        }

        if (this.acceptedConstructors == null) {
            this.acceptedConstructors = new ObjectVector();
        }
        this.acceptedConstructors
                .add(new AcceptedConstructor(modifiers, simpleTypeName, parameterCount, signature,
                        parameterTypes, parameterNames, typeModifiers, packageName, extraFlags, accessibility));
    }

}

From source file:org.codehaus.groovy.eclipse.codeassist.processors.GroovyProposalTypeSearchRequestor.java

License:Apache License

public void acceptType(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, int modifiers,
        AccessRestriction accessRestriction) {
    // does not check cancellation for every types to avoid performance
    // loss/*  ww  w. j a  v  a  2s  .c  o  m*/
    if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY) == 0)
        checkCancel();
    this.foundTypesCount++;

    // ignore synthetic
    if (CharOperation.contains('$', simpleTypeName)) {
        return;
    }

    int accessibility = IAccessRule.K_ACCESSIBLE;
    if (accessRestriction != null) {
        switch (accessRestriction.getProblemId()) {
        case IProblem.ForbiddenReference:
            // forbidden references are removed
            return;
        case IProblem.DiscouragedReference:
            // discouraged references have a lower priority
            accessibility = IAccessRule.K_DISCOURAGED;
            break;
        }
    }

    if (this.acceptedTypes == null) {
        this.acceptedTypes = new ObjectVector();
    }
    this.acceptedTypes
            .add(new AcceptedType(packageName, simpleTypeName, enclosingTypeNames, modifiers, accessibility));
}

From source file:org.eclipse.che.jdt.internal.core.search.TypeNameMatchRequestorWrapper.java

License:Open Source License

public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames,
        String path, AccessRestriction access) {

    // Get type//  w  w w  .  jav a 2 s  . c o m
    try {
        IType type = null;
        if (this.handleFactory != null) {
            Openable openable = this.handleFactory.createOpenable(path, this.scope);
            if (openable == null)
                return;
            switch (openable.getElementType()) {
            case IJavaElement.COMPILATION_UNIT:
                ICompilationUnit cu = (ICompilationUnit) openable;
                if (enclosingTypeNames != null && enclosingTypeNames.length > 0) {
                    type = cu.getType(new String(enclosingTypeNames[0]));
                    for (int j = 1, l = enclosingTypeNames.length; j < l; j++) {
                        type = type.getType(new String(enclosingTypeNames[j]));
                    }
                    type = type.getType(new String(simpleTypeName));
                } else {
                    type = cu.getType(new String(simpleTypeName));
                }
                break;
            case IJavaElement.CLASS_FILE:
                type = ((IClassFile) openable).getType();
                break;
            }
        } else {
            int separatorIndex = path.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR);
            type = separatorIndex == -1
                    ? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames)
                    : createTypeFromJar(path, separatorIndex);
        }

        // Accept match if the type has been found
        if (type != null) {
            // hierarchy scopes require one more check:
            if (!(this.scope instanceof HierarchyScope)
                    || ((HierarchyScope) this.scope).enclosesFineGrained(type)) {

                // Create the match
                final JavaSearchTypeNameMatch match = new JavaSearchTypeNameMatch(type, modifiers);

                // Update match accessibility
                if (access != null) {
                    switch (access.getProblemId()) {
                    case IProblem.ForbiddenReference:
                        match.setAccessibility(IAccessRule.K_NON_ACCESSIBLE);
                        break;
                    case IProblem.DiscouragedReference:
                        match.setAccessibility(IAccessRule.K_DISCOURAGED);
                        break;
                    }
                }

                // Accept match
                this.requestor.acceptTypeNameMatch(match);
            }
        }
    } catch (JavaModelException e) {
        // skip
    }
}

From source file:org.eclipse.che.jdt.JsonSearchRequester.java

License:Open Source License

@Override
public void acceptConstructor(int modifiers, char[] simpleTypeName, int parameterCount, char[] signature,
        char[][] parameterTypes, char[][] parameterNames, int typeModifiers, char[] packageName, int extraFlags,
        String path, AccessRestriction access) {
    if (access != null) {
        switch (access.getProblemId()) {
        case IProblem.ForbiddenReference:
            return;
        }//  w  ww . ja  va2 s  . c o m
    }
    JsonObject constructor = new JsonObject();
    constructor.addProperty("modifiers", modifiers);
    constructor.addProperty("simpleTypeName", new String(simpleTypeName));
    constructor.addProperty("parameterCount", parameterCount);
    constructor.add("signature",
            signature == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(signature)));
    constructor.add("parameterTypes", BinaryTypeConvector.toJsonArrayString(parameterTypes));
    constructor.add("parameterNames", BinaryTypeConvector.toJsonArrayString(parameterNames));
    constructor.addProperty("typeModifiers", typeModifiers);
    constructor.addProperty("packageName", new String(packageName));
    constructor.addProperty("extraFlags", extraFlags);
    result.add(constructor);
}

From source file:org.eclipse.che.jdt.JsonSearchRequester.java

License:Open Source License

@Override
public void acceptType(char[] packageName, char[] typeName, char[][] enclosingTypeNames, int modifiers,
        AccessRestriction accessRestriction) {
    if (accessRestriction != null) {
        switch (accessRestriction.getProblemId()) {
        case IProblem.ForbiddenReference:
            return;
        }//from ww  w  .  j a  va2  s. c  o  m
    }
    JsonObject type = new JsonObject();
    type.addProperty("packageName", new String(packageName));
    type.addProperty("typeName", new String(typeName));
    type.add("enclosingTypeNames", BinaryTypeConvector.toJsonArrayString(enclosingTypeNames));
    type.addProperty("modifiers", modifiers);
    result.add(type);
}

From source file:org.eclipse.xtext.common.types.xtext.ui.JdtTypesProposalProvider.java

License:Open Source License

protected void searchAndCreateProposals(IJavaSearchScope scope,
        final ICompletionProposalFactory proposalFactory, ContentAssistContext context,
        EReference typeReference, final Filter filter, final IValueConverter<String> valueConverter,
        final ICompletionProposalAcceptor acceptor) throws JavaModelException {
    String prefix = context.getPrefix();
    List<String> split = Strings.split(prefix, '.');
    char[] typeName = null;
    char[] packageName = null;
    if (prefix.length() > 0 && !split.isEmpty()) {
        CharMatcher dotMatcher = CharMatcher.is('.');
        if (Character.isUpperCase(split.get(split.size() - 1).charAt(0))) {
            typeName = split.get(split.size() - 1).toCharArray();
            if (split.size() > 1)
                packageName = ("*" + dotMatcher
                        .replaceFrom(prefix.substring(0, prefix.length() - (typeName.length + 1)), "*.") + "*")
                                .toCharArray();
        } else {/*  ww w .j a v a 2 s .  c o m*/
            if (prefix.endsWith("."))
                prefix = prefix.substring(0, prefix.length() - 1);
            packageName = ("*" + dotMatcher.replaceFrom(prefix, "*.") + "*").toCharArray();
        }
    }
    IScope typeScope = null;
    if (context.getCurrentModel() != null) {
        typeScope = scopeProvider.getScope(context.getCurrentModel(), typeReference);
    }
    final IReplacementTextApplier textApplier = createTextApplier(context, typeScope, qualifiedNameConverter,
            valueConverter);
    final ICompletionProposalAcceptor scopeAware = textApplier != null
            ? new ICompletionProposalAcceptor.Delegate(acceptor) {
                @Override
                public void accept(ICompletionProposal proposal) {
                    if (proposal instanceof ConfigurableCompletionProposal) {
                        ((ConfigurableCompletionProposal) proposal).setTextApplier(textApplier);
                    }
                    super.accept(proposal);
                }
            }
            : acceptor;
    Builder contextBuilder = context.copy();
    final PrefixMatcher original = context.getMatcher();
    contextBuilder.setMatcher(new PrefixMatcher() {
        @Override
        public boolean isCandidateMatchingPrefix(String name, String prefix) {
            if (original.isCandidateMatchingPrefix(name, prefix))
                return true;
            String nameWithoutDollars = name.replace('$', '.');
            String prefixWithoutDollars = prefix.replace('$', '.');
            final boolean nameOrPrefixHasDollars = (nameWithoutDollars != name)
                    || (prefixWithoutDollars != prefix);
            if (nameOrPrefixHasDollars
                    && original.isCandidateMatchingPrefix(nameWithoutDollars, prefixWithoutDollars))
                return true;
            String sub = nameWithoutDollars;
            int delimiter = sub.indexOf('.');
            while (delimiter != -1) {
                sub = sub.substring(delimiter + 1);
                delimiter = sub.indexOf('.');
                if (delimiter == -1 || prefixWithoutDollars.length() > 0
                        && Character.isLowerCase(prefixWithoutDollars.charAt(0))) {
                    if (original.isCandidateMatchingPrefix(sub, prefixWithoutDollars))
                        return true;
                }
            }
            return false;
        }
    });
    final ContentAssistContext myContext = contextBuilder.toContext();
    final IJvmTypeProvider jvmTypeProvider = jdtTypeProviderFactory
            .findOrCreateTypeProvider(context.getResource().getResourceSet());
    final Set<String> filteredTypeNames = getDirtyTypeNames();
    final Filter dirtyTypenameFilter = new ITypesProposalProvider.Filter() {
        @Override
        public boolean accept(int modifiers, char[] packageName, char[] simpleTypeName,
                char[][] enclosingTypeNames, String path) {
            if (path == null || path.endsWith(".class") || path.endsWith(".java")) { // Java index match
                String identifier = getIdentifier(packageName, simpleTypeName, enclosingTypeNames);
                if (filteredTypeNames.contains(identifier)) {
                    return false;
                }
            }
            return true;
        }

        @Override
        public int getSearchFor() {
            return filter.getSearchFor();
        }
    };

    BasicSearchEngine searchEngine = new BasicSearchEngine();
    searchEngine.searchAllTypeNames(packageName, SearchPattern.R_PATTERN_MATCH, typeName,
            SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CAMELCASE_MATCH, filter.getSearchFor(), scope,
            new IRestrictedAccessTypeRequestor() {
                @Override
                public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
                        char[][] enclosingTypeNames, String path, AccessRestriction access) {
                    if (dirtyTypenameFilter.accept(modifiers, packageName, simpleTypeName, enclosingTypeNames,
                            path)
                            && filter.accept(modifiers, packageName, simpleTypeName, enclosingTypeNames, path)
                            && (!checkAccessRestriction()
                                    || (access == null || access.getProblemId() != IProblem.ForbiddenReference
                                            && !access.ignoreIfBetter()))) {
                        StringBuilder fqName = new StringBuilder(
                                packageName.length + simpleTypeName.length + 1);
                        if (packageName.length != 0) {
                            fqName.append(packageName);
                            fqName.append('.');
                        }
                        for (char[] enclosingType : enclosingTypeNames) {
                            /*
                             * the JDT index sometimes yields enclosingTypeNames in the form
                             * char[][] { { Outer$Middle } }
                             * rather than
                             * char[][] { { Outer }, { Middle } }
                             * thus we create the fqName as the binary name and post process the proposal later on
                             */
                            fqName.append(enclosingType);
                            fqName.append('$');
                        }
                        fqName.append(simpleTypeName);
                        String fqNameAsString = fqName.toString();
                        createTypeProposal(fqNameAsString, modifiers, enclosingTypeNames.length > 0,
                                proposalFactory, myContext, scopeAware, jvmTypeProvider, valueConverter);
                    }
                }
            }, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, new NullProgressMonitor() {
                @Override
                public boolean isCanceled() {
                    return !acceptor.canAcceptMoreProposals();
                }
            });
    if (acceptor.canAcceptMoreProposals()) {
        Iterable<IEObjectDescription> allDirtyTypes = dirtyStateManager
                .getExportedObjectsByType(TypesPackage.Literals.JVM_TYPE);
        for (IEObjectDescription description : allDirtyTypes) {
            QualifiedName qualifiedName = description.getQualifiedName();
            final int modifiers = getDirtyStateModifiers(context, description);
            if (filter.accept(modifiers, qualifiedName.skipLast(1).toString().toCharArray(),
                    qualifiedName.getLastSegment().toCharArray(), new char[0][0],
                    description.getEObjectURI().toPlatformString(true))) {
                String fqName = description.getQualifiedName().toString();
                createTypeProposal(fqName, modifiers, fqName.indexOf('$') > 0, proposalFactory, myContext,
                        scopeAware, jvmTypeProvider, valueConverter);
            }
        }
    }
}

From source file:org.eclipse.xtext.xbase.ui.imports.InteractiveUnresolvedTypeResolver.java

License:Open Source License

protected void findCandidateTypes(final JvmDeclaredType contextType, final String typeSimpleName,
        IJavaSearchScope searchScope, final IAcceptor<JvmDeclaredType> acceptor) throws JavaModelException {
    BasicSearchEngine searchEngine = new BasicSearchEngine();
    final IVisibilityHelper contextualVisibilityHelper = new ContextualVisibilityHelper(visibilityHelper,
            contextType);//  www.j a  v  a2 s .  c  o  m
    searchEngine.searchAllTypeNames(null, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
            typeSimpleName.toCharArray(), SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
            IJavaSearchConstants.TYPE, searchScope, new IRestrictedAccessTypeRequestor() {
                @Override
                public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
                        char[][] enclosingTypeNames, String path, AccessRestriction access) {
                    final String qualifiedTypeName = getQualifiedTypeName(packageName, enclosingTypeNames,
                            simpleTypeName);
                    if ((access == null || (access.getProblemId() != IProblem.ForbiddenReference
                            && !access.ignoreIfBetter()))
                            && !TypeFilter.isFiltered(packageName, simpleTypeName)) {
                        JvmType importType = typeRefs.findDeclaredType(qualifiedTypeName,
                                contextType.eResource());
                        if (importType instanceof JvmDeclaredType
                                && contextualVisibilityHelper.isVisible((JvmDeclaredType) importType)) {
                            acceptor.accept((JvmDeclaredType) importType);
                        }
                    }
                }
            }, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, new NullProgressMonitor());
}

From source file:org.eclipse.xtext.xbase.ui.quickfix.JavaTypeQuickfixes.java

License:Open Source License

@SuppressWarnings("restriction")
protected void createImportProposals(final JvmDeclaredType contextType, final Issue issue, String typeName,
        IJavaSearchScope searchScope, final IssueResolutionAcceptor acceptor) throws JavaModelException {
    if (contextType != null) {
        final IVisibilityHelper visibilityHelper = getVisibilityHelper(contextType);
        final Pair<String, String> packageAndType = typeNameGuesser.guessPackageAndTypeName(contextType,
                typeName);/* www.java 2  s.  c o m*/
        final String wantedPackageName = packageAndType.getFirst();
        org.eclipse.jdt.internal.core.search.BasicSearchEngine searchEngine = new org.eclipse.jdt.internal.core.search.BasicSearchEngine();
        final char[] wantedPackageChars = (isEmpty(wantedPackageName)) ? null : wantedPackageName.toCharArray();
        final String wantedTypeName = packageAndType.getSecond();
        searchEngine.searchAllTypeNames(wantedPackageChars, SearchPattern.R_EXACT_MATCH,
                wantedTypeName.toCharArray(), SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.TYPE,
                searchScope, new org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor() {

                    @Override
                    public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
                            char[][] enclosingTypeNames, String path,
                            org.eclipse.jdt.internal.compiler.env.AccessRestriction access) {
                        final String qualifiedTypeName = getQualifiedTypeName(packageName, enclosingTypeNames,
                                simpleTypeName);
                        if (access == null || (access.getProblemId() != IProblem.ForbiddenReference
                                && !access.ignoreIfBetter())) {
                            JvmType importType = services.getTypeReferences()
                                    .findDeclaredType(qualifiedTypeName, contextType);
                            if (importType instanceof JvmDeclaredType
                                    && visibilityHelper.isVisible((JvmDeclaredType) importType)) {
                                StringBuilder label = new StringBuilder("Import '");
                                label.append(simpleTypeName);
                                label.append("' (");
                                label.append(packageName);
                                if (enclosingTypeNames.length > 0) {
                                    for (char[] enclosingTypeName : enclosingTypeNames) {
                                        label.append(".");
                                        label.append(enclosingTypeName);
                                    }
                                }
                                label.append(")");
                                acceptor.accept(issue, label.toString(), label.toString(), "impc_obj.gif",
                                        new ISemanticModification() {
                                            @Override
                                            public void apply(EObject element, IModificationContext context)
                                                    throws Exception {
                                                ReplacingAppendable appendable = appendableFactory.create(
                                                        context.getXtextDocument(),
                                                        (XtextResource) element.eResource(), 0, 0);
                                                appendable.append(services.getTypeReferences()
                                                        .findDeclaredType(qualifiedTypeName, element));
                                                appendable.insertNewImports();
                                            }
                                        },
                                        jdtTypeRelevance.getRelevance(qualifiedTypeName, wantedTypeName) + 100);
                            }
                        }
                    }
                }, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, new NullProgressMonitor());
    }
}

From source file:org.eclipse.xtext.xbase.ui.quickfix.JavaTypeQuickfixes.java

License:Open Source License

@SuppressWarnings("restriction")
protected boolean createConstructorProposals(final JvmDeclaredType contextType, final Issue issue,
        String typeName, IJavaSearchScope searchScope, final IssueResolutionAcceptor acceptor)
        throws JavaModelException {
    final boolean[] result = new boolean[] { false };
    if (contextType != null) {
        final IVisibilityHelper visibilityHelper = getVisibilityHelper(contextType);
        final Pair<String, String> packageAndType = typeNameGuesser.guessPackageAndTypeName(contextType,
                typeName);//from   w w w.  j  av  a 2  s  .c  o m
        final String wantedPackageName = packageAndType.getFirst();
        final String wantedTypeName = packageAndType.getSecond();
        if (typeName.endsWith(wantedTypeName)) {
            return false;
        }
        org.eclipse.jdt.internal.core.search.BasicSearchEngine searchEngine = new org.eclipse.jdt.internal.core.search.BasicSearchEngine();
        final char[] wantedPackageChars = (isEmpty(wantedPackageName)) ? null : wantedPackageName.toCharArray();
        searchEngine.searchAllTypeNames(wantedPackageChars, SearchPattern.R_EXACT_MATCH,
                wantedTypeName.toCharArray(), SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.TYPE,
                searchScope, new org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor() {

                    @Override
                    public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
                            char[][] enclosingTypeNames, String path,
                            org.eclipse.jdt.internal.compiler.env.AccessRestriction access) {
                        final String qualifiedTypeName = getQualifiedTypeName(packageName, enclosingTypeNames,
                                simpleTypeName);
                        if (access == null || (access.getProblemId() != IProblem.ForbiddenReference
                                && !access.ignoreIfBetter())) {
                            JvmType importType = services.getTypeReferences()
                                    .findDeclaredType(qualifiedTypeName, contextType);
                            if (importType instanceof JvmDeclaredType
                                    && visibilityHelper.isVisible((JvmDeclaredType) importType)) {
                                result[0] = true;
                                StringBuilder label = new StringBuilder("Change to constructor call 'new ");
                                label.append(simpleTypeName);
                                label.append("()'");
                                if (!equal(wantedPackageName, new String(packageName))) {
                                    label.append(" (");
                                    label.append(packageName);
                                    if (enclosingTypeNames.length > 0) {
                                        for (char[] enclosingTypeName : enclosingTypeNames) {
                                            label.append(".");
                                            label.append(enclosingTypeName);
                                        }
                                    }
                                    label.append(")");
                                }
                                acceptor.accept(issue, label.toString(), label.toString(), "impc_obj.gif",
                                        new ISemanticModification() {
                                            @Override
                                            public void apply(EObject element, IModificationContext context)
                                                    throws Exception {
                                                IXtextDocument document = context.getXtextDocument();
                                                DocumentRewriter rewriter = rewriterFactory.create(document,
                                                        (XtextResource) element.eResource());
                                                final int typeEndOffset = document.get().indexOf(wantedTypeName,
                                                        issue.getOffset() + wantedPackageName.length())
                                                        + wantedTypeName.length();
                                                final Section section = rewriter.newSection(issue.getOffset(),
                                                        typeEndOffset - issue.getOffset());
                                                section.append(services.getTypeReferences()
                                                        .findDeclaredType(qualifiedTypeName, element));
                                                section.append("()");
                                                final TextEdit textEdit = replaceConverter
                                                        .convertToTextEdit(rewriter.getChanges());
                                                textEdit.apply(document);
                                            }
                                        },
                                        jdtTypeRelevance.getRelevance(qualifiedTypeName, wantedTypeName) + 100);
                            }
                        }
                    }
                }, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, new NullProgressMonitor());
    }
    return result[0];
}