当前位置: 首页>>代码示例>>Java>>正文


Java AbstractJavaCompletionProposal类代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal的典型用法代码示例。如果您正苦于以下问题:Java AbstractJavaCompletionProposal类的具体用法?Java AbstractJavaCompletionProposal怎么用?Java AbstractJavaCompletionProposal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AbstractJavaCompletionProposal类属于org.eclipse.jdt.internal.ui.text.java包,在下文中一共展示了AbstractJavaCompletionProposal类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAssists

import org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal; //导入依赖的package包/类
@Override
public IJavaCompletionProposal[] getAssists(IInvocationContext context, IProblemLocation[] locations)
		throws CoreException {
	return new IJavaCompletionProposal[] { new AbstractJavaCompletionProposal() {
		public org.eclipse.jface.viewers.StyledString getStyledDisplayString() {
			ICompilationUnit compilationUnit = context.getCompilationUnit();
			return new StyledString(
					"Generate Getter and setter for " + compilationUnit.findPrimaryType().getElementName());
		}
		
		protected int getPatternMatchRule(String pattern, String string) {
			// override the match rule since we do not work with a pattern, but just want to open the "Generate Getters and Setters..." dialog
			return -1;
		};
		
		public void apply(org.eclipse.jface.text.ITextViewer viewer, char trigger, int stateMask, int offset) {
			
			if(context instanceof AssistContext) {
				AssistContext assistContext = (AssistContext) context;
				AddGetterSetterAction addGetterSetterAction = new AddGetterSetterAction((CompilationUnitEditor)assistContext.getEditor());
				
				addGetterSetterAction.run();
			}
			
		}
	} };
}
 
开发者ID:vogellacompany,项目名称:codeexamples-eclipse,代码行数:28,代码来源:QuickAssistProcessor1.java

示例2: createCollector

import org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal; //导入依赖的package包/类
/**
 * Create a proposal collector that's able to gather the passed completions/related java elements and adds 
 * them to the passed 'ret' parameter
 * 
 * @param filterCompletionName may be null or a name to which we want to match the java element name (so, only
 * a java element with an exact match of its name to filterCompletionName is added).
 * 
 * @param ret the placeholder for the found java elements and completion proposals
 * @param unit the ICompilationUnit that's used (must be passed in the CompletionProposalCollector constructor).
 * @return the collector that will gather the completions (note that it'll keep the 'ret' placeholder alive unti it's 
 * garbage-collected.
 */
protected CompletionProposalCollector createCollector(final String filterCompletionName,
        final List<Tuple<IJavaElement, CompletionProposal>> ret, ICompilationUnit unit) {
    CompletionProposalCollector collector = new CompletionProposalCollector(unit) {

        /**
         * Override the java proposal creation to always return null, as we'll keep just what we actually need.
         */
        @SuppressWarnings("restriction")
        @Override
        public IJavaCompletionProposal createJavaCompletionProposal(CompletionProposal proposal) {
            IJavaCompletionProposal javaCompletionProposal = super.createJavaCompletionProposal(proposal);
            if (javaCompletionProposal instanceof AbstractJavaCompletionProposal) {
                AbstractJavaCompletionProposal prop = (AbstractJavaCompletionProposal) javaCompletionProposal;
                IJavaElement javaElement = prop.getJavaElement();
                if (javaElement != null) {

                    if (filterCompletionName == null) {
                        ret.add(new Tuple<IJavaElement, CompletionProposal>(javaElement, proposal));
                        return null;
                    }

                    if (javaElement.getElementName().equals(filterCompletionName)) {
                        ret.add(new Tuple<IJavaElement, CompletionProposal>(javaElement, proposal));
                        return null;
                    }

                }
            }
            return null;
        }
    };
    return collector;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:46,代码来源:AbstractJavaClassModule.java

示例3: existsDefaultHelper

import org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal; //导入依赖的package包/类
protected boolean existsDefaultHelper(ICompletionProposal[] proposals) {
	if(proposals == null) {
		return false;
	}
	for(ICompletionProposal p : proposals) {
		if(p instanceof AbstractJavaCompletionProposal) {
			if(((AbstractJavaCompletionProposal) p).getReplacementString().equals(Helper.class.getCanonicalName())) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:masao-kunii,项目名称:byteman-editor,代码行数:14,代码来源:BytemanHelperAssistProcessor.java

示例4: getSortKey

import org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal; //导入依赖的package包/类
private String getSortKey(ICompletionProposal p) {
  if (p instanceof AbstractJavaCompletionProposal)
    return ((AbstractJavaCompletionProposal) p).getSortString();
  return p.getDisplayString();
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:CompletionProposalComparator.java

示例5: getSortKey

import org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal; //导入依赖的package包/类
private String getSortKey(ICompletionProposal p) {
	if (p instanceof AbstractJavaCompletionProposal)
		return ((AbstractJavaCompletionProposal) p).getSortString();
	return p.getDisplayString();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:6,代码来源:CompletionProposalComparator.java

示例6: computeCompletionProposals

import org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal; //导入依赖的package包/类
protected ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset, boolean isHelper) {
	IJavaProject project = getActiveProject();
	if(project == null || !project.isOpen()){
		return null;
	}

	try {
		String source = viewer.getDocument().get(0, offset);
		String lastWord = StringUtils.getLastWord(source);

		IJavaCompletionProposal[] proposals = getJavaCompletionProposals(project, lastWord);

		List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();

		for(ICompletionProposal proposal : proposals) {
			if(proposal.getImage() != null){
				if(proposal instanceof LazyJavaTypeCompletionProposal ||
						proposal instanceof JavaCompletionProposal){
					AbstractJavaCompletionProposal p = (AbstractJavaCompletionProposal) proposal;
					if("_xxx".equals(p.getDisplayString())
							|| (PATTERN_BYTEMAN.matcher(p.getDisplayString()).matches() && !isHelper)) {
						continue;
					}
					if(PATTERN_JAVA_LANG.matcher(p.getDisplayString()).matches()) {
						if(!isAssistJavaLangPackage()) {
							continue;
						}
						if(!p.getReplacementString().startsWith("java.lang.")) {
							p.setReplacementString("java.lang." + p.getReplacementString());
						}
					}

					String replacementString = p.getReplacementString();
					IType type = project.findType(replacementString);
					if(type != null) {
						p.setReplacementString(convert4InnerClass(type, replacementString));
					}

					p.setReplacementOffset(offset - lastWord.length());
					p.setReplacementLength(lastWord.length());
					p.setCursorPosition(p.getReplacementString().length());
					result.add(p);
				}
			}
		}

		return result.toArray(new ICompletionProposal[result.size()]);

	} catch(Exception ex){
		BytemanEditorPlugin.logException(ex);
	}

	return null;
}
 
开发者ID:masao-kunii,项目名称:byteman-editor,代码行数:55,代码来源:BytemanClassAssistProcessor.java


注:本文中的org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。