mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
API cleanup
This commit is contained in:
parent
599d1947f7
commit
df675c8a18
13 changed files with 68 additions and 5181 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2008 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -111,13 +111,13 @@ public class TypeUtil {
|
|||
* exception occurs while accessing its corresponding resource
|
||||
*/
|
||||
public static ICElement[] getTypes(ITranslationUnit tu) throws CModelException {
|
||||
List typeList = new ArrayList();
|
||||
List<ICElement> typeList = new ArrayList<ICElement>();
|
||||
ICElement[] children = tu.getChildren();
|
||||
for (int i = 0; i < children.length; ++i) {
|
||||
if (isDeclaringType(children[i]))
|
||||
typeList.add(children[i]);
|
||||
}
|
||||
return (ICElement[])typeList.toArray(new ICElement[typeList.size()]);
|
||||
return typeList.toArray(new ICElement[typeList.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,13 +132,13 @@ public class TypeUtil {
|
|||
*/
|
||||
public static ICElement[] getAllTypes(ITranslationUnit tu) throws CModelException {
|
||||
ICElement[] types = getTypes(tu);
|
||||
ArrayList allTypes = new ArrayList(types.length);
|
||||
ArrayList typesToTraverse = new ArrayList(types.length);
|
||||
ArrayList<ICElement> allTypes = new ArrayList<ICElement>(types.length);
|
||||
ArrayList<ICElement> typesToTraverse = new ArrayList<ICElement>(types.length);
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
typesToTraverse.add(types[i]);
|
||||
}
|
||||
while (!typesToTraverse.isEmpty()) {
|
||||
ICElement type = (ICElement) typesToTraverse.get(0);
|
||||
ICElement type = typesToTraverse.get(0);
|
||||
typesToTraverse.remove(type);
|
||||
allTypes.add(type);
|
||||
types = getTypes(type);
|
||||
|
@ -146,7 +146,7 @@ public class TypeUtil {
|
|||
typesToTraverse.add(types[i]);
|
||||
}
|
||||
}
|
||||
return (ICElement[])allTypes.toArray(new ICElement[allTypes.size()]);
|
||||
return allTypes.toArray(new ICElement[allTypes.size()]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class TypeUtil {
|
|||
* @return the immediate member types declared by this type
|
||||
*/
|
||||
public static ICElement[] getTypes(ICElement elem) throws CModelException {
|
||||
List typeList = new ArrayList();
|
||||
List<ICElement> typeList = new ArrayList<ICElement>();
|
||||
if (isDeclaringType(elem) && elem instanceof IParent) {
|
||||
ICElement[] children = ((IParent)elem).getChildren();
|
||||
for (int i = 0; i < children.length; ++i) {
|
||||
|
@ -168,7 +168,7 @@ public class TypeUtil {
|
|||
typeList.add(children[i]);
|
||||
}
|
||||
}
|
||||
return (ICElement[])typeList.toArray(new ICElement[typeList.size()]);
|
||||
return typeList.toArray(new ICElement[typeList.size()]);
|
||||
}
|
||||
|
||||
public static ITranslationUnit getTranslationUnit(ICElement elem) {
|
||||
|
@ -257,8 +257,9 @@ public class TypeUtil {
|
|||
String[] currParamTypes= curr.getParameterTypes();
|
||||
if (paramTypes.length == currParamTypes.length) {
|
||||
for (int i= 0; i < paramTypes.length; i++) {
|
||||
String t1= Signature.getSimpleName(Signature.toString(paramTypes[i]));
|
||||
String t2= Signature.getSimpleName(Signature.toString(currParamTypes[i]));
|
||||
// TODO should compare signatures
|
||||
String t1= paramTypes[i];
|
||||
String t2= currParamTypes[i];
|
||||
if (!t1.equals(t2)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -137,8 +137,8 @@ public class AssemblyLanguage extends AbstractLanguage implements IAsmLanguage,
|
|||
* @see org.eclipse.cdt.core.model.IAsmLanguage#getPreprocessorKeywords()
|
||||
*/
|
||||
public String[] getPreprocessorKeywords() {
|
||||
Set ppDirectives= ParserFactory.getKeywordSet(KeywordSetKey.PP_DIRECTIVE, ParserLanguage.C);
|
||||
String[] result= (String[]) ppDirectives.toArray(new String[ppDirectives.size()]);
|
||||
Set<String> ppDirectives= ParserFactory.getKeywordSet(KeywordSetKey.PP_DIRECTIVE, ParserLanguage.C);
|
||||
String[] result= ppDirectives.toArray(new String[ppDirectives.size()]);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -26,8 +26,6 @@ public interface IFunctionDeclaration extends IDeclaration {
|
|||
*
|
||||
* @exception CModelException if this element does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource.
|
||||
*
|
||||
* @see Signature
|
||||
*/
|
||||
String[] getExceptions();
|
||||
|
||||
|
@ -55,8 +53,6 @@ public interface IFunctionDeclaration extends IDeclaration {
|
|||
*
|
||||
* <p>For example, a source method declared as <code>void foo(string text, int length)</code>
|
||||
* would return the array <code>{"string","int"}</code>.
|
||||
*
|
||||
* @see Signature
|
||||
*/
|
||||
String[] getParameterTypes();
|
||||
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model.util;
|
||||
|
||||
public interface IQualifiedTypeName extends Comparable {
|
||||
|
||||
public final static String QUALIFIER = "::"; //$NON-NLS-1$
|
||||
|
||||
public String getName();
|
||||
|
||||
public String getFullyQualifiedName();
|
||||
public IQualifiedTypeName getEnclosingTypeName();
|
||||
public String[] getEnclosingNames();
|
||||
|
||||
public boolean isQualified();
|
||||
public boolean isEmpty();
|
||||
public boolean isGlobal();
|
||||
|
||||
public IQualifiedTypeName append(String qualifiedName);
|
||||
public IQualifiedTypeName append(String[] names);
|
||||
public IQualifiedTypeName append(IQualifiedTypeName typeName);
|
||||
|
||||
public String[] segments();
|
||||
public String segment(int index);
|
||||
public int segmentCount();
|
||||
public String lastSegment();
|
||||
public int matchingFirstSegments(IQualifiedTypeName typeName);
|
||||
public IQualifiedTypeName removeFirstSegments(int count);
|
||||
public IQualifiedTypeName removeLastSegments(int count);
|
||||
public boolean isPrefixOf(IQualifiedTypeName typeName);
|
||||
|
||||
public boolean isLowLevel();
|
||||
public boolean isValidSegment(String segment);
|
||||
public boolean isValid();
|
||||
|
||||
public boolean equals(IQualifiedTypeName typeName);
|
||||
public boolean equalsIgnoreCase(IQualifiedTypeName typeName);
|
||||
public int compareTo(IQualifiedTypeName typeName);
|
||||
public int compareToIgnoreCase(IQualifiedTypeName typeName);
|
||||
}
|
|
@ -1,391 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model.util;
|
||||
|
||||
import org.eclipse.cdt.core.CConventions;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
||||
public class QualifiedTypeName implements IQualifiedTypeName {
|
||||
|
||||
private static final String[] NO_SEGMENTS = new String[0];
|
||||
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
private static final int INITIAL_SEGMENT_LENGTH = 12;
|
||||
private static final int HASH_INIT = 17;
|
||||
private static final int HASH_MULTIPLIER = 37;
|
||||
|
||||
private String[] fSegments = NO_SEGMENTS;
|
||||
private int fHashCode = 0;
|
||||
|
||||
public static final QualifiedTypeName EMPTY = new QualifiedTypeName();
|
||||
|
||||
public QualifiedTypeName(IQualifiedTypeName typeName) {
|
||||
fSegments = typeName.segments();
|
||||
}
|
||||
|
||||
public QualifiedTypeName(String qualifiedName) {
|
||||
fSegments = createSegments(qualifiedName);
|
||||
}
|
||||
|
||||
public QualifiedTypeName(String[] names) {
|
||||
fSegments = createSegments(names);
|
||||
}
|
||||
|
||||
public QualifiedTypeName(String name, String[] enclosingNames) {
|
||||
if (enclosingNames == null)
|
||||
fSegments = createSegments(name);
|
||||
else
|
||||
fSegments = createSegments(name, enclosingNames);
|
||||
}
|
||||
|
||||
private QualifiedTypeName() {
|
||||
}
|
||||
|
||||
private String[] createSegments(String qualifiedName) {
|
||||
String[] segments;
|
||||
int qualifierIndex = qualifiedName.indexOf(QUALIFIER, 0);
|
||||
if (qualifierIndex == -1) {
|
||||
segments = new String[] { qualifiedName };
|
||||
} else {
|
||||
int maxSegments = 1;
|
||||
int lastIndex = 0;
|
||||
while (qualifierIndex >= 0) {
|
||||
lastIndex = qualifierIndex + QUALIFIER.length();
|
||||
++maxSegments;
|
||||
qualifierIndex = qualifiedName.indexOf(QUALIFIER, lastIndex);
|
||||
}
|
||||
segments = new String[maxSegments];
|
||||
int segmentCount = 0;
|
||||
lastIndex = 0;
|
||||
qualifierIndex = qualifiedName.indexOf(QUALIFIER, 0);
|
||||
while (qualifierIndex >= 0) {
|
||||
// note: we allocate a new string rather than use the returned substring,
|
||||
// otherwise we're holding a reference to the entire original string
|
||||
segments[segmentCount] = new String(qualifiedName.substring(lastIndex, qualifierIndex));
|
||||
++segmentCount;
|
||||
lastIndex = qualifierIndex + QUALIFIER.length();
|
||||
qualifierIndex = qualifiedName.indexOf(QUALIFIER, lastIndex);
|
||||
}
|
||||
// note: we allocate a new string rather than use the returned substring,
|
||||
// otherwise we're holding a reference to the entire original string
|
||||
segments[segmentCount] = new String(qualifiedName.substring(lastIndex));
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
|
||||
private String[] createSegments(String[] names) {
|
||||
String[] segments = new String[names.length];
|
||||
System.arraycopy(names, 0, segments, 0, names.length);
|
||||
return segments;
|
||||
}
|
||||
|
||||
private String[] createSegments(String name, String[] enclosingNames) {
|
||||
String[] segments = new String[enclosingNames.length + 1];
|
||||
System.arraycopy(enclosingNames, 0, segments, 0, enclosingNames.length);
|
||||
segments[segments.length - 1] = name;
|
||||
return segments;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (fSegments.length > 0) {
|
||||
return fSegments[fSegments.length - 1];
|
||||
}
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
|
||||
public String[] getEnclosingNames() {
|
||||
if (fSegments.length > 1) {
|
||||
String[] enclosingNames = new String[fSegments.length - 1];
|
||||
System.arraycopy(fSegments, 0, enclosingNames, 0, fSegments.length - 1);
|
||||
return enclosingNames;
|
||||
}
|
||||
return NO_SEGMENTS;
|
||||
}
|
||||
|
||||
public String getFullyQualifiedName() {
|
||||
if (fSegments.length > 0) {
|
||||
StringBuffer buf = new StringBuffer(fSegments.length * INITIAL_SEGMENT_LENGTH);
|
||||
for (int i = 0; i < fSegments.length; ++i) {
|
||||
if (i > 0) {
|
||||
buf.append(QUALIFIER);
|
||||
}
|
||||
buf.append(fSegments[i]);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
|
||||
public IQualifiedTypeName getEnclosingTypeName() {
|
||||
String[] enclosingNames = getEnclosingNames();
|
||||
if (enclosingNames.length > 0) {
|
||||
QualifiedTypeName enclosingTypeName = new QualifiedTypeName();
|
||||
enclosingTypeName.fSegments = enclosingNames;
|
||||
return enclosingTypeName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isQualified() {
|
||||
return (fSegments.length > 1);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return (fSegments.length == 0);
|
||||
}
|
||||
|
||||
public boolean isGlobal() {
|
||||
return (fSegments.length <= 1 || fSegments[0].length() == 0);
|
||||
}
|
||||
|
||||
public int segmentCount() {
|
||||
return fSegments.length;
|
||||
}
|
||||
|
||||
public String[] segments() {
|
||||
String[] segmentCopy = new String[fSegments.length];
|
||||
System.arraycopy(fSegments, 0, segmentCopy, 0, fSegments.length);
|
||||
return segmentCopy;
|
||||
}
|
||||
|
||||
public String segment(int index) {
|
||||
if (index >= fSegments.length) {
|
||||
return null;
|
||||
}
|
||||
return fSegments[index];
|
||||
}
|
||||
|
||||
public String lastSegment() {
|
||||
if (fSegments.length > 0) {
|
||||
return fSegments[fSegments.length - 1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int matchingFirstSegments(IQualifiedTypeName typeName) {
|
||||
int max = Math.min(fSegments.length, typeName.segmentCount());
|
||||
int count = 0;
|
||||
for (int i = 0; i < max; ++i) {
|
||||
if (!fSegments[i].equals(typeName.segment(i))) {
|
||||
return count;
|
||||
}
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public boolean isPrefixOf(IQualifiedTypeName typeName) {
|
||||
if (fSegments.length == 0)
|
||||
return true;
|
||||
|
||||
if (fSegments.length > typeName.segmentCount()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < fSegments.length; ++i) {
|
||||
if (!fSegments[i].equals(typeName.segment(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IQualifiedTypeName append(String[] names) {
|
||||
int length = fSegments.length;
|
||||
int typeNameLength = names.length;
|
||||
String[] newSegments = new String[length + typeNameLength];
|
||||
System.arraycopy(fSegments, 0, newSegments, 0, length);
|
||||
System.arraycopy(names, 0, newSegments, length, typeNameLength);
|
||||
QualifiedTypeName newTypeName = new QualifiedTypeName();
|
||||
newTypeName.fSegments = newSegments;
|
||||
return newTypeName;
|
||||
}
|
||||
|
||||
public IQualifiedTypeName append(IQualifiedTypeName typeName) {
|
||||
int length = fSegments.length;
|
||||
int typeNameLength = typeName.segmentCount();
|
||||
String[] newSegments = new String[length + typeNameLength];
|
||||
System.arraycopy(fSegments, 0, newSegments, 0, length);
|
||||
for (int i = 0; i < typeNameLength; ++i) {
|
||||
newSegments[i + length] = typeName.segment(i);
|
||||
}
|
||||
QualifiedTypeName newTypeName = new QualifiedTypeName();
|
||||
newTypeName.fSegments = newSegments;
|
||||
return newTypeName;
|
||||
}
|
||||
|
||||
public IQualifiedTypeName append(String qualifiedName) {
|
||||
return append(createSegments(qualifiedName));
|
||||
}
|
||||
|
||||
public IQualifiedTypeName removeFirstSegments(int count) {
|
||||
if (count == 0) {
|
||||
return this;
|
||||
} else if (count >= fSegments.length || count < 0) {
|
||||
return EMPTY;
|
||||
} else {
|
||||
int newSize = fSegments.length - count;
|
||||
String[] newSegments = new String[newSize];
|
||||
System.arraycopy(fSegments, count, newSegments, 0, newSize);
|
||||
QualifiedTypeName newTypeName = new QualifiedTypeName();
|
||||
newTypeName.fSegments = newSegments;
|
||||
return newTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
public IQualifiedTypeName removeLastSegments(int count) {
|
||||
if (count == 0) {
|
||||
return this;
|
||||
} else if (count >= fSegments.length || count < 0) {
|
||||
return EMPTY;
|
||||
} else {
|
||||
int newSize = fSegments.length - count;
|
||||
String[] newSegments = new String[newSize];
|
||||
System.arraycopy(fSegments, 0, newSegments, 0, newSize);
|
||||
QualifiedTypeName newTypeName = new QualifiedTypeName();
|
||||
newTypeName.fSegments = newSegments;
|
||||
return newTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLowLevel() {
|
||||
for (int i = 0; i < fSegments.length; ++i) {
|
||||
if (fSegments[i].startsWith("_")) { //$NON-NLS-1$
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
for (int i = 0; i < fSegments.length; ++i) {
|
||||
String segment = fSegments[i];
|
||||
// type name must follow C conventions
|
||||
IStatus val = CConventions.validateIdentifier(segment);
|
||||
if (val.getSeverity() == IStatus.ERROR)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isValidSegment(String segment) {
|
||||
if (segment.indexOf(QUALIFIER) != -1)
|
||||
return false;
|
||||
// type name must follow C conventions
|
||||
IStatus val = CConventions.validateIdentifier(segment);
|
||||
return (val.getSeverity() != IStatus.ERROR);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
if (fHashCode == 0) {
|
||||
fHashCode = HASH_INIT;
|
||||
for (int i = 0; i < fSegments.length; ++i) {
|
||||
fHashCode = fHashCode * HASH_MULTIPLIER + fSegments[i].hashCode();
|
||||
}
|
||||
}
|
||||
return fHashCode;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getFullyQualifiedName();
|
||||
}
|
||||
|
||||
public int compareTo(Object obj) {
|
||||
if (obj == this) {
|
||||
return 0;
|
||||
}
|
||||
if (!(obj instanceof IQualifiedTypeName)) {
|
||||
throw new ClassCastException();
|
||||
}
|
||||
return compareTo((IQualifiedTypeName)obj);
|
||||
}
|
||||
|
||||
public int compareTo(IQualifiedTypeName typeName) {
|
||||
if (typeName == this)
|
||||
return 0;
|
||||
if (typeName == null)
|
||||
return 1;
|
||||
|
||||
int length = fSegments.length;
|
||||
int typeNameLength = typeName.segmentCount();
|
||||
int len = Math.min(length, typeNameLength);
|
||||
int result = 0;
|
||||
for (int i = 0; result == 0 && i < len; ++i) {
|
||||
result = fSegments[i].compareTo(typeName.segment(i));
|
||||
}
|
||||
if (result == 0 && length != typeNameLength) {
|
||||
result = (length < typeNameLength) ? -1 : 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int compareToIgnoreCase(IQualifiedTypeName typeName) {
|
||||
if (typeName == this)
|
||||
return 0;
|
||||
if (typeName == null)
|
||||
return 1;
|
||||
|
||||
int length = fSegments.length;
|
||||
int typeNameLength = typeName.segmentCount();
|
||||
int len = Math.min(length, typeNameLength);
|
||||
int result = 0;
|
||||
for (int i = 0; result == 0 && i < len; ++i) {
|
||||
result = fSegments[i].compareToIgnoreCase(typeName.segment(i));
|
||||
}
|
||||
if (result == 0 && length != typeNameLength) {
|
||||
result = (length < typeNameLength) ? -1 : 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof IQualifiedTypeName)) {
|
||||
return false;
|
||||
}
|
||||
return equals((IQualifiedTypeName)obj);
|
||||
}
|
||||
|
||||
public boolean equals(IQualifiedTypeName typeName) {
|
||||
if (typeName == this)
|
||||
return true;
|
||||
if (typeName == null)
|
||||
return false;
|
||||
|
||||
int length = fSegments.length;
|
||||
int typeNameLength = typeName.segmentCount();
|
||||
if (length != typeNameLength)
|
||||
return false;
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (!fSegments[i].equals(typeName.segment(i)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean equalsIgnoreCase(IQualifiedTypeName typeName) {
|
||||
if (typeName == this)
|
||||
return true;
|
||||
if (typeName == null)
|
||||
return false;
|
||||
|
||||
int length = fSegments.length;
|
||||
int typeNameLength = typeName.segmentCount();
|
||||
if (length != typeNameLength)
|
||||
return false;
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (!fSegments[i].equalsIgnoreCase(typeName.segment(i)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,317 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IMember;
|
||||
import org.eclipse.cdt.core.model.IMethodDeclaration;
|
||||
import org.eclipse.cdt.core.model.IParent;
|
||||
import org.eclipse.cdt.core.model.IStructure;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
||||
public class TypeUtil {
|
||||
|
||||
public static boolean isDeclaringType(ICElement elem) {
|
||||
int type = elem.getElementType();
|
||||
return (type == ICElement.C_CLASS
|
||||
|| type == ICElement.C_STRUCT
|
||||
|| type == ICElement.C_ENUMERATION
|
||||
|| type == ICElement.C_UNION
|
||||
|| type == ICElement.C_TYPEDEF
|
||||
|| type == ICElement.C_NAMESPACE);
|
||||
}
|
||||
|
||||
public static boolean isMemberType(ICElement elem) {
|
||||
int type = elem.getElementType();
|
||||
if (type == ICElement.C_CLASS
|
||||
|| type == ICElement.C_STRUCT
|
||||
|| type == ICElement.C_ENUMERATION
|
||||
|| type == ICElement.C_UNION
|
||||
|| type == ICElement.C_TYPEDEF
|
||||
|| type == ICElement.C_NAMESPACE)
|
||||
return true;
|
||||
return elem instanceof IMember;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type in which this member is declared, or <code>null</code>
|
||||
* if this member is not declared in a type (for example, a top-level type).
|
||||
* This is a handle-only method.
|
||||
*
|
||||
* @return the type in which this member is declared, or <code>null</code>
|
||||
* if this member is not declared in a type (for example, a top-level type)
|
||||
*/
|
||||
public static ICElement getDeclaringType(ICElement elem) {
|
||||
if (!isMemberType(elem))
|
||||
return null;
|
||||
ICElement parent = elem.getParent();
|
||||
while (parent != null && !(parent instanceof ITranslationUnit)) {
|
||||
if (isDeclaringType(parent))
|
||||
return parent;
|
||||
parent = parent.getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ICElement getDeclaringClass(ICElement type) {
|
||||
ICElement parentElement = type.getParent();
|
||||
if (parentElement != null && isClassOrStruct(parentElement)) {
|
||||
return parentElement;
|
||||
}
|
||||
|
||||
if (isClassOrStruct(type)) {
|
||||
while (parentElement != null) {
|
||||
if (isClassOrStruct(parentElement)) {
|
||||
return parentElement;
|
||||
} else if (parentElement instanceof IMember) {
|
||||
parentElement = parentElement.getParent();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isClassOrStruct(ICElement type) {
|
||||
int kind = type.getElementType();
|
||||
// case ICElement.C_TEMPLATE_CLASS:
|
||||
// case ICElement.C_TEMPLATE_STRUCT:
|
||||
return (kind == ICElement.C_CLASS || kind == ICElement.C_STRUCT);
|
||||
}
|
||||
|
||||
public static boolean isClass(ICElement type) {
|
||||
return (type.getElementType() == ICElement.C_CLASS);
|
||||
}
|
||||
|
||||
public static boolean isNamespace(ICElement type) {
|
||||
return (type.getElementType() == ICElement.C_NAMESPACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the top-level types declared in the given translation unit
|
||||
* in the order in which they appear in the source.
|
||||
*
|
||||
* @param tu the translation unit
|
||||
* @return the top-level types declared in the given translation unit
|
||||
* @throws CModelException if this element does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource
|
||||
*/
|
||||
public static ICElement[] getTypes(ITranslationUnit tu) throws CModelException {
|
||||
List typeList = new ArrayList();
|
||||
ICElement[] children = tu.getChildren();
|
||||
for (int i = 0; i < children.length; ++i) {
|
||||
if (isDeclaringType(children[i]))
|
||||
typeList.add(children[i]);
|
||||
}
|
||||
return (ICElement[])typeList.toArray(new ICElement[typeList.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all types declared in the given translation unit in the order
|
||||
* in which they appear in the source.
|
||||
* This includes all top-level types and nested member types.
|
||||
* It does NOT include local types (types defined in methods).
|
||||
*
|
||||
* @return the array of top-level and member types defined in the given translation unit, in declaration order.
|
||||
* @throws CModelException if this element does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource
|
||||
*/
|
||||
public static ICElement[] getAllTypes(ITranslationUnit tu) throws CModelException {
|
||||
ICElement[] types = getTypes(tu);
|
||||
ArrayList allTypes = new ArrayList(types.length);
|
||||
ArrayList typesToTraverse = new ArrayList(types.length);
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
typesToTraverse.add(types[i]);
|
||||
}
|
||||
while (!typesToTraverse.isEmpty()) {
|
||||
ICElement type = (ICElement) typesToTraverse.get(0);
|
||||
typesToTraverse.remove(type);
|
||||
allTypes.add(type);
|
||||
types = getTypes(type);
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
typesToTraverse.add(types[i]);
|
||||
}
|
||||
}
|
||||
return (ICElement[])allTypes.toArray(new ICElement[allTypes.size()]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the immediate member types declared by the given element.
|
||||
* The results are listed in the order in which they appear in the source file.
|
||||
*
|
||||
* @param elem the element
|
||||
* @exception CModelException if this element does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource.
|
||||
* @return the immediate member types declared by this type
|
||||
*/
|
||||
public static ICElement[] getTypes(ICElement elem) throws CModelException {
|
||||
List typeList = new ArrayList();
|
||||
if (isDeclaringType(elem) && elem instanceof IParent) {
|
||||
ICElement[] children = ((IParent)elem).getChildren();
|
||||
for (int i = 0; i < children.length; ++i) {
|
||||
if (isDeclaringType(children[i]))
|
||||
typeList.add(children[i]);
|
||||
}
|
||||
}
|
||||
return (ICElement[])typeList.toArray(new ICElement[typeList.size()]);
|
||||
}
|
||||
|
||||
public static ITranslationUnit getTranslationUnit(ICElement elem) {
|
||||
while (elem != null) {
|
||||
if (elem instanceof ITranslationUnit)
|
||||
return (ITranslationUnit)elem;
|
||||
elem = elem.getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO move method to CModelUtil
|
||||
public static IQualifiedTypeName getFullyQualifiedName(ICElement type) {
|
||||
String name = type.getElementName();
|
||||
IQualifiedTypeName qualifiedName = new QualifiedTypeName(name);
|
||||
ICElement parent = type.getParent();
|
||||
while (parent != null && (isNamespace(parent) || isClass(parent))) {
|
||||
qualifiedName = new QualifiedTypeName(parent.getElementName()).append(qualifiedName);
|
||||
parent = parent.getParent();
|
||||
}
|
||||
return qualifiedName;
|
||||
}
|
||||
|
||||
public static IMethodDeclaration[] getMethods(ICElement elem) {
|
||||
if (elem instanceof IStructure) {
|
||||
try {
|
||||
List list = ((IParent)elem).getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
return (IMethodDeclaration[]) list.toArray(new IMethodDeclaration[list.size()]);
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ICElement[] getFields(ICElement elem) {
|
||||
if (elem instanceof IStructure) {
|
||||
try {
|
||||
List list = ((IParent)elem).getChildrenOfType(ICElement.C_FIELD);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
return (ICElement[]) list.toArray(new ICElement[list.size()]);
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds a method by name.
|
||||
* This searches for a method with a name and signature. Parameter types are only
|
||||
* compared by the simple name, no resolving for the fully qualified type name is done.
|
||||
* Constructors are only compared by parameters, not the name.
|
||||
* @param name The name of the method to find
|
||||
* @param paramTypes The type signatures of the parameters e.g. <code>{"QString;","I"}</code>
|
||||
* @param isConstructor If the method is a constructor
|
||||
* @param methods The methods to search in
|
||||
* @return The found method or <code>null</code>, if nothing found
|
||||
*/
|
||||
// TODO move methods to CModelUtil
|
||||
public static IMethodDeclaration findMethod(String name, String[] paramTypes, boolean isConstructor, boolean isDestructor, IMethodDeclaration[] methods) throws CModelException {
|
||||
for (int i= methods.length - 1; i >= 0; i--) {
|
||||
if (isSameMethodSignature(name, paramTypes, isConstructor, isDestructor, methods[i])) {
|
||||
return methods[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a method equals to the given signature.
|
||||
* Parameter types are only compared by the simple name, no resolving for
|
||||
* the fully qualified type name is done. Constructors are only compared by
|
||||
* parameters, not the name.
|
||||
* @param name Name of the method
|
||||
* @param paramTypes The type signatures of the parameters e.g. <code>{"QString;","I"}</code>
|
||||
* @param isConstructor Specifies if the method is a constructor
|
||||
* @return Returns <code>true</code> if the method has the given name and parameter types and constructor state.
|
||||
*/
|
||||
//TODO move methods to CModelUtil
|
||||
public static boolean isSameMethodSignature(String name, String[] paramTypes, boolean isConstructor, boolean isDestructor, IMethodDeclaration curr) throws CModelException {
|
||||
if (isConstructor || isDestructor || name.equals(curr.getElementName())) {
|
||||
if ((isConstructor == curr.isConstructor()) && (isDestructor == curr.isDestructor())) {
|
||||
String[] currParamTypes= curr.getParameterTypes();
|
||||
if (paramTypes.length == currParamTypes.length) {
|
||||
for (int i= 0; i < paramTypes.length; i++) {
|
||||
String t1= Signature.getSimpleName(Signature.toString(paramTypes[i]));
|
||||
String t2= Signature.getSimpleName(Signature.toString(currParamTypes[i]));
|
||||
if (!t1.equals(t2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a method in a type.
|
||||
* This searches for a method with the same name and signature. Parameter types are only
|
||||
* compared by the simple name, no resolving for the fully qualified type name is done.
|
||||
* Constructors are only compared by parameters, not the name.
|
||||
* @param name The name of the method to find
|
||||
* @param paramTypes The type signatures of the parameters e.g. <code>{"QString;","I"}</code>
|
||||
* @param isConstructor If the method is a constructor
|
||||
* @return The first found method or <code>null</code>, if nothing found
|
||||
*/
|
||||
// TODO move methods to CModelUtil
|
||||
public static IMethodDeclaration findMethod(String name, String[] paramTypes, boolean isConstructor, boolean isDestructor, ICElement type) throws CModelException {
|
||||
return findMethod(name, paramTypes, isConstructor, isDestructor, getMethods(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a method declararion in a type's hierarchy. The search is top down, so this
|
||||
* returns the first declaration of the method in the hierarchy.
|
||||
* This searches for a method with a name and signature. Parameter types are only
|
||||
* compared by the simple name, no resolving for the fully qualified type name is done.
|
||||
* Constructors are only compared by parameters, not the name.
|
||||
* @param type Searches in this type's supertypes.
|
||||
* @param name The name of the method to find
|
||||
* @param paramTypes The type signatures of the parameters e.g. <code>{"QString;","I"}</code>
|
||||
* @param isConstructor If the method is a constructor
|
||||
* @return The first method found or null, if nothing found
|
||||
*/
|
||||
// TODO move methods to CModelUtil
|
||||
// public static IMethodDeclaration findMethodDeclarationInHierarchy(ITypeHierarchy hierarchy, ICElement type, String name, String[] paramTypes, boolean isConstructor, boolean isDestructor) throws CModelException {
|
||||
// ICElement[] superTypes= hierarchy.getAllSupertypes(type);
|
||||
// for (int i= superTypes.length - 1; i >= 0; i--) {
|
||||
// IMethodDeclaration first= findMethod(name, paramTypes, isConstructor, isDestructor, superTypes[i]);
|
||||
// if (first != null && first.getVisibility() != ASTAccessVisibility.PRIVATE) {
|
||||
// // the order getAllSupertypes does make assumptions of the order of inner elements -> search recursivly
|
||||
// IMethodDeclaration res= findMethodDeclarationInHierarchy(hierarchy, TypeUtil.getDeclaringClass(first), name, paramTypes, isConstructor, isDestructor);
|
||||
// if (res != null) {
|
||||
// return res;
|
||||
// }
|
||||
// return first;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
}
|
|
@ -1,374 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text;
|
||||
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.IDocumentListener;
|
||||
import org.eclipse.jface.text.IDocumentPartitioner;
|
||||
import org.eclipse.jface.text.IDocumentPartitioningListener;
|
||||
import org.eclipse.jface.text.IPositionUpdater;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.ITypedRegion;
|
||||
import org.eclipse.jface.text.Position;
|
||||
|
||||
/**
|
||||
* Minimal implementation of IDocument to apply text edit onto a string.
|
||||
*/
|
||||
public class SimpleDocument implements IDocument {
|
||||
|
||||
private StringBuffer buffer;
|
||||
|
||||
public SimpleDocument(String source) {
|
||||
buffer = new StringBuffer(source);
|
||||
}
|
||||
|
||||
public SimpleDocument(char[] source) {
|
||||
buffer = new StringBuffer(source.length);
|
||||
buffer.append(source);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getChar(int)
|
||||
*/
|
||||
public char getChar(int offset) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getLength()
|
||||
*/
|
||||
public int getLength() {
|
||||
return this.buffer.length();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#get()
|
||||
*/
|
||||
public String get() {
|
||||
return this.buffer.toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#get(int, int)
|
||||
*/
|
||||
public String get(int offset, int length) {
|
||||
return this.buffer.substring(offset, offset + length);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#set(java.lang.String)
|
||||
*/
|
||||
public void set(String text) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#replace(int, int, java.lang.String)
|
||||
*/
|
||||
public void replace(int offset, int length, String text) {
|
||||
|
||||
this.buffer.replace(offset, offset + length, text);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#addDocumentListener(org.eclipse.jface.text.IDocumentListener)
|
||||
*/
|
||||
public void addDocumentListener(IDocumentListener listener) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#removeDocumentListener(org.eclipse.jface.text.IDocumentListener)
|
||||
*/
|
||||
public void removeDocumentListener(IDocumentListener listener) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#addPrenotifiedDocumentListener(org.eclipse.jface.text.IDocumentListener)
|
||||
*/
|
||||
public void addPrenotifiedDocumentListener(IDocumentListener documentAdapter) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#removePrenotifiedDocumentListener(org.eclipse.jface.text.IDocumentListener)
|
||||
*/
|
||||
public void removePrenotifiedDocumentListener(IDocumentListener documentAdapter) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#addPositionCategory(java.lang.String)
|
||||
*/
|
||||
public void addPositionCategory(String category) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#removePositionCategory(java.lang.String)
|
||||
*/
|
||||
public void removePositionCategory(String category) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getPositionCategories()
|
||||
*/
|
||||
public String[] getPositionCategories() {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#containsPositionCategory(java.lang.String)
|
||||
*/
|
||||
public boolean containsPositionCategory(String category) {
|
||||
// defining interface method
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#addPosition(org.eclipse.jface.text.Position)
|
||||
*/
|
||||
public void addPosition(Position position) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#removePosition(org.eclipse.jface.text.Position)
|
||||
*/
|
||||
public void removePosition(Position position) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#addPosition(java.lang.String, org.eclipse.jface.text.Position)
|
||||
*/
|
||||
public void addPosition(String category, Position position) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#removePosition(java.lang.String, org.eclipse.jface.text.Position)
|
||||
*/
|
||||
public void removePosition(String category, Position position) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getPositions(java.lang.String)
|
||||
*/
|
||||
public Position[] getPositions(String category) {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#containsPosition(java.lang.String, int, int)
|
||||
*/
|
||||
public boolean containsPosition(String category, int offset, int length) {
|
||||
// defining interface method
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#computeIndexInCategory(java.lang.String, int)
|
||||
*/
|
||||
public int computeIndexInCategory(String category, int offset) {
|
||||
// defining interface method
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#addPositionUpdater(org.eclipse.jface.text.IPositionUpdater)
|
||||
*/
|
||||
public void addPositionUpdater(IPositionUpdater updater) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#removePositionUpdater(org.eclipse.jface.text.IPositionUpdater)
|
||||
*/
|
||||
public void removePositionUpdater(IPositionUpdater updater) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#insertPositionUpdater(org.eclipse.jface.text.IPositionUpdater, int)
|
||||
*/
|
||||
public void insertPositionUpdater(IPositionUpdater updater, int index) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getPositionUpdaters()
|
||||
*/
|
||||
public IPositionUpdater[] getPositionUpdaters() {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getLegalContentTypes()
|
||||
*/
|
||||
public String[] getLegalContentTypes() {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getContentType(int)
|
||||
*/
|
||||
public String getContentType(int offset) {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getPartition(int)
|
||||
*/
|
||||
public ITypedRegion getPartition(int offset) {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#computePartitioning(int, int)
|
||||
*/
|
||||
public ITypedRegion[] computePartitioning(int offset, int length) {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#addDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener)
|
||||
*/
|
||||
public void addDocumentPartitioningListener(IDocumentPartitioningListener listener) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#removeDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener)
|
||||
*/
|
||||
public void removeDocumentPartitioningListener(IDocumentPartitioningListener listener) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#setDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner)
|
||||
*/
|
||||
public void setDocumentPartitioner(IDocumentPartitioner partitioner) {
|
||||
// defining interface method
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getDocumentPartitioner()
|
||||
*/
|
||||
public IDocumentPartitioner getDocumentPartitioner() {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getLineLength(int)
|
||||
*/
|
||||
public int getLineLength(int line) {
|
||||
// defining interface method
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getLineOfOffset(int)
|
||||
*/
|
||||
public int getLineOfOffset(int offset) {
|
||||
// defining interface method
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getLineOffset(int)
|
||||
*/
|
||||
public int getLineOffset(int line) {
|
||||
// defining interface method
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getLineInformation(int)
|
||||
*/
|
||||
public IRegion getLineInformation(int line) {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getLineInformationOfOffset(int)
|
||||
*/
|
||||
public IRegion getLineInformationOfOffset(int offset) {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getNumberOfLines()
|
||||
*/
|
||||
public int getNumberOfLines() {
|
||||
// defining interface method
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getNumberOfLines(int, int)
|
||||
*/
|
||||
public int getNumberOfLines(int offset, int length) {
|
||||
// defining interface method
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#computeNumberOfLines(java.lang.String)
|
||||
*/
|
||||
public int computeNumberOfLines(String text) {
|
||||
// defining interface method
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getLegalLineDelimiters()
|
||||
*/
|
||||
public String[] getLegalLineDelimiters() {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IDocument#getLineDelimiter(int)
|
||||
*/
|
||||
public String getLineDelimiter(int line) {
|
||||
// defining interface method
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jface.text.IDocument#search(int, java.lang.String, boolean, boolean, boolean)
|
||||
* @deprecated
|
||||
*/
|
||||
public int search(
|
||||
int startOffset,
|
||||
String findString,
|
||||
boolean forwardSearch,
|
||||
boolean caseSensitive,
|
||||
boolean wholeWord) {
|
||||
// defining interface method
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2007 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -76,7 +76,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
|||
protected Object fInput;
|
||||
|
||||
/** Remember what refreshes we already have pending so we don't post them again. */
|
||||
protected HashSet pendingRefreshes = new HashSet();
|
||||
protected HashSet<IRefreshable> pendingRefreshes = new HashSet<IRefreshable>();
|
||||
|
||||
/**
|
||||
* Creates a new content provider for C elements.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.actions;
|
||||
|
||||
|
@ -22,6 +23,7 @@ import java.util.SortedSet;
|
|||
import java.util.Stack;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
|
@ -159,9 +161,9 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
private StructuredViewer fViewer;
|
||||
|
||||
private NamePatternFilter fPatternFilter;
|
||||
private Map fInstalledBuiltInFilters;
|
||||
private Map<String, ViewerFilter> fInstalledBuiltInFilters;
|
||||
|
||||
private Map fEnabledFilterIds;
|
||||
private Map<String, Boolean> fEnabledFilterIds;
|
||||
private boolean fUserDefinedPatternsEnabled;
|
||||
private String[] fUserDefinedPatterns;
|
||||
/**
|
||||
|
@ -169,7 +171,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
private Stack fLRUFilterIdsStack;
|
||||
private Stack<String> fLRUFilterIdsStack;
|
||||
/**
|
||||
* Handle to menu manager to dynamically update
|
||||
* the last recently used filters.
|
||||
|
@ -190,7 +192,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
* @since 3.0
|
||||
*/
|
||||
private String[] fFilterIdsUsedInLastViewMenu;
|
||||
private HashMap fFilterDescriptorMap;
|
||||
private HashMap<String, FilterDescriptor> fFilterDescriptorMap;
|
||||
private String fTargetId;
|
||||
|
||||
/**
|
||||
|
@ -215,7 +217,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
fTargetId= ownerId;
|
||||
fViewer= viewer;
|
||||
|
||||
fLRUFilterIdsStack= new Stack();
|
||||
fLRUFilterIdsStack= new Stack<String>();
|
||||
|
||||
initializeWithPluginContributions();
|
||||
initializeWithViewDefaults();
|
||||
|
@ -233,10 +235,10 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
|
||||
public String[] removeFiltersFor(Object parent, Object element, IContentProvider contentProvider) {
|
||||
String[] enabledFilters= getEnabledFilterIds();
|
||||
Set newFilters= new HashSet();
|
||||
Set<String> newFilters= new HashSet<String>();
|
||||
for (int i= 0; i < enabledFilters.length; i++) {
|
||||
String filterName= enabledFilters[i];
|
||||
ViewerFilter filter= (ViewerFilter) fInstalledBuiltInFilters.get(filterName);
|
||||
ViewerFilter filter= fInstalledBuiltInFilters.get(filterName);
|
||||
if (filter == null)
|
||||
newFilters.add(filterName);
|
||||
else if (isSelected(parent, element, contentProvider, filter))
|
||||
|
@ -244,7 +246,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
}
|
||||
if (newFilters.size() == enabledFilters.length)
|
||||
return new String[0];
|
||||
return (String[])newFilters.toArray(new String[newFilters.size()]);
|
||||
return newFilters.toArray(new String[newFilters.size()]);
|
||||
}
|
||||
|
||||
public void setFilters(String[] newFilters) {
|
||||
|
@ -284,7 +286,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
}
|
||||
|
||||
private String[] getEnabledFilterIds() {
|
||||
Set enabledFilterIds= new HashSet(fEnabledFilterIds.size());
|
||||
Set<String> enabledFilterIds= new HashSet<String>(fEnabledFilterIds.size());
|
||||
Iterator iter= fEnabledFilterIds.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry entry= (Map.Entry)iter.next();
|
||||
|
@ -293,14 +295,14 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
if (isEnabled)
|
||||
enabledFilterIds.add(id);
|
||||
}
|
||||
return (String[])enabledFilterIds.toArray(new String[enabledFilterIds.size()]);
|
||||
return enabledFilterIds.toArray(new String[enabledFilterIds.size()]);
|
||||
}
|
||||
|
||||
|
||||
private void setEnabledFilterIds(String[] enabledIds) {
|
||||
Iterator iter= fEnabledFilterIds.keySet().iterator();
|
||||
Iterator<String> iter= fEnabledFilterIds.keySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
String id= (String)iter.next();
|
||||
String id= iter.next();
|
||||
fEnabledFilterIds.put(id, Boolean.FALSE);
|
||||
}
|
||||
for (int i= 0; i < enabledIds.length; i++)
|
||||
|
@ -319,7 +321,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
* @since 3.0
|
||||
*/
|
||||
private void setRecentlyChangedFilters(Stack changeHistory) {
|
||||
Stack oldestFirstStack= new Stack();
|
||||
Stack<String> oldestFirstStack= new Stack<String>();
|
||||
|
||||
int length= Math.min(changeHistory.size(), MAX_FILTER_MENU_ENTRIES);
|
||||
for (int i= 0; i < length; i++)
|
||||
|
@ -328,7 +330,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
length= Math.min(fLRUFilterIdsStack.size(), MAX_FILTER_MENU_ENTRIES - oldestFirstStack.size());
|
||||
int NEWEST= 0;
|
||||
for (int i= 0; i < length; i++) {
|
||||
Object filter= fLRUFilterIdsStack.remove(NEWEST);
|
||||
String filter= fLRUFilterIdsStack.remove(NEWEST);
|
||||
if (!oldestFirstStack.contains(filter))
|
||||
oldestFirstStack.push(filter);
|
||||
}
|
||||
|
@ -380,15 +382,15 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
return;
|
||||
}
|
||||
|
||||
SortedSet sortedFilters= new TreeSet(fLRUFilterIdsStack);
|
||||
String[] recentlyChangedFilterIds= (String[])sortedFilters.toArray(new String[sortedFilters.size()]);
|
||||
SortedSet<Object> sortedFilters= new TreeSet<Object>(fLRUFilterIdsStack);
|
||||
String[] recentlyChangedFilterIds= sortedFilters.toArray(new String[sortedFilters.size()]);
|
||||
|
||||
fFilterIdsUsedInLastViewMenu= new String[recentlyChangedFilterIds.length];
|
||||
for (int i= 0; i < recentlyChangedFilterIds.length; i++) {
|
||||
String id= recentlyChangedFilterIds[i];
|
||||
fFilterIdsUsedInLastViewMenu[i]= id;
|
||||
boolean state= fEnabledFilterIds.containsKey(id) && ((Boolean)fEnabledFilterIds.get(id)).booleanValue();
|
||||
FilterDescriptor filterDesc= (FilterDescriptor)fFilterDescriptorMap.get(id);
|
||||
boolean state= fEnabledFilterIds.containsKey(id) && fEnabledFilterIds.get(id).booleanValue();
|
||||
FilterDescriptor filterDesc= fFilterDescriptorMap.get(id);
|
||||
if (filterDesc != null) {
|
||||
IContributionItem item= new FilterActionMenuContributionItem(this, id, filterDesc.getName(), state, i+1);
|
||||
mm.insertBefore(RECENT_FILTERS_GROUP_NAME, item);
|
||||
|
@ -410,8 +412,8 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
fUserDefinedPatternsEnabled= false;
|
||||
|
||||
FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors(fTargetId);
|
||||
fFilterDescriptorMap= new HashMap(filterDescs.length);
|
||||
fEnabledFilterIds= new HashMap(filterDescs.length);
|
||||
fFilterDescriptorMap= new HashMap<String, FilterDescriptor>(filterDescs.length);
|
||||
fEnabledFilterIds= new HashMap<String, Boolean>(filterDescs.length);
|
||||
for (int i= 0; i < filterDescs.length; i++) {
|
||||
String id= filterDescs[i].getId();
|
||||
Boolean isEnabled= new Boolean(filterDescs[i].isEnabled());
|
||||
|
@ -425,7 +427,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
// ---------- viewer filter handling ----------
|
||||
|
||||
private void installFilters() {
|
||||
fInstalledBuiltInFilters= new HashMap(fEnabledFilterIds.size());
|
||||
fInstalledBuiltInFilters= new HashMap<String, ViewerFilter>(fEnabledFilterIds.size());
|
||||
fPatternFilter= new NamePatternFilter();
|
||||
fPatternFilter.setPatterns(getUserAndBuiltInPatterns());
|
||||
fViewer.addFilter(fPatternFilter);
|
||||
|
@ -443,9 +445,9 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
}
|
||||
|
||||
private void updateBuiltInFilters() {
|
||||
Set installedFilters= fInstalledBuiltInFilters.keySet();
|
||||
Set filtersToAdd= new HashSet(fEnabledFilterIds.size());
|
||||
Set filtersToRemove= new HashSet(fEnabledFilterIds.size());
|
||||
Set<String> installedFilters= fInstalledBuiltInFilters.keySet();
|
||||
Set<String> filtersToAdd= new HashSet<String>(fEnabledFilterIds.size());
|
||||
Set<String> filtersToRemove= new HashSet<String>(fEnabledFilterIds.size());
|
||||
Iterator iter= fEnabledFilterIds.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry entry= (Map.Entry)iter.next();
|
||||
|
@ -472,7 +474,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
}
|
||||
}
|
||||
if (filtersToRemove.contains(id)) {
|
||||
fViewer.removeFilter((ViewerFilter)fInstalledBuiltInFilters.get(id));
|
||||
fViewer.removeFilter(fInstalledBuiltInFilters.get(id));
|
||||
fInstalledBuiltInFilters.remove(id);
|
||||
}
|
||||
}
|
||||
|
@ -480,7 +482,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
}
|
||||
|
||||
private String[] getUserAndBuiltInPatterns() {
|
||||
List patterns= new ArrayList(fUserDefinedPatterns.length);
|
||||
List<String> patterns= new ArrayList<String>(fUserDefinedPatterns.length);
|
||||
if (areUserDefinedPatternsEnabled())
|
||||
patterns.addAll(Arrays.asList(fUserDefinedPatterns));
|
||||
FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors(fTargetId);
|
||||
|
@ -491,7 +493,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
if (isEnabled != null && isPatternFilter && ((Boolean)isEnabled).booleanValue())
|
||||
patterns.add(filterDescs[i].getPattern());
|
||||
}
|
||||
return (String[])patterns.toArray(new String[patterns.size()]);
|
||||
return patterns.toArray(new String[patterns.size()]);
|
||||
}
|
||||
|
||||
// ---------- view kind/defaults persistency ----------
|
||||
|
@ -511,9 +513,9 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
fUserDefinedPatternsEnabled= store.getBoolean(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED));
|
||||
setUserDefinedPatterns(CustomFiltersDialog.convertFromString(store.getString(getPreferenceKey(TAG_USER_DEFINED_PATTERNS)), SEPARATOR));
|
||||
|
||||
Iterator iter= fEnabledFilterIds.keySet().iterator();
|
||||
Iterator<String> iter= fEnabledFilterIds.keySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
String id= (String)iter.next();
|
||||
String id= iter.next();
|
||||
Boolean isEnabled= new Boolean(store.getBoolean(id));
|
||||
fEnabledFilterIds.put(id, isEnabled);
|
||||
}
|
||||
|
@ -538,18 +540,18 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
store.setValue(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED), fUserDefinedPatternsEnabled);
|
||||
store.setValue(getPreferenceKey(TAG_USER_DEFINED_PATTERNS), CustomFiltersDialog.convertToString(fUserDefinedPatterns ,SEPARATOR));
|
||||
|
||||
Iterator iter= fEnabledFilterIds.entrySet().iterator();
|
||||
Iterator<Entry<String, Boolean>> iter= fEnabledFilterIds.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry entry= (Map.Entry)iter.next();
|
||||
Map.Entry entry= iter.next();
|
||||
String id= (String)entry.getKey();
|
||||
boolean isEnabled= ((Boolean)entry.getValue()).booleanValue();
|
||||
store.setValue(id, isEnabled);
|
||||
}
|
||||
|
||||
StringBuffer buf= new StringBuffer(fLRUFilterIdsStack.size() * 20);
|
||||
iter= fLRUFilterIdsStack.iterator();
|
||||
while (iter.hasNext()) {
|
||||
buf.append((String)iter.next());
|
||||
Iterator<String> iterIds= fLRUFilterIdsStack.iterator();
|
||||
while (iterIds.hasNext()) {
|
||||
buf.append(iterIds.next());
|
||||
buf.append(SEPARATOR);
|
||||
}
|
||||
store.setValue(TAG_LRU_FILTERS, buf.toString());
|
||||
|
@ -598,9 +600,9 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
private void saveLRUFilters(IMemento memento) {
|
||||
if(fLRUFilterIdsStack != null && !fLRUFilterIdsStack.isEmpty()) {
|
||||
IMemento lruFilters= memento.createChild(TAG_LRU_FILTERS);
|
||||
Iterator iter= fLRUFilterIdsStack.iterator();
|
||||
Iterator<String> iter= fLRUFilterIdsStack.iterator();
|
||||
while (iter.hasNext()) {
|
||||
String id= (String)iter.next();
|
||||
String id= iter.next();
|
||||
IMemento child= lruFilters.createChild(TAG_CHILD);
|
||||
child.putString(TAG_FILTER_ID, id);
|
||||
}
|
||||
|
@ -684,7 +686,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
private void cleanUpPatternDuplicates() {
|
||||
if (!areUserDefinedPatternsEnabled())
|
||||
return;
|
||||
List userDefinedPatterns= new ArrayList(Arrays.asList(fUserDefinedPatterns));
|
||||
List<String> userDefinedPatterns= new ArrayList<String>(Arrays.asList(fUserDefinedPatterns));
|
||||
FilterDescriptor[] filters= FilterDescriptor.getFilterDescriptors(fTargetId);
|
||||
|
||||
for (int i= 0; i < filters.length; i++) {
|
||||
|
@ -698,7 +700,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
|
|||
}
|
||||
}
|
||||
}
|
||||
fUserDefinedPatterns= (String[])userDefinedPatterns.toArray(new String[userDefinedPatterns.size()]);
|
||||
fUserDefinedPatterns= userDefinedPatterns.toArray(new String[userDefinedPatterns.size()]);
|
||||
setUserDefinedPatternsEnabled(fUserDefinedPatternsEnabled && fUserDefinedPatterns.length > 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -99,7 +99,7 @@ public class GenerateActionGroup extends ActionGroup {
|
|||
private CEditor fEditor;
|
||||
private IWorkbenchSite fSite;
|
||||
private String fGroupName= IContextMenuConstants.GROUP_REORGANIZE;
|
||||
private List fRegisteredSelectionListeners;
|
||||
private List<ISelectionChangedListener> fRegisteredSelectionListeners;
|
||||
|
||||
private AddIncludeOnSelectionAction fAddInclude;
|
||||
// private OverrideMethodsAction fOverrideMethods;
|
||||
|
@ -249,10 +249,10 @@ public class GenerateActionGroup extends ActionGroup {
|
|||
// fAddCppDocStub= new AddJavaDocStubAction(site);
|
||||
// fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
|
||||
|
||||
fAddBookmark= new AddBookmarkAction(site.getShell());
|
||||
fAddBookmark= new AddBookmarkAction(site, true);
|
||||
fAddBookmark.setActionDefinitionId(IWorkbenchActionDefinitionIds.ADD_BOOKMARK);
|
||||
|
||||
fAddTaskAction= new AddTaskAction(site.getShell());
|
||||
fAddTaskAction= new AddTaskAction(site);
|
||||
fAddTaskAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.ADD_TASK);
|
||||
|
||||
// fExternalizeStrings= new ExternalizeStringsAction(site);
|
||||
|
@ -318,7 +318,7 @@ public class GenerateActionGroup extends ActionGroup {
|
|||
|
||||
private void registerSelectionListener(ISelectionProvider provider, ISelectionChangedListener listener) {
|
||||
if (fRegisteredSelectionListeners == null)
|
||||
fRegisteredSelectionListeners= new ArrayList(10);
|
||||
fRegisteredSelectionListeners= new ArrayList<ISelectionChangedListener>(10);
|
||||
provider.addSelectionChangedListener(listener);
|
||||
fRegisteredSelectionListeners.add(listener);
|
||||
}
|
||||
|
@ -433,8 +433,8 @@ public class GenerateActionGroup extends ActionGroup {
|
|||
public void dispose() {
|
||||
if (fRegisteredSelectionListeners != null) {
|
||||
ISelectionProvider provider= fSite.getSelectionProvider();
|
||||
for (Iterator iter= fRegisteredSelectionListeners.iterator(); iter.hasNext();) {
|
||||
ISelectionChangedListener listener= (ISelectionChangedListener) iter.next();
|
||||
for (Iterator<ISelectionChangedListener> iter= fRegisteredSelectionListeners.iterator(); iter.hasNext();) {
|
||||
ISelectionChangedListener listener= iter.next();
|
||||
provider.removeSelectionChangedListener(listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ public class MemberFilterActionGroup extends ActionGroup {
|
|||
fFilter= new MemberFilter();
|
||||
|
||||
String title, helpContext;
|
||||
ArrayList actions= new ArrayList(4);
|
||||
ArrayList<MemberFilterAction> actions= new ArrayList<MemberFilterAction>(4);
|
||||
|
||||
// fields
|
||||
int filterProperty= FILTER_FIELDS;
|
||||
|
@ -207,7 +207,7 @@ public class MemberFilterActionGroup extends ActionGroup {
|
|||
}
|
||||
|
||||
// order corresponds to order in toolbar
|
||||
fFilterActions= (MemberFilterAction[]) actions.toArray(new MemberFilterAction[actions.size()]);
|
||||
fFilterActions= actions.toArray(new MemberFilterAction[actions.size()]);
|
||||
|
||||
fViewer.addFilter(fFilter);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue