KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > search > matching > VariablePattern


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.core.search.matching;
12
13 import org.eclipse.jdt.core.compiler.CharOperation;
14
15 public abstract class VariablePattern extends JavaSearchPattern {
16
17 protected boolean findDeclarations;
18 protected boolean findReferences;
19 protected boolean readAccess;
20 protected boolean writeAccess;
21
22 protected char[] name;
23
24 public VariablePattern(int patternKind, boolean findDeclarations, boolean readAccess, boolean writeAccess, char[] name, int matchRule) {
25     super(patternKind, matchRule);
26
27     this.findDeclarations = findDeclarations; // set to find declarations & all occurences
28
this.readAccess = readAccess; // set to find any reference, read only references & all occurences
29
this.writeAccess = writeAccess; // set to find any reference, write only references & all occurences
30
this.findReferences = readAccess || writeAccess;
31
32     this.name = (isCaseSensitive() || isCamelCase()) ? name : CharOperation.toLowerCase(name);
33 }
34 /*
35  * Returns whether a method declaration or message send will need to be resolved to
36  * find out if this method pattern matches it.
37  */

38 protected boolean mustResolve() {
39     // would like to change this so that we only do it if generic references are found
40
return this.findReferences; // always resolve (in case of a simple name reference being a potential match)
41
}
42 }
43
Popular Tags