本文整理汇总了Java中org.eclipse.jdt.ui.text.java.CompletionProposalComparator类的典型用法代码示例。如果您正苦于以下问题:Java CompletionProposalComparator类的具体用法?Java CompletionProposalComparator怎么用?Java CompletionProposalComparator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompletionProposalComparator类属于org.eclipse.jdt.ui.text.java包,在下文中一共展示了CompletionProposalComparator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJavaAnnotationFixes
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
private ICompletionProposal[] getJavaAnnotationFixes(IJavaAnnotation javaAnnotation) {
ProblemLocation location= new ProblemLocation(position.getOffset(), position.getLength(), javaAnnotation);
ICompilationUnit cu= javaAnnotation.getCompilationUnit();
if (cu == null)
return NO_PROPOSALS;
ISourceViewer sourceViewer= null;
if (viewer instanceof ISourceViewer)
sourceViewer= (ISourceViewer) viewer;
IInvocationContext context= new AssistContext(cu, sourceViewer, location.getOffset(), location.getLength(), SharedASTProvider.WAIT_ACTIVE_ONLY);
if (!SpellingAnnotation.TYPE.equals(javaAnnotation.getType()) && !hasProblem(context.getASTRoot().getProblems(), location))
return NO_PROPOSALS;
ArrayList<IJavaCompletionProposal> proposals= new ArrayList<IJavaCompletionProposal>();
JavaCorrectionProcessor.collectCorrections(context, new IProblemLocation[] { location }, proposals);
Collections.sort(proposals, new CompletionProposalComparator());
return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
示例2: computeCompletionProposals
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
@Override
public ICompletionProposal[] computeCompletionProposals(
ITextViewer textViewer, int documentPosition) {
rememberJavaProject(textViewer.getDocument());
addedDynamicWidgetProposals = false;
DtdRemover dtdRemover = DtdRemover.create(textViewer, documentPosition);
try {
if (dtdRemover != null) {
textViewer = dtdRemover.textViewer;
}
List<ICompletionProposal> proposals = getWstCompletionProposals(
textViewer, documentPosition);
if (proposals == null) {
return null;
}
// Sort all of the proposals based on relevance and alphabet
Collections.sort(proposals, new CompletionProposalComparator());
if (addedDynamicWidgetProposals) {
removeSchemaWidgetProposals(proposals, textViewer.getDocument());
}
removeSchemaUiBinderElementProposal(
(IStructuredDocument) textViewer.getDocument(), proposals);
return proposals.toArray(new ICompletionProposal[proposals.size()]);
} finally {
if (dtdRemover != null) {
dtdRemover.release();
}
}
}
示例3: StrutsTaglibCompletionProposalComputer
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
public StrutsTaglibCompletionProposalComputer() {
strutsTaglibParser = new StrutsTaglibParser();
strutsXmlParser = new StrutsXmlParser();
annotationParser = new AnnotationParser();
proposalComparator = new CompletionProposalComparator();
proposalComparator.setOrderAlphabetically(true);
}
示例4: StrutsXmlCompletionProposalComputer
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
public StrutsXmlCompletionProposalComputer() {
strutsXmlParser = new StrutsXmlParser();
tilesXmlParser = new TilesXmlParser();
proposalComparator = new CompletionProposalComparator();
proposalComparator.setOrderAlphabetically(true);
methodProposalComparator = new ActionMethodProposalComparator();
}
示例5: JavaSourcePackageFragmentRootCompletionProcessor
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
public JavaSourcePackageFragmentRootCompletionProcessor() {
fRoot= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
String triggers= preferenceStore.getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
fProposalAutoActivationSet= triggers.toCharArray();
fComparator= new CompletionProposalComparator();
fLabelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_SMALL_ICONS);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:JavaSourcePackageFragmentRootCompletionProcessor.java
示例6: JavaPackageFragmentRootCompletionProcessor
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
/**
* Creates a <code>JavaPackageCompletionProcessor</code> to complete existing packages
* in the context of <code>packageFragmentRoot</code>.
*
* @param packageFragmentRoot the context for package completion
*/
public JavaPackageFragmentRootCompletionProcessor(IPackageFragmentRoot packageFragmentRoot) {
fPackageFragmentRoot= packageFragmentRoot;
fComparator= new CompletionProposalComparator();
IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
String triggers= preferenceStore.getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
fProposalAutoActivationSet = triggers.toCharArray();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:JavaPackageFragmentRootCompletionProcessor.java
示例7: JavaPackageCompletionProcessor
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
/**
* Creates a <code>JavaPackageCompletionProcessor</code>.
* The Processor uses the given <code>ILabelProvider</code> to show text and icons for the
* possible completions.
* @param labelProvider Used for the popups.
*/
public JavaPackageCompletionProcessor(ILabelProvider labelProvider) {
fComparator= new CompletionProposalComparator();
fLabelProvider= labelProvider;
IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
String triggers= preferenceStore.getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
fProposalAutoActivationSet = triggers.toCharArray();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:JavaPackageCompletionProcessor.java
示例8: CUPositionCompletionProcessor
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
/**
* Creates a <code>CUPositionCompletionProcessor</code>.
* The completion context must be set via {@link #setCompletionContext(ICompilationUnit,String,String)}.
* @param completionRequestor the completion requestor
*/
public CUPositionCompletionProcessor(CUPositionCompletionRequestor completionRequestor) {
fCompletionRequestor= completionRequestor;
fComparator= new CompletionProposalComparator();
IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
String triggers= preferenceStore.getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA);
fProposalAutoActivationSet = triggers.toCharArray();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:CUPositionCompletionProcessor.java
示例9: computeQuickAssistProposals
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) {
ISourceViewer viewer= quickAssistContext.getSourceViewer();
int documentOffset= quickAssistContext.getOffset();
IEditorPart part= fAssistant.getEditor();
ICompilationUnit cu= JavaUI.getWorkingCopyManager().getWorkingCopy(part.getEditorInput());
IAnnotationModel model= JavaUI.getDocumentProvider().getAnnotationModel(part.getEditorInput());
AssistContext context= null;
if (cu != null) {
int length= viewer != null ? viewer.getSelectedRange().y : 0;
context= new AssistContext(cu, viewer, part, documentOffset, length);
}
Annotation[] annotations= fAssistant.getAnnotationsAtOffset();
fErrorMessage= null;
ICompletionProposal[] res= null;
if (model != null && context != null && annotations != null) {
ArrayList<IJavaCompletionProposal> proposals= new ArrayList<IJavaCompletionProposal>(10);
IStatus status= collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(), proposals);
res= proposals.toArray(new ICompletionProposal[proposals.size()]);
if (!status.isOK()) {
fErrorMessage= status.getMessage();
JavaPlugin.log(status);
}
}
if (res == null || res.length == 0) {
return new ICompletionProposal[] { new ChangeCorrectionProposal(CorrectionMessages.NoCorrectionProposal_description, new NullChange(""), IProposalRelevance.NO_SUGGESSTIONS_AVAILABLE, null) }; //$NON-NLS-1$
}
if (res.length > 1) {
Arrays.sort(res, new CompletionProposalComparator());
}
return res;
}
示例10: internalGetResolutions
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
private static IMarkerResolution[] internalGetResolutions(IMarker marker) {
if (!internalHasResolutions(marker)) {
return NO_RESOLUTIONS;
}
ICompilationUnit cu= getCompilationUnit(marker);
if (cu != null) {
IEditorInput input= EditorUtility.getEditorInput(cu);
if (input != null) {
IProblemLocation location= findProblemLocation(input, marker);
if (location != null) {
IInvocationContext context= new AssistContext(cu, location.getOffset(), location.getLength());
if (!hasProblem (context.getASTRoot().getProblems(), location))
return NO_RESOLUTIONS;
ArrayList<IJavaCompletionProposal> proposals= new ArrayList<IJavaCompletionProposal>();
JavaCorrectionProcessor.collectCorrections(context, new IProblemLocation[] { location }, proposals);
Collections.sort(proposals, new CompletionProposalComparator());
int nProposals= proposals.size();
IMarkerResolution[] resolutions= new IMarkerResolution[nProposals];
for (int i= 0; i < nProposals; i++) {
resolutions[i]= new CorrectionMarkerResolution(context.getCompilationUnit(), location.getOffset(), location.getLength(), proposals.get(i), marker);
}
return resolutions;
}
}
}
return NO_RESOLUTIONS;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:CorrectionMarkerResolutionGenerator.java
示例11: computeQuickAssistProposals
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) {
ISourceViewer viewer= quickAssistContext.getSourceViewer();
int documentOffset= quickAssistContext.getOffset();
IEditorPart part= fAssistant.getEditor();
ICompilationUnit cu= JavaUI.getWorkingCopyManager().getWorkingCopy(part.getEditorInput());
IAnnotationModel model= JavaUI.getDocumentProvider().getAnnotationModel(part.getEditorInput());
AssistContext context= null;
if (cu != null) {
int length= viewer != null ? viewer.getSelectedRange().y : 0;
context= new AssistContext(cu, viewer, part, documentOffset, length);
}
Annotation[] annotations= fAssistant.getAnnotationsAtOffset();
fErrorMessage= null;
ICompletionProposal[] res= null;
if (model != null && context != null && annotations != null) {
ArrayList<IJavaCompletionProposal> proposals= new ArrayList<IJavaCompletionProposal>(10);
IStatus status= collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(), proposals);
res= proposals.toArray(new ICompletionProposal[proposals.size()]);
if (!status.isOK()) {
fErrorMessage= status.getMessage();
JavaPlugin.log(status);
}
}
if (res == null || res.length == 0) {
return new ICompletionProposal[] { new ChangeCorrectionProposal(CorrectionMessages.NoCorrectionProposal_description, new NullChange(""), 0, null) }; //$NON-NLS-1$
}
if (res.length > 1) {
Arrays.sort(res, new CompletionProposalComparator());
}
return res;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:39,代码来源:JavaCorrectionProcessor.java
示例12: createAttrCompletionProposals
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
public static List<ICompletionProposal> createAttrCompletionProposals(
String[][] proposalsData, String prefix, IRegion region,
String valueSeparator, String attrvalue,
CompletionProposalComparator proposalComparator) {
List<ICompletionProposal> list = new ArrayList<ICompletionProposal>();
if (proposalsData != null && region != null) {
ElementRegion parsedValue = ParseUtil.parseElementValue(attrvalue,
prefix, valueSeparator, region.getOffset());
List<String> excludes = new ArrayList<String>();
// multivalue
if (valueSeparator != null && !valueSeparator.isEmpty()
&& attrvalue.contains(valueSeparator)) {
// exclude already defined values except current value
String[] valArr = attrvalue.split(valueSeparator);
for (String val : valArr) {
if (!parsedValue.getValue().equalsIgnoreCase(val.trim())) {
excludes.add(val.trim());
}
}
}
// if first contains '/' assume all proposals are paths
boolean pathLike = proposalsData[0][0].contains("/");
String prefixLowCase = parsedValue.getName().toLowerCase(
Locale.ROOT);
if (pathLike && !prefixLowCase.isEmpty()
&& prefixLowCase.charAt(0) != '/') {
prefixLowCase = "/" + prefixLowCase;
}
for (String[] proposal : proposalsData) {
String propLowCase = proposal[0].toLowerCase(Locale.ROOT);
if (!excludes.contains(proposal[0])
&& (propLowCase.startsWith(prefixLowCase) || (pathLike && propLowCase
.contains(prefixLowCase)))) {
list.add(new CompletionProposal(proposal[0], parsedValue
.getValueRegion().getOffset(), parsedValue
.getValueRegion().getLength(),
proposal[0].length(), null, null, null, proposal[1]));
}
}
}
if (proposalComparator != null) {
Collections.sort(list, proposalComparator);
}
return list;
}
示例13: StrutsValidatorsXmlCompletionProposalComputer
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
public StrutsValidatorsXmlCompletionProposalComputer() {
strutsValidatorsXmlParser = new StrutsValidatorsXmlParser();
proposalComparator = new CompletionProposalComparator();
proposalComparator.setOrderAlphabetically(true);
}
示例14: TilesXmlCompletionProposalComputer
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator; //导入依赖的package包/类
public TilesXmlCompletionProposalComputer() {
tilesXmlParser = new TilesXmlParser();
proposalComparator = new CompletionProposalComparator();
proposalComparator.setOrderAlphabetically(true);
}