1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 79459 by Sergey Prigogin, Task tags for CDT.

This commit is contained in:
Markus Schorn 2007-05-30 11:08:06 +00:00
parent 7a193cbacc
commit a03112ed99
28 changed files with 1437 additions and 109 deletions

View file

@ -48,6 +48,7 @@ public class DOMParserTestSuite extends TestCase {
suite.addTestSuite( GCCCompleteParseExtensionsTest.class );
suite.addTestSuite(DOMPreprocessorInformationTest.class);
suite.addTest(CommentTests.suite());
suite.addTest(TaskParserTest.suite());
suite.addTest( CompletionTestSuite.suite() );
return suite;
}

View file

@ -0,0 +1,90 @@
/*******************************************************************************
* Copyright (c) 2007 Google, 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser;
import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser.Task;
public class TaskParserTest extends AST2BaseTest {
public static TestSuite suite() {
return suite(TaskParserTest.class);
}
public void testTaskParser() throws Exception {
final char[][] taskTags = new char[][] {
"TODO".toCharArray(),
"TODO(my name):".toCharArray(),
"FIXME".toCharArray()
};
final int PRIORITY_LOW = 1;
final int PRIORITY_NORMAL = 2;
final int PRIORITY_HIGH = 3;
final int[] taskPriorities = new int[] {
PRIORITY_LOW,
PRIORITY_NORMAL,
PRIORITY_HIGH
};
final boolean isTaskCaseSensitive = true;
String code = "/* TODO tag 1\n" +
" * FIXME tag 2\n" +
" */\n" +
"\n" +
"// TODO(my name): tag 3\n" +
"// TODO(his name): tag 4\n" +
"// todo Not a tag\n" +
"// TODO FIXME tag 5\n" +
"\n" +
"const char* x = \"TODO Not a tag\";";
IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, false, true, true);
TodoTaskParser parser = new TodoTaskParser(taskTags, taskPriorities, isTaskCaseSensitive);
Task[] tasks = parser.parse(tu.getComments());
assertEquals(6, tasks.length);
assertEquals("TODO", tasks[0].getTag());
assertEquals("tag 1", tasks[0].getMessage());
assertEquals(PRIORITY_LOW, tasks[0].getPriority());
assertEquals(1, tasks[0].getLineNumber());
assertEquals(3, tasks[0].getStart());
assertEquals(13, tasks[0].getEnd());
assertEquals("FIXME", tasks[1].getTag());
assertEquals("tag 2", tasks[1].getMessage());
assertEquals(PRIORITY_HIGH, tasks[1].getPriority());
assertEquals(2, tasks[1].getLineNumber());
assertEquals("TODO(my name):", tasks[2].getTag());
assertEquals("tag 3", tasks[2].getMessage());
assertEquals(PRIORITY_NORMAL, tasks[2].getPriority());
assertEquals(5, tasks[2].getLineNumber());
assertEquals("TODO", tasks[3].getTag());
assertEquals("(his name): tag 4", tasks[3].getMessage());
assertEquals(PRIORITY_LOW, tasks[3].getPriority());
assertEquals(6, tasks[3].getLineNumber());
assertEquals("TODO", tasks[4].getTag());
assertEquals("tag 5", tasks[4].getMessage());
assertEquals(PRIORITY_LOW, tasks[4].getPriority());
assertEquals(8, tasks[4].getLineNumber());
assertEquals("FIXME", tasks[5].getTag());
assertEquals("tag 5", tasks[5].getMessage());
assertEquals(PRIORITY_HIGH, tasks[5].getPriority());
assertEquals(8, tasks[5].getLineNumber());
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems and others.
* Copyright (c) 2000, 2007 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
@ -46,9 +46,9 @@ public interface ICModelMarker {
/**
* C model task marker type (value <code>"org.eclipse.cdt.core.task"</code>).
* This can be used to recognize task markers in the workspace that correspond to tasks
* specified in C/C++ source comments and detected during translation (for example, 'TO-DO: ...').
* specified in C/C++ source comments and detected during code indexing (for example, 'TO-DO: ...').
* Tasks are identified by a task tag, which can be customized through <code>CCorePlugin</code>
* option <code>"org.eclipse.cdt.core.translation.taskTag"</code>.
* option <code>"org.eclipse.cdt.core.taskTag"</code>.
*/
public static final String TASK_MARKER = CCorePlugin.PLUGIN_ID + ".task"; //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2005 IBM Corporation and others.
* Copyright (c) 2000, 2007 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
@ -474,7 +474,7 @@ public interface IProblem
/**
* Invalid type provided
* Required attribugtes: A_TYPE_NAME
* Required attributes: A_TYPE_NAME
* @see #A_TYPE_NAME
*/
public static final int SEMANTIC_INVALID_TYPE = SEMANTICS_RELATED | 0x007;

View file

@ -101,6 +101,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
protected final boolean supportDeclspecSpecifiers;
protected final IBuiltinBindingsProvider builtinBindingsProvider;
private IToken lastTokenFromScanner;
protected AbstractGNUSourceCodeParser(IScanner scanner,
IParserLogService logService, ParserMode parserMode,
@ -253,8 +255,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
* thrown when the scanner.nextToken() yields no tokens
*/
protected IToken fetchToken() throws EndOfFileException {
IToken value= null;
boolean adjustNextToken= false;
try {
IToken value = scanner.nextToken();
value= scanner.nextToken();
// Put the Comments in the Array for later processing
int type = value.getType();
while(type == IToken.tCOMMENT || type == IToken.tBLOCKCOMMENT){
@ -262,12 +266,18 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
comments = ASTComment.addComment(comments, comment);
value = scanner.nextToken();
type= value.getType();
adjustNextToken= true;
}
return value;
} catch (OffsetLimitReachedException olre) {
handleOffsetLimitException(olre);
return null;
value= null;
}
if (lastTokenFromScanner != null && adjustNextToken) {
lastTokenFromScanner.setNext(value);
}
lastTokenFromScanner= value;
return value;
}
protected boolean isCancelled = false;

View file

@ -0,0 +1,19 @@
/*******************************************************************************
* Copyright (c) 2007 Google, 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.index.IIndexFileLocation;
public interface ITodoTaskUpdater {
public void updateTasks(IASTComment[] comments, IIndexFileLocation[] files);
}

View file

@ -6,9 +6,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian)
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom;
@ -103,7 +104,6 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChange
* @author Doug Schaefer
*/
public class PDOMManager implements IWritableIndexManager, IListener {
private static final class PerInstanceSchedulingRule implements ISchedulingRule {
public boolean contains(ISchedulingRule rule) {
return rule == this;
@ -113,7 +113,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
}
}
private final class PCL implements IPreferenceChangeListener {
private final class PCL implements IPreferenceChangeListener, IPropertyChangeListener {
private ICProject fProject;
public PCL(ICProject prj) {
fProject= prj;
@ -123,9 +123,17 @@ public class PDOMManager implements IWritableIndexManager, IListener {
onPreferenceChange(fProject, event);
}
}
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
if (property.equals(CCorePreferenceConstants.TODO_TASK_TAGS) ||
property.equals(CCorePreferenceConstants.TODO_TASK_PRIORITIES) ||
property.equals(CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE)) {
// Rebuild index if task tag preferences change.
reindex(fProject);
}
}
}
private static final String SETTINGS_FOLDER_NAME = ".settings"; //$NON-NLS-1$
private static final QualifiedName dbNameProperty= new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomName"); //$NON-NLS-1$
@ -659,6 +667,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
fPrefListeners.put(prj, pcl);
}
IndexerPreferences.addChangeListener(prj, pcl);
Preferences pref = CCorePlugin.getDefault().getPluginPreferences();
pref.addPropertyChangeListener(pcl);
}
private void unregisterPreferenceListener(ICProject project) {
@ -666,6 +676,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
PCL pcl= (PCL) fPrefListeners.remove(prj);
if (pcl != null) {
IndexerPreferences.removeChangeListener(prj, pcl);
Preferences pref = CCorePlugin.getDefault().getPluginPreferences();
pref.removePropertyChangeListener(pcl);
}
}

View file

@ -110,13 +110,13 @@ abstract public class PDOMWriter {
/**
* Fully equivalent to
* <code>addSymbols(IASTTranslationUnit, IWritableIndex, int, true, int, IProgressMonitor)</code>.
* <code>addSymbols(IASTTranslationUnit, IWritableIndex, int, true, int, null, IProgressMonitor)</code>.
* @since 4.0
*/
public void addSymbols(IASTTranslationUnit ast,
IWritableIndex index, int readlockCount,
int configHash, IProgressMonitor pm) throws InterruptedException, CoreException {
addSymbols(ast, index, readlockCount, true, configHash, pm);
addSymbols(ast, index, readlockCount, true, configHash, null, pm);
}
/**
@ -133,7 +133,7 @@ abstract public class PDOMWriter {
*/
public void addSymbols(IASTTranslationUnit ast,
IWritableIndex index, int readlockCount, boolean flushIndex,
int configHash, IProgressMonitor pm) throws InterruptedException, CoreException {
int configHash, ITodoTaskUpdater taskUpdater, IProgressMonitor pm) throws InterruptedException, CoreException {
final Map symbolMap= new HashMap();
try {
HashSet contextIncludes= new HashSet();
@ -205,6 +205,10 @@ abstract public class PDOMWriter {
index.releaseWriteLock(readlockCount, flushIndex);
}
fStatistics.fAddToIndexTime+= System.currentTimeMillis()-start;
if (taskUpdater != null) {
taskUpdater.updateTasks(ast.getComments(), orderedPaths);
}
}
finally {
synchronized(fInfo) {

View file

@ -21,6 +21,8 @@ public class Messages extends NLS {
public static String PDOMIndexerTask_errorWhileParsing;
public static String PDOMIndexerTask_parsingFileTask;
public static String PDOMIndexerTask_tooManyIndexProblems;
public static String TodoTaskUpdater_taskFormat;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer;
@ -46,6 +47,7 @@ import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.CContentTypes;
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.cdt.internal.core.index.IWritableIndex;
import org.eclipse.cdt.internal.core.pdom.ITodoTaskUpdater;
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
import org.eclipse.cdt.internal.core.pdom.PDOMWriter;
import org.eclipse.cdt.internal.core.pdom.db.ChunkCache;
@ -155,15 +157,15 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
return null;
}
ILanguage language = tu.getLanguage();
if (! (language instanceof AbstractLanguage))
if (!(language instanceof AbstractLanguage))
return null;
CodeReader codeReader = tu.getCodeReader();
if (codeReader == null) {
return null;
}
return createAST((AbstractLanguage)language, codeReader, scannerInfo, options, pm);
return createAST((AbstractLanguage) language, codeReader, scannerInfo, options, pm);
}
/**
@ -172,7 +174,8 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
* @see #parseTUs(IWritableIndex, int, Collection, Collection, IProgressMonitor)
* @since 4.0
*/
abstract protected IASTTranslationUnit createAST(AbstractLanguage lang, CodeReader codeReader, IScannerInfo scanInfo, int options, IProgressMonitor pm) throws CoreException;
abstract protected IASTTranslationUnit createAST(AbstractLanguage lang, CodeReader codeReader,
IScannerInfo scanInfo, int options, IProgressMonitor pm) throws CoreException;
/**
* Convenience method for subclasses, parses the files calling out to the methods
@ -194,15 +197,17 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
}
private void internalParseTUs(IWritableIndex index, int readlockCount, Collection sources, Collection headers, IProgressMonitor monitor) throws CoreException, InterruptedException {
int options= 0;
TodoTaskUpdater taskUpdater = new TodoTaskUpdater();
int options= AbstractLanguage.OPTION_ADD_COMMENTS;
if (checkProperty(IndexerPreferences.KEY_SKIP_ALL_REFERENCES)) {
options |= AbstractLanguage.OPTION_SKIP_FUNCTION_BODIES;
}
for (Iterator iter = fFilesUpFront.iterator(); iter.hasNext();) {
String upfront= (String) iter.next();
parseUpFront(upfront, options, index, readlockCount, monitor);
parseUpFront(upfront, options, index, readlockCount, taskUpdater, monitor);
}
// sources first
for (Iterator iter = sources.iterator(); iter.hasNext();) {
if (monitor.isCanceled())
@ -210,7 +215,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
ITranslationUnit tu = (ITranslationUnit) iter.next();
final IIndexFileLocation ifl = IndexLocationFactory.getIFL(tu);
if (needToUpdate(ifl, 0)) {
parseTU(ifl, tu, options, index, readlockCount, monitor);
parseTU(ifl, tu, options, index, readlockCount, taskUpdater, monitor);
}
}
@ -226,7 +231,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
else {
ITranslationUnit context= findContext(index, ifl);
if (context != null) {
parseTU(ifl, context, options, index, readlockCount, monitor);
parseTU(ifl, context, options, index, readlockCount, taskUpdater, monitor);
}
}
}
@ -242,14 +247,14 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
iter.remove();
}
else {
parseTU(ifl, tu, options, index, readlockCount, monitor);
parseTU(ifl, tu, options, index, readlockCount, taskUpdater, monitor);
}
}
}
}
/**
* Convinience method to check whether a translation unit in the index is outdated
* Convenience method to check whether a translation unit in the index is outdated
* with respect to its timestamp.
* @throws CoreException
* @since 4.0
@ -271,7 +276,8 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
}
private void parseTU(IIndexFileLocation originator, ITranslationUnit tu, int options, IWritableIndex index, int readlockCount, IProgressMonitor pm) throws CoreException, InterruptedException {
private void parseTU(IIndexFileLocation originator, ITranslationUnit tu, int options, IWritableIndex index,
int readlockCount, ITodoTaskUpdater taskUpdater, IProgressMonitor pm) throws CoreException, InterruptedException {
IPath path= tu.getPath();
try {
// skip if no scanner info
@ -291,7 +297,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
IASTTranslationUnit ast= createAST(tu, scanner, options, pm);
fStatistics.fParsingTime += System.currentTimeMillis()-start;
if (ast != null) {
addSymbols(ast, index, readlockCount, false, configHash, pm);
addSymbols(ast, index, readlockCount, false, configHash, taskUpdater, pm);
}
}
}
@ -307,7 +313,8 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
}
}
private void parseUpFront(String file, int options, IWritableIndex index, int readlockCount, IProgressMonitor pm) throws CoreException, InterruptedException {
private void parseUpFront(String file, int options, IWritableIndex index, int readlockCount,
ITodoTaskUpdater taskUpdater, IProgressMonitor pm) throws CoreException, InterruptedException {
file= file.trim();
if (file.length() == 0) {
return;
@ -348,7 +355,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
fStatistics.fParsingTime += System.currentTimeMillis()-start;
if (ast != null) {
addSymbols(ast, index, readlockCount, false, 0, pm);
addSymbols(ast, index, readlockCount, false, 0, taskUpdater, pm);
updateInfo(-1, +1, 0);
}
}
@ -364,7 +371,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
}
/**
* Overriders must call super.needToUpdate(). If <code>false</code> is returned
* Overrides must call super.needToUpdate(). If <code>false</code> is returned
* this must be passed on to their caller:
* <pre>
* if (super.needToUpdate()) {

View file

@ -0,0 +1,263 @@
/*******************************************************************************
* Copyright (c) 2007 Google, 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.internal.core.CharOperation;
public class TodoTaskParser {
private static final Task[] EMPTY_TASK_ARRAY = new Task[0];
private final char[][] tags;
private final int[] priorities;
private final boolean isTaskCaseSensitive;
private final int[] order;
public TodoTaskParser(char[][] taskTags, int[] taskPriorities, boolean isTaskCaseSensitive) {
assert taskPriorities.length == taskTags.length;
this.tags = taskTags;
this.priorities = taskPriorities;
this.isTaskCaseSensitive = isTaskCaseSensitive;
// Calculate task checking order that gives preference to the longest matching tag.
this.order = new int[taskTags.length];
for (int i = 0; i < order.length; i++) {
order[i] = i;
}
// Sort order array in reverse order of tag lengths.
// Shell sort algorithm from http://en.wikipedia.org/wiki/Shell_sort
for (int inc = order.length / 2; inc > 0; inc /= 2) {
for (int i = inc; i < order.length; i++) {
for (int j = i;
j >= inc && taskTags[order[j - inc]].length < taskTags[order[j]].length;
j -= inc) {
int temp = order[j];
order[j] = order[j - inc];
order[j - inc] = temp;
}
}
}
}
public Task[] parse(IASTComment[] comments) {
List/*<Task>*/ tasks = new ArrayList();
for (int i = 0; i < comments.length; i++) {
IASTComment comment = comments[i];
IASTFileLocation location = comment.getFileLocation();
parse(comment.getComment(), location.getFileName(), location.getNodeOffset(),
location.getStartingLineNumber(), tasks);
}
if (tasks.isEmpty()) {
return EMPTY_TASK_ARRAY;
}
return (Task[]) tasks.toArray(new Task[tasks.size()]);
}
private void parse(char[] comment, String filename, int offset, int lineNumber,
List/*<Task>*/ tasks) {
int commentLength = comment.length;
int foundTaskIndex = tasks.size();
char previous = comment[1]; // Should be '*' or '/'
for (int i = 2; i < commentLength; i++) {
char[] tag = null;
nextTag : for (int j = 0; j < order.length; j++) {
int itag = order[j];
tag = tags[itag];
int tagLength = tag.length;
if (tagLength == 0 || i + tagLength > commentLength)
continue nextTag;
// Ensure tag is not leaded with letter if tag starts with a letter
if (isIdentifierStart(tag[0]) && isIdentifierPart(previous)) {
continue nextTag;
}
for (int t = 0; t < tagLength; t++) {
int x = i + t;
if (x >= commentLength)
continue nextTag;
char sc = comment[x];
char tc = tag[t];
if (sc != tc) { // case sensitive check
if (isTaskCaseSensitive || Character.toLowerCase(sc) != Character.toLowerCase(tc)) { // case insensitive check
continue nextTag;
}
}
}
// Ensure tag is not followed with letter if tag finishes with a letter
if (i + tagLength < commentLength && isIdentifierPart(comment[i + tagLength - 1])) {
if (isIdentifierPart(comment[i + tagLength]))
continue nextTag;
}
Task task = new Task(filename, i, i + tagLength, lineNumber,
String.valueOf(tag), "", priorities[itag]); //$NON-NLS-1$
tasks.add(task);
i += tagLength - 1; // Will be incremented when looping
break nextTag;
}
previous = comment[i];
}
boolean containsEmptyTask = false;
for (int i = foundTaskIndex; i < tasks.size(); i++) {
Task task = (Task) tasks.get(i);
// Retrieve message start and end positions
int msgStart = task.start + task.tag.length();
int maxValue = i + 1 < tasks.size() ?
((Task) tasks.get(i + 1)).start : commentLength;
// At most beginning of next task
if (maxValue < msgStart) {
maxValue = msgStart; // Would only occur if tag is before EOF.
}
int end = -1;
char c;
for (int j = msgStart; j < maxValue; j++) {
if ((c = comment[j]) == '\n' || c == '\r') {
end = j;
break;
}
}
if (end == -1) {
for (int j = maxValue; --j >= msgStart;) {
if ((c = comment[j]) == '*') {
end = j;
break;
}
}
if (end == -1) {
end = maxValue;
}
}
// Trim the message
while (msgStart < end && CharOperation.isWhitespace(comment[end - 1]))
end--;
while (msgStart < end && CharOperation.isWhitespace(comment[msgStart]))
msgStart++;
if (msgStart == end) {
// If the description is empty, we might want to see if two tags
// are not sharing the same message.
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=110797
containsEmptyTask = true;
continue;
}
// Update the end position of the task
task.end = end;
// Get the message source
int messageLength = end - msgStart;
task.message = String.valueOf(comment, msgStart, messageLength);
}
if (containsEmptyTask) {
for (int i = foundTaskIndex; i < tasks.size(); i++) {
Task task1 = (Task) tasks.get(i);
if (task1.message.length() == 0) {
for (int j = i + 1; j < tasks.size(); j++) {
Task task2 = (Task) tasks.get(j);
if (task2.message.length() != 0) {
task1.message = task2.message;
task1.end = task2.end;
break;
}
}
}
}
}
// Add comment offset.
for (int i = foundTaskIndex; i < tasks.size(); i++) {
Task task = (Task) tasks.get(i);
task.lineNumber += getLineOffset(comment, task.start);
task.start += offset;
task.end += offset;
}
}
/**
* Returns zero-based line number for a given character position.
*/
private static int getLineOffset(char[] buffer, int pos) {
int count = 0;
for (int i = 0; i < pos && i < buffer.length; i++) {
if (buffer[i] == '\n') {
count++;
}
}
return count;
}
private static boolean isIdentifierStart(char c) {
return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'
|| Character.isUnicodeIdentifierPart(c);
}
private static boolean isIdentifierPart(char c) {
return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'
|| c >= '0' && c <= '9'
|| Character.isUnicodeIdentifierPart(c);
}
public static class Task {
private String fileLocation;
private int start;
private int end;
private int lineNumber;
private String tag;
private String message;
private int priority;
Task(String fileLocation, int start, int end, int lineNumber,
String tag, String message, int priority) {
this.fileLocation = fileLocation;
this.start = start;
this.end = end;
this.lineNumber = lineNumber;
this.tag = tag;
this.message = message;
this.priority = priority;
}
public String getFileLocation() {
return fileLocation;
}
public int getStart() {
return start;
}
public int getEnd() {
return end;
}
public int getLineNumber() {
return lineNumber;
}
public String getTag() {
return tag;
}
public String getMessage() {
return message;
}
public int getPriority() {
return priority;
}
}
}

View file

@ -0,0 +1,165 @@
/*******************************************************************************
* Copyright (c) 2007 Google, 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer;
import java.util.StringTokenizer;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CCorePreferenceConstants;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.internal.core.pdom.ITodoTaskUpdater;
import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser.Task;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.osgi.util.NLS;
public class TodoTaskUpdater implements ITodoTaskUpdater {
private static final IMarker[] EMPTY_MARKER_ARRAY = new IMarker[0];
private static final String SOURCE_ID = "CDT"; //$NON-NLS-1$
private static final String[] TASK_MARKER_ATTRIBUTE_NAMES = {
IMarker.MESSAGE,
IMarker.PRIORITY,
IMarker.CHAR_START,
IMarker.CHAR_END,
IMarker.LINE_NUMBER,
IMarker.USER_EDITABLE,
IMarker.SOURCE_ID,
};
private final TodoTaskParser taskParser;
public TodoTaskUpdater() {
String value = CCorePlugin.getOption(CCorePreferenceConstants.TODO_TASK_TAGS);
if (value == null) {
value = CCorePreferenceConstants.DEFAULT_TASK_TAG;
}
String[] tags = split(value, ","); //$NON-NLS-1$
char[][] taskTags = new char[tags.length][];
for (int i = 0; i < tags.length; i++) {
taskTags[i] = tags[i].toCharArray();
}
value = CCorePlugin.getOption(CCorePreferenceConstants.TODO_TASK_PRIORITIES);
if (value == null) {
value = CCorePreferenceConstants.DEFAULT_TASK_PRIORITY;
}
String[] priorities = split(value, ","); //$NON-NLS-1$
int[] taskPriorities = new int[taskTags.length];
for (int i = 0; i < taskPriorities.length; i++) {
String priority = i < priorities.length ?
priorities[i] : CCorePreferenceConstants.DEFAULT_TASK_PRIORITY;
taskPriorities[i] =
CCorePreferenceConstants.TASK_PRIORITY_HIGH.equals(priority) ?
IMarker.PRIORITY_HIGH :
CCorePreferenceConstants.TASK_PRIORITY_LOW.equals(priority) ?
IMarker.PRIORITY_LOW : IMarker.PRIORITY_NORMAL;
}
value = CCorePlugin.getOption(CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE);
if (value == null) {
value = CCorePreferenceConstants.DEFAULT_TASK_CASE_SENSITIVE;
}
boolean isTaskCaseSensitive = Boolean.valueOf(value).booleanValue();
taskParser = new TodoTaskParser(taskTags, taskPriorities, isTaskCaseSensitive);
}
public void updateTasks(IASTComment[] comments, IIndexFileLocation[] fileLocations) {
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
for (int i = 0; i < fileLocations.length; i++) {
IIndexFileLocation indexFileLocation = fileLocations[i];
String filepath = indexFileLocation.getFullPath();
if (filepath != null) {
IFile file = workspaceRoot.getFile(new Path(filepath));
if (file != null && getTasksFor(file).length != 0) {
removeTasksFor(file);
}
}
}
if (comments.length == 0) {
return;
}
Task[] tasks = taskParser.parse(comments);
String location = null;
IFile[] files = null;
for (int i = 0; i < tasks.length; i++) {
Task task = tasks[i];
if (!task.getFileLocation().equals(location)) {
location = task.getFileLocation();
files = workspaceRoot.findFilesForLocation(new Path(location));
}
for (int j = 0; j < files.length; j++) {
try {
applyTask(task, files[j]);
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
}
}
private void applyTask(Task task, IResource resource) throws CoreException {
IMarker marker = resource.createMarker(ICModelMarker.TASK_MARKER);
String description = NLS.bind(Messages.TodoTaskUpdater_taskFormat,
task.getTag(), task.getMessage());
marker.setAttributes(
TASK_MARKER_ATTRIBUTE_NAMES,
new Object[] {
description,
new Integer(task.getPriority()),
new Integer(task.getStart()),
new Integer(task.getEnd()),
new Integer(task.getLineNumber()),
Boolean.FALSE,
SOURCE_ID
});
}
private static IMarker[] getTasksFor(IResource resource) {
try {
if (resource != null && resource.exists())
return resource.findMarkers(ICModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
} catch (CoreException e) {
CCorePlugin.log(e);
}
return EMPTY_MARKER_ARRAY;
}
private static void removeTasksFor(IResource resource) {
try {
if (resource != null && resource.exists())
resource.deleteMarkers(ICModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
private String[] split(String value, String delimiters) {
StringTokenizer tokenizer = new StringTokenizer(value, delimiters);
int size = tokenizer.countTokens();
String[] tokens = new String[size];
for (int i = 0; i < size; i++)
tokens[i] = tokenizer.nextToken();
return tokens;
}
}

View file

@ -14,3 +14,6 @@ PDOMImportTask_errorInvalidPDOMVersion=The version of the cdt-index to import fo
PDOMIndexerTask_parsingFileTask=parsing {0} ({1})
PDOMIndexerTask_errorWhileParsing=Error while parsing {0}.
PDOMImportTask_errorInvalidArchive=Invalid Archive: {0}
# {0} - task tag, {1} - task message.
TodoTaskUpdater_taskFormat={0} {1}

View file

@ -418,7 +418,7 @@
</ignore>
</extension>
<!-- =================================================================================== -->
<!-- C/C++ Task marker(disable for now) -->
<!-- C/C++ Task marker -->
<!-- =================================================================================== -->
<extension
id="task"

View file

@ -119,21 +119,6 @@ public class CCorePlugin extends Plugin {
*/
public static final String FORMATTER_EXTPOINT_ID = "CodeFormatter" ; //$NON-NLS-1$
/**
* Possible configurable option value for TRANSLATION_TASK_PRIORITIES.
* @see #getDefaultOptions
*/
public static final String TRANSLATION_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
/**
* Possible configurable option value for TRANSLATION_TASK_PRIORITIES.
* @see #getDefaultOptions
*/
public static final String TRANSLATION_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
/**
* Possible configurable option value for TRANSLATION_TASK_PRIORITIES.
* @see #getDefaultOptions
*/
public static final String TRANSLATION_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
/**
* Possible configurable option ID.
* @see #getDefaultOptions
@ -354,18 +339,18 @@ public class CCorePlugin extends Plugin {
pdomManager = new PDOMManager();
final Job post2= pdomManager.startup();
// bug 186755, when started after the platform has been started the jobmanager
// bug 186755, when started after the platform has been started the job manager
// is no longer suspended. So we have to start a job at the very end to make
// sure we don't trigger a concurrent plugin activation from within the job.
post1.schedule();
post2.schedule();
}
/**
* TODO: Add all options here
* Returns a table of all known configurable options with their default values.
* These options allow to configure the behaviour of the underlying components.
* These options allow to configure the behavior of the underlying components.
* The client may safely use the result as a template that they can modify and
* then pass to <code>setOptions</code>.
*
@ -375,26 +360,6 @@ public class CCorePlugin extends Plugin {
* Note: more options might be added in further releases.
* <pre>
* RECOGNIZED OPTIONS:
* TRANSLATION / Define the Automatic Task Tags
* When the tag list is not empty, translation will issue a task marker whenever it encounters
* one of the corresponding tags inside any comment in C/C++ source code.
* Generated task messages will include the tag, and range until the next line separator or comment ending.
* Note that tasks messages are trimmed. If a tag is starting with a letter or digit, then it cannot be leaded by
* another letter or digit to be recognized ("fooToDo" will not be recognized as a task for tag "ToDo", but "foo#ToDo"
* will be detected for either tag "ToDo" or "#ToDo"). Respectively, a tag ending with a letter or digit cannot be followed
* by a letter or digit to be recognized ("ToDofoo" will not be recognized as a task for tag "ToDo", but "ToDo:foo" will
* be detected either for tag "ToDo" or "ToDo:").
* - option id: "org.eclipse.cdt.core.translation.taskTags"
* - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
* - default: ""
*
* TRANSLATION / Define the Automatic Task Priorities
* In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
* of the task markers issued by the translation.
* If the default is specified, the priority of each task marker is "NORMAL".
* - option id: "org.eclipse.cdt.core.transltaion.taskPriorities"
* - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
* - default: ""
*
* CORE / Specify Default Source Encoding Format
* Get the encoding format for translated sources. This setting is read-only, it is equivalent

View file

@ -8,6 +8,7 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.core;
@ -15,25 +16,71 @@ package org.eclipse.cdt.core;
public class CCorePreferenceConstants {
/**
* Possible configurable option ID.
* @see #getDefaultOptions
* <pre>
* RECOGNIZED OPTIONS:
* Define the Automatic Task Tags
* When the tag list is not empty, indexer will issue a task marker whenever it encounters
* one of the corresponding tags inside any comment in C/C++ source code.
* Generated task messages will include the tag, and range until the next line separator or comment ending.
* Note that tasks messages are trimmed. If a tag is starting with a letter or digit, then it cannot be leaded by
* another letter or digit to be recognized ("fooToDo" will not be recognized as a task for tag "ToDo", but "foo#ToDo"
* will be detected for either tag "ToDo" or "#ToDo"). Respectively, a tag ending with a letter or digit cannot be followed
* by a letter or digit to be recognized ("ToDofoo" will not be recognized as a task for tag "ToDo", but "ToDo:foo" will
* be detected either for tag "ToDo" or "ToDo:").
* - option id: "org.eclipse.cdt.core.taskTags"
* - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
* - default: ""
*
* Define the Automatic Task Priorities
* In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
* of the task markers issued by the translation.
* If the default is specified, the priority of each task marker is "normal".
* - option id: "org.eclipse.cdt.core.taskPriorities"
* - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "high", "normal" or "low"
* - default: ""
*/
/**
* Task tags used in code comments.
*/
public static final String TRANSLATION_TASK_TAGS = CCorePlugin.PLUGIN_ID + ".translation.taskTags"; //$NON-NLS-1$
public static final String TODO_TASK_TAGS = CCorePlugin.PLUGIN_ID + ".taskTags"; //$NON-NLS-1$
/**
* Default task tag
*/
public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
/**
* Possible configurable option value for TODO_TASK_PRIORITIES.
*/
public static final String TASK_PRIORITY_NORMAL = "normal"; //$NON-NLS-1$
/**
* Possible configurable option value for TODO_TASK_PRIORITIES.
*/
public static final String TASK_PRIORITY_HIGH = "high"; //$NON-NLS-1$
/**
* Possible configurable option value for TODO_TASK_PRIORITIES.
*/
public static final String TASK_PRIORITY_LOW = "low"; //$NON-NLS-1$
/**
* Default task priority
*/
public static final String DEFAULT_TASK_PRIORITY = CCorePlugin.TRANSLATION_TASK_PRIORITY_NORMAL;
public static final String DEFAULT_TASK_PRIORITY = TASK_PRIORITY_NORMAL;
/**
* Possible configurable option ID.
* @see #getDefaultOptions
* Priorities associated with task tags.
*/
public static final String TRANSLATION_TASK_PRIORITIES = CCorePlugin.PLUGIN_ID + ".translation.taskPriorities"; //$NON-NLS-1$
public static final String TODO_TASK_PRIORITIES = CCorePlugin.PLUGIN_ID + ".taskPriorities"; //$NON-NLS-1$
/**
* Case sensitivity of task tags.
*/
public static final String TODO_TASK_CASE_SENSITIVE = CCorePlugin.PLUGIN_ID + ".taskCaseSensitive"; //$NON-NLS-1$
/**
* Default case sensitivity of task tags.
*/
public static final String DEFAULT_TASK_CASE_SENSITIVE = "false"; //$NON-NLS-1$
/**
* Active code formatter ID.

View file

@ -40,8 +40,9 @@ public class CCorePreferenceInitializer extends AbstractPreferenceInitializer {
Map defaultOptionsMap = DefaultCodeFormatterConstants.getDefaultSettings(); // code formatter defaults
// Compiler settings
defaultOptionsMap.put(CCorePreferenceConstants.TRANSLATION_TASK_TAGS, CCorePreferenceConstants.DEFAULT_TASK_TAG);
defaultOptionsMap.put(CCorePreferenceConstants.TRANSLATION_TASK_PRIORITIES, CCorePreferenceConstants.DEFAULT_TASK_PRIORITY);
defaultOptionsMap.put(CCorePreferenceConstants.TODO_TASK_TAGS, CCorePreferenceConstants.DEFAULT_TASK_TAG);
defaultOptionsMap.put(CCorePreferenceConstants.TODO_TASK_PRIORITIES, CCorePreferenceConstants.DEFAULT_TASK_PRIORITY);
defaultOptionsMap.put(CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE, CCorePreferenceConstants.DEFAULT_TASK_CASE_SENSITIVE);
defaultOptionsMap.put(CCorePreferenceConstants.CODE_FORMATTER, CCorePreferenceConstants.DEFAULT_CODE_FORMATTER);
defaultOptionsMap.put(CCorePreferenceConstants.INDEX_DB_CACHE_SIZE_PCT, CCorePreferenceConstants.DEFAULT_INDEX_DB_CACHE_SIZE_PCT);
defaultOptionsMap.put(CCorePreferenceConstants.MAX_INDEX_DB_CACHE_SIZE_MB, CCorePreferenceConstants.DEFAULT_MAX_INDEX_DB_CACHE_SIZE_MB);

View file

@ -374,6 +374,9 @@ callHierarchy.name = Call Hierarchy
typeHierarchy.name = Type Hierarchy
cSearchPage.name = CSearchPage
# Task tags
todoTaskPrefName = Task Tags
# dummy label (not displayed)
Dummy.label = dummy

View file

@ -673,6 +673,11 @@
id="org.eclipse.cdt.ui.preferences.LanguageMappings"
name="%CDTLanguagesProperty.name">
</page>
<page
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.TodoTaskPreferencePage"
id="org.eclipse.cdt.ui.preferences.TodoTaskPreferencePage"
name="%todoTaskPrefName"/>
<!--page
name="%WorkInProgress.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 QNX Software Systems and others.
* Copyright (c) 2004, 2007 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
@ -55,7 +55,7 @@ public class CPathProjectsEntryPage extends CPathBasePage {
fProjectsList.setCheckAllButtonIndex(0);
fProjectsList.setUncheckAllButtonIndex(1);
fProjectsList.setViewerSorter(new CPElementSorter());
fProjectsList.setViewerComparator(new CPElementSorter());
fCPathList = cPathList;
}

View file

@ -10,7 +10,7 @@
* QNX Software System
* Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
* Sergey Prigogin, Google
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
@ -1076,7 +1076,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
private final static String CLOSE_ANGULAR_BRACKETS = PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS;
/** Preference key for compiler task tags */
private final static String TRANSLATION_TASK_TAGS = CCorePreferenceConstants.TRANSLATION_TASK_TAGS;
private final static String TODO_TASK_TAGS = CCorePreferenceConstants.TODO_TASK_TAGS;
/**
* This editor's projection support
@ -1328,8 +1328,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
}
}
// Not implemented ... for the future.
if (TRANSLATION_TASK_TAGS.equals(event.getProperty())) {
if (TODO_TASK_TAGS.equals(event.getProperty())) {
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer != null && affectsTextPresentation(event))
sourceViewer.invalidateTextPresentation();

View file

@ -192,7 +192,34 @@ public final class PreferencesMessages extends NLS {
public static String CodeFormatterPreferencePage_title;
public static String CodeFormatterPreferencePage_description;
public static String TodoTaskPreferencePage_title;
public static String TodoTaskPreferencePage_description;
public static String TodoTaskConfigurationBlock_markers_tasks_high_priority;
public static String TodoTaskConfigurationBlock_markers_tasks_normal_priority;
public static String TodoTaskConfigurationBlock_markers_tasks_low_priority;
public static String TodoTaskConfigurationBlock_markers_tasks_add_button;
public static String TodoTaskConfigurationBlock_markers_tasks_remove_button;
public static String TodoTaskConfigurationBlock_markers_tasks_edit_button;
public static String TodoTaskConfigurationBlock_markers_tasks_name_column;
public static String TodoTaskConfigurationBlock_markers_tasks_priority_column;
public static String TodoTaskConfigurationBlock_markers_tasks_setdefault_button;
public static String TodoTaskConfigurationBlock_casesensitive_label;
public static String TodoTaskConfigurationBlock_needsbuild_title;
public static String TodoTaskConfigurationBlock_tasks_default;
public static String TodoTaskInputDialog_new_title;
public static String TodoTaskInputDialog_edit_title;
public static String TodoTaskInputDialog_name_label;
public static String TodoTaskInputDialog_priority_label;
public static String TodoTaskInputDialog_priority_high;
public static String TodoTaskInputDialog_priority_normal;
public static String TodoTaskInputDialog_priority_low;
public static String TodoTaskInputDialog_error_enterName;
public static String TodoTaskInputDialog_error_comma;
public static String TodoTaskInputDialog_error_entryExists;
public static String TodoTaskInputDialog_error_noSpace;
public static String LanguageMappings_missingLanguageTitle;
public static String WorkspaceLanguagesPreferencePage_description;

View file

@ -193,6 +193,36 @@ CEditorPreferencePage_typing_smartTab= &Tab key indents the current line
CodeFormatterPreferencePage_title=Code Style
CodeFormatterPreferencePage_description=Sele&ct a profile:
# Task tags.
TodoTaskPreferencePage_title=Task Tags
TodoTaskPreferencePage_description=&Strings indicating tasks in C/C++ comments. The entry marked as default will be used in the code templates.
TodoTaskConfigurationBlock_markers_tasks_high_priority=High
TodoTaskConfigurationBlock_markers_tasks_normal_priority=Normal
TodoTaskConfigurationBlock_markers_tasks_low_priority=Low
TodoTaskConfigurationBlock_markers_tasks_add_button=&New...
TodoTaskConfigurationBlock_markers_tasks_remove_button=&Remove
TodoTaskConfigurationBlock_markers_tasks_edit_button=&Edit...
TodoTaskConfigurationBlock_markers_tasks_name_column=Tag
TodoTaskConfigurationBlock_markers_tasks_priority_column=Priority
TodoTaskConfigurationBlock_markers_tasks_setdefault_button=Defa&ult
TodoTaskConfigurationBlock_casesensitive_label=&Case sensitive task tag names
TodoTaskConfigurationBlock_needsbuild_title=Task Tags Settings Changed
TodoTaskConfigurationBlock_tasks_default={0} (default)
TodoTaskInputDialog_new_title=New Task Tag
TodoTaskInputDialog_edit_title=Edit Task Tag
TodoTaskInputDialog_name_label=T&ag:
TodoTaskInputDialog_priority_label=&Priority:
TodoTaskInputDialog_priority_high=High
TodoTaskInputDialog_priority_normal=Normal
TodoTaskInputDialog_priority_low=Low
TodoTaskInputDialog_error_enterName=Enter task tag name.
TodoTaskInputDialog_error_comma=Name cannot contain a comma.
TodoTaskInputDialog_error_entryExists=An entry with the same name already exists.
TodoTaskInputDialog_error_noSpace=Name cannot begin or end with a whitespace.
# --- Linked Resources ---
PathEntryVariablePreference_explanation = PathEntry variables.

View file

@ -0,0 +1,360 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 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
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.resources.IProject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
import org.eclipse.cdt.core.CCorePreferenceConstants;
import org.eclipse.cdt.internal.corext.util.Messages;
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.util.PixelConverter;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
/**
* UI for editing task tags.
*/
public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
private static final Key PREF_TODO_TASK_TAGS = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_TAGS);
private static final Key PREF_TODO_TASK_PRIORITIES = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_PRIORITIES);
private static final Key PREF_TODO_TASK_CASE_SENSITIVE = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE);
private static final String TASK_PRIORITY_HIGH = CCorePreferenceConstants.TASK_PRIORITY_HIGH;
private static final String TASK_PRIORITY_NORMAL = CCorePreferenceConstants.TASK_PRIORITY_NORMAL;
private static final String TASK_PRIORITY_LOW = CCorePreferenceConstants.TASK_PRIORITY_LOW;
public static class TodoTask {
public String name;
public String priority;
}
private class TodoTaskLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider {
public TodoTaskLabelProvider() {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object element) {
return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO);
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
public String getText(Object element) {
return getColumnText(element, 0);
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
*/
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
public String getColumnText(Object element, int columnIndex) {
TodoTask task = (TodoTask) element;
if (columnIndex == 0) {
String name = task.name;
if (isDefaultTask(task)) {
name = Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name);
}
return name;
} else {
if (TASK_PRIORITY_HIGH.equals(task.priority)) {
return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority;
} else if (TASK_PRIORITY_NORMAL.equals(task.priority)) {
return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority;
} else if (TASK_PRIORITY_LOW.equals(task.priority)) {
return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority;
}
return ""; //$NON-NLS-1$
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
public Font getFont(Object element) {
if (isDefaultTask((TodoTask) element)) {
return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
}
return null;
}
}
private static class TodoTaskSorter extends ViewerComparator {
public int compare(Viewer viewer, Object e1, Object e2) {
return getComparator().compare(((TodoTask) e1).name, ((TodoTask) e2).name);
}
}
private static final int IDX_ADD = 0;
private static final int IDX_EDIT = 1;
private static final int IDX_REMOVE = 2;
private static final int IDX_DEFAULT = 4;
private IStatus fTaskTagsStatus;
private ListDialogField fTodoTasksList;
private SelectionButtonDialogField fCaseSensitiveCheckBox;
public TodoTaskConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
super(context, project, getKeys(), container);
TaskTagAdapter adapter = new TaskTagAdapter();
String[] buttons = new String[] {
PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_add_button,
PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_edit_button,
PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_remove_button,
null,
PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button,
};
fTodoTasksList = new ListDialogField(adapter, buttons, new TodoTaskLabelProvider());
fTodoTasksList.setDialogFieldListener(adapter);
fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE);
String[] columnsHeaders = new String[] {
PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_name_column,
PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_priority_column,
};
fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
fTodoTasksList.setViewerComparator(new TodoTaskSorter());
fCaseSensitiveCheckBox = new SelectionButtonDialogField(SWT.CHECK);
fCaseSensitiveCheckBox.setLabelText(PreferencesMessages.TodoTaskConfigurationBlock_casesensitive_label);
fCaseSensitiveCheckBox.setDialogFieldListener(adapter);
unpackTodoTasks();
if (fTodoTasksList.getSize() > 0) {
fTodoTasksList.selectFirstElement();
} else {
fTodoTasksList.enableButton(IDX_EDIT, false);
fTodoTasksList.enableButton(IDX_DEFAULT, false);
}
fTaskTagsStatus = new StatusInfo();
}
public void setEnabled(boolean isEnabled) {
fTodoTasksList.setEnabled(isEnabled);
fCaseSensitiveCheckBox.setEnabled(isEnabled);
}
final boolean isDefaultTask(TodoTask task) {
return fTodoTasksList.getIndexOfElement(task) == 0;
}
private void setToDefaultTask(TodoTask task) {
List elements = fTodoTasksList.getElements();
elements.remove(task);
elements.add(0, task);
fTodoTasksList.setElements(elements);
fTodoTasksList.enableButton(IDX_DEFAULT, false);
}
private static Key[] getKeys() {
return new Key[] {
PREF_TODO_TASK_TAGS, PREF_TODO_TASK_PRIORITIES, PREF_TODO_TASK_CASE_SENSITIVE
};
}
public class TaskTagAdapter implements IListAdapter, IDialogFieldListener {
private boolean canEdit(List selectedElements) {
return selectedElements.size() == 1;
}
private boolean canSetToDefault(List selectedElements) {
return selectedElements.size() == 1 && !isDefaultTask((TodoTask) selectedElements.get(0));
}
public void customButtonPressed(ListDialogField field, int index) {
doTodoButtonPressed(index);
}
public void selectionChanged(ListDialogField field) {
List selectedElements = field.getSelectedElements();
field.enableButton(IDX_EDIT, canEdit(selectedElements));
field.enableButton(IDX_DEFAULT, canSetToDefault(selectedElements));
}
public void doubleClicked(ListDialogField field) {
if (canEdit(field.getSelectedElements())) {
doTodoButtonPressed(IDX_EDIT);
}
}
public void dialogFieldChanged(DialogField field) {
updateModel(field);
}
}
protected Control createContents(Composite parent) {
setShell(parent.getShell());
Composite markersComposite = createMarkersTabContent(parent);
validateSettings(null, null, null);
return markersComposite;
}
private Composite createMarkersTabContent(Composite folder) {
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
PixelConverter conv = new PixelConverter(folder);
Composite markersComposite = new Composite(folder, SWT.NULL);
markersComposite.setLayout(layout);
markersComposite.setFont(folder.getFont());
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = conv.convertWidthInCharsToPixels(50);
Control listControl = fTodoTasksList.getListControl(markersComposite);
listControl.setLayoutData(data);
Control buttonsControl = fTodoTasksList.getButtonBox(markersComposite);
buttonsControl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));
fCaseSensitiveCheckBox.doFillIntoGrid(markersComposite, 2);
return markersComposite;
}
protected void validateSettings(Key changedKey, String oldValue, String newValue) {
if (!areSettingsEnabled()) {
return;
}
if (changedKey != null) {
if (PREF_TODO_TASK_TAGS.equals(changedKey)) {
fTaskTagsStatus = validateTaskTags();
} else {
return;
}
} else {
fTaskTagsStatus = validateTaskTags();
}
IStatus status = fTaskTagsStatus; //StatusUtil.getMostSevere(new IStatus[] { fTaskTagsStatus });
fContext.statusChanged(status);
}
private IStatus validateTaskTags() {
return new StatusInfo();
}
protected final void updateModel(DialogField field) {
if (field == fTodoTasksList) {
StringBuffer tags = new StringBuffer();
StringBuffer prios = new StringBuffer();
List list = fTodoTasksList.getElements();
for (int i = 0; i < list.size(); i++) {
if (i > 0) {
tags.append(',');
prios.append(',');
}
TodoTask elem = (TodoTask) list.get(i);
tags.append(elem.name);
prios.append(elem.priority);
}
setValue(PREF_TODO_TASK_TAGS, tags.toString());
setValue(PREF_TODO_TASK_PRIORITIES, prios.toString());
validateSettings(PREF_TODO_TASK_TAGS, null, null);
} else if (field == fCaseSensitiveCheckBox) {
String state = String.valueOf(fCaseSensitiveCheckBox.isSelected());
setValue(PREF_TODO_TASK_CASE_SENSITIVE, state);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
*/
protected void updateControls() {
unpackTodoTasks();
}
private void unpackTodoTasks() {
String currTags = getValue(PREF_TODO_TASK_TAGS);
String currPrios = getValue(PREF_TODO_TASK_PRIORITIES);
String[] tags = getTokens(currTags, ","); //$NON-NLS-1$
String[] prios = getTokens(currPrios, ","); //$NON-NLS-1$
ArrayList elements = new ArrayList(tags.length);
for (int i = 0; i < tags.length; i++) {
TodoTask task = new TodoTask();
task.name = tags[i].trim();
task.priority = (i < prios.length) ? prios[i] : TASK_PRIORITY_NORMAL;
elements.add(task);
}
fTodoTasksList.setElements(elements);
boolean isCaseSensitive = getBooleanValue(PREF_TODO_TASK_CASE_SENSITIVE);
fCaseSensitiveCheckBox.setSelection(isCaseSensitive);
}
private void doTodoButtonPressed(int index) {
TodoTask edited = null;
if (index != IDX_ADD) {
edited = (TodoTask) fTodoTasksList.getSelectedElements().get(0);
}
if (index == IDX_ADD || index == IDX_EDIT) {
TodoTaskInputDialog dialog = new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements());
if (dialog.open() == Window.OK) {
if (edited != null) {
fTodoTasksList.replaceElement(edited, dialog.getResult());
} else {
fTodoTasksList.addElement(dialog.getResult());
}
}
} else if (index == IDX_DEFAULT) {
setToDefaultTask(edited);
}
}
}

