01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.core.search.matching;
11:
12: import org.eclipse.jdt.core.compiler.CharOperation;
13:
14: public abstract class VariablePattern extends JavaSearchPattern {
15:
16: protected boolean findDeclarations;
17: protected boolean findReferences;
18: protected boolean readAccess;
19: protected boolean writeAccess;
20:
21: protected char[] name;
22:
23: public VariablePattern(int patternKind, boolean findDeclarations,
24: boolean readAccess, boolean writeAccess, char[] name,
25: int matchRule) {
26: super (patternKind, matchRule);
27:
28: this .findDeclarations = findDeclarations; // set to find declarations & all occurrences
29: this .readAccess = readAccess; // set to find any reference, read only references & all occurrences
30: this .writeAccess = writeAccess; // set to find any reference, write only references & all occurrences
31: this .findReferences = readAccess || writeAccess;
32:
33: this .name = (this .isCaseSensitive || this .isCamelCase) ? name
34: : CharOperation.toLowerCase(name);
35: }
36:
37: /*
38: * Returns whether a method declaration or message send will need to be resolved to
39: * find out if this method pattern matches it.
40: */
41: protected boolean mustResolve() {
42: // would like to change this so that we only do it if generic references are found
43: return this .findReferences; // always resolve (in case of a simple name reference being a potential match)
44: }
45: }
|