mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-07 16:26:11 +02:00
Fix warnings.
This commit is contained in:
parent
d29b51bbd4
commit
29abe81d9e
68 changed files with 581 additions and 601 deletions
|
@ -86,8 +86,8 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner implemen
|
||||||
if(fTokenStore.affectsBehavior(event)) {
|
if(fTokenStore.affectsBehavior(event)) {
|
||||||
fTokenStore.adaptToPreferenceChange(event);
|
fTokenStore.adaptToPreferenceChange(event);
|
||||||
}
|
}
|
||||||
for(Iterator i= pcps.iterator(); i.hasNext(); ) {
|
for (IPropertyChangeParticipant propertyChangeParticipant : pcps) {
|
||||||
((IPropertyChangeParticipant)i.next()).adaptToPreferenceChange(event);
|
propertyChangeParticipant.adaptToPreferenceChange(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +96,8 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner implemen
|
||||||
*/
|
*/
|
||||||
public boolean affectsBehavior(PropertyChangeEvent event) {
|
public boolean affectsBehavior(PropertyChangeEvent event) {
|
||||||
boolean result= fTokenStore.affectsBehavior(event);
|
boolean result= fTokenStore.affectsBehavior(event);
|
||||||
for(Iterator i= pcps.iterator(); !result && i.hasNext(); ) {
|
for(Iterator<IPropertyChangeParticipant> i= pcps.iterator(); !result && i.hasNext(); ) {
|
||||||
result |= ((IPropertyChangeParticipant)i.next()).affectsBehavior(event);
|
result |= (i.next()).affectsBehavior(event);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,8 +96,8 @@ public abstract class AbstractInformationControl extends PopupDialog implements
|
||||||
private boolean hasUnfilteredChild(TreeViewer viewer, Object element) {
|
private boolean hasUnfilteredChild(TreeViewer viewer, Object element) {
|
||||||
if (element instanceof IParent) {
|
if (element instanceof IParent) {
|
||||||
Object[] children= ((ITreeContentProvider) viewer.getContentProvider()).getChildren(element);
|
Object[] children= ((ITreeContentProvider) viewer.getContentProvider()).getChildren(element);
|
||||||
for (int i= 0; i < children.length; i++)
|
for (Object element2 : children)
|
||||||
if (select(viewer, element, children[i]))
|
if (select(viewer, element, element2))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -413,21 +413,19 @@ public abstract class AbstractInformationControl extends PopupDialog implements
|
||||||
|
|
||||||
private ICElement findElement(TreeItem[] items) {
|
private ICElement findElement(TreeItem[] items) {
|
||||||
ILabelProvider labelProvider= (ILabelProvider)fTreeViewer.getLabelProvider();
|
ILabelProvider labelProvider= (ILabelProvider)fTreeViewer.getLabelProvider();
|
||||||
for (int i= 0; i < items.length; i++) {
|
for (TreeItem item2 : items) {
|
||||||
Object item= items[i].getData();
|
Object item= item2.getData();
|
||||||
ICElement element= null;
|
ICElement element= null;
|
||||||
if (item instanceof ICElement) {
|
if (item instanceof ICElement) {
|
||||||
element= (ICElement)item;
|
element= (ICElement)item;
|
||||||
if (fStringMatcher == null)
|
if (fStringMatcher == null)
|
||||||
return element;
|
return element;
|
||||||
|
|
||||||
if (element != null) {
|
String label= labelProvider.getText(element);
|
||||||
String label= labelProvider.getText(element);
|
if (fStringMatcher.match(label))
|
||||||
if (fStringMatcher.match(label))
|
return element;
|
||||||
return element;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
element= findElement(items[i].getItems());
|
element= findElement(item2.getItems());
|
||||||
if (element != null)
|
if (element != null)
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.internal.ui.text;
|
package org.eclipse.cdt.internal.ui.text;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jface.action.IMenuManager;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
|
@ -128,8 +127,7 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
|
||||||
@Override
|
@Override
|
||||||
protected Control createContents(Composite parent) {
|
protected Control createContents(Composite parent) {
|
||||||
Control contents= super.createContents(parent);
|
Control contents= super.createContents(parent);
|
||||||
for (Iterator<Control> it= fColorExclusionControls.iterator(); it.hasNext(); ) {
|
for (Control ctrl : fColorExclusionControls) {
|
||||||
Control ctrl = it.next();
|
|
||||||
ctrl.setBackground(fBackgroundColor);
|
ctrl.setBackground(fBackgroundColor);
|
||||||
}
|
}
|
||||||
return contents;
|
return contents;
|
||||||
|
@ -207,6 +205,7 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected List<Control> getBackgroundColorExclusions() {
|
protected List<Control> getBackgroundColorExclusions() {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
List<Control> exclusions= super.getBackgroundColorExclusions();
|
List<Control> exclusions= super.getBackgroundColorExclusions();
|
||||||
exclusions.addAll(fColorExclusionControls);
|
exclusions.addAll(fColorExclusionControls);
|
||||||
return exclusions;
|
return exclusions;
|
||||||
|
@ -217,6 +216,7 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected List<Control> getForegroundColorExclusions() {
|
protected List<Control> getForegroundColorExclusions() {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
List<Control> exclusions= super.getForegroundColorExclusions();
|
List<Control> exclusions= super.getForegroundColorExclusions();
|
||||||
exclusions.addAll(fColorExclusionControls);
|
exclusions.addAll(fColorExclusionControls);
|
||||||
return exclusions;
|
return exclusions;
|
||||||
|
|
|
@ -765,8 +765,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
||||||
private int computeVisualLength(char ch) {
|
private int computeVisualLength(char ch) {
|
||||||
if (ch == '\t')
|
if (ch == '\t')
|
||||||
return getVisualTabLengthPreference();
|
return getVisualTabLengthPreference();
|
||||||
else
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,11 +11,12 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.text;
|
package org.eclipse.cdt.internal.ui.text;
|
||||||
|
|
||||||
import com.ibm.icu.text.BreakIterator;
|
|
||||||
import java.text.CharacterIterator;
|
import java.text.CharacterIterator;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
|
||||||
|
import com.ibm.icu.text.BreakIterator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A C break iterator. It returns all breaks, including before and after
|
* A C break iterator. It returns all breaks, including before and after
|
||||||
|
@ -355,8 +356,7 @@ public class CBreakIterator extends BreakIterator {
|
||||||
public boolean isBoundary(int offset) {
|
public boolean isBoundary(int offset) {
|
||||||
if (offset == getText().getBeginIndex())
|
if (offset == getText().getBeginIndex())
|
||||||
return true;
|
return true;
|
||||||
else
|
return following(offset - 1) == offset;
|
||||||
return following(offset - 1) == offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.internal.ui.text;
|
package org.eclipse.cdt.internal.ui.text;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
@ -35,9 +36,9 @@ public class CFormattingStrategy extends ContextBasedFormattingStrategy {
|
||||||
|
|
||||||
|
|
||||||
/** Documents to be formatted by this strategy */
|
/** Documents to be formatted by this strategy */
|
||||||
private final LinkedList fDocuments= new LinkedList();
|
private final LinkedList<IDocument> fDocuments= new LinkedList<IDocument>();
|
||||||
/** Partitions to be formatted by this strategy */
|
/** Partitions to be formatted by this strategy */
|
||||||
private final LinkedList fPartitions= new LinkedList();
|
private final LinkedList<TypedPosition> fPartitions= new LinkedList<TypedPosition>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new java formatting strategy.
|
* Creates a new java formatting strategy.
|
||||||
|
@ -53,17 +54,18 @@ public class CFormattingStrategy extends ContextBasedFormattingStrategy {
|
||||||
public void format() {
|
public void format() {
|
||||||
super.format();
|
super.format();
|
||||||
|
|
||||||
final IDocument document= (IDocument)fDocuments.removeFirst();
|
final IDocument document= fDocuments.removeFirst();
|
||||||
final TypedPosition partition= (TypedPosition)fPartitions.removeFirst();
|
final TypedPosition partition= fPartitions.removeFirst();
|
||||||
|
|
||||||
if (document != null && partition != null) {
|
if (document != null && partition != null) {
|
||||||
try {
|
try {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final Map<String,String> preferences = getPreferences();
|
||||||
final TextEdit edit = CodeFormatterUtil.format(
|
final TextEdit edit = CodeFormatterUtil.format(
|
||||||
CodeFormatter.K_TRANSLATION_UNIT, document.get(),
|
CodeFormatter.K_TRANSLATION_UNIT, document.get(),
|
||||||
partition.getOffset(), partition.getLength(), 0,
|
partition.getOffset(), partition.getLength(), 0,
|
||||||
TextUtilities.getDefaultLineDelimiter(document),
|
TextUtilities.getDefaultLineDelimiter(document),
|
||||||
getPreferences());
|
preferences);
|
||||||
|
|
||||||
if (edit != null)
|
if (edit != null)
|
||||||
edit.apply(document);
|
edit.apply(document);
|
||||||
|
@ -85,8 +87,14 @@ public class CFormattingStrategy extends ContextBasedFormattingStrategy {
|
||||||
public void formatterStarts(final IFormattingContext context) {
|
public void formatterStarts(final IFormattingContext context) {
|
||||||
super.formatterStarts(context);
|
super.formatterStarts(context);
|
||||||
|
|
||||||
fPartitions.addLast(context.getProperty(FormattingContextProperties.CONTEXT_PARTITION));
|
Object property = context.getProperty(FormattingContextProperties.CONTEXT_PARTITION);
|
||||||
fDocuments.addLast(context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM));
|
if (property instanceof TypedPosition) {
|
||||||
|
fPartitions.addLast((TypedPosition) property);
|
||||||
|
}
|
||||||
|
property= context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM);
|
||||||
|
if (property instanceof IDocument) {
|
||||||
|
fDocuments.addLast((IDocument) property);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class CHelpProviderDescriptor {
|
||||||
final private static String ELEMENT_PROVIDER = "provider"; //$NON-NLS-1$
|
final private static String ELEMENT_PROVIDER = "provider"; //$NON-NLS-1$
|
||||||
final private static String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
|
final private static String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static Map fProvidersMap = null;
|
private static Map<String, ICHelpProvider> fProvidersMap = null;
|
||||||
|
|
||||||
private ICHelpProvider fHelpProvider = null;
|
private ICHelpProvider fHelpProvider = null;
|
||||||
private IConfigurationElement fConfigElement;
|
private IConfigurationElement fConfigElement;
|
||||||
|
@ -79,9 +79,9 @@ public class CHelpProviderDescriptor {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map getProvidersMap(){
|
private static Map<String, ICHelpProvider> getProvidersMap(){
|
||||||
if(fProvidersMap == null){
|
if(fProvidersMap == null){
|
||||||
fProvidersMap = new HashMap();
|
fProvidersMap = new HashMap<String, ICHelpProvider>();
|
||||||
}
|
}
|
||||||
return fProvidersMap;
|
return fProvidersMap;
|
||||||
}
|
}
|
||||||
|
@ -91,9 +91,9 @@ public class CHelpProviderDescriptor {
|
||||||
if(id == null || "".equals(id)) //$NON-NLS-1$
|
if(id == null || "".equals(id)) //$NON-NLS-1$
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Map providersMap = getProvidersMap();
|
Map<String, ICHelpProvider> providersMap = getProvidersMap();
|
||||||
try{
|
try{
|
||||||
ICHelpProvider provider = (ICHelpProvider)providersMap.get(id);
|
ICHelpProvider provider = providersMap.get(id);
|
||||||
if(provider == null){
|
if(provider == null){
|
||||||
provider = (ICHelpProvider)element.createExecutableExtension(CLASS);
|
provider = (ICHelpProvider)element.createExecutableExtension(CLASS);
|
||||||
providersMap.put(id,provider);
|
providersMap.put(id,provider);
|
||||||
|
@ -133,13 +133,13 @@ public class CHelpProviderDescriptor {
|
||||||
if (provider != null && fProject != null) {
|
if (provider != null && fProject != null) {
|
||||||
ICHelpBook books[] = provider.getCHelpBooks();
|
ICHelpBook books[] = provider.getCHelpBooks();
|
||||||
if(books != null){
|
if(books != null){
|
||||||
List descriptorList = new ArrayList();
|
List<CHelpBookDescriptor> descriptorList = new ArrayList<CHelpBookDescriptor>();
|
||||||
for(int i = 0; i < books.length; i++){
|
for(int i = 0; i < books.length; i++){
|
||||||
CHelpBookDescriptor des = new CHelpBookDescriptor(books[i],projectElement);
|
CHelpBookDescriptor des = new CHelpBookDescriptor(books[i],projectElement);
|
||||||
if(des.matches(fProject))
|
if(des.matches(fProject))
|
||||||
descriptorList.add(des);
|
descriptorList.add(des);
|
||||||
}
|
}
|
||||||
fHelpBookDescriptors = (CHelpBookDescriptor[])descriptorList.toArray(new CHelpBookDescriptor[descriptorList.size()]);
|
fHelpBookDescriptors = descriptorList.toArray(new CHelpBookDescriptor[descriptorList.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(fHelpBookDescriptors == null)
|
if(fHelpBookDescriptors == null)
|
||||||
|
@ -156,12 +156,12 @@ public class CHelpProviderDescriptor {
|
||||||
CHelpBookDescriptor bookDescriptors[] = getCHelpBookDescriptors();
|
CHelpBookDescriptor bookDescriptors[] = getCHelpBookDescriptors();
|
||||||
if(bookDescriptors.length == 0)
|
if(bookDescriptors.length == 0)
|
||||||
return null;
|
return null;
|
||||||
List bookList = new ArrayList();
|
List<ICHelpBook> bookList = new ArrayList<ICHelpBook>();
|
||||||
for(int i = 0; i < bookDescriptors.length; i++){
|
for(int i = 0; i < bookDescriptors.length; i++){
|
||||||
if(bookDescriptors[i].isEnabled() && bookDescriptors[i].matches(context))
|
if(bookDescriptors[i].isEnabled() && bookDescriptors[i].matches(context))
|
||||||
bookList.add(bookDescriptors[i].getCHelpBook());
|
bookList.add(bookDescriptors[i].getCHelpBook());
|
||||||
}
|
}
|
||||||
return (ICHelpBook[])bookList.toArray(new ICHelpBook[bookList.size()]);
|
return bookList.toArray(new ICHelpBook[bookList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(Document doc, Element parentElement){
|
public void serialize(Document doc, Element parentElement){
|
||||||
|
|
|
@ -93,13 +93,13 @@ public class CHelpSettings {
|
||||||
if(providerDescriptors.length == 0)
|
if(providerDescriptors.length == 0)
|
||||||
return new CHelpBookDescriptor[0];
|
return new CHelpBookDescriptor[0];
|
||||||
|
|
||||||
List bookList = new ArrayList();
|
List<CHelpBookDescriptor> bookList = new ArrayList<CHelpBookDescriptor>();
|
||||||
for(int i = 0; i < providerDescriptors.length; i++){
|
for(int i = 0; i < providerDescriptors.length; i++){
|
||||||
CHelpBookDescriptor bookDescriptors[] = providerDescriptors[i].getCHelpBookDescriptors();
|
CHelpBookDescriptor bookDescriptors[] = providerDescriptors[i].getCHelpBookDescriptors();
|
||||||
if(bookDescriptors.length != 0)
|
if(bookDescriptors.length != 0)
|
||||||
bookList.addAll(Arrays.asList(bookDescriptors));
|
bookList.addAll(Arrays.asList(bookDescriptors));
|
||||||
}
|
}
|
||||||
return (CHelpBookDescriptor[])bookList.toArray(new CHelpBookDescriptor[bookList.size()]);
|
return bookList.toArray(new CHelpBookDescriptor[bookList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IConfigurationElement[] getConfigElements(){
|
private static IConfigurationElement[] getConfigElements(){
|
||||||
|
@ -129,7 +129,7 @@ public class CHelpSettings {
|
||||||
|
|
||||||
public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, String frag){
|
public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, String frag){
|
||||||
CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
|
CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
|
||||||
List sumaryList = new ArrayList();
|
List<IFunctionSummary> sumaryList = new ArrayList<IFunctionSummary>();
|
||||||
for(int i = 0; i < providerDescriptors.length; i++){
|
for(int i = 0; i < providerDescriptors.length; i++){
|
||||||
ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
|
ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
|
||||||
if(books != null && books.length != 0){
|
if(books != null && books.length != 0){
|
||||||
|
@ -144,12 +144,12 @@ public class CHelpSettings {
|
||||||
if(sumaryList.size() == 0)
|
if(sumaryList.size() == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return (IFunctionSummary[])sumaryList.toArray(new IFunctionSummary[sumaryList.size()]);
|
return sumaryList.toArray(new IFunctionSummary[sumaryList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, String name){
|
public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, String name){
|
||||||
CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
|
CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
|
||||||
List resourcesList = new ArrayList();
|
List<ICHelpResourceDescriptor> resourcesList = new ArrayList<ICHelpResourceDescriptor>();
|
||||||
for(int i = 0; i < providerDescriptors.length; i++){
|
for(int i = 0; i < providerDescriptors.length; i++){
|
||||||
ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
|
ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
|
||||||
if(books != null && books.length != 0){
|
if(books != null && books.length != 0){
|
||||||
|
@ -164,7 +164,7 @@ public class CHelpSettings {
|
||||||
if(resourcesList.size() == 0)
|
if(resourcesList.size() == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return (ICHelpResourceDescriptor[])resourcesList.toArray(new ICHelpResourceDescriptor[resourcesList.size()]);
|
return resourcesList.toArray(new ICHelpResourceDescriptor[resourcesList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(Document doc, Element parentElement){
|
public void serialize(Document doc, Element parentElement){
|
||||||
|
|
|
@ -409,10 +409,9 @@ public final class CHeuristicScanner implements Symbols {
|
||||||
return getToken(identOrKeyword);
|
return getToken(identOrKeyword);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// operators, number literals etc
|
|
||||||
return TokenOTHER;
|
|
||||||
}
|
}
|
||||||
|
// operators, number literals etc
|
||||||
|
return TokenOTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -511,10 +510,9 @@ public final class CHeuristicScanner implements Symbols {
|
||||||
return getToken(identOrKeyword);
|
return getToken(identOrKeyword);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// operators, number literals etc
|
|
||||||
return TokenOTHER;
|
|
||||||
}
|
}
|
||||||
|
// operators, number literals etc
|
||||||
|
return TokenOTHER;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1084,6 +1082,7 @@ public final class CHeuristicScanner implements Symbols {
|
||||||
* <code>bound</code> < <code>start</code>, or <code>UNBOUND</code>
|
* <code>bound</code> < <code>start</code>, or <code>UNBOUND</code>
|
||||||
* @return <code>true</code> if the current position looks like a composite type definition
|
* @return <code>true</code> if the current position looks like a composite type definition
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("fallthrough")
|
||||||
public boolean looksLikeCompositeTypeDefinitionBackward(int start, int bound) {
|
public boolean looksLikeCompositeTypeDefinitionBackward(int start, int bound) {
|
||||||
int token= previousToken(start - 1, bound);
|
int token= previousToken(start - 1, bound);
|
||||||
switch (token) {
|
switch (token) {
|
||||||
|
|
|
@ -217,7 +217,7 @@ public class CParameterListValidator implements IContextInformationValidator, IC
|
||||||
private int[] computeCommaPositions(String code) {
|
private int[] computeCommaPositions(String code) {
|
||||||
final int length= code.length();
|
final int length= code.length();
|
||||||
int pos= 0;
|
int pos= 0;
|
||||||
List positions= new ArrayList();
|
List<Integer> positions= new ArrayList<Integer>();
|
||||||
positions.add(new Integer(-1));
|
positions.add(new Integer(-1));
|
||||||
while (pos < length && pos != -1) {
|
while (pos < length && pos != -1) {
|
||||||
char ch= code.charAt(pos);
|
char ch= code.charAt(pos);
|
||||||
|
@ -244,7 +244,7 @@ public class CParameterListValidator implements IContextInformationValidator, IC
|
||||||
|
|
||||||
int[] fields= new int[positions.size()];
|
int[] fields= new int[positions.size()];
|
||||||
for (int i= 0; i < fields.length; i++)
|
for (int i= 0; i < fields.length; i++)
|
||||||
fields[i]= ((Integer) positions.get(i)).intValue();
|
fields[i]= positions.get(i).intValue();
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
|
@ -642,10 +643,10 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
|
||||||
CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
|
CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
|
||||||
int stateMasks[]= new int[hoverDescs.length];
|
int stateMasks[]= new int[hoverDescs.length];
|
||||||
int stateMasksLength= 0;
|
int stateMasksLength= 0;
|
||||||
for (int i= 0; i < hoverDescs.length; i++) {
|
for (CEditorTextHoverDescriptor hoverDesc : hoverDescs) {
|
||||||
if (hoverDescs[i].isEnabled()) {
|
if (hoverDesc.isEnabled()) {
|
||||||
int j= 0;
|
int j= 0;
|
||||||
int stateMask= hoverDescs[i].getStateMask();
|
int stateMask= hoverDesc.getStateMask();
|
||||||
while (j < stateMasksLength) {
|
while (j < stateMasksLength) {
|
||||||
if (stateMasks[j] == stateMask)
|
if (stateMasks[j] == stateMask)
|
||||||
break;
|
break;
|
||||||
|
@ -784,8 +785,8 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
|
||||||
// Register information provider
|
// Register information provider
|
||||||
IInformationProvider provider= new CInformationProvider(getEditor());
|
IInformationProvider provider= new CInformationProvider(getEditor());
|
||||||
String[] contentTypes= getConfiguredContentTypes(sourceViewer);
|
String[] contentTypes= getConfiguredContentTypes(sourceViewer);
|
||||||
for (int i= 0; i < contentTypes.length; i++)
|
for (String contentType : contentTypes)
|
||||||
presenter.setInformationProvider(provider, contentTypes[i]);
|
presenter.setInformationProvider(provider, contentType);
|
||||||
|
|
||||||
presenter.setSizeConstraints(60, 10, true, true);
|
presenter.setSizeConstraints(60, 10, true, true);
|
||||||
return presenter;
|
return presenter;
|
||||||
|
@ -975,8 +976,9 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
|
||||||
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectorTargets(org.eclipse.jface.text.source.ISourceViewer)
|
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectorTargets(org.eclipse.jface.text.source.ISourceViewer)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
|
protected Map<String, IAdaptable> getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
|
||||||
Map targets= super.getHyperlinkDetectorTargets(sourceViewer);
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, IAdaptable> targets= super.getHyperlinkDetectorTargets(sourceViewer);
|
||||||
targets.put("org.eclipse.cdt.ui.cCode", fTextEditor); //$NON-NLS-1$
|
targets.put("org.eclipse.cdt.ui.cCode", fTextEditor); //$NON-NLS-1$
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,12 @@
|
||||||
package org.eclipse.cdt.internal.ui.text;
|
package org.eclipse.cdt.internal.ui.text;
|
||||||
|
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
|
import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
|
||||||
import org.eclipse.jface.text.DocumentCommand;
|
import org.eclipse.jface.text.DocumentCommand;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.ITypedRegion;
|
import org.eclipse.jface.text.ITypedRegion;
|
||||||
import org.eclipse.jface.text.TextUtilities;
|
import org.eclipse.jface.text.TextUtilities;
|
||||||
|
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.part.MultiPageEditorPart;
|
import org.eclipse.ui.part.MultiPageEditorPart;
|
||||||
|
@ -60,11 +58,10 @@ public class CStringAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy
|
||||||
buffer.append(indentation);
|
buffer.append(indentation);
|
||||||
buffer.append("\""); //$NON-NLS-1$
|
buffer.append("\""); //$NON-NLS-1$
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
buffer.append("\"" + delimiter); //$NON-NLS-1$
|
|
||||||
buffer.append(indentation);
|
|
||||||
buffer.append("\""); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
buffer.append("\"" + delimiter); //$NON-NLS-1$
|
||||||
|
buffer.append(indentation);
|
||||||
|
buffer.append("\""); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,8 +278,9 @@ public class CWordFinder {
|
||||||
* @return true if curled brace found.
|
* @return true if curled brace found.
|
||||||
*/
|
*/
|
||||||
public static boolean hasCBraces (String s) {
|
public static boolean hasCBraces (String s) {
|
||||||
if (s.indexOf(CBRACE_L) > -1 || s.indexOf(CBRACE_R) > -1) return true;
|
if (s.indexOf(CBRACE_L) > -1 || s.indexOf(CBRACE_R) > -1)
|
||||||
else return false;
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,8 +97,7 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
|
||||||
public char last() {
|
public char last() {
|
||||||
if (fFirst == fLast)
|
if (fFirst == fLast)
|
||||||
return setIndex(getEndIndex());
|
return setIndex(getEndIndex());
|
||||||
else
|
return setIndex(getEndIndex() - 1);
|
||||||
return setIndex(getEndIndex() - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -127,9 +126,8 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
|
||||||
public char previous() {
|
public char previous() {
|
||||||
if (fIndex > getBeginIndex()) {
|
if (fIndex > getBeginIndex()) {
|
||||||
return setIndex(fIndex - 1);
|
return setIndex(fIndex - 1);
|
||||||
} else {
|
|
||||||
return DONE;
|
|
||||||
}
|
}
|
||||||
|
return DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -204,8 +202,7 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
|
||||||
// ignore and return DONE
|
// ignore and return DONE
|
||||||
return DONE;
|
return DONE;
|
||||||
}
|
}
|
||||||
else
|
throw new IndexOutOfBoundsException();
|
||||||
throw new IndexOutOfBoundsException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -31,12 +31,12 @@ import org.eclipse.swt.custom.StyleRange;
|
||||||
* the tags or cut them out.
|
* the tags or cut them out.
|
||||||
*/
|
*/
|
||||||
public class HTML2TextReader extends SubstitutionTextReader {
|
public class HTML2TextReader extends SubstitutionTextReader {
|
||||||
private static final Map fgEntityLookup;
|
private static final Map<String, String> fgEntityLookup;
|
||||||
private static final Set fgTags;
|
private static final Set<String> fgTags;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
fgTags= new HashSet();
|
fgTags= new HashSet<String>();
|
||||||
fgTags.add("b"); //$NON-NLS-1$
|
fgTags.add("b"); //$NON-NLS-1$
|
||||||
fgTags.add("br"); //$NON-NLS-1$
|
fgTags.add("br"); //$NON-NLS-1$
|
||||||
fgTags.add("h5"); //$NON-NLS-1$
|
fgTags.add("h5"); //$NON-NLS-1$
|
||||||
|
@ -47,7 +47,7 @@ public class HTML2TextReader extends SubstitutionTextReader {
|
||||||
fgTags.add("li"); //$NON-NLS-1$
|
fgTags.add("li"); //$NON-NLS-1$
|
||||||
fgTags.add("ul"); //$NON-NLS-1$
|
fgTags.add("ul"); //$NON-NLS-1$
|
||||||
|
|
||||||
fgEntityLookup= new HashMap(7);
|
fgEntityLookup= new HashMap<String, String>(7);
|
||||||
fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
|
fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
|
fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -230,7 +230,7 @@ public class HTML2TextReader extends SubstitutionTextReader {
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String str= (String) fgEntityLookup.get(symbol);
|
String str= fgEntityLookup.get(symbol);
|
||||||
if (str != null) {
|
if (str != null) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class HTMLAnnotationHover extends DefaultAnnotationHover {
|
||||||
/*
|
/*
|
||||||
* Formats several message as HTML text.
|
* Formats several message as HTML text.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected String formatMultipleMessages(List messages) {
|
protected String formatMultipleMessages(List messages) {
|
||||||
StringBuffer buffer= new StringBuffer();
|
StringBuffer buffer= new StringBuffer();
|
||||||
|
@ -47,9 +48,9 @@ public class HTMLAnnotationHover extends DefaultAnnotationHover {
|
||||||
HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(CUIMessages.getString("CAnnotationHover.multipleMarkers"))); //$NON-NLS-1$
|
HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(CUIMessages.getString("CAnnotationHover.multipleMarkers"))); //$NON-NLS-1$
|
||||||
|
|
||||||
HTMLPrinter.startBulletList(buffer);
|
HTMLPrinter.startBulletList(buffer);
|
||||||
Iterator e= messages.iterator();
|
Iterator<String> e= messages.iterator();
|
||||||
while (e.hasNext())
|
while (e.hasNext())
|
||||||
HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent((String) e.next()));
|
HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent(e.next()));
|
||||||
HTMLPrinter.endBulletList(buffer);
|
HTMLPrinter.endBulletList(buffer);
|
||||||
|
|
||||||
HTMLPrinter.addPageEpilog(buffer);
|
HTMLPrinter.addPageEpilog(buffer);
|
||||||
|
|
|
@ -14,16 +14,16 @@ package org.eclipse.cdt.internal.ui.text;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.jface.text.DefaultInformationControl;
|
||||||
|
import org.eclipse.jface.text.Region;
|
||||||
|
import org.eclipse.jface.text.TextPresentation;
|
||||||
import org.eclipse.swt.custom.StyleRange;
|
import org.eclipse.swt.custom.StyleRange;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.jface.text.DefaultInformationControl;
|
|
||||||
import org.eclipse.jface.text.Region;
|
|
||||||
import org.eclipse.jface.text.TextPresentation;
|
|
||||||
|
|
||||||
|
|
||||||
public class HTMLTextPresenter implements DefaultInformationControl.IInformationPresenter {
|
public class HTMLTextPresenter implements DefaultInformationControl.IInformationPresenter {
|
||||||
|
@ -52,10 +52,11 @@ public class HTMLTextPresenter implements DefaultInformationControl.IInformation
|
||||||
int yoursEnd= offset + insertLength -1;
|
int yoursEnd= offset + insertLength -1;
|
||||||
yoursEnd= Math.max(yoursStart, yoursEnd);
|
yoursEnd= Math.max(yoursStart, yoursEnd);
|
||||||
|
|
||||||
Iterator e= presentation.getAllStyleRangeIterator();
|
@SuppressWarnings("unchecked")
|
||||||
|
Iterator<StyleRange> e= presentation.getAllStyleRangeIterator();
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
|
|
||||||
StyleRange range= (StyleRange) e.next();
|
StyleRange range= e.next();
|
||||||
|
|
||||||
int myStart= range.start;
|
int myStart= range.start;
|
||||||
int myEnd= range.start + range.length -1;
|
int myEnd= range.start + range.length -1;
|
||||||
|
|
|
@ -87,8 +87,7 @@ public class SequenceCharacterIterator implements CharacterIterator {
|
||||||
public char last() {
|
public char last() {
|
||||||
if (fFirst == fLast)
|
if (fFirst == fLast)
|
||||||
return setIndex(getEndIndex());
|
return setIndex(getEndIndex());
|
||||||
else
|
return setIndex(getEndIndex() - 1);
|
||||||
return setIndex(getEndIndex() - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -97,8 +96,7 @@ public class SequenceCharacterIterator implements CharacterIterator {
|
||||||
public char current() {
|
public char current() {
|
||||||
if (fIndex >= fFirst && fIndex < fLast)
|
if (fIndex >= fFirst && fIndex < fLast)
|
||||||
return fSequence.charAt(fIndex);
|
return fSequence.charAt(fIndex);
|
||||||
else
|
return DONE;
|
||||||
return DONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -114,9 +112,8 @@ public class SequenceCharacterIterator implements CharacterIterator {
|
||||||
public char previous() {
|
public char previous() {
|
||||||
if (fIndex > getBeginIndex()) {
|
if (fIndex > getBeginIndex()) {
|
||||||
return setIndex(fIndex - 1);
|
return setIndex(fIndex - 1);
|
||||||
} else {
|
|
||||||
return DONE;
|
|
||||||
}
|
}
|
||||||
|
return DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
package org.eclipse.cdt.internal.ui.text;
|
package org.eclipse.cdt.internal.ui.text;
|
||||||
|
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
|
||||||
import org.eclipse.jface.text.IAutoEditStrategy;
|
import org.eclipse.jface.text.IAutoEditStrategy;
|
||||||
import org.eclipse.jface.text.IInformationControlCreator;
|
import org.eclipse.jface.text.IInformationControlCreator;
|
||||||
import org.eclipse.jface.text.ITextHover;
|
import org.eclipse.jface.text.ITextHover;
|
||||||
|
@ -22,7 +21,6 @@ import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
|
||||||
import org.eclipse.jface.text.information.IInformationPresenter;
|
import org.eclipse.jface.text.information.IInformationPresenter;
|
||||||
import org.eclipse.jface.text.source.IAnnotationHover;
|
import org.eclipse.jface.text.source.IAnnotationHover;
|
||||||
import org.eclipse.jface.text.source.ISourceViewer;
|
import org.eclipse.jface.text.source.ISourceViewer;
|
||||||
|
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,8 +106,7 @@ public class SimpleCSourceViewerConfiguration extends CSourceViewerConfiguration
|
||||||
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
|
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
|
||||||
if (fConfigureFormatter)
|
if (fConfigureFormatter)
|
||||||
return super.getContentFormatter(sourceViewer);
|
return super.getContentFormatter(sourceViewer);
|
||||||
else
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -13,10 +13,6 @@ package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CAnnotationIterator;
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
|
||||||
import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.ITextViewer;
|
import org.eclipse.jface.text.ITextViewer;
|
||||||
|
@ -29,6 +25,12 @@ import org.eclipse.ui.texteditor.AnnotationPreference;
|
||||||
import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
|
import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.CAnnotationIterator;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractAnnotationHover
|
* AbstractAnnotationHover
|
||||||
* Abstract super class for annotation hovers.
|
* Abstract super class for annotation hovers.
|
||||||
|
@ -68,11 +70,11 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
|
||||||
IAnnotationModel model= provider.getAnnotationModel(getEditor().getEditorInput());
|
IAnnotationModel model= provider.getAnnotationModel(getEditor().getEditorInput());
|
||||||
|
|
||||||
if (model != null) {
|
if (model != null) {
|
||||||
Iterator e= new CAnnotationIterator(model, true, fAllAnnotations);
|
Iterator<Annotation> e= new CAnnotationIterator(model, true, fAllAnnotations);
|
||||||
int layer= -1;
|
int layer= -1;
|
||||||
String message= null;
|
String message= null;
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
Annotation a= (Annotation) e.next();
|
Annotation a= e.next();
|
||||||
|
|
||||||
AnnotationPreference preference= getAnnotationPreference(a);
|
AnnotationPreference preference= getAnnotationPreference(a);
|
||||||
if (preference == null || !(preference.getTextPreferenceKey() != null && fStore.getBoolean(preference.getTextPreferenceKey()) || (preference.getHighlightPreferenceKey() != null && fStore.getBoolean(preference.getHighlightPreferenceKey()))))
|
if (preference == null || !(preference.getTextPreferenceKey() != null && fStore.getBoolean(preference.getTextPreferenceKey()) || (preference.getHighlightPreferenceKey() != null && fStore.getBoolean(preference.getHighlightPreferenceKey()))))
|
||||||
|
|
|
@ -33,8 +33,8 @@ import org.eclipse.ui.IEditorPart;
|
||||||
*/
|
*/
|
||||||
public class BestMatchHover extends AbstractCEditorTextHover {
|
public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
private List fTextHoverSpecifications;
|
private List<CEditorTextHoverDescriptor> fTextHoverSpecifications;
|
||||||
private List fInstantiatedTextHovers;
|
private List<ITextHover> fInstantiatedTextHovers;
|
||||||
private ITextHover fBestHover;
|
private ITextHover fBestHover;
|
||||||
|
|
||||||
public BestMatchHover() {
|
public BestMatchHover() {
|
||||||
|
@ -52,8 +52,8 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
private void installTextHovers() {
|
private void installTextHovers() {
|
||||||
|
|
||||||
// initialize lists - indicates that the initialization happened
|
// initialize lists - indicates that the initialization happened
|
||||||
fTextHoverSpecifications= new ArrayList(2);
|
fTextHoverSpecifications= new ArrayList<CEditorTextHoverDescriptor>(2);
|
||||||
fInstantiatedTextHovers= new ArrayList(2);
|
fInstantiatedTextHovers= new ArrayList<ITextHover>(2);
|
||||||
|
|
||||||
// populate list
|
// populate list
|
||||||
CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
|
CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
|
||||||
|
@ -68,8 +68,8 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
if (fTextHoverSpecifications.size() == 0)
|
if (fTextHoverSpecifications.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Iterator iterator= new ArrayList(fTextHoverSpecifications).iterator(); iterator.hasNext(); ) {
|
for (Iterator<CEditorTextHoverDescriptor> iterator= new ArrayList<CEditorTextHoverDescriptor>(fTextHoverSpecifications).iterator(); iterator.hasNext(); ) {
|
||||||
CEditorTextHoverDescriptor spec= (CEditorTextHoverDescriptor) iterator.next();
|
CEditorTextHoverDescriptor spec= iterator.next();
|
||||||
|
|
||||||
ICEditorTextHover hover= spec.createTextHover();
|
ICEditorTextHover hover= spec.createTextHover();
|
||||||
if (hover != null) {
|
if (hover != null) {
|
||||||
|
@ -97,8 +97,8 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
if (fInstantiatedTextHovers == null)
|
if (fInstantiatedTextHovers == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
for (Iterator iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) {
|
for (Iterator<ITextHover> iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) {
|
||||||
ITextHover hover= (ITextHover)iterator.next();
|
ITextHover hover= iterator.next();
|
||||||
|
|
||||||
String s= hover.getHoverInfo(textViewer, hoverRegion);
|
String s= hover.getHoverInfo(textViewer, hoverRegion);
|
||||||
if (s != null && s.trim().length() > 0) {
|
if (s != null && s.trim().length() > 0) {
|
||||||
|
@ -122,8 +122,8 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
if (fInstantiatedTextHovers == null)
|
if (fInstantiatedTextHovers == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
for (Iterator iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) {
|
for (Iterator<ITextHover> iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) {
|
||||||
ITextHover hover= (ITextHover)iterator.next();
|
ITextHover hover= iterator.next();
|
||||||
|
|
||||||
if (hover instanceof ITextHoverExtension2) {
|
if (hover instanceof ITextHoverExtension2) {
|
||||||
Object info= ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, hoverRegion);
|
Object info= ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, hoverRegion);
|
||||||
|
|
|
@ -119,14 +119,16 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IRegion getHoverRegion(ITextViewer viewer, int offset) {
|
public IRegion getHoverRegion(ITextViewer viewer, int offset) {
|
||||||
Point selectedRange = viewer.getSelectedRange();
|
if (viewer != null) {
|
||||||
if (selectedRange.x >= 0 &&
|
Point selectedRange = viewer.getSelectedRange();
|
||||||
selectedRange.y > 0 &&
|
if (selectedRange.x >= 0 &&
|
||||||
offset >= selectedRange.x &&
|
selectedRange.y > 0 &&
|
||||||
offset <= selectedRange.x + selectedRange.y)
|
offset >= selectedRange.x &&
|
||||||
return new Region( selectedRange.x, selectedRange.y );
|
offset <= selectedRange.x + selectedRange.y)
|
||||||
if (viewer != null)
|
return new Region( selectedRange.x, selectedRange.y );
|
||||||
|
|
||||||
return CWordFinder.findWord(viewer.getDocument(), offset);
|
return CWordFinder.findWord(viewer.getDocument(), offset);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,24 +18,26 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
|
||||||
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.Assert;
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CEditorTexHoverDescriptor
|
* CEditorTexHoverDescriptor
|
||||||
*/
|
*/
|
||||||
public class CEditorTextHoverDescriptor implements Comparable {
|
public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDescriptor> {
|
||||||
|
|
||||||
private static final String C_EDITOR_TEXT_HOVER_EXTENSION_POINT= "org.eclipse.cdt.ui.textHovers"; //$NON-NLS-1$
|
private static final String C_EDITOR_TEXT_HOVER_EXTENSION_POINT= "org.eclipse.cdt.ui.textHovers"; //$NON-NLS-1$
|
||||||
private static final String HOVER_TAG= "hover"; //$NON-NLS-1$
|
private static final String HOVER_TAG= "hover"; //$NON-NLS-1$
|
||||||
|
@ -182,28 +184,27 @@ public class CEditorTextHoverDescriptor implements Comparable {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public int compareTo(Object o) {
|
public int compareTo(CEditorTextHoverDescriptor o) {
|
||||||
return Collator.getInstance().compare(getLabel(), ((CEditorTextHoverDescriptor)o).getLabel());
|
return Collator.getInstance().compare(getLabel(), o.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CEditorTextHoverDescriptor[] createDescriptors(IConfigurationElement[] elements) {
|
private static CEditorTextHoverDescriptor[] createDescriptors(IConfigurationElement[] elements) {
|
||||||
List result= new ArrayList(elements.length);
|
List<CEditorTextHoverDescriptor> result= new ArrayList<CEditorTextHoverDescriptor>(elements.length);
|
||||||
for (int i= 0; i < elements.length; i++) {
|
for (IConfigurationElement element : elements) {
|
||||||
IConfigurationElement element= elements[i];
|
|
||||||
if (HOVER_TAG.equals(element.getName())) {
|
if (HOVER_TAG.equals(element.getName())) {
|
||||||
CEditorTextHoverDescriptor desc= new CEditorTextHoverDescriptor(element);
|
CEditorTextHoverDescriptor desc= new CEditorTextHoverDescriptor(element);
|
||||||
result.add(desc);
|
result.add(desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(result);
|
Collections.sort(result);
|
||||||
return (CEditorTextHoverDescriptor[])result.toArray(new CEditorTextHoverDescriptor[result.size()]);
|
return result.toArray(new CEditorTextHoverDescriptor[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeFromPreferences(CEditorTextHoverDescriptor[] hovers) {
|
private static void initializeFromPreferences(CEditorTextHoverDescriptor[] hovers) {
|
||||||
String compiledTextHoverModifiers= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
|
String compiledTextHoverModifiers= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
|
||||||
|
|
||||||
StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, VALUE_SEPARATOR);
|
StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, VALUE_SEPARATOR);
|
||||||
HashMap idToModifier= new HashMap(tokenizer.countTokens() / 2);
|
HashMap<String, String> idToModifier= new HashMap<String, String>(tokenizer.countTokens() / 2);
|
||||||
|
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
String id= tokenizer.nextToken();
|
String id= tokenizer.nextToken();
|
||||||
|
@ -214,7 +215,7 @@ public class CEditorTextHoverDescriptor implements Comparable {
|
||||||
String compiledTextHoverModifierMasks= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
|
String compiledTextHoverModifierMasks= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
|
||||||
|
|
||||||
tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, VALUE_SEPARATOR);
|
tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, VALUE_SEPARATOR);
|
||||||
HashMap idToModifierMask= new HashMap(tokenizer.countTokens() / 2);
|
HashMap<String, String> idToModifierMask= new HashMap<String, String>(tokenizer.countTokens() / 2);
|
||||||
|
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
String id= tokenizer.nextToken();
|
String id= tokenizer.nextToken();
|
||||||
|
@ -223,7 +224,7 @@ public class CEditorTextHoverDescriptor implements Comparable {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i= 0; i < hovers.length; i++) {
|
for (int i= 0; i < hovers.length; i++) {
|
||||||
String modifierString= (String)idToModifier.get(hovers[i].getId());
|
String modifierString= idToModifier.get(hovers[i].getId());
|
||||||
boolean enabled= true;
|
boolean enabled= true;
|
||||||
if (modifierString == null)
|
if (modifierString == null)
|
||||||
modifierString= DISABLED_TAG;
|
modifierString= DISABLED_TAG;
|
||||||
|
@ -242,7 +243,7 @@ public class CEditorTextHoverDescriptor implements Comparable {
|
||||||
if (hovers[i].fStateMask == -1) {
|
if (hovers[i].fStateMask == -1) {
|
||||||
// Fallback: use stored modifier masks
|
// Fallback: use stored modifier masks
|
||||||
try {
|
try {
|
||||||
hovers[i].fStateMask= Integer.parseInt((String)idToModifierMask.get(hovers[i].getId()));
|
hovers[i].fStateMask= Integer.parseInt(idToModifierMask.get(hovers[i].getId()));
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
hovers[i].fStateMask= -1;
|
hovers[i].fStateMask= -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,9 +188,9 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
IASTPreprocessorMacroDefinition[] macroDefs;
|
IASTPreprocessorMacroDefinition[] macroDefs;
|
||||||
final IASTPreprocessorMacroDefinition[] localMacroDefs= ast.getMacroDefinitions();
|
final IASTPreprocessorMacroDefinition[] localMacroDefs= ast.getMacroDefinitions();
|
||||||
for (macroDefs= localMacroDefs; macroDefs != null; macroDefs= (macroDefs == localMacroDefs) ? ast.getBuiltinMacroDefinitions() : null) {
|
for (macroDefs= localMacroDefs; macroDefs != null; macroDefs= (macroDefs == localMacroDefs) ? ast.getBuiltinMacroDefinitions() : null) {
|
||||||
for (int i = 0; i < macroDefs.length; i++) {
|
for (IASTPreprocessorMacroDefinition macroDef2 : macroDefs) {
|
||||||
if (Arrays.equals(macroDefs[i].getName().toCharArray(), macroName)) {
|
if (Arrays.equals(macroDef2.getName().toCharArray(), macroName)) {
|
||||||
macroDef= macroDefs[i];
|
macroDef= macroDef2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,8 +244,8 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
names= findDeclarations(ast, binding);
|
names= findDeclarations(ast, binding);
|
||||||
}
|
}
|
||||||
if (names.length > 0) {
|
if (names.length > 0) {
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (IName name : names) {
|
||||||
String source= computeSourceForName(names[0], binding);
|
String source= computeSourceForName(name, binding);
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
@ -417,9 +417,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
type= ((ITypedef)binding).getType();
|
type= ((ITypedef)binding).getType();
|
||||||
} else if (binding instanceof IVariable) {
|
} else if (binding instanceof IVariable) {
|
||||||
type= ((IVariable)binding).getType();
|
type= ((IVariable)binding).getType();
|
||||||
} else {
|
}
|
||||||
type= null;
|
|
||||||
}
|
|
||||||
} catch (DOMException exc) {
|
} catch (DOMException exc) {
|
||||||
}
|
}
|
||||||
expectClosingBrace= type instanceof ICompositeType || type instanceof IEnumeration;
|
expectClosingBrace= type instanceof ICompositeType || type instanceof IEnumeration;
|
||||||
|
@ -786,8 +784,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
i= 0;
|
i= 0;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (reader != null)
|
reader.close();
|
||||||
reader.close();
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
CUIPlugin.log(ex);
|
CUIPlugin.log(ex);
|
||||||
}
|
}
|
||||||
|
@ -831,7 +828,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
* name is not considered a keyword
|
* name is not considered a keyword
|
||||||
*/
|
*/
|
||||||
private boolean selectionIsKeyword(String name) {
|
private boolean selectionIsKeyword(String name) {
|
||||||
Set keywords= ParserFactory.getKeywordSet(KeywordSetKey.KEYWORDS, ParserLanguage.CPP);
|
Set<String> keywords= ParserFactory.getKeywordSet(KeywordSetKey.KEYWORDS, ParserLanguage.CPP);
|
||||||
return keywords.contains(name);
|
return keywords.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,9 @@
|
||||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.preference.PreferenceConverter;
|
import org.eclipse.jface.preference.PreferenceConverter;
|
||||||
import org.eclipse.core.runtime.Assert;
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.BadPositionCategoryException;
|
import org.eclipse.jface.text.BadPositionCategoryException;
|
||||||
import org.eclipse.jface.text.DefaultPositionUpdater;
|
import org.eclipse.jface.text.DefaultPositionUpdater;
|
||||||
|
@ -52,6 +49,11 @@ import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import org.eclipse.swt.graphics.RGB;
|
||||||
import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
|
import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
||||||
|
|
||||||
public class CCompletionProposal implements ICCompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3 {
|
public class CCompletionProposal implements ICCompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3 {
|
||||||
|
|
||||||
private String fDisplayString;
|
private String fDisplayString;
|
||||||
|
@ -510,7 +512,10 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
|
||||||
* <code>false</code> otherwise.
|
* <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
protected boolean startsWith(IDocument document, int offset, String word) {
|
protected boolean startsWith(IDocument document, int offset, String word) {
|
||||||
int wordLength= word == null ? 0 : word.length();
|
if (word == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
final int wordLength= word.length();
|
||||||
if (offset >= fReplacementOffset + wordLength)
|
if (offset >= fReplacementOffset + wordLength)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -148,14 +147,14 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
|
||||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistProcessor#filterAndSort(java.util.List, org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistProcessor#filterAndSort(java.util.List, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected List filterAndSortProposals(List proposals, IProgressMonitor monitor, ContentAssistInvocationContext context) {
|
protected List<ICompletionProposal> filterAndSortProposals(List<ICompletionProposal> proposals, IProgressMonitor monitor, ContentAssistInvocationContext context) {
|
||||||
IProposalFilter filter = getCompletionFilter();
|
IProposalFilter filter = getCompletionFilter();
|
||||||
ICCompletionProposal[] proposalsInput= new ICCompletionProposal[proposals.size()];
|
ICCompletionProposal[] proposalsInput= new ICCompletionProposal[proposals.size()];
|
||||||
// wrap proposals which are no ICCompletionProposals
|
// wrap proposals which are no ICCompletionProposals
|
||||||
boolean wrapped= false;
|
boolean wrapped= false;
|
||||||
int i=0;
|
int i=0;
|
||||||
for (Iterator iterator = proposals.iterator(); iterator.hasNext(); ) {
|
for (Object element : proposals) {
|
||||||
ICompletionProposal proposal= (ICompletionProposal) iterator.next();
|
ICompletionProposal proposal= (ICompletionProposal) element;
|
||||||
if (proposal instanceof ICCompletionProposal) {
|
if (proposal instanceof ICCompletionProposal) {
|
||||||
proposalsInput[i++]= (ICCompletionProposal)proposal;
|
proposalsInput[i++]= (ICCompletionProposal)proposal;
|
||||||
} else {
|
} else {
|
||||||
|
@ -177,12 +176,11 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
|
||||||
propsComp.setOrderAlphabetically(sortByAlphabet);
|
propsComp.setOrderAlphabetically(sortByAlphabet);
|
||||||
Arrays.sort(proposalsFiltered, propsComp);
|
Arrays.sort(proposalsFiltered, propsComp);
|
||||||
}
|
}
|
||||||
List filteredList;
|
List<ICompletionProposal> filteredList;
|
||||||
if (wrapped) {
|
if (wrapped) {
|
||||||
// unwrap again
|
// unwrap again
|
||||||
filteredList= new ArrayList(proposalsFiltered.length);
|
filteredList= new ArrayList<ICompletionProposal>(proposalsFiltered.length);
|
||||||
for (int j= 0; j < proposalsFiltered.length; j++) {
|
for (ICCompletionProposal proposal : proposalsFiltered) {
|
||||||
ICCompletionProposal proposal= proposalsFiltered[j];
|
|
||||||
if (proposal instanceof CCompletionProposalWrapper) {
|
if (proposal instanceof CCompletionProposalWrapper) {
|
||||||
filteredList.add(((CCompletionProposalWrapper)proposal).unwrap());
|
filteredList.add(((CCompletionProposalWrapper)proposal).unwrap());
|
||||||
} else {
|
} else {
|
||||||
|
@ -190,7 +188,8 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filteredList= Arrays.asList(proposalsFiltered);
|
final ICompletionProposal[] tmp= proposalsFiltered;
|
||||||
|
filteredList= Arrays.asList(tmp);
|
||||||
}
|
}
|
||||||
return filteredList;
|
return filteredList;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +221,7 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List filterAndSortContextInformation(List contexts,
|
protected List<IContextInformation> filterAndSortContextInformation(List<IContextInformation> contexts,
|
||||||
IProgressMonitor monitor) {
|
IProgressMonitor monitor) {
|
||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.commands.IParameterValues;
|
import org.eclipse.core.commands.IParameterValues;
|
||||||
|
@ -27,11 +26,10 @@ public final class ContentAssistComputerParameter implements IParameterValues {
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.core.commands.IParameterValues#getParameterValues()
|
* @see org.eclipse.core.commands.IParameterValues#getParameterValues()
|
||||||
*/
|
*/
|
||||||
public Map getParameterValues() {
|
public Map<String,String> getParameterValues() {
|
||||||
Collection descriptors= CompletionProposalComputerRegistry.getDefault().getProposalCategories();
|
Collection<CompletionProposalCategory> descriptors= CompletionProposalComputerRegistry.getDefault().getProposalCategories();
|
||||||
Map map= new HashMap(descriptors.size());
|
Map<String, String> map= new HashMap<String, String>(descriptors.size());
|
||||||
for (Iterator it= descriptors.iterator(); it.hasNext();) {
|
for (CompletionProposalCategory category : descriptors) {
|
||||||
CompletionProposalCategory category= (CompletionProposalCategory) it.next();
|
|
||||||
map.put(category.getDisplayName(), category.getId());
|
map.put(category.getDisplayName(), category.getId());
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
|
|
|
@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
@ -91,12 +90,9 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
*/
|
*/
|
||||||
private static final String PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY= "EmptyDefaultAssistCategory"; //$NON-NLS-1$
|
private static final String PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY= "EmptyDefaultAssistCategory"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final Comparator ORDER_COMPARATOR= new Comparator() {
|
private static final Comparator<CompletionProposalCategory> ORDER_COMPARATOR= new Comparator<CompletionProposalCategory>() {
|
||||||
|
|
||||||
public int compare(Object o1, Object o2) {
|
public int compare(CompletionProposalCategory d1, CompletionProposalCategory d2) {
|
||||||
CompletionProposalCategory d1= (CompletionProposalCategory) o1;
|
|
||||||
CompletionProposalCategory d2= (CompletionProposalCategory) o2;
|
|
||||||
|
|
||||||
return d1.getSortOrder() - d2.getSortOrder();
|
return d1.getSortOrder() - d2.getSortOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +100,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
|
|
||||||
private static final ICompletionProposal[] NO_PROPOSALS= {};
|
private static final ICompletionProposal[] NO_PROPOSALS= {};
|
||||||
|
|
||||||
private final List fCategories;
|
private final List<CompletionProposalCategory> fCategories;
|
||||||
private final String fPartition;
|
private final String fPartition;
|
||||||
private final ContentAssistant fAssistant;
|
private final ContentAssistant fAssistant;
|
||||||
|
|
||||||
|
@ -112,7 +108,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
|
|
||||||
/* cycling stuff */
|
/* cycling stuff */
|
||||||
private int fRepetition= -1;
|
private int fRepetition= -1;
|
||||||
private List/*<List<CompletionProposalCategory>>*/ fCategoryIteration= null;
|
private List<List<CompletionProposalCategory>> fCategoryIteration= null;
|
||||||
private String fIterationGesture= null;
|
private String fIterationGesture= null;
|
||||||
private int fNumberOfComputedResults= 0;
|
private int fNumberOfComputedResults= 0;
|
||||||
private String fErrorMessage;
|
private String fErrorMessage;
|
||||||
|
@ -139,8 +135,8 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
|
|
||||||
// this may show the warning dialog if all categories are disabled
|
// this may show the warning dialog if all categories are disabled
|
||||||
fCategoryIteration= getCategoryIteration();
|
fCategoryIteration= getCategoryIteration();
|
||||||
for (Iterator it= fCategories.iterator(); it.hasNext();) {
|
for (Object element : fCategories) {
|
||||||
CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
|
CompletionProposalCategory cat= (CompletionProposalCategory) element;
|
||||||
cat.sessionStarted();
|
cat.sessionStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,8 +168,8 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
if (event.processor != ContentAssistProcessor.this)
|
if (event.processor != ContentAssistProcessor.this)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Iterator it= fCategories.iterator(); it.hasNext();) {
|
for (Object element : fCategories) {
|
||||||
CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
|
CompletionProposalCategory cat= (CompletionProposalCategory) element;
|
||||||
cat.sessionEnded();
|
cat.sessionEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,15 +217,15 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
long setup= DEBUG ? System.currentTimeMillis() : 0;
|
long setup= DEBUG ? System.currentTimeMillis() : 0;
|
||||||
|
|
||||||
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_collecting_proposals);
|
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_collecting_proposals);
|
||||||
List proposals= collectProposals(viewer, offset, monitor, context);
|
List<ICompletionProposal> proposals= collectProposals(viewer, offset, monitor, context);
|
||||||
long collect= DEBUG ? System.currentTimeMillis() : 0;
|
long collect= DEBUG ? System.currentTimeMillis() : 0;
|
||||||
|
|
||||||
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_sorting_proposals);
|
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_sorting_proposals);
|
||||||
List filtered= filterAndSortProposals(proposals, monitor, context);
|
List<ICompletionProposal> filtered= filterAndSortProposals(proposals, monitor, context);
|
||||||
fNumberOfComputedResults= filtered.size();
|
fNumberOfComputedResults= filtered.size();
|
||||||
long filter= DEBUG ? System.currentTimeMillis() : 0;
|
long filter= DEBUG ? System.currentTimeMillis() : 0;
|
||||||
|
|
||||||
ICompletionProposal[] result= (ICompletionProposal[]) filtered.toArray(new ICompletionProposal[filtered.size()]);
|
ICompletionProposal[] result= filtered.toArray(new ICompletionProposal[filtered.size()]);
|
||||||
monitor.done();
|
monitor.done();
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
@ -264,12 +260,11 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
fNumberOfComputedResults= 0;
|
fNumberOfComputedResults= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) {
|
private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) {
|
||||||
List proposals= new ArrayList();
|
List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>();
|
||||||
List providers= getCategories();
|
List<CompletionProposalCategory> providers= getCategories();
|
||||||
for (Iterator it= providers.iterator(); it.hasNext();) {
|
for (CompletionProposalCategory cat : providers) {
|
||||||
CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
|
List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1));
|
||||||
List computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1));
|
|
||||||
proposals.addAll(computed);
|
proposals.addAll(computed);
|
||||||
if (fErrorMessage == null)
|
if (fErrorMessage == null)
|
||||||
fErrorMessage= cat.getErrorMessage();
|
fErrorMessage= cat.getErrorMessage();
|
||||||
|
@ -289,7 +284,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
* @return the list of filtered and sorted proposals, ready for
|
* @return the list of filtered and sorted proposals, ready for
|
||||||
* display (element type: {@link ICompletionProposal})
|
* display (element type: {@link ICompletionProposal})
|
||||||
*/
|
*/
|
||||||
protected List filterAndSortProposals(List proposals, IProgressMonitor monitor, ContentAssistInvocationContext context) {
|
protected List<ICompletionProposal> filterAndSortProposals(List<ICompletionProposal> proposals, IProgressMonitor monitor, ContentAssistInvocationContext context) {
|
||||||
return proposals;
|
return proposals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,26 +298,25 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
monitor.beginTask(ContentAssistMessages.ContentAssistProcessor_computing_contexts, fCategories.size() + 1);
|
monitor.beginTask(ContentAssistMessages.ContentAssistProcessor_computing_contexts, fCategories.size() + 1);
|
||||||
|
|
||||||
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_collecting_contexts);
|
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_collecting_contexts);
|
||||||
List proposals= collectContextInformation(viewer, offset, monitor);
|
List<IContextInformation> proposals= collectContextInformation(viewer, offset, monitor);
|
||||||
|
|
||||||
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_sorting_contexts);
|
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_sorting_contexts);
|
||||||
List filtered= filterAndSortContextInformation(proposals, monitor);
|
List<IContextInformation> filtered= filterAndSortContextInformation(proposals, monitor);
|
||||||
fNumberOfComputedResults= filtered.size();
|
fNumberOfComputedResults= filtered.size();
|
||||||
|
|
||||||
IContextInformation[] result= (IContextInformation[]) filtered.toArray(new IContextInformation[filtered.size()]);
|
IContextInformation[] result= filtered.toArray(new IContextInformation[filtered.size()]);
|
||||||
monitor.done();
|
monitor.done();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List collectContextInformation(ITextViewer viewer, int offset, IProgressMonitor monitor) {
|
private List<IContextInformation> collectContextInformation(ITextViewer viewer, int offset, IProgressMonitor monitor) {
|
||||||
List proposals= new ArrayList();
|
List<IContextInformation> proposals= new ArrayList<IContextInformation>();
|
||||||
ContentAssistInvocationContext context= createContext(viewer, offset, false);
|
ContentAssistInvocationContext context= createContext(viewer, offset, false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List providers= getCategories();
|
List<CompletionProposalCategory> providers= getCategories();
|
||||||
for (Iterator it= providers.iterator(); it.hasNext();) {
|
for (CompletionProposalCategory cat : providers) {
|
||||||
CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
|
List<IContextInformation> computed= cat.computeContextInformation(context, fPartition, new SubProgressMonitor(monitor, 1));
|
||||||
List computed= cat.computeContextInformation(context, fPartition, new SubProgressMonitor(monitor, 1));
|
|
||||||
proposals.addAll(computed);
|
proposals.addAll(computed);
|
||||||
if (fErrorMessage == null)
|
if (fErrorMessage == null)
|
||||||
fErrorMessage= cat.getErrorMessage();
|
fErrorMessage= cat.getErrorMessage();
|
||||||
|
@ -345,7 +339,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
* @return the list of filtered and sorted proposals, ready for
|
* @return the list of filtered and sorted proposals, ready for
|
||||||
* display (element type: {@link IContextInformation})
|
* display (element type: {@link IContextInformation})
|
||||||
*/
|
*/
|
||||||
protected List filterAndSortContextInformation(List contexts, IProgressMonitor monitor) {
|
protected List<IContextInformation> filterAndSortContextInformation(List<IContextInformation> contexts, IProgressMonitor monitor) {
|
||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,7 +420,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
return fIsAutoActivated;
|
return fIsAutoActivated;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List getCategories() {
|
private List<CompletionProposalCategory> getCategories() {
|
||||||
if (fCategoryIteration == null)
|
if (fCategoryIteration == null)
|
||||||
return fCategories;
|
return fCategories;
|
||||||
|
|
||||||
|
@ -437,22 +431,21 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
|
|
||||||
// fAssistant.setShowMessage(fRepetition % 2 != 0);
|
// fAssistant.setShowMessage(fRepetition % 2 != 0);
|
||||||
//
|
//
|
||||||
return (List) fCategoryIteration.get(iteration);
|
return fCategoryIteration.get(iteration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List getCategoryIteration() {
|
private List<List<CompletionProposalCategory>> getCategoryIteration() {
|
||||||
List sequence= new ArrayList();
|
List<List<CompletionProposalCategory>> sequence= new ArrayList<List<CompletionProposalCategory>>();
|
||||||
sequence.add(getDefaultCategories());
|
sequence.add(getDefaultCategories());
|
||||||
for (Iterator it= getSeparateCategories().iterator(); it.hasNext();) {
|
for (CompletionProposalCategory cat : getSeparateCategories()) {
|
||||||
CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
|
|
||||||
sequence.add(Collections.singletonList(cat));
|
sequence.add(Collections.singletonList(cat));
|
||||||
}
|
}
|
||||||
return sequence;
|
return sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List getDefaultCategories() {
|
private List<CompletionProposalCategory> getDefaultCategories() {
|
||||||
// default mix - enable all included computers
|
// default mix - enable all included computers
|
||||||
List included= getDefaultCategoriesUnchecked();
|
List<CompletionProposalCategory> included= getDefaultCategoriesUnchecked();
|
||||||
|
|
||||||
if (IDocument.DEFAULT_CONTENT_TYPE.equals(fPartition) && included.isEmpty() && !fCategories.isEmpty())
|
if (IDocument.DEFAULT_CONTENT_TYPE.equals(fPartition) && included.isEmpty() && !fCategories.isEmpty())
|
||||||
if (informUserAboutEmptyDefaultCategory())
|
if (informUserAboutEmptyDefaultCategory())
|
||||||
|
@ -462,10 +455,10 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
return included;
|
return included;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List getDefaultCategoriesUnchecked() {
|
private List<CompletionProposalCategory> getDefaultCategoriesUnchecked() {
|
||||||
List included= new ArrayList();
|
List<CompletionProposalCategory> included= new ArrayList<CompletionProposalCategory>();
|
||||||
for (Iterator it= fCategories.iterator(); it.hasNext();) {
|
for (Object element : fCategories) {
|
||||||
CompletionProposalCategory category= (CompletionProposalCategory) it.next();
|
CompletionProposalCategory category= (CompletionProposalCategory) element;
|
||||||
if (category.isIncluded() && category.hasComputers(fPartition))
|
if (category.isIncluded() && category.hasComputers(fPartition))
|
||||||
included.add(category);
|
included.add(category);
|
||||||
}
|
}
|
||||||
|
@ -554,10 +547,10 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List getSeparateCategories() {
|
private List<CompletionProposalCategory> getSeparateCategories() {
|
||||||
ArrayList sorted= new ArrayList();
|
ArrayList<CompletionProposalCategory> sorted= new ArrayList<CompletionProposalCategory>();
|
||||||
for (Iterator it= fCategories.iterator(); it.hasNext();) {
|
for (Object element : fCategories) {
|
||||||
CompletionProposalCategory category= (CompletionProposalCategory) it.next();
|
CompletionProposalCategory category= (CompletionProposalCategory) element;
|
||||||
if (category.isSeparateCommand() && category.hasComputers(fPartition))
|
if (category.isSeparateCommand() && category.hasComputers(fPartition))
|
||||||
sorted.add(category);
|
sorted.add(category);
|
||||||
}
|
}
|
||||||
|
@ -577,7 +570,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
||||||
int iteration= repetition % fCategoryIteration.size();
|
int iteration= repetition % fCategoryIteration.size();
|
||||||
if (iteration == 0)
|
if (iteration == 0)
|
||||||
return ContentAssistMessages.ContentAssistProcessor_defaultProposalCategory;
|
return ContentAssistMessages.ContentAssistProcessor_defaultProposalCategory;
|
||||||
return toString((CompletionProposalCategory) ((List) fCategoryIteration.get(iteration)).get(0));
|
return toString(fCategoryIteration.get(iteration).get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toString(CompletionProposalCategory category) {
|
private String toString(CompletionProposalCategory category) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.ITypedRegion;
|
import org.eclipse.jface.text.ITypedRegion;
|
||||||
import org.eclipse.jface.text.TextUtilities;
|
import org.eclipse.jface.text.TextUtilities;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
|
@ -86,11 +87,11 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CCompletionProposal> computeCompletionProposals(
|
protected List<ICompletionProposal> computeCompletionProposals(
|
||||||
CContentAssistInvocationContext context,
|
CContentAssistInvocationContext context,
|
||||||
IASTCompletionNode completionNode, String prefix) {
|
IASTCompletionNode completionNode, String prefix) {
|
||||||
|
|
||||||
List<CCompletionProposal> proposals = new ArrayList<CCompletionProposal>();
|
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
|
||||||
|
|
||||||
if(inPreprocessorDirective(context)) {
|
if(inPreprocessorDirective(context)) {
|
||||||
if (!inPreprocessorKeyword(context)) {
|
if (!inPreprocessorKeyword(context)) {
|
||||||
|
@ -183,7 +184,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMacroProposals(CContentAssistInvocationContext context, String prefix, List<CCompletionProposal> proposals) {
|
private void addMacroProposals(CContentAssistInvocationContext context, String prefix, List<ICompletionProposal> proposals) {
|
||||||
char[] prefixChars= prefix.toCharArray();
|
char[] prefixChars= prefix.toCharArray();
|
||||||
final boolean matchPrefix= !context.isContextInformationStyle();
|
final boolean matchPrefix= !context.isContextInformationStyle();
|
||||||
IASTCompletionNode completionNode = context.getCompletionNode();
|
IASTCompletionNode completionNode = context.getCompletionNode();
|
||||||
|
@ -203,7 +204,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMacro(IASTPreprocessorMacroDefinition macro, CContentAssistInvocationContext context, String prefix, List<CCompletionProposal> proposals) {
|
private void handleMacro(IASTPreprocessorMacroDefinition macro, CContentAssistInvocationContext context, String prefix, List<ICompletionProposal> proposals) {
|
||||||
final String macroName = macro.getName().toString();
|
final String macroName = macro.getName().toString();
|
||||||
final int baseRelevance= computeBaseRelevance(prefix, macroName);
|
final int baseRelevance= computeBaseRelevance(prefix, macroName);
|
||||||
|
|
||||||
|
@ -255,7 +256,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
CContentAssistInvocationContext cContext,
|
CContentAssistInvocationContext cContext,
|
||||||
String prefix,
|
String prefix,
|
||||||
IASTCompletionContext astContext,
|
IASTCompletionContext astContext,
|
||||||
List<CCompletionProposal> proposals) {
|
List<ICompletionProposal> proposals) {
|
||||||
|
|
||||||
if ((binding instanceof CPPImplicitFunction
|
if ((binding instanceof CPPImplicitFunction
|
||||||
|| binding instanceof CPPImplicitFunctionTemplate || binding instanceof CPPImplicitTypedef)
|
|| binding instanceof CPPImplicitFunctionTemplate || binding instanceof CPPImplicitTypedef)
|
||||||
|
@ -293,12 +294,12 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
return name.length == 0 || name[0] == '{';
|
return name.length == 0 || name[0] == '{';
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleClass(ICPPClassType classType, IASTCompletionContext astContext, CContentAssistInvocationContext context, int baseRelevance, List<CCompletionProposal> proposals) {
|
private void handleClass(ICPPClassType classType, IASTCompletionContext astContext, CContentAssistInvocationContext context, int baseRelevance, List<ICompletionProposal> proposals) {
|
||||||
if (context.isContextInformationStyle()) {
|
if (context.isContextInformationStyle()) {
|
||||||
try {
|
try {
|
||||||
ICPPConstructor[] constructors = classType.getConstructors();
|
ICPPConstructor[] constructors = classType.getConstructors();
|
||||||
for (int i = 0; i < constructors.length; i++) {
|
for (ICPPConstructor constructor : constructors) {
|
||||||
handleFunction(constructors[i], context, baseRelevance, proposals);
|
handleFunction(constructor, context, baseRelevance, proposals);
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
}
|
}
|
||||||
|
@ -309,10 +310,10 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
case ICPPClassType.k_class:
|
case ICPPClassType.k_class:
|
||||||
relevance= RelevanceConstants.CLASS_TYPE_RELEVANCE;
|
relevance= RelevanceConstants.CLASS_TYPE_RELEVANCE;
|
||||||
break;
|
break;
|
||||||
case ICPPClassType.k_struct:
|
case ICompositeType.k_struct:
|
||||||
relevance= RelevanceConstants.STRUCT_TYPE_RELEVANCE;
|
relevance= RelevanceConstants.STRUCT_TYPE_RELEVANCE;
|
||||||
break;
|
break;
|
||||||
case ICPPClassType.k_union:
|
case ICompositeType.k_union:
|
||||||
relevance= RelevanceConstants.UNION_TYPE_RELEVANCE;
|
relevance= RelevanceConstants.UNION_TYPE_RELEVANCE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +329,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleFunction(IFunction function, CContentAssistInvocationContext context, int baseRelevance, List<CCompletionProposal> proposals) {
|
private void handleFunction(IFunction function, CContentAssistInvocationContext context, int baseRelevance, List<ICompletionProposal> proposals) {
|
||||||
Image image = getImage(function);
|
Image image = getImage(function);
|
||||||
|
|
||||||
StringBuilder repStringBuff = new StringBuilder();
|
StringBuilder repStringBuff = new StringBuilder();
|
||||||
|
@ -340,7 +341,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
String returnTypeStr = null;
|
String returnTypeStr = null;
|
||||||
try {
|
try {
|
||||||
IParameter[] params = function.getParameters();
|
IParameter[] params = function.getParameters();
|
||||||
if (params != null)
|
if (params != null) {
|
||||||
for (int i = 0; i < params.length; ++i) {
|
for (int i = 0; i < params.length; ++i) {
|
||||||
IType paramType = params[i].getType();
|
IType paramType = params[i].getType();
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
|
@ -357,18 +358,18 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function.takesVarArgs()) {
|
if (function.takesVarArgs()) {
|
||||||
if (params.length > 0) {
|
if (params.length > 0) {
|
||||||
dispargs.append(',');
|
dispargs.append(',');
|
||||||
idargs.append(',');
|
idargs.append(',');
|
||||||
}
|
}
|
||||||
dispargs.append("..."); //$NON-NLS-1$
|
dispargs.append("..."); //$NON-NLS-1$
|
||||||
idargs.append("..."); //$NON-NLS-1$
|
idargs.append("..."); //$NON-NLS-1$
|
||||||
} else if (params.length == 0) { // force the void in
|
} else if (params.length == 0) { // force the void in
|
||||||
dispargs.append("void"); //$NON-NLS-1$
|
dispargs.append("void"); //$NON-NLS-1$
|
||||||
idargs.append("void"); //$NON-NLS-1$
|
idargs.append("void"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
}
|
||||||
IFunctionType functionType = function.getType();
|
IFunctionType functionType = function.getType();
|
||||||
if (functionType != null) {
|
if (functionType != null) {
|
||||||
IType returnType = functionType.getReturnType();
|
IType returnType = functionType.getReturnType();
|
||||||
|
@ -413,7 +414,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
proposals.add(proposal);
|
proposals.add(proposal);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleVariable(IVariable variable, CContentAssistInvocationContext context, int baseRelevance, List<CCompletionProposal> proposals) {
|
private void handleVariable(IVariable variable, CContentAssistInvocationContext context, int baseRelevance, List<ICompletionProposal> proposals) {
|
||||||
StringBuilder repStringBuff = new StringBuilder();
|
StringBuilder repStringBuff = new StringBuilder();
|
||||||
repStringBuff.append(variable.getName());
|
repStringBuff.append(variable.getName());
|
||||||
|
|
||||||
|
@ -479,7 +480,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
IASTCompletionContext astContext,
|
IASTCompletionContext astContext,
|
||||||
CContentAssistInvocationContext cContext,
|
CContentAssistInvocationContext cContext,
|
||||||
int baseRelevance,
|
int baseRelevance,
|
||||||
List<CCompletionProposal> proposals) {
|
List<ICompletionProposal> proposals) {
|
||||||
|
|
||||||
if (astContext instanceof ICPPASTQualifiedName) {
|
if (astContext instanceof ICPPASTQualifiedName) {
|
||||||
IASTCompletionContext parent = ((ICPPASTQualifiedName) astContext)
|
IASTCompletionContext parent = ((ICPPASTQualifiedName) astContext)
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
||||||
|
@ -33,7 +34,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||||
public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer {
|
public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List computeCompletionProposals(
|
protected List<ICompletionProposal> computeCompletionProposals(
|
||||||
CContentAssistInvocationContext cContext,
|
CContentAssistInvocationContext cContext,
|
||||||
IASTCompletionNode completionNode, String prefix)
|
IASTCompletionNode completionNode, String prefix)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
|
@ -58,7 +59,7 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handleHelp) {
|
if (!handleHelp) {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
final ITranslationUnit tu = cContext.getTranslationUnit();
|
final ITranslationUnit tu = cContext.getTranslationUnit();
|
||||||
|
@ -77,17 +78,16 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
IFunctionSummary[] summaries = CHelpProviderManager.getDefault()
|
IFunctionSummary[] summaries = CHelpProviderManager.getDefault()
|
||||||
.getMatchingFunctions(helpContext, prefix);
|
.getMatchingFunctions(helpContext, prefix);
|
||||||
if (summaries == null)
|
if (summaries == null)
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
|
|
||||||
int repOffset = cContext.getInvocationOffset() - prefix.length();
|
int repOffset = cContext.getInvocationOffset() - prefix.length();
|
||||||
int repLength = prefix.length();
|
int repLength = prefix.length();
|
||||||
Image image = CUIPlugin.getImageDescriptorRegistry().get(
|
Image image = CUIPlugin.getImageDescriptorRegistry().get(
|
||||||
CElementImageProvider.getFunctionImageDescriptor());
|
CElementImageProvider.getFunctionImageDescriptor());
|
||||||
|
|
||||||
List proposals = new ArrayList();
|
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
|
||||||
|
|
||||||
for (int j = 0; j < summaries.length; j++) {
|
for (IFunctionSummary summary : summaries) {
|
||||||
IFunctionSummary summary = summaries[j];
|
|
||||||
String fname = summary.getName() + "()"; //$NON-NLS-1$
|
String fname = summary.getName() + "()"; //$NON-NLS-1$
|
||||||
String fdesc = summary.getDescription();
|
String fdesc = summary.getDescription();
|
||||||
IFunctionSummary.IFunctionPrototypeSummary fproto = summary
|
IFunctionSummary.IFunctionPrototypeSummary fproto = summary
|
||||||
|
|
|
@ -15,6 +15,8 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
|
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||||
import org.eclipse.ui.texteditor.HippieProposalProcessor;
|
import org.eclipse.ui.texteditor.HippieProposalProcessor;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
|
import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
|
||||||
|
@ -39,14 +41,14 @@ public final class HippieProposalComputer implements ICompletionProposalComputer
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
return Arrays.asList(fProcessor.computeCompletionProposals(context.getViewer(), context.getInvocationOffset()));
|
return Arrays.asList(fProcessor.computeCompletionProposals(context.getViewer(), context.getInvocationOffset()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
return Arrays.asList(fProcessor.computeContextInformation(context.getViewer(), context.getInvocationOffset()));
|
return Arrays.asList(fProcessor.computeContextInformation(context.getViewer(), context.getInvocationOffset()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.ITypedRegion;
|
import org.eclipse.jface.text.ITypedRegion;
|
||||||
import org.eclipse.jface.text.TextUtilities;
|
import org.eclipse.jface.text.TextUtilities;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
|
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
@ -54,15 +56,15 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
|
||||||
|
|
||||||
private String fErrorMessage;
|
private String fErrorMessage;
|
||||||
|
|
||||||
public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
List<CCompletionProposal> proposals= Collections.emptyList();
|
List<ICompletionProposal> proposals= Collections.emptyList();
|
||||||
fErrorMessage= null;
|
fErrorMessage= null;
|
||||||
|
|
||||||
if (context instanceof CContentAssistInvocationContext) {
|
if (context instanceof CContentAssistInvocationContext) {
|
||||||
CContentAssistInvocationContext cContext= (CContentAssistInvocationContext) context;
|
CContentAssistInvocationContext cContext= (CContentAssistInvocationContext) context;
|
||||||
if (inIncludeDirective(cContext)) {
|
if (inIncludeDirective(cContext)) {
|
||||||
// add include file proposals
|
// add include file proposals
|
||||||
proposals= new ArrayList<CCompletionProposal>();
|
proposals= new ArrayList<ICompletionProposal>();
|
||||||
try {
|
try {
|
||||||
addInclusionProposals(cContext, proposals);
|
addInclusionProposals(cContext, proposals);
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
|
@ -74,7 +76,7 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
|
||||||
return proposals;
|
return proposals;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +115,7 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addInclusionProposals(CContentAssistInvocationContext context, List<CCompletionProposal> proposals) throws Exception {
|
private void addInclusionProposals(CContentAssistInvocationContext context, List<ICompletionProposal> proposals) throws Exception {
|
||||||
if (context.isContextInformationStyle()) {
|
if (context.isContextInformationStyle()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -130,13 +132,11 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
|
||||||
if (potentialIncludes.length > 0) {
|
if (potentialIncludes.length > 0) {
|
||||||
IInclude[] includes= context.getTranslationUnit().getIncludes();
|
IInclude[] includes= context.getTranslationUnit().getIncludes();
|
||||||
Set<String> alreadyIncluded= new HashSet<String>();
|
Set<String> alreadyIncluded= new HashSet<String>();
|
||||||
for (int i = 0; i < includes.length; i++) {
|
for (IInclude includeDirective : includes) {
|
||||||
IInclude includeDirective= includes[i];
|
|
||||||
alreadyIncluded.add(includeDirective.getElementName());
|
alreadyIncluded.add(includeDirective.getElementName());
|
||||||
}
|
}
|
||||||
Image image = getImage(CElementImageProvider.getIncludeImageDescriptor());
|
Image image = getImage(CElementImageProvider.getIncludeImageDescriptor());
|
||||||
for (int i = 0; i < potentialIncludes.length; i++) {
|
for (String include : potentialIncludes) {
|
||||||
String include= potentialIncludes[i];
|
|
||||||
if (alreadyIncluded.add(include)) {
|
if (alreadyIncluded.add(include)) {
|
||||||
final char openingBracket= angleBrackets ? '<' : '"';
|
final char openingBracket= angleBrackets ? '<' : '"';
|
||||||
final char closingBracket= angleBrackets ? '>' : '"';
|
final char closingBracket= angleBrackets ? '>' : '"';
|
||||||
|
@ -205,16 +205,16 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
|
||||||
String[] quoteIncludes= extendedInfo.getLocalIncludePath();
|
String[] quoteIncludes= extendedInfo.getLocalIncludePath();
|
||||||
|
|
||||||
if (quoteIncludes != null) {
|
if (quoteIncludes != null) {
|
||||||
for (int i = 0; i < quoteIncludes.length; i++) {
|
for (String quoteInclude : quoteIncludes) {
|
||||||
IPath includeDir= new Path(quoteIncludes[i]);
|
IPath includeDir= new Path(quoteInclude);
|
||||||
collectIncludeFilesFromDirectory(tu, includeDir, prefixPath, includeFiles);
|
collectIncludeFilesFromDirectory(tu, includeDir, prefixPath, includeFiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] allIncludes= info.getIncludePaths();
|
String[] allIncludes= info.getIncludePaths();
|
||||||
for (int i = 0; i < allIncludes.length; i++) {
|
for (String allInclude : allIncludes) {
|
||||||
IPath includeDir= new Path(allIncludes[i]);
|
IPath includeDir= new Path(allInclude);
|
||||||
collectIncludeFilesFromDirectory(tu, includeDir, prefixPath, includeFiles);
|
collectIncludeFilesFromDirectory(tu, includeDir, prefixPath, includeFiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,6 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
|
||||||
* @param includeFiles the result list
|
* @param includeFiles the result list
|
||||||
*/
|
*/
|
||||||
private void collectIncludeFilesFromDirectory(ITranslationUnit tu, IPath directory, IPath prefixPath, List<String> includeFiles) {
|
private void collectIncludeFilesFromDirectory(ITranslationUnit tu, IPath directory, IPath prefixPath, List<String> includeFiles) {
|
||||||
final boolean isCpp= tu.isCXXLanguage();
|
|
||||||
final String namePrefix;
|
final String namePrefix;
|
||||||
if (prefixPath.segmentCount() == 0) {
|
if (prefixPath.segmentCount() == 0) {
|
||||||
namePrefix= ""; //$NON-NLS-1$
|
namePrefix= ""; //$NON-NLS-1$
|
||||||
|
@ -250,8 +249,7 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
|
||||||
final int prefixLength = namePrefix.length();
|
final int prefixLength = namePrefix.length();
|
||||||
final IProject project= tu.getCProject().getProject();
|
final IProject project= tu.getCProject().getProject();
|
||||||
File[] files= fileDir.listFiles();
|
File[] files= fileDir.listFiles();
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (File file : files) {
|
||||||
File file = files[i];
|
|
||||||
final String name= file.getName();
|
final String name= file.getName();
|
||||||
if (name.length() >= prefixLength && namePrefix.equalsIgnoreCase(name.substring(0, prefixLength))) {
|
if (name.length() >= prefixLength && namePrefix.equalsIgnoreCase(name.substring(0, prefixLength))) {
|
||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
|
@ -275,7 +273,6 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
private void collectIncludeFilesFromContainer(final ITranslationUnit tu, IContainer parent, IPath prefixPath, final List<String> includeFiles) throws CoreException {
|
private void collectIncludeFilesFromContainer(final ITranslationUnit tu, IContainer parent, IPath prefixPath, final List<String> includeFiles) throws CoreException {
|
||||||
final boolean isCpp= tu.isCXXLanguage();
|
|
||||||
final String namePrefix;
|
final String namePrefix;
|
||||||
if (prefixPath.segmentCount() == 0) {
|
if (prefixPath.segmentCount() == 0) {
|
||||||
namePrefix= ""; //$NON-NLS-1$
|
namePrefix= ""; //$NON-NLS-1$
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.ITypedRegion;
|
import org.eclipse.jface.text.ITypedRegion;
|
||||||
import org.eclipse.jface.text.TextUtilities;
|
import org.eclipse.jface.text.TextUtilities;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
||||||
|
@ -31,14 +32,13 @@ import org.eclipse.cdt.core.parser.Directives;
|
||||||
import org.eclipse.cdt.core.parser.Keywords;
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.text.ICPartitions;
|
import org.eclipse.cdt.ui.text.ICPartitions;
|
||||||
import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||||
|
|
||||||
public class KeywordCompletionProposalComputer extends ParsingBasedProposalComputer implements ICompletionProposalComputer {
|
public class KeywordCompletionProposalComputer extends ParsingBasedProposalComputer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CCompletionProposal> computeCompletionProposals(
|
protected List<ICompletionProposal> computeCompletionProposals(
|
||||||
CContentAssistInvocationContext context,
|
CContentAssistInvocationContext context,
|
||||||
IASTCompletionNode completionNode, String prefix)
|
IASTCompletionNode completionNode, String prefix)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
|
@ -58,7 +58,7 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu
|
||||||
// keywords are matched case-sensitive
|
// keywords are matched case-sensitive
|
||||||
final int relevance = RelevanceConstants.CASE_MATCH_RELEVANCE + RelevanceConstants.KEYWORD_TYPE_RELEVANCE;
|
final int relevance = RelevanceConstants.CASE_MATCH_RELEVANCE + RelevanceConstants.KEYWORD_TYPE_RELEVANCE;
|
||||||
|
|
||||||
List<CCompletionProposal> proposals = new ArrayList<CCompletionProposal>();
|
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
|
||||||
|
|
||||||
if (inPreprocessorDirective(context)) {
|
if (inPreprocessorDirective(context)) {
|
||||||
// TODO split this into a separate proposal computer?
|
// TODO split this into a separate proposal computer?
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -38,14 +38,15 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa
|
||||||
|
|
||||||
private String fErrorMessage = null;
|
private String fErrorMessage = null;
|
||||||
|
|
||||||
public List computeCompletionProposals(
|
public List<ICompletionProposal> computeCompletionProposals(
|
||||||
ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
if (context instanceof CContentAssistInvocationContext) {
|
if (context instanceof CContentAssistInvocationContext) {
|
||||||
CContentAssistInvocationContext cContext = (CContentAssistInvocationContext) context;
|
CContentAssistInvocationContext cContext = (CContentAssistInvocationContext) context;
|
||||||
|
|
||||||
IASTCompletionNode completionNode = cContext.getCompletionNode();
|
IASTCompletionNode completionNode = cContext.getCompletionNode();
|
||||||
if (completionNode == null) return Collections.EMPTY_LIST;
|
if (completionNode == null)
|
||||||
|
return Collections.emptyList();
|
||||||
String prefix = completionNode.getPrefix();
|
String prefix = completionNode.getPrefix();
|
||||||
if (prefix == null) {
|
if (prefix == null) {
|
||||||
prefix = cContext.computeIdentifierPrefix().toString();
|
prefix = cContext.computeIdentifierPrefix().toString();
|
||||||
|
@ -58,23 +59,22 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa
|
||||||
CUIPlugin.log(e);
|
CUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract List computeCompletionProposals(
|
protected abstract List<ICompletionProposal> computeCompletionProposals(
|
||||||
CContentAssistInvocationContext context,
|
CContentAssistInvocationContext context,
|
||||||
IASTCompletionNode completionNode,
|
IASTCompletionNode completionNode,
|
||||||
String prefix) throws CoreException;
|
String prefix) throws CoreException;
|
||||||
|
|
||||||
public List computeContextInformation(
|
public List<IContextInformation> computeContextInformation(
|
||||||
ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
List proposals= computeCompletionProposals(context, monitor);
|
Collection<ICompletionProposal> proposals= computeCompletionProposals(context, monitor);
|
||||||
// remove duplicates
|
// remove duplicates
|
||||||
proposals= new ArrayList(new LinkedHashSet(proposals));
|
|
||||||
List result= new ArrayList();
|
proposals= (new LinkedHashSet<ICompletionProposal>(proposals));
|
||||||
|
List<IContextInformation> result= new ArrayList<IContextInformation>();
|
||||||
for (Iterator it= proposals.iterator(); it.hasNext();) {
|
for (ICompletionProposal proposal : proposals) {
|
||||||
ICompletionProposal proposal= (ICompletionProposal) it.next();
|
|
||||||
IContextInformation contextInformation= proposal.getContextInformation();
|
IContextInformation contextInformation= proposal.getContextInformation();
|
||||||
if (contextInformation != null) {
|
if (contextInformation != null) {
|
||||||
result.add(contextInformation);
|
result.add(contextInformation);
|
||||||
|
@ -106,11 +106,10 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa
|
||||||
boolean caseMatch= prefix.length() > 0 && match.startsWith(prefix);
|
boolean caseMatch= prefix.length() > 0 && match.startsWith(prefix);
|
||||||
if (caseMatch) {
|
if (caseMatch) {
|
||||||
return RelevanceConstants.CASE_MATCH_RELEVANCE;
|
return RelevanceConstants.CASE_MATCH_RELEVANCE;
|
||||||
} else {
|
}
|
||||||
boolean exactNameMatch= match.equalsIgnoreCase(prefix);
|
boolean exactNameMatch= match.equalsIgnoreCase(prefix);
|
||||||
if (exactNameMatch) {
|
if (exactNameMatch) {
|
||||||
return RelevanceConstants.EXACT_NAME_MATCH_RELEVANCE;
|
return RelevanceConstants.EXACT_NAME_MATCH_RELEVANCE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.ITextViewer;
|
import org.eclipse.jface.text.ITextViewer;
|
||||||
import org.eclipse.jface.text.TextUtilities;
|
import org.eclipse.jface.text.TextUtilities;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
|
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||||
import org.eclipse.jface.text.templates.TemplateContextType;
|
import org.eclipse.jface.text.templates.TemplateContextType;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
@ -51,25 +53,19 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
|
||||||
contextType= new CContextType();
|
contextType= new CContextType();
|
||||||
CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
|
CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
|
||||||
}
|
}
|
||||||
if (contextType != null)
|
fCTemplateEngine= new TemplateEngine(contextType);
|
||||||
fCTemplateEngine= new TemplateEngine(contextType);
|
|
||||||
else
|
|
||||||
fCTemplateEngine= null;
|
|
||||||
contextType= CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(CommentContextType.ID);
|
contextType= CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(CommentContextType.ID);
|
||||||
if (contextType == null) {
|
if (contextType == null) {
|
||||||
contextType= new CommentContextType();
|
contextType= new CommentContextType();
|
||||||
CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
|
CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
|
||||||
}
|
}
|
||||||
if (contextType != null)
|
fCommentTemplateEngine= new TemplateEngine(contextType);
|
||||||
fCommentTemplateEngine= new TemplateEngine(contextType);
|
|
||||||
else
|
|
||||||
fCommentTemplateEngine= null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
ITextViewer viewer= context.getViewer();
|
ITextViewer viewer= context.getViewer();
|
||||||
int offset= context.getInvocationOffset();
|
int offset= context.getInvocationOffset();
|
||||||
TemplateEngine engine= null;
|
TemplateEngine engine= null;
|
||||||
|
@ -83,23 +79,23 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (engine != null && context instanceof CContentAssistInvocationContext) {
|
if (engine != null && context instanceof CContentAssistInvocationContext) {
|
||||||
CContentAssistInvocationContext cContext= (CContentAssistInvocationContext)context;
|
CContentAssistInvocationContext cContext= (CContentAssistInvocationContext)context;
|
||||||
ITranslationUnit tUnit = cContext.getTranslationUnit();
|
ITranslationUnit tUnit = cContext.getTranslationUnit();
|
||||||
if (tUnit == null) {
|
if (tUnit == null) {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
engine.reset();
|
engine.reset();
|
||||||
engine.complete(viewer, offset, tUnit);
|
engine.complete(viewer, offset, tUnit);
|
||||||
|
|
||||||
List result= engine.getResults();
|
List<ICompletionProposal> result= engine.getResults();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,8 +113,8 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -18,15 +18,8 @@ import java.util.Iterator;
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
|
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.preference.PreferenceConverter;
|
import org.eclipse.jface.preference.PreferenceConverter;
|
||||||
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.DefaultInformationControl;
|
import org.eclipse.jface.text.DefaultInformationControl;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
@ -40,7 +33,10 @@ import org.eclipse.jface.text.quickassist.QuickAssistAssistant;
|
||||||
import org.eclipse.jface.text.source.Annotation;
|
import org.eclipse.jface.text.source.Annotation;
|
||||||
import org.eclipse.jface.text.source.IAnnotationModel;
|
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||||
import org.eclipse.jface.text.source.ISourceViewer;
|
import org.eclipse.jface.text.source.ISourceViewer;
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
@ -156,7 +152,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
|
||||||
return super.showPossibleQuickAssists();
|
return super.showPossibleQuickAssists();
|
||||||
|
|
||||||
|
|
||||||
ArrayList resultingAnnotations= new ArrayList(20);
|
ArrayList<Annotation> resultingAnnotations= new ArrayList<Annotation>(20);
|
||||||
try {
|
try {
|
||||||
Point selectedRange= fViewer.getSelectedRange();
|
Point selectedRange= fViewer.getSelectedRange();
|
||||||
int currOffset= selectedRange.x;
|
int currOffset= selectedRange.x;
|
||||||
|
@ -172,7 +168,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
CUIPlugin.log(e);
|
CUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
fCurrentAnnotations= (Annotation[]) resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
|
fCurrentAnnotations= resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
|
||||||
|
|
||||||
return super.showPossibleQuickAssists();
|
return super.showPossibleQuickAssists();
|
||||||
}
|
}
|
||||||
|
@ -190,7 +186,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
|
||||||
return document.getLineInformationOfOffset(invocationLocation);
|
return document.getLineInformationOfOffset(invocationLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int collectQuickFixableAnnotations(ITextEditor editor, int invocationLocation, boolean goToClosest, ArrayList resultingAnnotations) throws BadLocationException {
|
public static int collectQuickFixableAnnotations(ITextEditor editor, int invocationLocation, boolean goToClosest, ArrayList<Annotation> resultingAnnotations) throws BadLocationException {
|
||||||
IAnnotationModel model= CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(editor.getEditorInput());
|
IAnnotationModel model= CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(editor.getEditorInput());
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
return invocationLocation;
|
return invocationLocation;
|
||||||
|
@ -198,7 +194,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
|
||||||
|
|
||||||
ensureUpdatedAnnotations(editor);
|
ensureUpdatedAnnotations(editor);
|
||||||
|
|
||||||
Iterator iter= model.getAnnotationIterator();
|
Iterator<?> iter= model.getAnnotationIterator();
|
||||||
if (goToClosest) {
|
if (goToClosest) {
|
||||||
IRegion lineInfo= getRegionOfInterest(editor, invocationLocation);
|
IRegion lineInfo= getRegionOfInterest(editor, invocationLocation);
|
||||||
if (lineInfo == null) {
|
if (lineInfo == null) {
|
||||||
|
@ -207,8 +203,8 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
|
||||||
int rangeStart= lineInfo.getOffset();
|
int rangeStart= lineInfo.getOffset();
|
||||||
int rangeEnd= rangeStart + lineInfo.getLength();
|
int rangeEnd= rangeStart + lineInfo.getLength();
|
||||||
|
|
||||||
ArrayList allAnnotations= new ArrayList();
|
ArrayList<Annotation> allAnnotations= new ArrayList<Annotation>();
|
||||||
ArrayList allPositions= new ArrayList();
|
ArrayList<Position> allPositions= new ArrayList<Position>();
|
||||||
int bestOffset= Integer.MAX_VALUE;
|
int bestOffset= Integer.MAX_VALUE;
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Annotation annot= (Annotation) iter.next();
|
Annotation annot= (Annotation) iter.next();
|
||||||
|
@ -225,24 +221,23 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
|
||||||
return invocationLocation;
|
return invocationLocation;
|
||||||
}
|
}
|
||||||
for (int i= 0; i < allPositions.size(); i++) {
|
for (int i= 0; i < allPositions.size(); i++) {
|
||||||
Position pos= (Position) allPositions.get(i);
|
Position pos= allPositions.get(i);
|
||||||
if (isInside(bestOffset, pos.offset, pos.offset + pos.length)) {
|
if (isInside(bestOffset, pos.offset, pos.offset + pos.length)) {
|
||||||
resultingAnnotations.add(allAnnotations.get(i));
|
resultingAnnotations.add(allAnnotations.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bestOffset;
|
return bestOffset;
|
||||||
} else {
|
}
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Annotation annot= (Annotation) iter.next();
|
Annotation annot= (Annotation) iter.next();
|
||||||
if (CCorrectionProcessor.isQuickFixableType(annot)) {
|
if (CCorrectionProcessor.isQuickFixableType(annot)) {
|
||||||
Position pos= model.getPosition(annot);
|
Position pos= model.getPosition(annot);
|
||||||
if (pos != null && isInside(invocationLocation, pos.offset, pos.offset + pos.length)) {
|
if (pos != null && isInside(invocationLocation, pos.offset, pos.offset + pos.length)) {
|
||||||
resultingAnnotations.add(annot);
|
resultingAnnotations.add(annot);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return invocationLocation;
|
|
||||||
}
|
}
|
||||||
|
return invocationLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ensureUpdatedAnnotations(ITextEditor editor) {
|
private static void ensureUpdatedAnnotations(ITextEditor editor) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
|
||||||
|
|
||||||
private static ContributedProcessorDescriptor[] getProcessorDescriptors(String contributionId, boolean testMarkerTypes) {
|
private static ContributedProcessorDescriptor[] getProcessorDescriptors(String contributionId, boolean testMarkerTypes) {
|
||||||
IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, contributionId);
|
IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, contributionId);
|
||||||
ArrayList res= new ArrayList(elements.length);
|
ArrayList<ContributedProcessorDescriptor> res= new ArrayList<ContributedProcessorDescriptor>(elements.length);
|
||||||
|
|
||||||
for (int i= 0; i < elements.length; i++) {
|
for (int i= 0; i < elements.length; i++) {
|
||||||
ContributedProcessorDescriptor desc= new ContributedProcessorDescriptor(elements[i], testMarkerTypes);
|
ContributedProcessorDescriptor desc= new ContributedProcessorDescriptor(elements[i], testMarkerTypes);
|
||||||
|
@ -70,7 +70,7 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
|
||||||
CUIPlugin.log(status);
|
CUIPlugin.log(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (ContributedProcessorDescriptor[]) res.toArray(new ContributedProcessorDescriptor[res.size()]);
|
return res.toArray(new ContributedProcessorDescriptor[res.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ContributedProcessorDescriptor[] getCorrectionProcessors() {
|
private static ContributedProcessorDescriptor[] getCorrectionProcessors() {
|
||||||
|
@ -198,9 +198,9 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
|
||||||
|
|
||||||
ICCompletionProposal[] res= null;
|
ICCompletionProposal[] res= null;
|
||||||
if (model != null && annotations != null) {
|
if (model != null && annotations != null) {
|
||||||
ArrayList proposals= new ArrayList(10);
|
ArrayList<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>(10);
|
||||||
IStatus status= collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(), proposals);
|
IStatus status= collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(), proposals);
|
||||||
res= (ICCompletionProposal[]) proposals.toArray(new ICCompletionProposal[proposals.size()]);
|
res= proposals.toArray(new ICCompletionProposal[proposals.size()]);
|
||||||
if (!status.isOK()) {
|
if (!status.isOK()) {
|
||||||
fErrorMessage= status.getMessage();
|
fErrorMessage= status.getMessage();
|
||||||
CUIPlugin.log(status);
|
CUIPlugin.log(status);
|
||||||
|
@ -217,8 +217,8 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IStatus collectProposals(CorrectionContext context, IAnnotationModel model, Annotation[] annotations, boolean addQuickFixes, boolean addQuickAssists, Collection proposals) {
|
public static IStatus collectProposals(CorrectionContext context, IAnnotationModel model, Annotation[] annotations, boolean addQuickFixes, boolean addQuickAssists, Collection<ICCompletionProposal> proposals) {
|
||||||
ArrayList problems= new ArrayList();
|
ArrayList<ProblemLocation> problems= new ArrayList<ProblemLocation>();
|
||||||
|
|
||||||
// collect problem locations and corrections from marker annotations
|
// collect problem locations and corrections from marker annotations
|
||||||
for (int i= 0; i < annotations.length; i++) {
|
for (int i= 0; i < annotations.length; i++) {
|
||||||
|
@ -235,7 +235,7 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
|
||||||
}
|
}
|
||||||
MultiStatus resStatus= null;
|
MultiStatus resStatus= null;
|
||||||
|
|
||||||
IProblemLocation[] problemLocations= (IProblemLocation[]) problems.toArray(new IProblemLocation[problems.size()]);
|
IProblemLocation[] problemLocations= problems.toArray(new IProblemLocation[problems.size()]);
|
||||||
if (addQuickFixes) {
|
if (addQuickFixes) {
|
||||||
IStatus status= collectCorrections(context, problemLocations, proposals);
|
IStatus status= collectCorrections(context, problemLocations, proposals);
|
||||||
if (!status.isOK()) {
|
if (!status.isOK()) {
|
||||||
|
@ -269,7 +269,7 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void collectMarkerProposals(SimpleMarkerAnnotation annotation, Collection proposals) {
|
private static void collectMarkerProposals(SimpleMarkerAnnotation annotation, Collection<ICCompletionProposal> proposals) {
|
||||||
IMarker marker= annotation.getMarker();
|
IMarker marker= annotation.getMarker();
|
||||||
IMarkerResolution[] res= IDE.getMarkerHelpRegistry().getResolutions(marker);
|
IMarkerResolution[] res= IDE.getMarkerHelpRegistry().getResolutions(marker);
|
||||||
if (res.length > 0) {
|
if (res.length > 0) {
|
||||||
|
@ -318,10 +318,10 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
|
||||||
|
|
||||||
private static class SafeCorrectionCollector extends SafeCorrectionProcessorAccess {
|
private static class SafeCorrectionCollector extends SafeCorrectionProcessorAccess {
|
||||||
private final CorrectionContext fContext;
|
private final CorrectionContext fContext;
|
||||||
private final Collection fProposals;
|
private final Collection<ICCompletionProposal> fProposals;
|
||||||
private IProblemLocation[] fLocations;
|
private IProblemLocation[] fLocations;
|
||||||
|
|
||||||
public SafeCorrectionCollector(CorrectionContext context, Collection proposals) {
|
public SafeCorrectionCollector(CorrectionContext context, Collection<ICCompletionProposal> proposals) {
|
||||||
fContext= context;
|
fContext= context;
|
||||||
fProposals= proposals;
|
fProposals= proposals;
|
||||||
}
|
}
|
||||||
|
@ -347,9 +347,9 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
|
||||||
private static class SafeAssistCollector extends SafeCorrectionProcessorAccess {
|
private static class SafeAssistCollector extends SafeCorrectionProcessorAccess {
|
||||||
private final CorrectionContext fContext;
|
private final CorrectionContext fContext;
|
||||||
private final IProblemLocation[] fLocations;
|
private final IProblemLocation[] fLocations;
|
||||||
private final Collection fProposals;
|
private final Collection<ICCompletionProposal> fProposals;
|
||||||
|
|
||||||
public SafeAssistCollector(CorrectionContext context, IProblemLocation[] locations, Collection proposals) {
|
public SafeAssistCollector(CorrectionContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
|
||||||
fContext= context;
|
fContext= context;
|
||||||
fLocations= locations;
|
fLocations= locations;
|
||||||
fProposals= proposals;
|
fProposals= proposals;
|
||||||
|
@ -415,7 +415,7 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IStatus collectCorrections(CorrectionContext context, IProblemLocation[] locations, Collection proposals) {
|
public static IStatus collectCorrections(CorrectionContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
|
||||||
ContributedProcessorDescriptor[] processors= getCorrectionProcessors();
|
ContributedProcessorDescriptor[] processors= getCorrectionProcessors();
|
||||||
SafeCorrectionCollector collector= new SafeCorrectionCollector(context, proposals);
|
SafeCorrectionCollector collector= new SafeCorrectionCollector(context, proposals);
|
||||||
for (int i= 0; i < processors.length; i++) {
|
for (int i= 0; i < processors.length; i++) {
|
||||||
|
@ -432,19 +432,19 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
|
||||||
private static IProblemLocation[] getHandledProblems(IProblemLocation[] locations, ContributedProcessorDescriptor processor) {
|
private static IProblemLocation[] getHandledProblems(IProblemLocation[] locations, ContributedProcessorDescriptor processor) {
|
||||||
// implementation tries to avoid creating a new array
|
// implementation tries to avoid creating a new array
|
||||||
boolean allHandled= true;
|
boolean allHandled= true;
|
||||||
ArrayList res= null;
|
ArrayList<IProblemLocation> res= null;
|
||||||
for (int i= 0; i < locations.length; i++) {
|
for (int i= 0; i < locations.length; i++) {
|
||||||
IProblemLocation curr= locations[i];
|
IProblemLocation curr= locations[i];
|
||||||
if (processor.canHandleMarkerType(curr.getMarkerType())) {
|
if (processor.canHandleMarkerType(curr.getMarkerType())) {
|
||||||
if (!allHandled) { // first handled problem
|
if (!allHandled) { // first handled problem
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
res= new ArrayList(locations.length - i);
|
res= new ArrayList<IProblemLocation>(locations.length - i);
|
||||||
}
|
}
|
||||||
res.add(curr);
|
res.add(curr);
|
||||||
}
|
}
|
||||||
} else if (allHandled) {
|
} else if (allHandled) {
|
||||||
if (i > 0) { // first non handled problem
|
if (i > 0) { // first non handled problem
|
||||||
res= new ArrayList(locations.length - i);
|
res= new ArrayList<IProblemLocation>(locations.length - i);
|
||||||
for (int k= 0; k < i; k++) {
|
for (int k= 0; k < i; k++) {
|
||||||
res.add(locations[k]);
|
res.add(locations[k]);
|
||||||
}
|
}
|
||||||
|
@ -458,10 +458,10 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (IProblemLocation[]) res.toArray(new IProblemLocation[res.size()]);
|
return res.toArray(new IProblemLocation[res.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IStatus collectAssists(CorrectionContext context, IProblemLocation[] locations, Collection proposals) {
|
public static IStatus collectAssists(CorrectionContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
|
||||||
ContributedProcessorDescriptor[] processors= getAssistProcessors();
|
ContributedProcessorDescriptor[] processors= getAssistProcessors();
|
||||||
SafeAssistCollector collector= new SafeAssistCollector(context, locations, proposals);
|
SafeAssistCollector collector= new SafeAssistCollector(context, locations, proposals);
|
||||||
collector.process(processors);
|
collector.process(processors);
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class CSelectAnnotationRulerAction extends SelectMarkerRulerAction {
|
||||||
if (model == null)
|
if (model == null)
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
Iterator iter= model.getAnnotationIterator();
|
Iterator<?> iter= model.getAnnotationIterator();
|
||||||
int layer= Integer.MIN_VALUE;
|
int layer= Integer.MIN_VALUE;
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
|
@ -138,21 +138,20 @@ public class CSelectAnnotationRulerAction extends SelectMarkerRulerAction {
|
||||||
fHasCorrection= true;
|
fHasCorrection= true;
|
||||||
layer= annotationLayer;
|
layer= annotationLayer;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
|
|
||||||
if (preference == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String key= preference.getVerticalRulerPreferenceKey();
|
|
||||||
if (key == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (fStore.getBoolean(key)) {
|
|
||||||
fPosition= position;
|
|
||||||
fHasCorrection= false;
|
|
||||||
layer= annotationLayer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
|
||||||
|
if (preference == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String key= preference.getVerticalRulerPreferenceKey();
|
||||||
|
if (key == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (fStore.getBoolean(key)) {
|
||||||
|
fPosition= position;
|
||||||
|
fHasCorrection= false;
|
||||||
|
layer= annotationLayer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,14 @@ import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
|
|
||||||
import org.eclipse.core.expressions.EvaluationContext;
|
import org.eclipse.core.expressions.EvaluationContext;
|
||||||
import org.eclipse.core.expressions.EvaluationResult;
|
import org.eclipse.core.expressions.EvaluationResult;
|
||||||
import org.eclipse.core.expressions.Expression;
|
import org.eclipse.core.expressions.Expression;
|
||||||
import org.eclipse.core.expressions.ExpressionConverter;
|
import org.eclipse.core.expressions.ExpressionConverter;
|
||||||
import org.eclipse.core.expressions.ExpressionTagNames;
|
import org.eclipse.core.expressions.ExpressionTagNames;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -37,7 +36,7 @@ public final class ContributedProcessorDescriptor {
|
||||||
private Object fProcessorInstance;
|
private Object fProcessorInstance;
|
||||||
private Boolean fStatus;
|
private Boolean fStatus;
|
||||||
private boolean fLastResult;
|
private boolean fLastResult;
|
||||||
private final Set fHandledMarkerTypes;
|
private final Set<String> fHandledMarkerTypes;
|
||||||
|
|
||||||
private static final String ID= "id"; //$NON-NLS-1$
|
private static final String ID= "id"; //$NON-NLS-1$
|
||||||
private static final String CLASS= "class"; //$NON-NLS-1$
|
private static final String CLASS= "class"; //$NON-NLS-1$
|
||||||
|
@ -55,13 +54,13 @@ public final class ContributedProcessorDescriptor {
|
||||||
fHandledMarkerTypes= testMarkerTypes ? getHandledMarkerTypes(element) : null;
|
fHandledMarkerTypes= testMarkerTypes ? getHandledMarkerTypes(element) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set getHandledMarkerTypes(IConfigurationElement element) {
|
private Set<String> getHandledMarkerTypes(IConfigurationElement element) {
|
||||||
HashSet map= new HashSet(7);
|
HashSet<String> map= new HashSet<String>(7);
|
||||||
IConfigurationElement[] children= element.getChildren(HANDLED_MARKER_TYPES);
|
IConfigurationElement[] children= element.getChildren(HANDLED_MARKER_TYPES);
|
||||||
for (int i= 0; i < children.length; i++) {
|
for (IConfigurationElement element2 : children) {
|
||||||
IConfigurationElement[] types= children[i].getChildren(MARKER_TYPE);
|
IConfigurationElement[] types= element2.getChildren(MARKER_TYPE);
|
||||||
for (int k= 0; k < types.length; k++) {
|
for (IConfigurationElement type : types) {
|
||||||
String attribute= types[k].getAttribute(ID);
|
String attribute= type.getAttribute(ID);
|
||||||
if (attribute != null) {
|
if (attribute != null) {
|
||||||
map.add(attribute);
|
map.add(attribute);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.ui.keys.IBindingService;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ public class CorrectionCommandHandler extends AbstractHandler {
|
||||||
|
|
||||||
private ICompletionProposal findCorrection(String id, boolean isAssist, ITextSelection selection, ITranslationUnit cu, IAnnotationModel model) {
|
private ICompletionProposal findCorrection(String id, boolean isAssist, ITextSelection selection, ITranslationUnit cu, IAnnotationModel model) {
|
||||||
CorrectionContext context= new CorrectionContext(cu, selection.getOffset(), selection.getLength());
|
CorrectionContext context= new CorrectionContext(cu, selection.getOffset(), selection.getLength());
|
||||||
Collection proposals= new ArrayList(10);
|
Collection<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>(10);
|
||||||
if (isAssist) {
|
if (isAssist) {
|
||||||
CCorrectionProcessor.collectAssists(context, new ProblemLocation[0], proposals);
|
CCorrectionProcessor.collectAssists(context, new ProblemLocation[0], proposals);
|
||||||
} else {
|
} else {
|
||||||
|
@ -86,7 +87,7 @@ public class CorrectionCommandHandler extends AbstractHandler {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Iterator iter= proposals.iterator(); iter.hasNext();) {
|
for (Iterator<ICCompletionProposal> iter= proposals.iterator(); iter.hasNext();) {
|
||||||
Object curr= iter.next();
|
Object curr= iter.next();
|
||||||
if (curr instanceof ICommandAccess) {
|
if (curr instanceof ICommandAccess) {
|
||||||
if (id.equals(((ICommandAccess) curr).getCommandId())) {
|
if (id.equals(((ICommandAccess) curr).getCommandId())) {
|
||||||
|
@ -98,9 +99,9 @@ public class CorrectionCommandHandler extends AbstractHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Annotation[] getAnnotations(int offset, boolean goToClosest) throws BadLocationException {
|
private Annotation[] getAnnotations(int offset, boolean goToClosest) throws BadLocationException {
|
||||||
ArrayList resultingAnnotations= new ArrayList();
|
ArrayList<Annotation> resultingAnnotations= new ArrayList<Annotation>();
|
||||||
CCorrectionAssistant.collectQuickFixableAnnotations(fEditor, offset, goToClosest, resultingAnnotations);
|
CCorrectionAssistant.collectQuickFixableAnnotations(fEditor, offset, goToClosest, resultingAnnotations);
|
||||||
return (Annotation[]) resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
|
return resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDocument getDocument() {
|
private IDocument getDocument() {
|
||||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.text.correction;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.ui.IWorkbench;
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
@ -39,7 +38,7 @@ public class CorrectionCommandInstaller {
|
||||||
*/
|
*/
|
||||||
public static final String ASSIST_SUFFIX= ".assist"; //$NON-NLS-1$
|
public static final String ASSIST_SUFFIX= ".assist"; //$NON-NLS-1$
|
||||||
|
|
||||||
private List fCorrectionHandlerActivations;
|
private List<IHandlerActivation> fCorrectionHandlerActivations;
|
||||||
|
|
||||||
public CorrectionCommandInstaller() {
|
public CorrectionCommandInstaller() {
|
||||||
fCorrectionHandlerActivations= null;
|
fCorrectionHandlerActivations= null;
|
||||||
|
@ -56,11 +55,12 @@ public class CorrectionCommandInstaller {
|
||||||
if (fCorrectionHandlerActivations != null) {
|
if (fCorrectionHandlerActivations != null) {
|
||||||
CUIPlugin.getDefault().logErrorMessage("correction handler activations not released"); //$NON-NLS-1$
|
CUIPlugin.getDefault().logErrorMessage("correction handler activations not released"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
fCorrectionHandlerActivations= new ArrayList();
|
fCorrectionHandlerActivations= new ArrayList<IHandlerActivation>();
|
||||||
|
|
||||||
Collection definedCommandIds= commandService.getDefinedCommandIds();
|
@SuppressWarnings("unchecked")
|
||||||
for (Iterator iter= definedCommandIds.iterator(); iter.hasNext();) {
|
Collection<String> definedCommandIds= commandService.getDefinedCommandIds();
|
||||||
String id= (String) iter.next();
|
for (Object element : definedCommandIds) {
|
||||||
|
String id= (String) element;
|
||||||
if (id.startsWith(COMMAND_PREFIX)) {
|
if (id.startsWith(COMMAND_PREFIX)) {
|
||||||
boolean isAssist= id.endsWith(ASSIST_SUFFIX);
|
boolean isAssist= id.endsWith(ASSIST_SUFFIX);
|
||||||
CorrectionCommandHandler handler= new CorrectionCommandHandler(editor, id, isAssist);
|
CorrectionCommandHandler handler= new CorrectionCommandHandler(editor, id, isAssist);
|
||||||
|
|
|
@ -260,7 +260,7 @@ public class QuickAssistLightBulbUpdater {
|
||||||
int currLine= document.getLineOfOffset(offset);
|
int currLine= document.getLineOfOffset(offset);
|
||||||
|
|
||||||
// this iterator is not protected, it may throw ConcurrentModificationExceptions
|
// this iterator is not protected, it may throw ConcurrentModificationExceptions
|
||||||
Iterator iter= model.getAnnotationIterator();
|
Iterator<?> iter= model.getAnnotationIterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Annotation annot= (Annotation) iter.next();
|
Annotation annot= (Annotation) iter.next();
|
||||||
if (CCorrectionProcessor.isQuickFixableType(annot)) {
|
if (CCorrectionProcessor.isQuickFixableType(annot)) {
|
||||||
|
|
|
@ -14,6 +14,8 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
|
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
@ -38,11 +40,11 @@ abstract class AbstractDocCommentProposalComputer implements ICompletionProposal
|
||||||
return getConfiguration(owner);
|
return getConfiguration(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
return getConfiguration().createProposalComputer().computeCompletionProposals(context, monitor);
|
return getConfiguration().createProposalComputer().computeCompletionProposals(context, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List computeContextInformation(
|
public List<IContextInformation> computeContextInformation(
|
||||||
ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
return getConfiguration().createProposalComputer().computeContextInformation(context, monitor);
|
return getConfiguration().createProposalComputer().computeContextInformation(context, monitor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.text.doctools;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -225,16 +224,15 @@ public class DocCommentOwnerManager {
|
||||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||||
IExtensionPoint indexProviders = registry.getExtensionPoint(CUIPlugin.ID_COMMENT_OWNER);
|
IExtensionPoint indexProviders = registry.getExtensionPoint(CUIPlugin.ID_COMMENT_OWNER);
|
||||||
IExtension[] extensions = indexProviders.getExtensions();
|
IExtension[] extensions = indexProviders.getExtensions();
|
||||||
for(int i=0; i<extensions.length; i++) {
|
for (IExtension extension : extensions) {
|
||||||
IExtension extension = extensions[i];
|
|
||||||
try {
|
try {
|
||||||
IConfigurationElement[] ce = extension.getConfigurationElements();
|
IConfigurationElement[] ce = extension.getConfigurationElements();
|
||||||
for(int j=0; j<ce.length; j++) {
|
for (IConfigurationElement element : ce) {
|
||||||
if(ce[j].getName().equals(ELEMENT_OWNER)) {
|
if(element.getName().equals(ELEMENT_OWNER)) {
|
||||||
IDocCommentViewerConfiguration multi = (IDocCommentViewerConfiguration) ce[j].createExecutableExtension(ATTRKEY_OWNER_MULTILINE);
|
IDocCommentViewerConfiguration multi = (IDocCommentViewerConfiguration) element.createExecutableExtension(ATTRKEY_OWNER_MULTILINE);
|
||||||
IDocCommentViewerConfiguration single = (IDocCommentViewerConfiguration) ce[j].createExecutableExtension(ATTRKEY_OWNER_SINGLELINE);
|
IDocCommentViewerConfiguration single = (IDocCommentViewerConfiguration) element.createExecutableExtension(ATTRKEY_OWNER_SINGLELINE);
|
||||||
String id= ce[j].getAttribute(ATTRKEY_OWNER_ID);
|
String id= element.getAttribute(ATTRKEY_OWNER_ID);
|
||||||
String name= ce[j].getAttribute(ATTRKEY_OWNER_NAME);
|
String name= element.getAttribute(ATTRKEY_OWNER_NAME);
|
||||||
if(result.put(id, new DocCommentOwner(id, name, multi, single))!=null) {
|
if(result.put(id, new DocCommentOwner(id, name, multi, single))!=null) {
|
||||||
String msg= MessageFormat.format(Messages.DocCommentOwnerManager_DuplicateMapping0, id);
|
String msg= MessageFormat.format(Messages.DocCommentOwnerManager_DuplicateMapping0, id);
|
||||||
CCorePlugin.log(new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, msg));
|
CCorePlugin.log(new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, msg));
|
||||||
|
@ -250,14 +248,14 @@ public class DocCommentOwnerManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fireOwnershipChanged(IResource resource, boolean submappingsRemoved, IDocCommentOwner oldOwner, IDocCommentOwner newOwner) {
|
private void fireOwnershipChanged(IResource resource, boolean submappingsRemoved, IDocCommentOwner oldOwner, IDocCommentOwner newOwner) {
|
||||||
for(Iterator i= fListeners.iterator(); i.hasNext();) {
|
for (IDocCommentOwnershipListener docCommentOwnershipListener : fListeners) {
|
||||||
((IDocCommentOwnershipListener)i.next()).ownershipChanged(resource, submappingsRemoved, oldOwner, newOwner);
|
docCommentOwnershipListener.ownershipChanged(resource, submappingsRemoved, oldOwner, newOwner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fireWorkspaceOwnershipChanged(IDocCommentOwner oldOwner, IDocCommentOwner newOwner) {
|
private void fireWorkspaceOwnershipChanged(IDocCommentOwner oldOwner, IDocCommentOwner newOwner) {
|
||||||
for(Iterator i= fListeners.iterator(); i.hasNext();) {
|
for (IDocCommentOwnershipListener element : fListeners) {
|
||||||
((IDocCommentOwnershipListener)i.next()).workspaceOwnershipChanged(oldOwner, newOwner);
|
element.workspaceOwnershipChanged(oldOwner, newOwner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,12 +158,12 @@ class ProjectMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
// invert and persist associations
|
// invert and persist associations
|
||||||
for(Iterator i= fMap.values().iterator(); i.hasNext();) {
|
for(Iterator<String> i= fMap.values().iterator(); i.hasNext();) {
|
||||||
String cid= (String) i.next();
|
String cid= i.next();
|
||||||
Element commentNode= data.getOwnerDocument().createElement(ELEMENT_DOC_COMMENT_OWNER);
|
Element commentNode= data.getOwnerDocument().createElement(ELEMENT_DOC_COMMENT_OWNER);
|
||||||
commentNode.setAttribute(ATTRKEY_DCO_ID, cid);
|
commentNode.setAttribute(ATTRKEY_DCO_ID, cid);
|
||||||
for(Iterator j= fMap.keySet().iterator(); j.hasNext(); ) {
|
for(Iterator<IPath> j= fMap.keySet().iterator(); j.hasNext(); ) {
|
||||||
IPath path= (IPath) j.next();
|
IPath path= j.next();
|
||||||
String ccid= fMap.get(path);
|
String ccid= fMap.get(path);
|
||||||
if(cid.equals(ccid)) {
|
if(cid.equals(ccid)) {
|
||||||
Element pathNode= data.getOwnerDocument().createElement(ELEMENT_PATH);
|
Element pathNode= data.getOwnerDocument().createElement(ELEMENT_PATH);
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class CFoldingStructureProviderRegistry {
|
||||||
private static final String EXTENSION_POINT= "foldingStructureProviders"; //$NON-NLS-1$
|
private static final String EXTENSION_POINT= "foldingStructureProviders"; //$NON-NLS-1$
|
||||||
|
|
||||||
/** The map of descriptors, indexed by their identifiers. */
|
/** The map of descriptors, indexed by their identifiers. */
|
||||||
private Map fDescriptors;
|
private Map<String, CFoldingStructureProviderDescriptor> fDescriptors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
|
@ -46,7 +46,7 @@ public class CFoldingStructureProviderRegistry {
|
||||||
public CFoldingStructureProviderDescriptor[] getFoldingProviderDescriptors() {
|
public CFoldingStructureProviderDescriptor[] getFoldingProviderDescriptors() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
ensureRegistered();
|
ensureRegistered();
|
||||||
return (CFoldingStructureProviderDescriptor[]) fDescriptors.values().toArray(new CFoldingStructureProviderDescriptor[fDescriptors.size()]);
|
return fDescriptors.values().toArray(new CFoldingStructureProviderDescriptor[fDescriptors.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class CFoldingStructureProviderRegistry {
|
||||||
public CFoldingStructureProviderDescriptor getFoldingProviderDescriptor(String id) {
|
public CFoldingStructureProviderDescriptor getFoldingProviderDescriptor(String id) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
ensureRegistered();
|
ensureRegistered();
|
||||||
return (CFoldingStructureProviderDescriptor) fDescriptors.get(id);
|
return fDescriptors.get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ public class CFoldingStructureProviderRegistry {
|
||||||
*/
|
*/
|
||||||
public void reloadExtensions() {
|
public void reloadExtensions() {
|
||||||
IExtensionRegistry registry= Platform.getExtensionRegistry();
|
IExtensionRegistry registry= Platform.getExtensionRegistry();
|
||||||
Map map= new HashMap();
|
Map<String, CFoldingStructureProviderDescriptor> map= new HashMap<String, CFoldingStructureProviderDescriptor>();
|
||||||
|
|
||||||
IConfigurationElement[] elements= registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT);
|
IConfigurationElement[] elements= registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT);
|
||||||
for (int i= 0; i < elements.length; i++) {
|
for (int i= 0; i < elements.length; i++) {
|
||||||
|
|
|
@ -43,14 +43,14 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
|
||||||
private IPreferenceStore fStore;
|
private IPreferenceStore fStore;
|
||||||
protected OverlayPreferenceStore fOverlayStore;
|
protected OverlayPreferenceStore fOverlayStore;
|
||||||
private OverlayKey[] fKeys;
|
private OverlayKey[] fKeys;
|
||||||
protected Map fCheckBoxes= new HashMap();
|
protected Map<Button, String> fCheckBoxes= new HashMap<Button, String>();
|
||||||
|
|
||||||
private SelectionListener fCheckBoxListener= new SelectionListener() {
|
private SelectionListener fCheckBoxListener= new SelectionListener() {
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
}
|
}
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
Button button= (Button) e.widget;
|
Button button= (Button) e.widget;
|
||||||
String key= (String) fCheckBoxes.get(button);
|
String key= fCheckBoxes.get(button);
|
||||||
fOverlayStore.setValue(key, button.getSelection());
|
fOverlayStore.setValue(key, button.getSelection());
|
||||||
updateEnablement(key);
|
updateEnablement(key);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
private OverlayKey[] createKeys() {
|
private OverlayKey[] createKeys() {
|
||||||
ArrayList overlayKeys= new ArrayList();
|
ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
|
||||||
|
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_MACROS));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_MACROS));
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_FUNCTIONS));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_FUNCTIONS));
|
||||||
|
@ -77,7 +77,7 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED));
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_STATEMENTS));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_STATEMENTS));
|
||||||
|
|
||||||
return (OverlayKey[]) overlayKeys.toArray(new OverlayKey[overlayKeys.size()]);
|
return overlayKeys.toArray(new OverlayKey[overlayKeys.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -127,10 +127,10 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeFields() {
|
private void initializeFields() {
|
||||||
Iterator it= fCheckBoxes.keySet().iterator();
|
Iterator<Button> it= fCheckBoxes.keySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Button b= (Button) it.next();
|
Button b= it.next();
|
||||||
String key= (String) fCheckBoxes.get(b);
|
String key= fCheckBoxes.get(b);
|
||||||
b.setSelection(fOverlayStore.getBoolean(key));
|
b.setSelection(fOverlayStore.getBoolean(key));
|
||||||
updateEnablement(key);
|
updateEnablement(key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.cdt.core.model.ISourceRange;
|
import org.eclipse.cdt.core.model.ISourceRange;
|
||||||
import org.eclipse.cdt.core.model.ISourceReference;
|
import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.cdt.ui.text.ICPartitions;
|
import org.eclipse.cdt.ui.text.ICPartitions;
|
||||||
|
@ -170,8 +171,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
if (switchstmt instanceof IASTCompoundStatement) {
|
if (switchstmt instanceof IASTCompoundStatement) {
|
||||||
IASTStatement[] stmts = ((IASTCompoundStatement)switchstmt).getStatements();
|
IASTStatement[] stmts = ((IASTCompoundStatement)switchstmt).getStatements();
|
||||||
boolean pushedMR = false;
|
boolean pushedMR = false;
|
||||||
for (int i = 0; i < stmts.length; i++) {
|
for (IASTStatement tmpstmt : stmts) {
|
||||||
IASTStatement tmpstmt = stmts[i];
|
|
||||||
StatementRegion tmpmr;
|
StatementRegion tmpmr;
|
||||||
if (!(tmpstmt instanceof IASTCaseStatement || tmpstmt instanceof IASTDefaultStatement)) {
|
if (!(tmpstmt instanceof IASTCaseStatement || tmpstmt instanceof IASTDefaultStatement)) {
|
||||||
if (!pushedMR) return PROCESS_SKIP;
|
if (!pushedMR) return PROCESS_SKIP;
|
||||||
|
@ -315,16 +315,14 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IASTProblem[] problems= ast.getPreprocessorProblems();
|
IASTProblem[] problems= ast.getPreprocessorProblems();
|
||||||
for (int i = 0; i < problems.length; i++) {
|
for (IASTProblem problem : problems) {
|
||||||
IASTProblem problem = problems[i];
|
if ((problem.getID() & (IProblem.SYNTAX_ERROR | IProblem.SCANNER_RELATED)) != 0) {
|
||||||
if ((problem.getID() & (IASTProblem.SYNTAX_ERROR | IASTProblem.SCANNER_RELATED)) != 0) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
problems= CPPVisitor.getProblems(ast);
|
problems= CPPVisitor.getProblems(ast);
|
||||||
for (int i = 0; i < problems.length; i++) {
|
for (IASTProblem problem : problems) {
|
||||||
IASTProblem problem = problems[i];
|
if ((problem.getID() & (IProblem.SYNTAX_ERROR | IProblem.SCANNER_RELATED)) != 0) {
|
||||||
if ((problem.getID() & (IASTProblem.SYNTAX_ERROR | IASTProblem.SCANNER_RELATED)) != 0) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1024,23 +1022,23 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
Map<CProjectionAnnotation,Position> updated= ctx.fMap;
|
Map<CProjectionAnnotation,Position> updated= ctx.fMap;
|
||||||
Map<Object, List<Tuple>> previous= computeCurrentStructure(ctx);
|
Map<Object, List<Tuple>> previous= computeCurrentStructure(ctx);
|
||||||
|
|
||||||
Iterator e= updated.keySet().iterator();
|
Iterator<CProjectionAnnotation> e= updated.keySet().iterator();
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
CProjectionAnnotation newAnnotation= (CProjectionAnnotation) e.next();
|
CProjectionAnnotation newAnnotation= e.next();
|
||||||
Object key= newAnnotation.getElement();
|
Object key= newAnnotation.getElement();
|
||||||
Position newPosition= updated.get(newAnnotation);
|
Position newPosition= updated.get(newAnnotation);
|
||||||
|
|
||||||
List annotations= previous.get(key);
|
List<Tuple> annotations= previous.get(key);
|
||||||
if (annotations == null) {
|
if (annotations == null) {
|
||||||
if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() new annotation " + newAnnotation); //$NON-NLS-1$
|
if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() new annotation " + newAnnotation); //$NON-NLS-1$
|
||||||
|
|
||||||
additions.put(newAnnotation, newPosition);
|
additions.put(newAnnotation, newPosition);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Iterator x= annotations.iterator();
|
Iterator<Tuple> x= annotations.iterator();
|
||||||
boolean matched= false;
|
boolean matched= false;
|
||||||
while (x.hasNext()) {
|
while (x.hasNext()) {
|
||||||
Tuple tuple= (Tuple) x.next();
|
Tuple tuple= x.next();
|
||||||
CProjectionAnnotation existingAnnotation= tuple.annotation;
|
CProjectionAnnotation existingAnnotation= tuple.annotation;
|
||||||
Position existingPosition= tuple.position;
|
Position existingPosition= tuple.position;
|
||||||
if (newAnnotation.getCategory() == existingAnnotation.getCategory()) {
|
if (newAnnotation.getCategory() == existingAnnotation.getCategory()) {
|
||||||
|
@ -1072,12 +1070,12 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e= previous.values().iterator();
|
Iterator<List<Tuple>> e2= previous.values().iterator();
|
||||||
while (e.hasNext()) {
|
while (e2.hasNext()) {
|
||||||
List list= (List) e.next();
|
List<Tuple> list= e2.next();
|
||||||
int size= list.size();
|
int size= list.size();
|
||||||
for (int i= 0; i < size; i++) {
|
for (int i= 0; i < size; i++) {
|
||||||
CProjectionAnnotation annotation= ((Tuple) list.get(i)).annotation;
|
CProjectionAnnotation annotation= list.get(i).annotation;
|
||||||
if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() deleted annotation " + annotation); //$NON-NLS-1$
|
if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() deleted annotation " + annotation); //$NON-NLS-1$
|
||||||
deletions.add(annotation);
|
deletions.add(annotation);
|
||||||
}
|
}
|
||||||
|
@ -1109,9 +1107,9 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
List<CProjectionAnnotation> newDeletions= new ArrayList<CProjectionAnnotation>();
|
List<CProjectionAnnotation> newDeletions= new ArrayList<CProjectionAnnotation>();
|
||||||
List<CProjectionAnnotation> newChanges= new ArrayList<CProjectionAnnotation>();
|
List<CProjectionAnnotation> newChanges= new ArrayList<CProjectionAnnotation>();
|
||||||
|
|
||||||
Iterator deletionIterator= deletions.iterator();
|
Iterator<CProjectionAnnotation> deletionIterator= deletions.iterator();
|
||||||
while (deletionIterator.hasNext()) {
|
while (deletionIterator.hasNext()) {
|
||||||
CProjectionAnnotation deleted= (CProjectionAnnotation) deletionIterator.next();
|
CProjectionAnnotation deleted= deletionIterator.next();
|
||||||
Position deletedPosition= ctx.getModel().getPosition(deleted);
|
Position deletedPosition= ctx.getModel().getPosition(deleted);
|
||||||
if (deletedPosition == null || deletedPosition.length < 5)
|
if (deletedPosition == null || deletedPosition.length < 5)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1197,7 +1195,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
boolean includeCModel= ctx.fAST != null || !(fPreprocessorBranchFoldingEnabled || fStatementsFoldingEnabled);
|
boolean includeCModel= ctx.fAST != null || !(fPreprocessorBranchFoldingEnabled || fStatementsFoldingEnabled);
|
||||||
Map<Object, List<Tuple>> map= new HashMap<Object, List<Tuple>>();
|
Map<Object, List<Tuple>> map= new HashMap<Object, List<Tuple>>();
|
||||||
ProjectionAnnotationModel model= ctx.getModel();
|
ProjectionAnnotationModel model= ctx.getModel();
|
||||||
Iterator e= model.getAnnotationIterator();
|
Iterator<?> e= model.getAnnotationIterator();
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
Object annotation= e.next();
|
Object annotation= e.next();
|
||||||
if (annotation instanceof CProjectionAnnotation) {
|
if (annotation instanceof CProjectionAnnotation) {
|
||||||
|
@ -1366,8 +1364,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
|
|
||||||
IASTPreprocessorStatement[] preprocStmts = ast.getAllPreprocessorStatements();
|
IASTPreprocessorStatement[] preprocStmts = ast.getAllPreprocessorStatements();
|
||||||
|
|
||||||
for (int i = 0; i < preprocStmts.length; i++) {
|
for (IASTPreprocessorStatement statement : preprocStmts) {
|
||||||
IASTPreprocessorStatement statement = preprocStmts[i];
|
|
||||||
if (!statement.isPartOfTranslationUnitFile()) {
|
if (!statement.isPartOfTranslationUnitFile()) {
|
||||||
// preprocessor directive is from a different file
|
// preprocessor directive is from a different file
|
||||||
continue;
|
continue;
|
||||||
|
@ -1418,8 +1415,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Counter> keys= new HashMap<String, Counter>(branches.size());
|
Map<String, Counter> keys= new HashMap<String, Counter>(branches.size());
|
||||||
for (Iterator<Branch> iter = branches.iterator(); iter.hasNext(); ) {
|
for (Branch branch : branches) {
|
||||||
Branch branch= iter.next();
|
|
||||||
IRegion aligned = alignRegion(branch, ctx, branch.fInclusive);
|
IRegion aligned = alignRegion(branch, ctx, branch.fInclusive);
|
||||||
if (aligned != null) {
|
if (aligned != null) {
|
||||||
Position alignedPos= new Position(aligned.getOffset(), aligned.getLength());
|
Position alignedPos= new Position(aligned.getOffset(), aligned.getLength());
|
||||||
|
@ -1468,8 +1464,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
int endLine = -1;
|
int endLine = -1;
|
||||||
List<Tuple> comments= new ArrayList<Tuple>();
|
List<Tuple> comments= new ArrayList<Tuple>();
|
||||||
ModifiableRegion commentRange = new ModifiableRegion();
|
ModifiableRegion commentRange = new ModifiableRegion();
|
||||||
for (int i = 0; i < partitions.length; i++) {
|
for (ITypedRegion partition : partitions) {
|
||||||
ITypedRegion partition = partitions[i];
|
|
||||||
boolean singleLine= false;
|
boolean singleLine= false;
|
||||||
if (ICPartitions.C_MULTI_LINE_COMMENT.equals(partition.getType())
|
if (ICPartitions.C_MULTI_LINE_COMMENT.equals(partition.getType())
|
||||||
|| ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(partition.getType())) {
|
|| ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(partition.getType())) {
|
||||||
|
@ -1550,9 +1545,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
}
|
}
|
||||||
|
|
||||||
private void computeFoldingStructure(ICElement[] elements, FoldingStructureComputationContext ctx) throws CModelException {
|
private void computeFoldingStructure(ICElement[] elements, FoldingStructureComputationContext ctx) throws CModelException {
|
||||||
for (int i= 0; i < elements.length; i++) {
|
for (ICElement element : elements) {
|
||||||
ICElement element= elements[i];
|
|
||||||
|
|
||||||
computeFoldingStructure(element, ctx);
|
computeFoldingStructure(element, ctx);
|
||||||
|
|
||||||
if (element instanceof IParent) {
|
if (element instanceof IParent) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
import org.eclipse.ui.texteditor.spelling.SpellingProblem;
|
import org.eclipse.ui.texteditor.spelling.SpellingProblem;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
||||||
|
@ -81,9 +82,9 @@ public class CSpellingProblem extends SpellingProblem {
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
if (isSentenceStart() && isDictionaryMatch())
|
if (isSentenceStart() && isDictionaryMatch())
|
||||||
return Messages.bind(Messages.Spelling_error_case_label, fSpellEvent.getWord());
|
return NLS.bind(Messages.Spelling_error_case_label, fSpellEvent.getWord());
|
||||||
|
|
||||||
return Messages.bind(Messages.Spelling_error_label, fSpellEvent.getWord());
|
return NLS.bind(Messages.Spelling_error_label, fSpellEvent.getWord());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -97,7 +98,7 @@ public class CSpellingProblem extends SpellingProblem {
|
||||||
|
|
||||||
final int threshold= SpellingPreferences.spellingProposalThreshold();
|
final int threshold= SpellingPreferences.spellingProposalThreshold();
|
||||||
int size= 0;
|
int size= 0;
|
||||||
List proposals= null;
|
List<RankedWordProposal> proposals= null;
|
||||||
|
|
||||||
RankedWordProposal proposal= null;
|
RankedWordProposal proposal= null;
|
||||||
ICCompletionProposal[] result= null;
|
ICCompletionProposal[] result= null;
|
||||||
|
@ -118,7 +119,7 @@ public class CSpellingProblem extends SpellingProblem {
|
||||||
arguments, getOffset(), getLength(), context,
|
arguments, getOffset(), getLength(), context,
|
||||||
engine.getLocale()) };
|
engine.getLocale()) };
|
||||||
} else {
|
} else {
|
||||||
proposals= new ArrayList(checker.getProposals(arguments[0],
|
proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0],
|
||||||
sentence));
|
sentence));
|
||||||
size= proposals.size();
|
size= proposals.size();
|
||||||
|
|
||||||
|
@ -132,7 +133,7 @@ public class CSpellingProblem extends SpellingProblem {
|
||||||
result= new ICCompletionProposal[size + (extendable ? 3 : 2)];
|
result= new ICCompletionProposal[size + (extendable ? 3 : 2)];
|
||||||
|
|
||||||
for (index= 0; index < size; index++) {
|
for (index= 0; index < size; index++) {
|
||||||
proposal= (RankedWordProposal) proposals.get(index);
|
proposal= proposals.get(index);
|
||||||
result[index]= new WordCorrectionProposal(proposal
|
result[index]= new WordCorrectionProposal(proposal
|
||||||
.getText(), arguments, getOffset(), getLength(),
|
.getText(), arguments, getOffset(), getLength(),
|
||||||
context, proposal.getRank());
|
context, proposal.getRank());
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class SpellCheckIterator implements ISpellCheckIterator {
|
||||||
protected int fPrevious= 0;
|
protected int fPrevious= 0;
|
||||||
|
|
||||||
/** The sentence breaks */
|
/** The sentence breaks */
|
||||||
private final LinkedList fSentenceBreaks= new LinkedList();
|
private final LinkedList<Integer> fSentenceBreaks= new LinkedList<Integer>();
|
||||||
|
|
||||||
/** Does the current word start a sentence? */
|
/** Does the current word start a sentence? */
|
||||||
private boolean fStartsSentence= false;
|
private boolean fStartsSentence= false;
|
||||||
|
@ -174,8 +174,8 @@ public class SpellCheckIterator implements ISpellCheckIterator {
|
||||||
*/
|
*/
|
||||||
protected final boolean isToken(final String token, final String[] tags) {
|
protected final boolean isToken(final String token, final String[] tags) {
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
for (int index= 0; index < tags.length; index++) {
|
for (String tag : tags) {
|
||||||
if (token.equals(tags[index]))
|
if (token.equals(tag))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,8 +211,8 @@ public class SpellCheckIterator implements ISpellCheckIterator {
|
||||||
* <code>false</code> otherwise
|
* <code>false</code> otherwise
|
||||||
*/
|
*/
|
||||||
protected final boolean isUrlToken(final int begin) {
|
protected final boolean isUrlToken(final int begin) {
|
||||||
for (int index= 0; index < DefaultSpellChecker.URL_PREFIXES.length; index++) {
|
for (String element : DefaultSpellChecker.URL_PREFIXES) {
|
||||||
if (fContent.startsWith(DefaultSpellChecker.URL_PREFIXES[index], begin))
|
if (fContent.startsWith(element, begin))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -237,7 +237,7 @@ public class SpellCheckIterator implements ISpellCheckIterator {
|
||||||
/*
|
/*
|
||||||
* @see java.util.Iterator#next()
|
* @see java.util.Iterator#next()
|
||||||
*/
|
*/
|
||||||
public Object next() {
|
public String next() {
|
||||||
String token= nextToken();
|
String token= nextToken();
|
||||||
while (token == null && fSuccessor != BreakIterator.DONE)
|
while (token == null && fSuccessor != BreakIterator.DONE)
|
||||||
token= nextToken();
|
token= nextToken();
|
||||||
|
@ -261,7 +261,7 @@ public class SpellCheckIterator implements ISpellCheckIterator {
|
||||||
* @return the next sentence break
|
* @return the next sentence break
|
||||||
*/
|
*/
|
||||||
protected final int nextSentence() {
|
protected final int nextSentence() {
|
||||||
return ((Integer) fSentenceBreaks.getFirst()).intValue();
|
return fSentenceBreaks.getFirst().intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class SpellingEngineDispatcher implements ISpellingEngine {
|
||||||
private static final IContentType CXXSOURCE_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
|
private static final IContentType CXXSOURCE_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
|
||||||
|
|
||||||
/** Available spelling engines by content type */
|
/** Available spelling engines by content type */
|
||||||
private Map fEngines= new HashMap();
|
private Map<IContentType, SpellingEngine> fEngines= new HashMap<IContentType, SpellingEngine>();
|
||||||
private ISpellingEngine defaultEngine;
|
private ISpellingEngine defaultEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,7 +96,7 @@ public class SpellingEngineDispatcher implements ISpellingEngine {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (fEngines.containsKey(contentType))
|
if (fEngines.containsKey(contentType))
|
||||||
return (ISpellingEngine) fEngines.get(contentType);
|
return fEngines.get(contentType);
|
||||||
|
|
||||||
return getEngine(contentType.getBaseType());
|
return getEngine(contentType.getBaseType());
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.text.spelling;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -22,6 +21,8 @@ import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.DocumentEvent;
|
import org.eclipse.jface.text.DocumentEvent;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
|
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
|
import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
|
||||||
|
@ -45,7 +46,7 @@ public final class WordCompletionProposalComputer implements ICompletionProposal
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.jface.text.contentassist.TextContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.jface.text.contentassist.TextContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
if (contributes()) {
|
if (contributes()) {
|
||||||
try {
|
try {
|
||||||
IDocument document= context.getDocument();
|
IDocument document= context.getDocument();
|
||||||
|
@ -66,11 +67,11 @@ public final class WordCompletionProposalComputer implements ICompletionProposal
|
||||||
final ISpellChecker checker= engine.getSpellChecker();
|
final ISpellChecker checker= engine.getSpellChecker();
|
||||||
|
|
||||||
if (checker != null) {
|
if (checker != null) {
|
||||||
final List proposals= new ArrayList(checker.getProposals(candidate, Character.isUpperCase(candidate.charAt(0))));
|
final List<RankedWordProposal> proposals= new ArrayList<RankedWordProposal>(checker.getProposals(candidate, Character.isUpperCase(candidate.charAt(0))));
|
||||||
final List result= new ArrayList(proposals.size());
|
final List<ICompletionProposal> result= new ArrayList<ICompletionProposal>(proposals.size());
|
||||||
|
|
||||||
for (Iterator it= proposals.iterator(); it.hasNext();) {
|
for (Object element : proposals) {
|
||||||
RankedWordProposal word= (RankedWordProposal) it.next();
|
RankedWordProposal word= (RankedWordProposal) element;
|
||||||
String text= word.getText();
|
String text= word.getText();
|
||||||
if (text.startsWith(candidate))
|
if (text.startsWith(candidate))
|
||||||
word.setRank(word.getRank() + PREFIX_RANK_SHIFT);
|
word.setRank(word.getRank() + PREFIX_RANK_SHIFT);
|
||||||
|
@ -95,7 +96,7 @@ public final class WordCompletionProposalComputer implements ICompletionProposal
|
||||||
CUIPlugin.log(exception);
|
CUIPlugin.log(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean contributes() {
|
private boolean contributes() {
|
||||||
|
@ -105,8 +106,8 @@ public final class WordCompletionProposalComputer implements ICompletionProposal
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.jface.text.contentassist.TextContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.jface.text.contentassist.TextContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class WordQuickFixProcessor implements IQuickFixProcessor {
|
||||||
final int threshold= SpellingPreferences.spellingProposalThreshold();
|
final int threshold= SpellingPreferences.spellingProposalThreshold();
|
||||||
|
|
||||||
int size= 0;
|
int size= 0;
|
||||||
List proposals= null;
|
List<RankedWordProposal> proposals= null;
|
||||||
String[] arguments= null;
|
String[] arguments= null;
|
||||||
|
|
||||||
IProblemLocation location= null;
|
IProblemLocation location= null;
|
||||||
|
@ -73,7 +73,7 @@ public class WordQuickFixProcessor implements IQuickFixProcessor {
|
||||||
if ((sentence && match) && !fixed) {
|
if ((sentence && match) && !fixed) {
|
||||||
result= new ICCompletionProposal[] { new ChangeCaseProposal(arguments, location.getOffset(), location.getLength(), context, engine.getLocale())};
|
result= new ICCompletionProposal[] { new ChangeCaseProposal(arguments, location.getOffset(), location.getLength(), context, engine.getLocale())};
|
||||||
} else {
|
} else {
|
||||||
proposals= new ArrayList(checker.getProposals(arguments[0], sentence));
|
proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0], sentence));
|
||||||
size= proposals.size();
|
size= proposals.size();
|
||||||
|
|
||||||
if (threshold > 0 && size > threshold) {
|
if (threshold > 0 && size > threshold) {
|
||||||
|
@ -86,7 +86,7 @@ public class WordQuickFixProcessor implements IQuickFixProcessor {
|
||||||
result= new ICCompletionProposal[size + (extendable ? 3 : 2)];
|
result= new ICCompletionProposal[size + (extendable ? 3 : 2)];
|
||||||
|
|
||||||
for (index= 0; index < size; index++) {
|
for (index= 0; index < size; index++) {
|
||||||
proposal= (RankedWordProposal)proposals.get(index);
|
proposal= proposals.get(index);
|
||||||
result[index]= new WordCorrectionProposal(proposal.getText(), arguments, location.getOffset(), location.getLength(), context, proposal.getRank());
|
result[index]= new WordCorrectionProposal(proposal.getText(), arguments, location.getOffset(), location.getLength(), context, proposal.getRank());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
@ -33,6 +34,7 @@ import java.util.Set;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
@ -59,7 +61,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
private IPhoneticDistanceAlgorithm fDistanceAlgorithm= new DefaultPhoneticDistanceAlgorithm();
|
private IPhoneticDistanceAlgorithm fDistanceAlgorithm= new DefaultPhoneticDistanceAlgorithm();
|
||||||
|
|
||||||
/** The mapping from phonetic hashes to word lists */
|
/** The mapping from phonetic hashes to word lists */
|
||||||
private final Map fHashBuckets= new HashMap(HASH_CAPACITY);
|
private final Map<String, Serializable> fHashBuckets= new HashMap<String, Serializable>(HASH_CAPACITY);
|
||||||
|
|
||||||
/** The phonetic hash provider */
|
/** The phonetic hash provider */
|
||||||
private IPhoneticHashProvider fHashProvider= new DefaultPhoneticHashProvider();
|
private IPhoneticHashProvider fHashProvider= new DefaultPhoneticHashProvider();
|
||||||
|
@ -100,17 +102,17 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
* Array of close hashes to find the matches
|
* Array of close hashes to find the matches
|
||||||
* @return Set of ranked words with bounded distance to the specified word
|
* @return Set of ranked words with bounded distance to the specified word
|
||||||
*/
|
*/
|
||||||
protected final Set getCandidates(final String word, final boolean sentence, final ArrayList hashs) {
|
protected final Set<RankedWordProposal> getCandidates(final String word, final boolean sentence, final ArrayList<String> hashs) {
|
||||||
|
|
||||||
int distance= 0;
|
int distance= 0;
|
||||||
String hash= null;
|
String hash= null;
|
||||||
|
|
||||||
final StringBuffer buffer= new StringBuffer(BUFFER_CAPACITY);
|
final StringBuffer buffer= new StringBuffer(BUFFER_CAPACITY);
|
||||||
final HashSet result= new HashSet(BUCKET_CAPACITY * hashs.size());
|
final HashSet<RankedWordProposal> result= new HashSet<RankedWordProposal>(BUCKET_CAPACITY * hashs.size());
|
||||||
|
|
||||||
for (int index= 0; index < hashs.size(); index++) {
|
for (int index= 0; index < hashs.size(); index++) {
|
||||||
|
|
||||||
hash= (String)hashs.get(index);
|
hash= hashs.get(index);
|
||||||
|
|
||||||
final Object candidates= getCandidates(hash);
|
final Object candidates= getCandidates(hash);
|
||||||
if (candidates == null)
|
if (candidates == null)
|
||||||
|
@ -128,10 +130,11 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ArrayList candidateList= (ArrayList)candidates;
|
@SuppressWarnings("unchecked")
|
||||||
|
final ArrayList<String> candidateList= (ArrayList<String>)candidates;
|
||||||
for (int offset= 0; offset < candidateList.size(); offset++) {
|
for (int offset= 0; offset < candidateList.size(); offset++) {
|
||||||
|
|
||||||
String candidate= (String)candidateList.get(offset);
|
String candidate= candidateList.get(offset);
|
||||||
distance= fDistanceAlgorithm.getDistance(word, candidate);
|
distance= fDistanceAlgorithm.getDistance(word, candidate);
|
||||||
|
|
||||||
if (distance < DISTANCE_THRESHOLD) {
|
if (distance < DISTANCE_THRESHOLD) {
|
||||||
|
@ -162,7 +165,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
* Set of ranked words with smallest possible distance to the
|
* Set of ranked words with smallest possible distance to the
|
||||||
* specified word
|
* specified word
|
||||||
*/
|
*/
|
||||||
protected final void getCandidates(final String word, final boolean sentence, final Set result) {
|
protected final void getCandidates(final String word, final boolean sentence, final Set<RankedWordProposal> result) {
|
||||||
|
|
||||||
int distance= 0;
|
int distance= 0;
|
||||||
int minimum= Integer.MAX_VALUE;
|
int minimum= Integer.MAX_VALUE;
|
||||||
|
@ -182,11 +185,12 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ArrayList candidateList= (ArrayList)candidates;
|
@SuppressWarnings("unchecked")
|
||||||
final ArrayList matches= new ArrayList(candidateList.size());
|
final ArrayList<String> candidateList= (ArrayList<String>)candidates;
|
||||||
|
final ArrayList<RankedWordProposal> matches= new ArrayList<RankedWordProposal>(candidateList.size());
|
||||||
|
|
||||||
for (int index= 0; index < candidateList.size(); index++) {
|
for (int index= 0; index < candidateList.size(); index++) {
|
||||||
String candidate= (String)candidateList.get(index);
|
String candidate= candidateList.get(index);
|
||||||
distance= fDistanceAlgorithm.getDistance(word, candidate);
|
distance= fDistanceAlgorithm.getDistance(word, candidate);
|
||||||
|
|
||||||
if (distance <= minimum) {
|
if (distance <= minimum) {
|
||||||
|
@ -238,7 +242,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary#getProposals(java.lang.String,boolean)
|
* @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary#getProposals(java.lang.String,boolean)
|
||||||
*/
|
*/
|
||||||
public Set getProposals(final String word, final boolean sentence) {
|
public Set<RankedWordProposal> getProposals(final String word, final boolean sentence) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -257,10 +261,10 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
final String hash= fHashProvider.getHash(word);
|
final String hash= fHashProvider.getHash(word);
|
||||||
final char[] mutators= fHashProvider.getMutators();
|
final char[] mutators= fHashProvider.getMutators();
|
||||||
|
|
||||||
final ArrayList neighborhood= new ArrayList((word.length() + 1) * (mutators.length + 2));
|
final ArrayList<String> neighborhood= new ArrayList<String>((word.length() + 1) * (mutators.length + 2));
|
||||||
neighborhood.add(hash);
|
neighborhood.add(hash);
|
||||||
|
|
||||||
final Set candidates= getCandidates(word, sentence, neighborhood);
|
final Set<RankedWordProposal> candidates= getCandidates(word, sentence, neighborhood);
|
||||||
neighborhood.clear();
|
neighborhood.clear();
|
||||||
|
|
||||||
char previous= 0;
|
char previous= 0;
|
||||||
|
@ -288,9 +292,9 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
for (int index= 0; index < mutators.length; index++) {
|
for (char mutator : mutators) {
|
||||||
|
|
||||||
characters[offset]= mutators[index];
|
characters[offset]= mutator;
|
||||||
neighborhood.add(fHashProvider.getHash(new String(characters)));
|
neighborhood.add(fHashProvider.getHash(new String(characters)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,9 +311,9 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
for (int index= 0; index < word.length(); index++) {
|
for (int index= 0; index < word.length(); index++) {
|
||||||
|
|
||||||
mutated= characters[index];
|
mutated= characters[index];
|
||||||
for (int mutator= 0; mutator < mutators.length; mutator++) {
|
for (char mutator2 : mutators) {
|
||||||
|
|
||||||
characters[index]= mutators[mutator];
|
characters[index]= mutator2;
|
||||||
neighborhood.add(fHashProvider.getHash(new String(characters)));
|
neighborhood.add(fHashProvider.getHash(new String(characters)));
|
||||||
}
|
}
|
||||||
characters[index]= mutated;
|
characters[index]= mutated;
|
||||||
|
@ -338,7 +342,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
neighborhood.remove(hash);
|
neighborhood.remove(hash);
|
||||||
final Set matches= getCandidates(word, sentence, neighborhood);
|
final Set<RankedWordProposal> matches= getCandidates(word, sentence, neighborhood);
|
||||||
|
|
||||||
if (matches.size() == 0 && candidates.size() == 0)
|
if (matches.size() == 0 && candidates.size() == 0)
|
||||||
getCandidates(word, sentence, candidates);
|
getCandidates(word, sentence, candidates);
|
||||||
|
@ -371,9 +375,11 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
if (bucket == null) {
|
if (bucket == null) {
|
||||||
fHashBuckets.put(hash, word);
|
fHashBuckets.put(hash, word);
|
||||||
} else if (bucket instanceof ArrayList) {
|
} else if (bucket instanceof ArrayList) {
|
||||||
((ArrayList)bucket).add(word);
|
@SuppressWarnings("unchecked")
|
||||||
|
final ArrayList<Object> bucket2 = (ArrayList)bucket;
|
||||||
|
bucket2.add(word);
|
||||||
} else {
|
} else {
|
||||||
ArrayList list= new ArrayList(BUCKET_CAPACITY);
|
ArrayList<Object> list= new ArrayList<Object>(BUCKET_CAPACITY);
|
||||||
list.add(bucket);
|
list.add(bucket);
|
||||||
list.add(word);
|
list.add(word);
|
||||||
fHashBuckets.put(hash, list);
|
fHashBuckets.put(hash, list);
|
||||||
|
@ -408,7 +414,8 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final ArrayList candidateList= (ArrayList)candidates;
|
@SuppressWarnings("unchecked")
|
||||||
|
final ArrayList<String> candidateList= (ArrayList)candidates;
|
||||||
if (candidateList.contains(word) || candidateList.contains(word.toLowerCase()))
|
if (candidateList.contains(word) || candidateList.contains(word.toLowerCase()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -492,7 +499,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
word= reader.readLine();
|
word= reader.readLine();
|
||||||
decoder.onMalformedInput(CodingErrorAction.REPORT);
|
decoder.onMalformedInput(CodingErrorAction.REPORT);
|
||||||
|
|
||||||
String message= Messages.bind(Messages.AbstractSpellingDictionary_encodingError,
|
String message= NLS.bind(Messages.AbstractSpellingDictionary_encodingError,
|
||||||
new String[] { word, decoder.replacement(), url.toString() });
|
new String[] { word, decoder.replacement(), url.toString() });
|
||||||
IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, ex);
|
IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, ex);
|
||||||
CUIPlugin.log(status);
|
CUIPlugin.log(status);
|
||||||
|
@ -520,7 +527,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
}
|
}
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
if (line > 0) {
|
if (line > 0) {
|
||||||
String message= Messages.bind(Messages.AbstractSpellingDictionary_encodingError,
|
String message= NLS.bind(Messages.AbstractSpellingDictionary_encodingError,
|
||||||
String.valueOf(line), url.toString());
|
String.valueOf(line), url.toString());
|
||||||
IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, exception);
|
IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, exception);
|
||||||
CUIPlugin.log(status);
|
CUIPlugin.log(status);
|
||||||
|
@ -543,11 +550,11 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
|
||||||
* Compacts the dictionary.
|
* Compacts the dictionary.
|
||||||
*/
|
*/
|
||||||
private void compact() {
|
private void compact() {
|
||||||
Iterator iter= fHashBuckets.values().iterator();
|
Iterator<Serializable> iter= fHashBuckets.values().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Object element= iter.next();
|
Object element= iter.next();
|
||||||
if (element instanceof ArrayList)
|
if (element instanceof ArrayList)
|
||||||
((ArrayList)element).trimToSize();
|
((ArrayList<?>)element).trimToSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,9 +142,9 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
final String checkable= new String(token, offset, length);
|
final String checkable= new String(token, offset, length);
|
||||||
for (int index= 0; index < candidates.length; index++) {
|
for (String candidate : candidates) {
|
||||||
|
|
||||||
if (candidates[index].equals(checkable))
|
if (candidate.equals(checkable))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -162,9 +162,9 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
|
||||||
* candidates, <code>false</code> otherwise.
|
* candidates, <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
protected static final boolean hasOneOf(final String[] candidates, final String token) {
|
protected static final boolean hasOneOf(final String[] candidates, final String token) {
|
||||||
for (int index= 0; index < candidates.length; index++) {
|
for (String candidate : candidates) {
|
||||||
|
|
||||||
if (token.indexOf(candidates[index]) >= 0)
|
if (token.indexOf(candidate) >= 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -186,8 +186,8 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
|
||||||
protected static final boolean hasVowel(final char[] token, final int offset, final int length) {
|
protected static final boolean hasVowel(final char[] token, final int offset, final int length) {
|
||||||
if (offset >= 0 && offset < length) {
|
if (offset >= 0 && offset < length) {
|
||||||
final char character= token[offset];
|
final char character= token[offset];
|
||||||
for (int index= 0; index < VOWEL_CHARACTERS.length; index++) {
|
for (char element : VOWEL_CHARACTERS) {
|
||||||
if (VOWEL_CHARACTERS[index] == character)
|
if (element == character)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,12 +291,11 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
|
||||||
else
|
else
|
||||||
buffer.append('X');
|
buffer.append('X');
|
||||||
offset += 3;
|
offset += 3;
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
buffer.append('K');
|
buffer.append('K');
|
||||||
offset += 2;
|
offset += 2;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (hasOneOf(meta24, hashable, offset, 2)) {
|
if (hasOneOf(meta24, hashable, offset, 2)) {
|
||||||
buffer.append('K');
|
buffer.append('K');
|
||||||
|
@ -324,12 +323,11 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
|
||||||
if (hasOneOf(meta31, hashable, offset + 2, 1)) {
|
if (hasOneOf(meta31, hashable, offset + 2, 1)) {
|
||||||
buffer.append('J');
|
buffer.append('J');
|
||||||
offset += 3;
|
offset += 3;
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
buffer.append("TK"); //$NON-NLS-1$
|
buffer.append("TK"); //$NON-NLS-1$
|
||||||
offset += 2;
|
offset += 2;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
buffer.append('T');
|
buffer.append('T');
|
||||||
if (hasOneOf(meta32, hashable, offset, 2)) {
|
if (hasOneOf(meta32, hashable, offset, 2)) {
|
||||||
|
@ -364,7 +362,6 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
|
||||||
}
|
}
|
||||||
if ((offset > 1) && hasOneOf(meta33, hashable, offset - 2, 1) || ((offset > 2) && hasOneOf(meta34, hashable, offset - 3, 1)) || ((offset > 3) && hasOneOf(meta35, hashable, offset - 4, 1))) {
|
if ((offset > 1) && hasOneOf(meta33, hashable, offset - 2, 1) || ((offset > 2) && hasOneOf(meta34, hashable, offset - 3, 1)) || ((offset > 3) && hasOneOf(meta35, hashable, offset - 4, 1))) {
|
||||||
offset += 2;
|
offset += 2;
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
if ((offset > 2) && (hashable[offset - 1] == 'U') && hasOneOf(meta36, hashable, offset - 3, 1)) {
|
if ((offset > 2) && (hashable[offset - 1] == 'U') && hasOneOf(meta36, hashable, offset - 3, 1)) {
|
||||||
buffer.append('F');
|
buffer.append('F');
|
||||||
|
@ -373,8 +370,8 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
|
||||||
buffer.append('K');
|
buffer.append('K');
|
||||||
}
|
}
|
||||||
offset += 2;
|
offset += 2;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (hashable[offset + 1] == 'N') {
|
if (hashable[offset + 1] == 'N') {
|
||||||
if ((offset == 1) && hasVowel(hashable, 0, hashable.length) && !has95) {
|
if ((offset == 1) && hasVowel(hashable, 0, hashable.length) && !has95) {
|
||||||
|
@ -553,7 +550,7 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (hasOneOf(meta74, hashable, offset, 2)) {
|
if (hasOneOf(meta74, hashable, offset, 2)) {
|
||||||
if (hashable[offset + 2] == 'H')
|
if (hashable[offset + 2] == 'H') {
|
||||||
if (hasOneOf(meta75, hashable, offset + 3, 2)) {
|
if (hasOneOf(meta75, hashable, offset + 3, 2)) {
|
||||||
if (hasOneOf(meta76, hashable, offset + 3, 2)) {
|
if (hasOneOf(meta76, hashable, offset + 3, 2)) {
|
||||||
buffer.append("X"); //$NON-NLS-1$
|
buffer.append("X"); //$NON-NLS-1$
|
||||||
|
@ -561,12 +558,12 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
|
||||||
buffer.append("SK"); //$NON-NLS-1$
|
buffer.append("SK"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
offset += 3;
|
offset += 3;
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
buffer.append('X');
|
buffer.append('X');
|
||||||
offset += 3;
|
offset += 3;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (hasOneOf(meta77, hashable, offset + 2, 1)) {
|
if (hasOneOf(meta77, hashable, offset + 2, 1)) {
|
||||||
buffer.append('S');
|
buffer.append('S');
|
||||||
offset += 3;
|
offset += 3;
|
||||||
|
@ -650,9 +647,8 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
|
||||||
buffer.append('J');
|
buffer.append('J');
|
||||||
offset += 2;
|
offset += 2;
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
buffer.append('S');
|
|
||||||
}
|
}
|
||||||
|
buffer.append('S');
|
||||||
if (hashable[offset + 1] == 'Z')
|
if (hashable[offset + 1] == 'Z')
|
||||||
offset += 2;
|
offset += 2;
|
||||||
else
|
else
|
||||||
|
|
|
@ -101,8 +101,8 @@ public class DefaultSpellChecker implements ISpellChecker {
|
||||||
* otherwise
|
* otherwise
|
||||||
*/
|
*/
|
||||||
protected static boolean isUrl(final String word) {
|
protected static boolean isUrl(final String word) {
|
||||||
for (int index= 0; index < URL_PREFIXES.length; index++) {
|
for (String element : URL_PREFIXES) {
|
||||||
if (word.startsWith(URL_PREFIXES[index]))
|
if (word.startsWith(element))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -112,18 +112,18 @@ public class DefaultSpellChecker implements ISpellChecker {
|
||||||
* The dictionaries to use for spell checking. Synchronized to avoid
|
* The dictionaries to use for spell checking. Synchronized to avoid
|
||||||
* concurrent modifications.
|
* concurrent modifications.
|
||||||
*/
|
*/
|
||||||
private final Set fDictionaries= Collections.synchronizedSet(new HashSet());
|
private final Set<ISpellDictionary> fDictionaries= Collections.synchronizedSet(new HashSet<ISpellDictionary>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The words to be ignored. Synchronized to avoid concurrent modifications.
|
* The words to be ignored. Synchronized to avoid concurrent modifications.
|
||||||
*/
|
*/
|
||||||
private final Set fIgnored= Collections.synchronizedSet(new HashSet());
|
private final Set<String> fIgnored= Collections.synchronizedSet(new HashSet<String>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The spell event listeners. Synchronized to avoid concurrent
|
* The spell event listeners. Synchronized to avoid concurrent
|
||||||
* modifications.
|
* modifications.
|
||||||
*/
|
*/
|
||||||
private final Set fListeners= Collections.synchronizedSet(new HashSet());
|
private final Set<ISpellEventListener> fListeners= Collections.synchronizedSet(new HashSet<ISpellEventListener>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The locale of this checker.
|
* The locale of this checker.
|
||||||
|
@ -166,14 +166,14 @@ public class DefaultSpellChecker implements ISpellChecker {
|
||||||
// synchronizing might not be needed here since acceptWords is
|
// synchronizing might not be needed here since acceptWords is
|
||||||
// a read-only access and only called in the same thread as
|
// a read-only access and only called in the same thread as
|
||||||
// the modifying methods add/checkWord (?)
|
// the modifying methods add/checkWord (?)
|
||||||
Set copy;
|
Set<ISpellDictionary> copy;
|
||||||
synchronized (fDictionaries) {
|
synchronized (fDictionaries) {
|
||||||
copy= new HashSet(fDictionaries);
|
copy= new HashSet<ISpellDictionary>(fDictionaries);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISpellDictionary dictionary= null;
|
ISpellDictionary dictionary= null;
|
||||||
for (final Iterator iterator= copy.iterator(); iterator.hasNext();) {
|
for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
|
||||||
dictionary= (ISpellDictionary) iterator.next();
|
dictionary= iterator.next();
|
||||||
if (dictionary.acceptsWords())
|
if (dictionary.acceptsWords())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -185,14 +185,13 @@ public class DefaultSpellChecker implements ISpellChecker {
|
||||||
*/
|
*/
|
||||||
public void addWord(final String word) {
|
public void addWord(final String word) {
|
||||||
// synchronizing is necessary as this is a write access
|
// synchronizing is necessary as this is a write access
|
||||||
Set copy;
|
Set<ISpellDictionary> copy;
|
||||||
synchronized (fDictionaries) {
|
synchronized (fDictionaries) {
|
||||||
copy= new HashSet(fDictionaries);
|
copy= new HashSet<ISpellDictionary>(fDictionaries);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String addable= word.toLowerCase();
|
final String addable= word.toLowerCase();
|
||||||
for (final Iterator iterator= copy.iterator(); iterator.hasNext();) {
|
for (ISpellDictionary dictionary : copy) {
|
||||||
ISpellDictionary dictionary= (ISpellDictionary) iterator.next();
|
|
||||||
if (dictionary.acceptsWords())
|
if (dictionary.acceptsWords())
|
||||||
dictionary.addWord(addable);
|
dictionary.addWord(addable);
|
||||||
}
|
}
|
||||||
|
@ -220,15 +219,15 @@ public class DefaultSpellChecker implements ISpellChecker {
|
||||||
|
|
||||||
iterator.setIgnoreSingleLetters(ignoreSingleLetters);
|
iterator.setIgnoreSingleLetters(ignoreSingleLetters);
|
||||||
|
|
||||||
Iterator iter= fDictionaries.iterator();
|
Iterator<ISpellDictionary> iter= fDictionaries.iterator();
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
((ISpellDictionary) iter.next()).setStripNonLetters(ignoreNonLetters);
|
iter.next().setStripNonLetters(ignoreNonLetters);
|
||||||
|
|
||||||
String word= null;
|
String word= null;
|
||||||
boolean starts= false;
|
boolean starts= false;
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
word= (String) iterator.next();
|
word= iterator.next();
|
||||||
if (word != null) {
|
if (word != null) {
|
||||||
// synchronizing is necessary as this is called inside the reconciler
|
// synchronizing is necessary as this is called inside the reconciler
|
||||||
if (!fIgnored.contains(word)) {
|
if (!fIgnored.contains(word)) {
|
||||||
|
@ -258,32 +257,32 @@ public class DefaultSpellChecker implements ISpellChecker {
|
||||||
*/
|
*/
|
||||||
protected final void fireEvent(final ISpellEvent event) {
|
protected final void fireEvent(final ISpellEvent event) {
|
||||||
// synchronizing is necessary as this is called from execute
|
// synchronizing is necessary as this is called from execute
|
||||||
Set copy;
|
Set<ISpellEventListener> copy;
|
||||||
synchronized (fListeners) {
|
synchronized (fListeners) {
|
||||||
copy= new HashSet(fListeners);
|
copy= new HashSet<ISpellEventListener>(fListeners);
|
||||||
}
|
}
|
||||||
for (final Iterator iterator= copy.iterator(); iterator.hasNext();) {
|
for (ISpellEventListener spellEventListener : copy) {
|
||||||
((ISpellEventListener)iterator.next()).handle(event);
|
spellEventListener.handle(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.spelling.done.ISpellChecker#getProposals(java.lang.String,boolean)
|
* @see org.eclipse.spelling.done.ISpellChecker#getProposals(java.lang.String,boolean)
|
||||||
*/
|
*/
|
||||||
public Set getProposals(final String word, final boolean sentence) {
|
public Set<RankedWordProposal> getProposals(final String word, final boolean sentence) {
|
||||||
// synchronizing might not be needed here since getProposals is
|
// synchronizing might not be needed here since getProposals is
|
||||||
// a read-only access and only called in the same thread as
|
// a read-only access and only called in the same thread as
|
||||||
// the modifying methods add/removeDictionary (?)
|
// the modifying methods add/removeDictionary (?)
|
||||||
Set copy;
|
Set<ISpellDictionary> copy;
|
||||||
synchronized (fDictionaries) {
|
synchronized (fDictionaries) {
|
||||||
copy= new HashSet(fDictionaries);
|
copy= new HashSet<ISpellDictionary>(fDictionaries);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISpellDictionary dictionary= null;
|
ISpellDictionary dictionary= null;
|
||||||
final HashSet proposals= new HashSet();
|
final HashSet<RankedWordProposal> proposals= new HashSet<RankedWordProposal>();
|
||||||
|
|
||||||
for (final Iterator iterator= copy.iterator(); iterator.hasNext();) {
|
for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
|
||||||
dictionary= (ISpellDictionary)iterator.next();
|
dictionary= iterator.next();
|
||||||
proposals.addAll(dictionary.getProposals(word, sentence));
|
proposals.addAll(dictionary.getProposals(word, sentence));
|
||||||
}
|
}
|
||||||
return proposals;
|
return proposals;
|
||||||
|
@ -302,17 +301,17 @@ public class DefaultSpellChecker implements ISpellChecker {
|
||||||
*/
|
*/
|
||||||
public final boolean isCorrect(final String word) {
|
public final boolean isCorrect(final String word) {
|
||||||
// synchronizing is necessary as this is called from execute
|
// synchronizing is necessary as this is called from execute
|
||||||
Set copy;
|
Set<ISpellDictionary> copy;
|
||||||
synchronized (fDictionaries) {
|
synchronized (fDictionaries) {
|
||||||
copy= new HashSet(fDictionaries);
|
copy= new HashSet<ISpellDictionary>(fDictionaries);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fIgnored.contains(word.toLowerCase()))
|
if (fIgnored.contains(word.toLowerCase()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
ISpellDictionary dictionary= null;
|
ISpellDictionary dictionary= null;
|
||||||
for (final Iterator iterator= copy.iterator(); iterator.hasNext();) {
|
for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
|
||||||
dictionary= (ISpellDictionary) iterator.next();
|
dictionary= iterator.next();
|
||||||
if (dictionary.isCorrect(word))
|
if (dictionary.isCorrect(word))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import java.util.Iterator;
|
||||||
/**
|
/**
|
||||||
* Interface for iterators used for spell checking.
|
* Interface for iterators used for spell checking.
|
||||||
*/
|
*/
|
||||||
public interface ISpellCheckIterator extends Iterator {
|
public interface ISpellCheckIterator extends Iterator<String> {
|
||||||
/**
|
/**
|
||||||
* Returns the begin index (inclusive) of the current word.
|
* Returns the begin index (inclusive) of the current word.
|
||||||
*
|
*
|
||||||
|
|
|
@ -71,7 +71,7 @@ public interface ISpellChecker {
|
||||||
* sentence, <code>false</code> otherwise
|
* sentence, <code>false</code> otherwise
|
||||||
* @return Set of ranked proposals for the word
|
* @return Set of ranked proposals for the word
|
||||||
*/
|
*/
|
||||||
Set getProposals(String word, boolean sentence);
|
Set<RankedWordProposal> getProposals(String word, boolean sentence);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ignores the specified word until calling <code>checkWord(String)</code>.
|
* Ignores the specified word until calling <code>checkWord(String)</code>.
|
||||||
|
|
|
@ -40,7 +40,7 @@ public interface ISpellDictionary {
|
||||||
* <code>false</code> otherwise
|
* <code>false</code> otherwise
|
||||||
* @return Array of ranked word proposals
|
* @return Array of ranked word proposals
|
||||||
*/
|
*/
|
||||||
public Set getProposals(String word, boolean sentence);
|
public Set<RankedWordProposal> getProposals(String word, boolean sentence);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the specified word correctly spelled?
|
* Is the specified word correctly spelled?
|
||||||
|
|
|
@ -38,7 +38,7 @@ public interface ISpellEvent {
|
||||||
*
|
*
|
||||||
* @return Array of proposals for the word
|
* @return Array of proposals for the word
|
||||||
*/
|
*/
|
||||||
public Set getProposals();
|
public Set<RankedWordProposal> getProposals();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the incorrectly spelled word.
|
* Returns the incorrectly spelled word.
|
||||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.text.spelling.engine;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
@ -53,7 +52,7 @@ public class PersistentSpellDictionary extends AbstractSpellDictionary {
|
||||||
if (isCorrect(word))
|
if (isCorrect(word))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OutputStreamWriter writer= null;
|
FileOutputStream fileStream= null;
|
||||||
try {
|
try {
|
||||||
Charset charset= Charset.forName(getEncoding());
|
Charset charset= Charset.forName(getEncoding());
|
||||||
ByteBuffer byteBuffer= charset.encode(word + "\n"); //$NON-NLS-1$
|
ByteBuffer byteBuffer= charset.encode(word + "\n"); //$NON-NLS-1$
|
||||||
|
@ -66,7 +65,7 @@ public class PersistentSpellDictionary extends AbstractSpellDictionary {
|
||||||
byteBuffer.get(byteArray);
|
byteBuffer.get(byteArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileOutputStream fileStream= new FileOutputStream(fLocation.getPath(), true);
|
fileStream= new FileOutputStream(fLocation.getPath(), true);
|
||||||
|
|
||||||
// Encoding UTF-16 charset writes a BOM. In which case we need to cut it away if the file isn't empty
|
// Encoding UTF-16 charset writes a BOM. In which case we need to cut it away if the file isn't empty
|
||||||
int bomCutSize= 0;
|
int bomCutSize= 0;
|
||||||
|
@ -79,8 +78,8 @@ public class PersistentSpellDictionary extends AbstractSpellDictionary {
|
||||||
return;
|
return;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (writer != null)
|
if (fileStream != null)
|
||||||
writer.close();
|
fileStream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.internal.ui.text.spelling.engine;
|
||||||
/**
|
/**
|
||||||
* Ranked word proposal for quick fix and content assist.
|
* Ranked word proposal for quick fix and content assist.
|
||||||
*/
|
*/
|
||||||
public class RankedWordProposal implements Comparable {
|
public class RankedWordProposal implements Comparable<RankedWordProposal> {
|
||||||
/** The word rank */
|
/** The word rank */
|
||||||
private int fRank;
|
private int fRank;
|
||||||
|
|
||||||
|
@ -36,9 +36,8 @@ public class RankedWordProposal implements Comparable {
|
||||||
/*
|
/*
|
||||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public final int compareTo(Object object) {
|
public final int compareTo(RankedWordProposal word) {
|
||||||
|
|
||||||
final RankedWordProposal word= (RankedWordProposal)object;
|
|
||||||
final int rank= word.getRank();
|
final int rank= word.getRank();
|
||||||
|
|
||||||
if (fRank < rank)
|
if (fRank < rank)
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class SpellEvent implements ISpellEvent {
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent#getProposals()
|
* @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent#getProposals()
|
||||||
*/
|
*/
|
||||||
public final Set getProposals() {
|
public final Set<RankedWordProposal> getProposals() {
|
||||||
return fChecker.getProposals(fWord, fSentence);
|
return fChecker.getProposals(fWord, fSentence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.text.template;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
@ -28,6 +27,7 @@ import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.ITextViewer;
|
import org.eclipse.jface.text.ITextViewer;
|
||||||
import org.eclipse.jface.text.Position;
|
import org.eclipse.jface.text.Position;
|
||||||
import org.eclipse.jface.text.Region;
|
import org.eclipse.jface.text.Region;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
import org.eclipse.jface.text.templates.GlobalTemplateVariables;
|
import org.eclipse.jface.text.templates.GlobalTemplateVariables;
|
||||||
import org.eclipse.jface.text.templates.Template;
|
import org.eclipse.jface.text.templates.Template;
|
||||||
import org.eclipse.jface.text.templates.TemplateContext;
|
import org.eclipse.jface.text.templates.TemplateContext;
|
||||||
|
@ -58,9 +58,9 @@ public class TemplateEngine {
|
||||||
/** The context type. */
|
/** The context type. */
|
||||||
private TemplateContextType fContextType;
|
private TemplateContextType fContextType;
|
||||||
/** The result proposals. */
|
/** The result proposals. */
|
||||||
private ArrayList fProposals= new ArrayList();
|
private ArrayList<ICompletionProposal> fProposals= new ArrayList<ICompletionProposal>();
|
||||||
/** Positions created on the key documents to remove in reset. */
|
/** Positions created on the key documents to remove in reset. */
|
||||||
private final Map fPositions= new HashMap();
|
private final Map<IDocument, Position> fPositions= new HashMap<IDocument, Position>();
|
||||||
|
|
||||||
public class CTemplateProposal extends TemplateProposal implements ICCompletionProposal {
|
public class CTemplateProposal extends TemplateProposal implements ICCompletionProposal {
|
||||||
|
|
||||||
|
@ -116,10 +116,10 @@ public class TemplateEngine {
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
fProposals.clear();
|
fProposals.clear();
|
||||||
for (Iterator it= fPositions.entrySet().iterator(); it.hasNext();) {
|
for (Entry<IDocument, Position> entry2 : fPositions.entrySet()) {
|
||||||
Entry entry= (Entry) it.next();
|
Entry<IDocument, Position> entry= entry2;
|
||||||
IDocument doc= (IDocument) entry.getKey();
|
IDocument doc= entry.getKey();
|
||||||
Position position= (Position) entry.getValue();
|
Position position= entry.getValue();
|
||||||
doc.removePosition(position);
|
doc.removePosition(position);
|
||||||
}
|
}
|
||||||
fPositions.clear();
|
fPositions.clear();
|
||||||
|
@ -128,7 +128,7 @@ public class TemplateEngine {
|
||||||
/**
|
/**
|
||||||
* Returns the array of matching templates.
|
* Returns the array of matching templates.
|
||||||
*/
|
*/
|
||||||
public List getResults() {
|
public List<ICompletionProposal> getResults() {
|
||||||
//return (TemplateProposal[]) fProposals.toArray(new TemplateProposal[fProposals.size()]);
|
//return (TemplateProposal[]) fProposals.toArray(new TemplateProposal[fProposals.size()]);
|
||||||
return fProposals;
|
return fProposals;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,9 @@ import org.eclipse.jface.text.templates.TemplateVariableResolver;
|
||||||
|
|
||||||
public class TemplateVariableProcessor implements IContentAssistProcessor {
|
public class TemplateVariableProcessor implements IContentAssistProcessor {
|
||||||
|
|
||||||
private static Comparator fgTemplateVariableProposalComparator= new Comparator() {
|
private static Comparator<TemplateVariableProposal> fgTemplateVariableProposalComparator= new Comparator<TemplateVariableProposal>() {
|
||||||
public int compare(Object arg0, Object arg1) {
|
public int compare(TemplateVariableProposal arg0, TemplateVariableProposal arg1) {
|
||||||
TemplateVariableProposal proposal0= (TemplateVariableProposal) arg0;
|
return arg0.getDisplayString().compareTo(arg1.getDisplayString());
|
||||||
TemplateVariableProposal proposal1= (TemplateVariableProposal) arg1;
|
|
||||||
|
|
||||||
return proposal0.getDisplayString().compareTo(proposal1.getDisplayString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,7 +70,7 @@ public class TemplateVariableProcessor implements IContentAssistProcessor {
|
||||||
if (fContextType == null)
|
if (fContextType == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List proposals= new ArrayList();
|
List<TemplateVariableProposal> proposals= new ArrayList<TemplateVariableProposal>();
|
||||||
|
|
||||||
String text= viewer.getDocument().get();
|
String text= viewer.getDocument().get();
|
||||||
int start= getStart(text, documentOffset);
|
int start= getStart(text, documentOffset);
|
||||||
|
@ -101,15 +98,17 @@ public class TemplateVariableProcessor implements IContentAssistProcessor {
|
||||||
|
|
||||||
int length= end - offset;
|
int length= end - offset;
|
||||||
|
|
||||||
for (Iterator iterator= fContextType.resolvers(); iterator.hasNext(); ) {
|
@SuppressWarnings("unchecked")
|
||||||
TemplateVariableResolver variable= (TemplateVariableResolver) iterator.next();
|
final Iterator<TemplateVariableResolver> resolvers = fContextType.resolvers();
|
||||||
|
while (resolvers.hasNext()) {
|
||||||
|
TemplateVariableResolver variable= resolvers.next();
|
||||||
|
|
||||||
if (variable.getType().startsWith(prefix))
|
if (variable.getType().startsWith(prefix))
|
||||||
proposals.add(new TemplateVariableProposal(variable, offset, length, viewer, includeBrace));
|
proposals.add(new TemplateVariableProposal(variable, offset, length, viewer, includeBrace));
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(proposals, fgTemplateVariableProposalComparator);
|
Collections.sort(proposals, fgTemplateVariableProposalComparator);
|
||||||
return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
|
return proposals.toArray(new ICompletionProposal[proposals.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Guesses the start position of the completion */
|
/* Guesses the start position of the completion */
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.text.util;
|
package org.eclipse.cdt.internal.ui.text.util;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.text.IColorManager;
|
|
||||||
import org.eclipse.cdt.internal.ui.text.IColorManagerExtension;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -22,13 +20,16 @@ import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import org.eclipse.swt.graphics.RGB;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.text.IColorManager;
|
||||||
|
import org.eclipse.cdt.internal.ui.text.IColorManagerExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CDT color manager.
|
* CDT color manager.
|
||||||
*/
|
*/
|
||||||
public class CColorManager implements IColorManager, IColorManagerExtension {
|
public class CColorManager implements IColorManager, IColorManagerExtension {
|
||||||
|
|
||||||
protected Map fKeyTable= new HashMap(10);
|
protected Map<String, RGB> fKeyTable= new HashMap<String, RGB>(10);
|
||||||
protected Map fDisplayTable= new HashMap(2);
|
protected Map<Display, Map<RGB, Color>> fDisplayTable= new HashMap<Display, Map<RGB, Color>>(2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag which tells if the colors are automatically disposed when
|
* Flag which tells if the colors are automatically disposed when
|
||||||
|
@ -59,11 +60,11 @@ public class CColorManager implements IColorManager, IColorManagerExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void dispose(Display display) {
|
protected void dispose(Display display) {
|
||||||
Map colorTable= (Map) fDisplayTable.get(display);
|
Map<RGB, Color> colorTable= fDisplayTable.get(display);
|
||||||
if (colorTable != null) {
|
if (colorTable != null) {
|
||||||
Iterator e= colorTable.values().iterator();
|
Iterator<Color> e= colorTable.values().iterator();
|
||||||
while (e.hasNext())
|
while (e.hasNext())
|
||||||
((Color) e.next()).dispose();
|
(e.next()).dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,9 +77,9 @@ public class CColorManager implements IColorManager, IColorManagerExtension {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
final Display display= Display.getCurrent();
|
final Display display= Display.getCurrent();
|
||||||
Map colorTable= (Map) fDisplayTable.get(display);
|
Map<RGB, Color> colorTable= fDisplayTable.get(display);
|
||||||
if (colorTable == null) {
|
if (colorTable == null) {
|
||||||
colorTable= new HashMap(10);
|
colorTable= new HashMap<RGB, Color>(10);
|
||||||
fDisplayTable.put(display, colorTable);
|
fDisplayTable.put(display, colorTable);
|
||||||
if (fAutoDisposeOnDisplayDispose) {
|
if (fAutoDisposeOnDisplayDispose) {
|
||||||
display.disposeExec(new Runnable() {
|
display.disposeExec(new Runnable() {
|
||||||
|
@ -89,7 +90,7 @@ public class CColorManager implements IColorManager, IColorManagerExtension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Color color= (Color) colorTable.get(rgb);
|
Color color= colorTable.get(rgb);
|
||||||
if (color == null) {
|
if (color == null) {
|
||||||
color= new Color(Display.getCurrent(), rgb);
|
color= new Color(Display.getCurrent(), rgb);
|
||||||
colorTable.put(rgb, color);
|
colorTable.put(rgb, color);
|
||||||
|
@ -114,7 +115,7 @@ public class CColorManager implements IColorManager, IColorManagerExtension {
|
||||||
if (key == null)
|
if (key == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
RGB rgb= (RGB) fKeyTable.get(key);
|
RGB rgb= fKeyTable.get(key);
|
||||||
return getColor(rgb);
|
return getColor(rgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class THHistoryListAction extends Action {
|
||||||
|
|
||||||
private class HistoryListDialog extends StatusDialog {
|
private class HistoryListDialog extends StatusDialog {
|
||||||
|
|
||||||
private ListDialogField fHistoryList;
|
private ListDialogField<ICElement> fHistoryList;
|
||||||
private IStatus fHistoryStatus;
|
private IStatus fHistoryStatus;
|
||||||
private ICElement fResult;
|
private ICElement fResult;
|
||||||
|
|
||||||
|
@ -53,22 +53,22 @@ public class THHistoryListAction extends Action {
|
||||||
Messages.THHistoryListAction_Remove,
|
Messages.THHistoryListAction_Remove,
|
||||||
};
|
};
|
||||||
|
|
||||||
IListAdapter adapter= new IListAdapter() {
|
IListAdapter<ICElement> adapter= new IListAdapter<ICElement>() {
|
||||||
public void customButtonPressed(ListDialogField field, int index) {
|
public void customButtonPressed(ListDialogField<ICElement> field, int index) {
|
||||||
doCustomButtonPressed();
|
doCustomButtonPressed();
|
||||||
}
|
}
|
||||||
public void selectionChanged(ListDialogField field) {
|
public void selectionChanged(ListDialogField<ICElement> field) {
|
||||||
doSelectionChanged();
|
doSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doubleClicked(ListDialogField field) {
|
public void doubleClicked(ListDialogField<ICElement> field) {
|
||||||
doDoubleClicked();
|
doDoubleClicked();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LabelProvider labelProvider= new CUILabelProvider(THHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS);
|
LabelProvider labelProvider= new CUILabelProvider(THHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS);
|
||||||
|
|
||||||
fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider);
|
fHistoryList= new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider);
|
||||||
fHistoryList.setLabelText(Messages.THHistoryListAction_HistoryList_label);
|
fHistoryList.setLabelText(Messages.THHistoryListAction_HistoryList_label);
|
||||||
fHistoryList.setElements(Arrays.asList(historyEntries));
|
fHistoryList.setElements(Arrays.asList(historyEntries));
|
||||||
|
|
||||||
|
|
|
@ -31,16 +31,16 @@ import org.eclipse.swt.widgets.Table;
|
||||||
* List model is independend of widget creation.
|
* List model is independend of widget creation.
|
||||||
* DialogFields controls are: Label, List and Composite containing buttons.
|
* DialogFields controls are: Label, List and Composite containing buttons.
|
||||||
*/
|
*/
|
||||||
public class CheckedListDialogField extends ListDialogField {
|
public class CheckedListDialogField<T> extends ListDialogField<T> {
|
||||||
|
|
||||||
private int fCheckAllButtonIndex;
|
private int fCheckAllButtonIndex;
|
||||||
private int fUncheckAllButtonIndex;
|
private int fUncheckAllButtonIndex;
|
||||||
|
|
||||||
private List fCheckElements;
|
private List<T> fCheckElements;
|
||||||
|
|
||||||
public CheckedListDialogField(IListAdapter adapter, String[] customButtonLabels, IBaseLabelProvider lprovider) {
|
public CheckedListDialogField(IListAdapter<T> adapter, String[] customButtonLabels, IBaseLabelProvider lprovider) {
|
||||||
super(adapter, customButtonLabels, lprovider);
|
super(adapter, customButtonLabels, lprovider);
|
||||||
fCheckElements= new ArrayList();
|
fCheckElements= new ArrayList<T>();
|
||||||
|
|
||||||
fCheckAllButtonIndex= -1;
|
fCheckAllButtonIndex= -1;
|
||||||
fUncheckAllButtonIndex= -1;
|
fUncheckAllButtonIndex= -1;
|
||||||
|
@ -117,8 +117,8 @@ public class CheckedListDialogField extends ListDialogField {
|
||||||
/**
|
/**
|
||||||
* Gets the checked elements.
|
* Gets the checked elements.
|
||||||
*/
|
*/
|
||||||
public List getCheckedElements() {
|
public List<T> getCheckedElements() {
|
||||||
return new ArrayList(fCheckElements);
|
return new ArrayList<T>(fCheckElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,8 +138,8 @@ public class CheckedListDialogField extends ListDialogField {
|
||||||
/**
|
/**
|
||||||
* Sets the checked elements.
|
* Sets the checked elements.
|
||||||
*/
|
*/
|
||||||
public void setCheckedElements(Collection list) {
|
public void setCheckedElements(Collection<T> list) {
|
||||||
fCheckElements= new ArrayList(list);
|
fCheckElements= new ArrayList<T>(list);
|
||||||
if (fTable != null) {
|
if (fTable != null) {
|
||||||
((CheckboxTableViewer)fTable).setCheckedElements(list.toArray());
|
((CheckboxTableViewer)fTable).setCheckedElements(list.toArray());
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ public class CheckedListDialogField extends ListDialogField {
|
||||||
/**
|
/**
|
||||||
* Sets the checked state of an element.
|
* Sets the checked state of an element.
|
||||||
*/
|
*/
|
||||||
public void setChecked(Object object, boolean state) {
|
public void setChecked(T object, boolean state) {
|
||||||
setCheckedWithoutUpdate(object, state);
|
setCheckedWithoutUpdate(object, state);
|
||||||
checkStateChanged();
|
checkStateChanged();
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ public class CheckedListDialogField extends ListDialogField {
|
||||||
/**
|
/**
|
||||||
* Sets the checked state of an element. No dialog changed listener is informed.
|
* Sets the checked state of an element. No dialog changed listener is informed.
|
||||||
*/
|
*/
|
||||||
public void setCheckedWithoutUpdate(Object object, boolean state) {
|
public void setCheckedWithoutUpdate(T object, boolean state) {
|
||||||
if (state) {
|
if (state) {
|
||||||
if (!fCheckElements.contains(object)) {
|
if (!fCheckElements.contains(object)) {
|
||||||
fCheckElements.add(object);
|
fCheckElements.add(object);
|
||||||
|
@ -188,7 +188,9 @@ public class CheckedListDialogField extends ListDialogField {
|
||||||
|
|
||||||
void doCheckStateChanged(CheckStateChangedEvent e) {
|
void doCheckStateChanged(CheckStateChangedEvent e) {
|
||||||
if (e.getChecked()) {
|
if (e.getChecked()) {
|
||||||
fCheckElements.add(e.getElement());
|
@SuppressWarnings("unchecked")
|
||||||
|
T elem= (T) e.getElement();
|
||||||
|
fCheckElements.add(elem);
|
||||||
} else {
|
} else {
|
||||||
fCheckElements.remove(e.getElement());
|
fCheckElements.remove(e.getElement());
|
||||||
}
|
}
|
||||||
|
@ -199,7 +201,7 @@ public class CheckedListDialogField extends ListDialogField {
|
||||||
* @see org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField#replaceElement(java.lang.Object, java.lang.Object)
|
* @see org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField#replaceElement(java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void replaceElement(Object oldElement, Object newElement) throws IllegalArgumentException {
|
public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
|
||||||
boolean wasChecked= isChecked(oldElement);
|
boolean wasChecked= isChecked(oldElement);
|
||||||
super.replaceElement(oldElement, newElement);
|
super.replaceElement(oldElement, newElement);
|
||||||
setChecked(newElement, wasChecked);
|
setChecked(newElement, wasChecked);
|
||||||
|
|
Loading…
Add table
Reference in a new issue