View file

@ -0,0 +1,168 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 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
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.StatusDialog;
import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.core.CCorePreferenceConstants;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.preferences.TodoTaskConfigurationBlock.TodoTask;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ComboDialogField;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
/**
* Dialog to enter a new task tag.
*/
public class TodoTaskInputDialog extends StatusDialog {
private class CompilerTodoTaskInputAdapter implements IDialogFieldListener {
public void dialogFieldChanged(DialogField field) {
doValidation();
}
}
private StringDialogField fNameDialogField;
private ComboDialogField fPriorityDialogField;
private List fExistingNames;
public TodoTaskInputDialog(Shell parent, TodoTask task, List existingEntries) {
super(parent);
fExistingNames = new ArrayList(existingEntries.size());
for (int i = 0; i < existingEntries.size(); i++) {
TodoTask curr = (TodoTask) existingEntries.get(i);
if (!curr.equals(task)) {
fExistingNames.add(curr.name);
}
}
if (task == null) {
setTitle(PreferencesMessages.TodoTaskInputDialog_new_title);
} else {
setTitle(PreferencesMessages.TodoTaskInputDialog_edit_title);
}
CompilerTodoTaskInputAdapter adapter = new CompilerTodoTaskInputAdapter();
fNameDialogField = new StringDialogField();
fNameDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_name_label);
fNameDialogField.setDialogFieldListener(adapter);
fNameDialogField.setText((task != null) ? task.name : ""); //$NON-NLS-1$
String[] items = new String[] {
PreferencesMessages.TodoTaskInputDialog_priority_high,
PreferencesMessages.TodoTaskInputDialog_priority_normal,
PreferencesMessages.TodoTaskInputDialog_priority_low
};
fPriorityDialogField = new ComboDialogField(SWT.READ_ONLY);
fPriorityDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_priority_label);
fPriorityDialogField.setItems(items);
if (task != null) {
if (CCorePreferenceConstants.TASK_PRIORITY_HIGH.equals(task.priority)) {
fPriorityDialogField.selectItem(0);
} else if (CCorePreferenceConstants.TASK_PRIORITY_NORMAL.equals(task.priority)) {
fPriorityDialogField.selectItem(1);
} else {
fPriorityDialogField.selectItem(2);
}
} else {
fPriorityDialogField.selectItem(1);
}
}
public TodoTask getResult() {
TodoTask task = new TodoTask();
task.name = fNameDialogField.getText().trim();
switch (fPriorityDialogField.getSelectionIndex()) {
case 0:
task.priority = CCorePreferenceConstants.TASK_PRIORITY_HIGH;
break;
case 1:
task.priority = CCorePreferenceConstants.TASK_PRIORITY_NORMAL;
break;
default:
task.priority = CCorePreferenceConstants.TASK_PRIORITY_LOW;
break;
}
return task;
}
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
Composite inner = new Composite(composite, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
inner.setLayout(layout);
fNameDialogField.doFillIntoGrid(inner, 2);
fPriorityDialogField.doFillIntoGrid(inner, 2);
LayoutUtil.setHorizontalGrabbing(fNameDialogField.getTextControl(null));
LayoutUtil.setWidthHint(fNameDialogField.getTextControl(null), convertWidthInCharsToPixels(45));
fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
applyDialogFont(composite);
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.TODO_TASK_INPUT_DIALOG);
return composite;
}
private void doValidation() {
StatusInfo status = new StatusInfo();
String newText = fNameDialogField.getText();
if (newText.length() == 0) {
status.setError(PreferencesMessages.TodoTaskInputDialog_error_enterName);
} else {
if (newText.indexOf(',') != -1) {
status.setError(PreferencesMessages.TodoTaskInputDialog_error_comma);
} else if (fExistingNames.contains(newText)) {
status.setError(PreferencesMessages.TodoTaskInputDialog_error_entryExists);
} else if (Character.isWhitespace(newText.charAt(0)) || Character.isWhitespace(newText.charAt(newText.length() - 1))) {
status.setError(PreferencesMessages.TodoTaskInputDialog_error_noSpace);
}
}
updateStatus(status);
}
/*
* @see org.eclipse.jface.window.Window#configureShell(Shell)
*/
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ICHelpContextIds.TODO_TASK_INPUT_DIALOG);
}
}

View file

@ -0,0 +1,148 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 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
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.resources.IProject;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.ui.CUIPlugin;
/*
* The page to configure the task tags
*/
public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
public static final String PREF_ID = "org.eclipse.cdt.ui.preferences.TodoTaskPreferencePage"; //$NON-NLS-1$
public static final String PROP_ID = "org.eclipse.cdt.ui.propertyPages.TodoTaskPreferencePage"; //$NON-NLS-1$
private TodoTaskConfigurationBlock fConfigurationBlock;
public TodoTaskPreferencePage() {
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
setDescription(PreferencesMessages.TodoTaskPreferencePage_description);
// only used when page is shown programatically
setTitle(PreferencesMessages.TodoTaskPreferencePage_title);
}
/*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
fConfigurationBlock = new TodoTaskConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
super.createControl(parent);
if (isProjectPreferencePage()) {
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.TODO_TASK_PROPERTY_PAGE);
} else {
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.TODO_TASK_PREFERENCE_PAGE);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite)
*/
protected Control createPreferenceContent(Composite composite) {
return fConfigurationBlock.createContents(composite);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject)
*/
protected boolean hasProjectSpecificOptions(IProject project) {
return fConfigurationBlock.hasProjectSpecificOptions(project);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
*/
protected String getPreferencePageID() {
return PREF_ID;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
*/
protected String getPropertyPageID() {
return PROP_ID;
}
// TODO: Project specific settings are not supported yet.
// /* (non-Javadoc)
// * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
// */
// protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
// super.enableProjectSpecificSettings(useProjectSpecificSettings);
// if (fConfigurationBlock != null) {
// fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
// }
// }
/*
* @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
*/
protected void performDefaults() {
super.performDefaults();
if (fConfigurationBlock != null) {
fConfigurationBlock.performDefaults();
}
}
/*
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/
public boolean performOk() {
if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
return false;
}
return super.performOk();
}
/*
* @see org.eclipse.jface.preference.IPreferencePage#performApply()
*/
public void performApply() {
if (fConfigurationBlock != null) {
fConfigurationBlock.performApply();
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.DialogPage#dispose()
*/
public void dispose() {
if (fConfigurationBlock != null) {
fConfigurationBlock.dispose();
}
super.dispose();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
*/
public void setElement(IAdaptable element) {
super.setElement(element);
setDescription(null); // no description for property page
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* Copyright (c) 2000, 2007 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
@ -68,14 +68,13 @@ public class CCommentScanner extends AbstractCScanner
StringTokenizer tokenizer= new StringTokenizer(value, delimiters);
int size= tokenizer.countTokens();
String[] tokens= new String[size];
int i= 0;
while (i < size)
tokens[i++]= tokenizer.nextToken();
for (int i = 0; i < size; i++)
tokens[i] = tokenizer.nextToken();
return tokens;
}
}
private static final String TRANSLATION_TASK_TAGS= CCorePreferenceConstants.TRANSLATION_TASK_TAGS;
private static final String TODO_TASK_TAGS= CCorePreferenceConstants.TODO_TASK_TAGS;
protected static final String TASK_TAG= ICColorConstants.TASK_TAG;
private TaskTagRule fTaskTagRule;
@ -108,10 +107,10 @@ public class CCommentScanner extends AbstractCScanner
List list= new ArrayList();
String tasks= null;
if (getPreferenceStore().contains(TRANSLATION_TASK_TAGS)) {
tasks= getPreferenceStore().getString(TRANSLATION_TASK_TAGS);
if (getPreferenceStore().contains(TODO_TASK_TAGS)) {
tasks= getPreferenceStore().getString(TODO_TASK_TAGS);
} else if (fCorePreferenceStore != null) {
tasks= fCorePreferenceStore.getString(TRANSLATION_TASK_TAGS);
tasks= fCorePreferenceStore.getString(TODO_TASK_TAGS);
}
if (tasks != null) {
@ -130,14 +129,14 @@ public class CCommentScanner extends AbstractCScanner
* @see org.eclipse.cdt.internal.ui.text.AbstractJavaScanner#affectsBehavior(org.eclipse.jface.util.PropertyChangeEvent)
*/
public boolean affectsBehavior(PropertyChangeEvent event) {
return event.getProperty().equals(TRANSLATION_TASK_TAGS) || super.affectsBehavior(event);
return event.getProperty().equals(TODO_TASK_TAGS) || super.affectsBehavior(event);
}
/*
* @see org.eclipse.cdt.internal.ui.text.AbstractJavaScanner#adaptToPreferenceChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
public void adaptToPreferenceChange(PropertyChangeEvent event) {
if (fTaskTagRule != null && event.getProperty().equals(TRANSLATION_TASK_TAGS)) {
if (fTaskTagRule != null && event.getProperty().equals(TODO_TASK_TAGS)) {
Object value= event.getNewValue();
if (value instanceof String) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2006 IBM Corporation and others.
* Copyright (c) 2001, 2007 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
@ -44,7 +44,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.cdt.internal.ui.util.PixelConverter;
import org.eclipse.cdt.internal.ui.util.SWTUtil;
@ -90,7 +90,7 @@ public class ListDialogField extends DialogField {
protected IBaseLabelProvider fLabelProvider;
protected ListViewerAdapter fListViewerAdapter;
protected List fElements;
protected ViewerSorter fViewerSorter;
protected ViewerComparator fViewerComparator;
protected String[] fButtonLabels;
private Button[] fButtonControls;
@ -182,11 +182,11 @@ public class ListDialogField extends DialogField {
}
/**
* Sets the viewerSorter.
* @param viewerSorter The viewerSorter to set
* Sets the viewerComparator.
* @param viewerComparator The viewerComparator to set
*/
public void setViewerSorter(ViewerSorter viewerSorter) {
fViewerSorter= viewerSorter;
public void setViewerComparator(ViewerComparator viewerComparator) {
fViewerComparator= viewerComparator;
}
public void setTableColumns(ColumnsDescription column) {
@ -329,8 +329,8 @@ public class ListDialogField extends DialogField {
fTable.setInput(fParentElement);
if (fViewerSorter != null) {
fTable.setSorter(fViewerSorter);
if (fViewerComparator != null) {
fTable.setComparator(fViewerComparator);
}
fTableControl.setEnabled(isEnabled());
@ -699,9 +699,9 @@ public class ListDialogField extends DialogField {
public void selectFirstElement() {
Object element= null;
if (fViewerSorter != null) {
if (fViewerComparator != null) {
Object[] arr= fElements.toArray();
fViewerSorter.sort(fTable, arr);
fViewerComparator.sort(fTable, arr);
if (arr.length > 0) {
element= arr[0];
}